Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Partly) stop background apps taking focus from the terminal #498

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/terminal/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,6 @@ window.main_term = async () => {
const ioController = new XTermIO({ term, pty });
ioController.bind();

window.addEventListener('focus', () => term.focus() );
term.focus();
};
20 changes: 14 additions & 6 deletions src/UI/UIWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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 += `<div class="window window-active
h += `<div class="window
${options.is_visible ? 'window-active' : ''}
${options.cover_page ? 'window-cover-page' : ''}
${options.uid !== undefined ? 'window-'+options.uid : ''}
${options.window_class}
Expand Down Expand Up @@ -538,7 +541,9 @@ async function UIWindow(options) {

// when a window is created, focus is brought to it and
// therefore it is the current active element
window.active_element = el_window;
if (options.is_visible) {
window.active_element = el_window;
}

// set name
$(el_window_head_title).html(html_encode(options.title));
Expand Down Expand Up @@ -1153,7 +1158,9 @@ async function UIWindow(options) {
if (options.iframe_url){
$(el_window_app_iframe).attr('src', options.iframe_url)
//bring focus to iframe
el_window_app_iframe.contentWindow.focus();
if (options.is_visible) {
el_window_app_iframe.contentWindow.focus();
}
}
// set the position of window
if(!options.is_maximized){
Expand Down Expand Up @@ -3320,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
Expand Down Expand Up @@ -3371,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
Expand Down