From c13a8fe9db2df6699a7a6346347fe5922d5a13fb Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Thu, 11 Jan 2024 23:12:26 +1100 Subject: [PATCH 1/4] FIX: targetWidth for column should be for all in column (set based on selected window or max of column windows). --- tiling.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tiling.js b/tiling.js index 71a1f0da..b01c7504 100644 --- a/tiling.js +++ b/tiling.js @@ -506,10 +506,6 @@ export class Space extends Array { let resizable = !mw.fullscreen && mw.get_maximized() !== Meta.MaximizeFlags.BOTH; - if (mw._fullscreen_frame?.tiledWidth) { - targetWidth = mw._fullscreen_frame.tiledWidth; - } - if (mw.preferredWidth) { let prop = mw.preferredWidth; if (prop.value <= 0) { @@ -640,14 +636,24 @@ export class Space extends Array { if (column.length === 0) continue; - let selectedInColumn = i === selectedIndex ? this.selectedWindow : null; + // selected window in column + const selectedInColumn = i === selectedIndex ? this.selectedWindow : null; let targetWidth; - if (i === selectedIndex) { - targetWidth = selectedInColumn.get_frame_rect().width; - } else { - targetWidth = Math.max(...column.map(w => w.get_frame_rect().width)); + if (selectedInColumn) { + // if selected window - use tiledWidth or frame.width (fallback) + targetWidth = + selectedInColumn?._fullscreen_frame?.tiledWidth ?? + selectedInColumn.get_frame_rect().width; } + else { + // otherwise get max of tiledWith or frame.with (fallback) + targetWidth = Math.max(...column.map(w => { + return w?._fullscreen_frame?.tiledWidth ?? w.get_frame_rect().width; + })); + } + + // enforce minimum targetWidth = Math.min(targetWidth, workArea.width - 2 * Settings.prefs.minimum_margin); let resultingWidth, relayout; @@ -3196,7 +3202,7 @@ export function nonTiledSizeHandler(metaWindow) { return; } - // if pwm fullscreen previously + // if here then was previously in fullscreen (and came out of) if (metaWindow._fullscreen_lock) { delete metaWindow._fullscreen_lock; let fsf = metaWindow._fullscreen_frame; From 4d350ac5cee86ec5b93774596510b1ff13a9b602 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Fri, 12 Jan 2024 00:46:39 +1100 Subject: [PATCH 2/4] FIX: address fullscreening a window in column group (expel it first). --- tiling.js | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tiling.js b/tiling.js index b01c7504..fd60b96a 100644 --- a/tiling.js +++ b/tiling.js @@ -3024,6 +3024,9 @@ export function registerWindow(metaWindow) { signals.connect(metaWindow, 'size-changed', allocateClone); // Note: runs before gnome-shell's minimize handling code signals.connect(metaWindow, 'notify::fullscreen', () => { + // if window is in a column, expel it + barfThis(metaWindow); + Topbar.fixTopBar(); spaces.spaceOfWindow(metaWindow)?.setSpaceTopbarElementsVisible(true); }); @@ -4494,7 +4497,8 @@ export function slurp(metaWindow) { from = index; } - if (!metaWindowToSlurp || space.length < 2) { + // slurping fullscreen windows is trouble + if (!metaWindowToSlurp || metaWindowToSlurp?.fullscreen || space.length < 2) { return; } @@ -4513,6 +4517,11 @@ export function slurp(metaWindow) { }); } +/** + * Barfs the bottom window from a column. + * @param {MetaWindow} metaWindow + * @returns + */ export function barf(metaWindow) { if (!metaWindow) return; @@ -4534,6 +4543,34 @@ export function barf(metaWindow) { }); } +/** + * Barfs (expels) a specific window from a column. + * @param {MetaWindow} metaWindow + * @returns + */ +export function barfThis(metaWindow) { + if (!metaWindow) + return; + + let space = spaces.spaceOfWindow(metaWindow); + let index = space.indexOf(metaWindow); + if (index === -1) + return; + + let column = space[index]; + if (column.length < 2) + return; + + // remove metawindow from column + const indexOfWindow = column.indexOf(metaWindow); + column.splice(indexOfWindow, 1); + space.splice(index + 1, 0, [metaWindow]); + + space.layout(true, { + customAllocators: { [index]: allocateEqualHeight, ensure: false }, + }); +} + export function selectPreviousSpace(mw, space) { spaces.selectStackSpace(Meta.MotionDirection.DOWN); } From 39eb02b75388205b45f2f4eb9697cbf8ca5c870c Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Fri, 12 Jan 2024 00:51:01 +1100 Subject: [PATCH 3/4] If slurping a fullscreen window, unfullscreen it first. --- tiling.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tiling.js b/tiling.js index fd60b96a..159939e1 100644 --- a/tiling.js +++ b/tiling.js @@ -4498,10 +4498,15 @@ export function slurp(metaWindow) { } // slurping fullscreen windows is trouble - if (!metaWindowToSlurp || metaWindowToSlurp?.fullscreen || space.length < 2) { + if (!metaWindowToSlurp || space.length < 2) { return; } + // slurping fullscreen windows is trouble, unfullscreen when slurping + if (metaWindowToSlurp?.fullscreen) { + metaWindowToSlurp.unmake_fullscreen(); + } + space[to].push(metaWindowToSlurp); { // Remove the slurped window From fc6e6ef3a4302423dc5b28daabdb3eb71b8e121d Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Fri, 12 Jan 2024 01:10:14 +1100 Subject: [PATCH 4/4] FIX: if space has fullscreen window, run layout on other window focus. --- tiling.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tiling.js b/tiling.js index 159939e1..12cebc21 100644 --- a/tiling.js +++ b/tiling.js @@ -3903,7 +3903,7 @@ export function getDefaultFocusMode() { } // `MetaWindow::focus` handling -export function focus_handler(metaWindow, user_data) { +export function focus_handler(metaWindow) { console.debug("focus:", metaWindow?.title); if (Scratch.isScratchWindow(metaWindow)) { setAllWorkspacesInactive(); @@ -3927,11 +3927,11 @@ export function focus_handler(metaWindow, user_data) { else { let needLayout = false; /** - * For non-topbar spaces, bring down fullscreen windows to mimic - * gnome behaviour with a topbar. + * If has fullscreen window - when selected non-fullscreen window, do layout: + * For non-topbar spaces, Bring down fullscreen windows to mimic gnome behaviour with a topbar, + * Also ensures if columns group, then it's windows are correctly proportioned. */ - if (!space.hasTopBar && - space.hasFullScreenWindow()) { + if (space.hasFullScreenWindow()) { needLayout = true; }