Skip to content

Commit ceea1d7

Browse files
committed
EXPERIMENTAL: save widths from prior to paperwm fullscreens.
1 parent 7e74143 commit ceea1d7

1 file changed

Lines changed: 68 additions & 21 deletions

File tree

tiling.js

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,10 @@ export class Space extends Array {
509509
let resizable = !mw.fullscreen &&
510510
mw.get_maximized() !== Meta.MaximizeFlags.BOTH;
511511

512+
if (mw._fullscreen_width) {
513+
targetWidth = mw._fullscreen_width;
514+
}
515+
512516
if (mw.preferredWidth) {
513517
let prop = mw.preferredWidth;
514518
if (prop.value <= 0) {
@@ -590,8 +594,9 @@ export class Space extends Array {
590594
return;
591595

592596
// option properties
593-
let ensure = options?.ensure ?? true;
594-
let allocators = options?.customAllocators;
597+
const ensure = options?.ensure ?? true;
598+
const allocators = options?.customAllocators;
599+
const callback = options?.callback;
595600

596601
this._inLayout = true;
597602
this.startAnimate();
@@ -709,24 +714,35 @@ export class Space extends Array {
709714
console.log(`with idle clear fullscreenOnLayout: ${global.get_current_time()}`);
710715
this.getWindows().forEach(w => {
711716
if (w.fullscreenOnLayout) {
712-
resizeHandler(w);
717+
resizeHandler(x);
713718
delete w.fullscreenOnLayout;
714719
}
715720
});
716721
});
717722

718723
console.log(`emit layout: ${global.get_current_time()}`);
724+
if (callback) {
725+
callback();
726+
}
719727
this.emit('layout', this);
720728
}
721729

722-
queueLayout(animate = true) {
730+
queueLayout(animate = true, options = {}) {
723731
if (this._layoutQueued)
724732
return;
725733

734+
const callback = options?.callback;
735+
726736
this._layoutQueued = true;
727737
Utils.later_add(Meta.LaterType.RESIZE, () => {
728738
this._layoutQueued = false;
729-
this.layout(animate);
739+
740+
if (callback) {
741+
this.layout(animate, { callback });
742+
}
743+
else {
744+
this.layout();
745+
}
730746
});
731747
}
732748

@@ -1910,6 +1926,7 @@ export const Spaces = class Spaces extends Map {
19101926
// Fixup allocations on reload
19111927
allocateClone(w);
19121928
this.signals.connect(w, 'size-changed', resizeHandler);
1929+
this.signals.connect(w, 'position-changed', positionChangeHandler);
19131930
});
19141931
this._initDone = true;
19151932

@@ -3055,8 +3072,19 @@ export function destroyHandler(actor) {
30553072
signals.disconnect(actor);
30563073
}
30573074

3075+
export function positionChangeHandler(metaWindow) {
3076+
// don't update saved position if fullscreen
3077+
if (metaWindow.fullscreen || metaWindow?._fullscreen_lock) {
3078+
return;
3079+
}
3080+
3081+
const f = metaWindow.get_frame_rect();
3082+
metaWindow._fullscreen_x = f.x;
3083+
console.log(`_fullscreen_x changed: ${f.x}`);
3084+
}
3085+
30583086
export function resizeHandler(metaWindow) {
3059-
console.log(`resize handler called on ${metaWindow?.title}`);
3087+
console.error(new Error(`resize handler called on ${metaWindow?.title}`));
30603088

30613089
// if navigator is showing, reset/refresh it after a window has resized
30623090
if (Navigator.navigating) {
@@ -3067,10 +3095,6 @@ export function resizeHandler(metaWindow) {
30673095
return;
30683096

30693097
const f = metaWindow.get_frame_rect();
3070-
let needLayout = false;
3071-
if (metaWindow._targetWidth !== f.width || metaWindow._targetHeight !== f.height) {
3072-
needLayout = true;
3073-
}
30743098
metaWindow._targetWidth = null;
30753099
metaWindow._targetHeight = null;
30763100

@@ -3079,28 +3103,48 @@ export function resizeHandler(metaWindow) {
30793103
return;
30803104

30813105
const selected = metaWindow === space.selectedWindow;
3106+
let moveToCallback = false;
30823107
let animate = true;
30833108
let x;
30843109

30853110
// if window is fullscreened, then don't animate background space.container animation etc.
3086-
if (metaWindow?.fullscreen) {
3111+
if (metaWindow.fullscreen) {
3112+
metaWindow._fullscreen_lock = true;
3113+
moveToCallback = true;
30873114
animate = false;
30883115
x = 0;
3089-
} else {
3090-
x = metaWindow.get_frame_rect().x - space.monitor.x;
3116+
}
3117+
else {
3118+
x = metaWindow._fullscreen_x ?? f.x - space.monitor.x;
3119+
x = Math.max(x, Settings.prefs.horizontal_margin);
3120+
3121+
// if pwm fullscreen previously
3122+
if (metaWindow._fullscreen_lock) {
3123+
moveToCallback = true;
3124+
delete metaWindow._fullscreen_lock;
3125+
}
3126+
else {
3127+
console.error(new Error('_fullscreen_width saved'));
3128+
metaWindow._fullscreen_width = f.width;
3129+
console.log(`save _fullscreen_width ${metaWindow?.title}: ${metaWindow?._fullscreen_width}`);
3130+
}
30913131
}
30923132

3093-
if (!space._inLayout && needLayout) {
3133+
if (!space._inLayout) {
30943134
// Restore window position when eg. exiting fullscreen
3095-
if (!Navigator.navigating && selected) {
3096-
move_to(space, metaWindow, {
3097-
x,
3098-
animate,
3099-
});
3135+
let callback = () => {};
3136+
if (moveToCallback && !Navigator.navigating && selected) {
3137+
callback = () => {
3138+
console.log(`callback! x:${x}`);
3139+
move_to(space, metaWindow, {
3140+
x,
3141+
animate,
3142+
});
3143+
};
31003144
}
31013145

31023146
// Resizing from within a size-changed signal is troube (#73). Queue instead.
3103-
space.queueLayout(animate);
3147+
space.queueLayout(animate, { callback });
31043148
}
31053149
}
31063150

@@ -3287,7 +3331,10 @@ export function insertWindow(metaWindow, { existing }) {
32873331
if (tiled) {
32883332
animateWindow(metaWindow);
32893333
}
3290-
metaWindow.unmapped && signals.connect(metaWindow, 'size-changed', resizeHandler);
3334+
if (metaWindow.unmapped) {
3335+
signals.connect(metaWindow, 'size-changed', resizeHandler);
3336+
signals.connect(metaWindow, 'position-changed', positionChangeHandler);
3337+
}
32913338
delete metaWindow.unmapped;
32923339
};
32933340

0 commit comments

Comments
 (0)