From cddfa0ca1152423078c163e483570075f0ed3845 Mon Sep 17 00:00:00 2001 From: Vara Rahul Rajana <123227543+rajanarahul93@users.noreply.github.com> Date: Mon, 8 Sep 2025 04:14:32 +0530 Subject: [PATCH] fix(gui): prevent background apps from stealing focus (#1491) * fix(gui): prevent background apps from stealing focus * remove the `background` option as it's not really needed or used in other parts --------- Co-authored-by: Nariman Jelveh --- src/gui/src/UI/UIWindow.js | 11 +++++++---- src/gui/src/helpers/launch_app.js | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/src/UI/UIWindow.js b/src/gui/src/UI/UIWindow.js index 8c481c5f6..d777ab591 100644 --- a/src/gui/src/UI/UIWindow.js +++ b/src/gui/src/UI/UIWindow.js @@ -601,7 +601,7 @@ async function UIWindow(options) { } // focus on this window and deactivate other windows if ( options.is_visible ) { - $(el_window).focusWindow(); + $(el_window).focusWindow() } if (window.animate_window_opening) { @@ -1523,7 +1523,9 @@ async function UIWindow(options) { el_window_app_iframe.contentWindow.postMessage({msg: "drop", x: (window.mouseX - rect.left), y: (window.mouseY - rect.top), items: items}, '*'); // bring focus to this window - $(el_window).focusWindow(); + if (options.is_visible) { + $(el_window).focusWindow() + } } // if this window is not a directory, cancel drop. @@ -1666,8 +1668,9 @@ async function UIWindow(options) { clearTimeout(drag_enter_timeout); // If items are dragged over this window long enough, bring it to front drag_enter_timeout = setTimeout(function(){ - // focus window - $(el_window).focusWindow(); + if (options.is_visible) { + $(el_window).focusWindow() + } }, 1400); }, leave: function (dragsterEvent, event) { diff --git a/src/gui/src/helpers/launch_app.js b/src/gui/src/helpers/launch_app.js index 66e226556..396ca0173 100644 --- a/src/gui/src/helpers/launch_app.js +++ b/src/gui/src/helpers/launch_app.js @@ -422,7 +422,7 @@ const launch_app = async (options)=>{ // Send any saved broadcasts to the new app globalThis.services.get('broadcast').sendSavedBroadcastsTo(uuid); - // If `window-active` is set (meanign the window is focused), focus the window one more time + // If `window-active` is set (meaning the window is focused), focus the window one more time // this is to ensure that the iframe is `definitely` focused and can receive keyboard events (e.g. keydown) if($(process.references.el_win).hasClass('window-active')){ $(process.references.el_win).focusWindow();