From 86d8b6275f5d9620cdb9549ca81985e7db9fbb07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Sun, 13 Oct 2019 23:37:54 +0200 Subject: [PATCH] app: Don't throw in `spawnWindow`, let `trySpawnWindow` throw `spawnWindow` can be useful from `user.js`, so we make it always succeed, while we while we introduce a throwing `trySpawnWindow` for internal use. --- app.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 9f560e7..598ca22 100644 --- a/app.js +++ b/app.js @@ -27,7 +27,7 @@ function init() { function spawnWithFallback(fallback, ...args) { try { - return spawnWindow(...args); + return trySpawnWindow(...args); } catch(e) { return fallback(); } @@ -133,7 +133,7 @@ function duplicateWindow(metaWindow) { return true; } -function spawnWindow(app, workspace) { +function trySpawnWindow(app, workspace) { if (typeof(app) === 'string') { app = new Shell.App({ app_info: Gio.DesktopAppInfo.new(app) }); } @@ -146,6 +146,17 @@ function spawnWindow(app, workspace) { } } +function spawnWindow(app, workspace) { + if (typeof(app) === 'string') { + app = new Shell.App({ app_info: Gio.DesktopAppInfo.new(app) }); + } + try { + return trySpawnWindow(app, workspace); + } catch(e) { + // Let the overide take care any fallback + return app.open_new_window(-1); + } +} function expandCommandline(commandline, space) { let dir = space.settings.get_string('directory');