Skip to content

Commit 71c9a03

Browse files
authored
FIX #747: regression when resizing consumed window group (#748)
This PR fixes #747. It also better manages fullscreening a window when it's in a consumed window group. Similarly, when "slurping" in a fullscreened window, unfullscreen it first (fullscreened windows in consumed window groups are trouble).
2 parents 84c6dab + fc6e6ef commit 71c9a03

File tree

1 file changed

+63
-15
lines changed

1 file changed

+63
-15
lines changed

Diff for: tiling.js

+63-15
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,6 @@ export class Space extends Array {
506506
let resizable = !mw.fullscreen &&
507507
mw.get_maximized() !== Meta.MaximizeFlags.BOTH;
508508

509-
if (mw._fullscreen_frame?.tiledWidth) {
510-
targetWidth = mw._fullscreen_frame.tiledWidth;
511-
}
512-
513509
if (mw.preferredWidth) {
514510
let prop = mw.preferredWidth;
515511
if (prop.value <= 0) {
@@ -640,14 +636,24 @@ export class Space extends Array {
640636
if (column.length === 0)
641637
continue;
642638

643-
let selectedInColumn = i === selectedIndex ? this.selectedWindow : null;
639+
// selected window in column
640+
const selectedInColumn = i === selectedIndex ? this.selectedWindow : null;
644641

645642
let targetWidth;
646-
if (i === selectedIndex) {
647-
targetWidth = selectedInColumn.get_frame_rect().width;
648-
} else {
649-
targetWidth = Math.max(...column.map(w => w.get_frame_rect().width));
643+
if (selectedInColumn) {
644+
// if selected window - use tiledWidth or frame.width (fallback)
645+
targetWidth =
646+
selectedInColumn?._fullscreen_frame?.tiledWidth ??
647+
selectedInColumn.get_frame_rect().width;
648+
}
649+
else {
650+
// otherwise get max of tiledWith or frame.with (fallback)
651+
targetWidth = Math.max(...column.map(w => {
652+
return w?._fullscreen_frame?.tiledWidth ?? w.get_frame_rect().width;
653+
}));
650654
}
655+
656+
// enforce minimum
651657
targetWidth = Math.min(targetWidth, workArea.width - 2 * Settings.prefs.minimum_margin);
652658

653659
let resultingWidth, relayout;
@@ -3018,6 +3024,9 @@ export function registerWindow(metaWindow) {
30183024
signals.connect(metaWindow, 'size-changed', allocateClone);
30193025
// Note: runs before gnome-shell's minimize handling code
30203026
signals.connect(metaWindow, 'notify::fullscreen', () => {
3027+
// if window is in a column, expel it
3028+
barfThis(metaWindow);
3029+
30213030
Topbar.fixTopBar();
30223031
spaces.spaceOfWindow(metaWindow)?.setSpaceTopbarElementsVisible(true);
30233032
});
@@ -3196,7 +3205,7 @@ export function nonTiledSizeHandler(metaWindow) {
31963205
return;
31973206
}
31983207

3199-
// if pwm fullscreen previously
3208+
// if here then was previously in fullscreen (and came out of)
32003209
if (metaWindow._fullscreen_lock) {
32013210
delete metaWindow._fullscreen_lock;
32023211
let fsf = metaWindow._fullscreen_frame;
@@ -3894,7 +3903,7 @@ export function getDefaultFocusMode() {
38943903
}
38953904

38963905
// `MetaWindow::focus` handling
3897-
export function focus_handler(metaWindow, user_data) {
3906+
export function focus_handler(metaWindow) {
38983907
console.debug("focus:", metaWindow?.title);
38993908
if (Scratch.isScratchWindow(metaWindow)) {
39003909
setAllWorkspacesInactive();
@@ -3918,11 +3927,11 @@ export function focus_handler(metaWindow, user_data) {
39183927
else {
39193928
let needLayout = false;
39203929
/**
3921-
* For non-topbar spaces, bring down fullscreen windows to mimic
3922-
* gnome behaviour with a topbar.
3930+
* If has fullscreen window - when selected non-fullscreen window, do layout:
3931+
* For non-topbar spaces, Bring down fullscreen windows to mimic gnome behaviour with a topbar,
3932+
* Also ensures if columns group, then it's windows are correctly proportioned.
39233933
*/
3924-
if (!space.hasTopBar &&
3925-
space.hasFullScreenWindow()) {
3934+
if (space.hasFullScreenWindow()) {
39263935
needLayout = true;
39273936
}
39283937

@@ -4488,10 +4497,16 @@ export function slurp(metaWindow) {
44884497
from = index;
44894498
}
44904499

4500+
// slurping fullscreen windows is trouble
44914501
if (!metaWindowToSlurp || space.length < 2) {
44924502
return;
44934503
}
44944504

4505+
// slurping fullscreen windows is trouble, unfullscreen when slurping
4506+
if (metaWindowToSlurp?.fullscreen) {
4507+
metaWindowToSlurp.unmake_fullscreen();
4508+
}
4509+
44954510
space[to].push(metaWindowToSlurp);
44964511

44974512
{ // Remove the slurped window
@@ -4507,6 +4522,11 @@ export function slurp(metaWindow) {
45074522
});
45084523
}
45094524

4525+
/**
4526+
* Barfs the bottom window from a column.
4527+
* @param {MetaWindow} metaWindow
4528+
* @returns
4529+
*/
45104530
export function barf(metaWindow) {
45114531
if (!metaWindow)
45124532
return;
@@ -4528,6 +4548,34 @@ export function barf(metaWindow) {
45284548
});
45294549
}
45304550

4551+
/**
4552+
* Barfs (expels) a specific window from a column.
4553+
* @param {MetaWindow} metaWindow
4554+
* @returns
4555+
*/
4556+
export function barfThis(metaWindow) {
4557+
if (!metaWindow)
4558+
return;
4559+
4560+
let space = spaces.spaceOfWindow(metaWindow);
4561+
let index = space.indexOf(metaWindow);
4562+
if (index === -1)
4563+
return;
4564+
4565+
let column = space[index];
4566+
if (column.length < 2)
4567+
return;
4568+
4569+
// remove metawindow from column
4570+
const indexOfWindow = column.indexOf(metaWindow);
4571+
column.splice(indexOfWindow, 1);
4572+
space.splice(index + 1, 0, [metaWindow]);
4573+
4574+
space.layout(true, {
4575+
customAllocators: { [index]: allocateEqualHeight, ensure: false },
4576+
});
4577+
}
4578+
45314579
export function selectPreviousSpace(mw, space) {
45324580
spaces.selectStackSpace(Meta.MotionDirection.DOWN);
45334581
}

0 commit comments

Comments
 (0)