From 9afd8db94b50cf672de6f6671fdaec6ef1912bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Fri, 13 Apr 2018 18:31:49 +0200 Subject: [PATCH] Use notify::fullscreen to handle fullscreen functionality `'in-fullscreen-changed'` only works for a single fullscreen window per workspace. Meaning it's useless for our purposes. This also makes neighbouring windows responsive to fullscreen changes. --- tiling.js | 36 ++++++++++++++++++++++++++++++++++++ topbar.js | 12 ------------ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/tiling.js b/tiling.js index 76ec6bb..5425dfc 100644 --- a/tiling.js +++ b/tiling.js @@ -113,6 +113,10 @@ function disable () { metaWindow.disconnect(metaWindow[minimizeSignal]); delete metaWindow[minimizeSignal]; } + if (metaWindow[signals]) { + metaWindow[signals].forEach(id => metaWindow.disconnect(id)); + delete metaWindow[signals]; + } }); // Copy the old spaces. @@ -247,6 +251,12 @@ var spaces = (function () { if (!metaWindow[focus_signal]) metaWindow[focus_signal] = metaWindow.connect("focus", focus_wrapper); + if (!metaWindow[signals]) { + metaWindow[signals] = []; + metaWindow[signals].push( + metaWindow.connect('notify::fullscreen', fullscreenWrapper) + ); + } if (!metaWindow[minimizeSignal]) { metaWindow[minimizeSignal] = metaWindow.connect('notify::minimized', minimizeWrapper); @@ -605,6 +615,26 @@ function minimizeHandler(metaWindow) { } let minimizeWrapper = utils.dynamic_function_ref('minimizeHandler', Me); +function fullscreenHandler(metaWindow) { + debug('fullscreen', metaWindow.title); + let space = spaces.spaceOfWindow(metaWindow); + if (space.selectedWindow !== metaWindow) + return; + + let frame = metaWindow.get_frame_rect(); + if (metaWindow.fullscreen) { + TopBar.hide(); + propogate_forward(space, space.selectedIndex() + 1, primary.width); + propogate_backward(space, space.selectedIndex() - 1, 0); + } else { + TopBar.show(); + propogate_forward(space, space.selectedIndex() + 1, + frame.x + frame.width + window_gap); + propogate_backward(space, space.selectedIndex() - 1, frame.x - window_gap); + } +} +let fullscreenWrapper = utils.dynamic_function_ref('fullscreenHandler', Me); + /** We need to stack windows in mru order, since mutter picks from the stack, not the mru, when auto choosing focus after closing a window. @@ -921,6 +951,12 @@ function add_all_from_workspace(workspace, windows = []) { meta_window[focus_signal] = meta_window.connect("focus", focus_wrapper); } + if (!meta_window[signals]) { + meta_window[signals] = []; + meta_window[signals].push( + meta_window.connect('notify::fullscreen', fullscreenWrapper) + ); + } if (!meta_window[minimizeSignal]) { meta_window[minimizeSignal] = diff --git a/topbar.js b/topbar.js index accc4ac..7fecdeb 100644 --- a/topbar.js +++ b/topbar.js @@ -27,18 +27,6 @@ function enable () { updateWorkspaceIndicator(to); })); - screenSignals.push( - global.screen.connect('in-fullscreen-changed', - (screen) => { - let workspace = global.screen.get_active_workspace(); - let space = Tiling.spaces.spaceOf(workspace); - if (space.selectedWindow.fullscreen) { - hide(); - } else { - show(); - } - })); - panelBoxShowId = panelBox.connect('show', show); panelBoxHideId = panelBox.connect('hide', () => { let space = Tiling.spaces.spaceOf(global.screen.get_active_workspace());