Skip to content

Commit 23f4553

Browse files
committed
Avoid stacking panels/invisible windows; reset URL
1 parent ce39c7f commit 23f4553

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

src/gui/src/UI/UIWindow.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ async function UIWindow (options) {
5555
}
5656

5757
// add this window's id to the window_stack
58-
window.window_stack.push(win_id);
58+
// don't add if invisible
59+
if ( options.is_visible && !options.is_panel ) {
60+
window.window_stack.push(win_id);
61+
}
5962

6063
// =====================================
6164
// set options defaults
@@ -3709,27 +3712,20 @@ $.fn.close = async function (options) {
37093712
else {
37103713
// close any open FileDialogs belonging to this window
37113714
$(`.window-filedialog[data-parent_uuid="${window_uuid}"]`).close();
3715+
// reset URL to desktop first; focusWindow will set the correct URL for the next focused window
3716+
window.history.replaceState(null, document.title, '/');
37123717
// bring focus to the last window in the window-stack (only if not minimized)
3718+
let next_window_focused = false;
37133719
if ( window.window_stack.length > 0 ) {
37143720
const $last_window_in_stack = $(`.window[data-id="${window.window_stack[window.window_stack.length - 1]}"]`);
37153721
// check if previous window is not minimized
37163722
if ( $last_window_in_stack !== null && $last_window_in_stack.attr('data-is_minimized') !== '1' && $last_window_in_stack.attr('data-is_minimized') !== 'true' ) {
37173723
$(`.window[data-id="${window.window_stack[window.window_stack.length - 1]}"]`).focusWindow();
3718-
}
3719-
// otherwise, change URL/Title to desktop
3720-
else {
3721-
window.history.replaceState(null, document.title, '/');
3722-
document.title = i18n('window_title_puter');
3723-
}
3724-
// if it's explore
3725-
if ( $last_window_in_stack.attr('data-app') && $last_window_in_stack.attr('data-app').toLowerCase() === 'explorer' ) {
3726-
window.history.replaceState(null, document.title, '/');
3727-
document.title = i18n('window_title_puter');
3724+
next_window_focused = true;
37283725
}
37293726
}
3730-
// otherwise, change URL/Title to desktop
3731-
else {
3732-
window.history.replaceState(null, document.title, '/');
3727+
// only reset title if no other window took focus
3728+
if ( !next_window_focused || window.window_stack.length === 0 ) {
37333729
document.title = i18n('window_title_puter');
37343730
}
37353731
}
@@ -4077,7 +4073,9 @@ $.fn.focusWindow = function (event) {
40774073
// grey out all selected items on other windows/desktop
40784074
$('.item-container').not(window.active_item_container).find('.item-selected').addClass('item-blurred');
40794075
// update window-stack
4080-
window.window_stack.push(parseInt($(this).attr('data-id')));
4076+
if ( !$(this).attr('data-is_panel') === '1' ) {
4077+
window.window_stack.push(parseInt($(this).attr('data-id')));
4078+
}
40814079
// remove blurred class from items on this window
40824080
$(window.active_item_container).find('.item-blurred').removeClass('item-blurred');
40834081
//change window URL (skip in dashboard mode — URL should stay on the dashboard route)

0 commit comments

Comments
 (0)