From 760bcee465c35fe7347a23d49d91a8ea7ee7b374 Mon Sep 17 00:00:00 2001 From: DanyLE Date: Wed, 4 Jan 2023 11:06:29 +0100 Subject: [PATCH] Hide spotlight when an application is selected on appdock --- d.ts/antos.d.ts | 1 + src/core/BaseApplication.ts | 1 + src/core/tags/AppDockTag.ts | 85 ++++++++++++++++++++------------- src/core/tags/SystemPanelTag.ts | 5 ++ 4 files changed, 58 insertions(+), 34 deletions(-) diff --git a/d.ts/antos.d.ts b/d.ts/antos.d.ts index 10d85ed..526fc63 100644 --- a/d.ts/antos.d.ts +++ b/d.ts/antos.d.ts @@ -8716,6 +8716,7 @@ declare namespace OS { * Handle the application selection action * * @private + * @returns {Promise} * @memberof AppDockTag */ private handleAppSelect; diff --git a/src/core/BaseApplication.ts b/src/core/BaseApplication.ts index f429719..bbfc1f7 100644 --- a/src/core/BaseApplication.ts +++ b/src/core/BaseApplication.ts @@ -110,6 +110,7 @@ namespace OS { this.on("exit", () => this.quit(false)); // first register some base event to the app this.on("focus", () => { + //if(this.sysdock.selectedApp != this) this.sysdock.selectedApp = this; (this.scheme as GUI.tag.WindowTag).onmenuopen = (el) => el.nodes = this.baseMenu() || []; OS.PM.pidactive = this.pid; diff --git a/src/core/tags/AppDockTag.ts b/src/core/tags/AppDockTag.ts index d53c232..7c258a2 100644 --- a/src/core/tags/AppDockTag.ts +++ b/src/core/tags/AppDockTag.ts @@ -162,6 +162,11 @@ namespace OS { } $(el.domel).addClass("selected"); ($(Ant.OS.GUI.workspace)[0] as FloatListTag).unselect(); + const evt = { + id: this.aid, + data: v + }; + announcer.trigger("appselect", evt); } get selectedApp(): application.BaseApplication { @@ -215,7 +220,8 @@ namespace OS { item.domel = bt; bt.onbtclick = (e) => { e.data.stopPropagation(); - this.handleAppSelect(bt); + this + .handleAppSelect(bt); }; } @@ -269,43 +275,54 @@ namespace OS { * Handle the application selection action * * @private + * @returns {Promise} * @memberof AppDockTag */ - private handleAppSelect(bt: ButtonTag) + private handleAppSelect(bt: ButtonTag): Promise { - const name = bt.data.name as string; - const collection = this.items.filter(it => it.app.name == name); - const ctxmenu = $("#contextmenu")[0] as tag.StackMenuTag; - ctxmenu.hide(); - if(collection.length == 0) - { - GUI.launch(name, []); - return; - } - if(collection.length == 1) - { - collection[0].app.trigger("focus"); - return; - } - // show the context menu containning a list of application to select - const menu_data = collection.map(e => { - return { - text: (e.app.scheme as WindowTag).apptitle, - icon: e.icon, - iconclass: e.iconclass, - app: e.app - }; + return new Promise(async (resolve, reject) => { + try { + const name = bt.data.name as string; + const collection = this.items.filter(it => it.app.name == name); + const ctxmenu = $("#contextmenu")[0] as tag.StackMenuTag; + ctxmenu.hide(); + if(collection.length == 0) + { + resolve(await GUI.launch(name, []) as application.BaseApplication); + return; + } + if(collection.length == 1) + { + collection[0].app.trigger("focus"); + resolve(collection[0].app); + return; + } + // show the context menu containning a list of application to select + const menu_data = collection.map(e => { + return { + text: (e.app.scheme as WindowTag).apptitle, + icon: e.icon, + iconclass: e.iconclass, + app: e.app + }; + }); + const offset = $(bt).offset(); + ctxmenu.nodes = menu_data; + $(ctxmenu) + .css("left", offset.left) + .css("bottom", $(this).height()); + ctxmenu.onmenuselect = (e) => + { + e.data.item.data.app.show(); + resolve(e.data.item.data.app); + } + ctxmenu.show(); + } + catch(e) + { + reject(__e(e)); + } }); - const offset = $(bt).offset(); - ctxmenu.nodes = menu_data; - $(ctxmenu) - .css("left", offset.left) - .css("bottom", $(this).height()); - ctxmenu.onmenuselect = (e) => - { - e.data.item.data.app.show(); - } - ctxmenu.show(); } /** diff --git a/src/core/tags/SystemPanelTag.ts b/src/core/tags/SystemPanelTag.ts index 654cc5d..e1138f7 100644 --- a/src/core/tags/SystemPanelTag.ts +++ b/src/core/tags/SystemPanelTag.ts @@ -438,6 +438,7 @@ namespace OS { const systray = this.refs.systray as GUI.tag.ButtonTag; (this.refs.osmenu as ButtonTag).set(this._osmenu); this._cb = (e) => { + console.log("Clicked"); if ( !$(e.target).closest($(this.refs.overlay)).length && !$(e.target).closest(this.refs.osmenu).length @@ -549,6 +550,10 @@ namespace OS { announcer.on("desktopresize", (e) => { this.calibrate(); }); + announcer.on("appselect", (e) => { + if(this._view) + this.toggle(false); + }); Ant.OS.announcer.trigger("syspanelloaded", undefined); } }