From 42eef65ff8cd23516c6144a6c1a0ce95bf2459ea Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 26 Jun 2024 12:46:25 +0100 Subject: [PATCH 1/3] tweak(terminal): Focus the terminal prompt when window is focused This slightly helps with #453. --- packages/terminal/src/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/terminal/src/main.js b/packages/terminal/src/main.js index d27f557fc8..2ae6053aa9 100644 --- a/packages/terminal/src/main.js +++ b/packages/terminal/src/main.js @@ -117,5 +117,6 @@ window.main_term = async () => { const ioController = new XTermIO({ term, pty }); ioController.bind(); + window.addEventListener('focus', () => term.focus() ); term.focus(); }; From 162dfd8ab51e834a8ee5dee719daa05528d36bca Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 26 Jun 2024 12:48:22 +0100 Subject: [PATCH 2/3] tweak: Avoid focusing a background window in more places This is a bit of a temporary hack for #453, and only partly effective. --- src/UI/UIWindow.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/UI/UIWindow.js b/src/UI/UIWindow.js index 0afbd0227b..9b927e2873 100644 --- a/src/UI/UIWindow.js +++ b/src/UI/UIWindow.js @@ -122,7 +122,9 @@ async function UIWindow(options) { if(options.single_instance && options.app !== ''){ let $already_open_window = $(`.window[data-app="${html_encode(options.app)}"]`); if($already_open_window.length){ - $(`.window[data-app="${html_encode(options.app)}"]`).focusWindow(); + if (options.is_visible) { + $(`.window[data-app="${html_encode(options.app)}"]`).focusWindow(); + } return; } } @@ -185,7 +187,8 @@ async function UIWindow(options) { if(user_set_url_params.length > 0) user_set_url_params = '?'+ user_set_url_params.join('&'); } - h += `
Date: Wed, 26 Jun 2024 13:01:13 +0100 Subject: [PATCH 3/3] fix: Stop adding duplicate window IDs to window_stack when focusing them Long-term we probably want a WindowService instead. --- src/UI/UIWindow.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/UI/UIWindow.js b/src/UI/UIWindow.js index 9b927e2873..6bffa0c4de 100644 --- a/src/UI/UIWindow.js +++ b/src/UI/UIWindow.js @@ -3327,7 +3327,7 @@ window.toggle_empty_folder_message = function(el_item_container){ $.fn.focusWindow = function(event) { if(this.hasClass('window')){ const $app_iframe = $(this).find('.window-app-iframe'); - const win_id = $(this).attr('data-id'); + const win_id = parseInt($(this).attr('data-id')); $('.window').not(this).removeClass('window-active'); $(this).addClass('window-active'); // disable pointer events on all windows' iframes, except for this window's iframe @@ -3378,7 +3378,8 @@ $.fn.focusWindow = function(event) { // grey out all selected items on other windows/desktop $('.item-container').not(window.active_item_container).find('.item-selected').addClass('item-blurred'); // update window-stack - window.window_stack.push(parseInt($(this).attr('data-id'))); + _.pullAll(window.window_stack, [win_id]); + window.window_stack.push(win_id); // remove blurred class from items on this window $(window.active_item_container).find('.item-blurred').removeClass('item-blurred'); //change window URL