Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
jtaala committed Jun 9, 2024
2 parents aa8107d + b4cc61f commit 43f0339
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 21 deletions.
38 changes: 37 additions & 1 deletion Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,43 @@
</child>
</object>
</child>

<child>
<object class="GtkListBoxRow">
<property name="activatable">False</property>
<property name="focusable">False</property>
<child>
<object class="GtkGrid">
<property name="focusable">False</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkLabel">
<property name="focusable">False</property>
<property name="tooltip_text" translatable="yes">Enables handling maximize events (like double clicking the header bar) by stretching window width but not going out of the tiling margins</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">Maximize within tiling</property>
<property name="xalign">0</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkSwitch" id="maximize-within-tiling">
<layout>
<property name="column">1</property>
<property name="row">0</property>
</layout>
</object>
</child>
</object>
</child>
</object>
</child>

<child>
<object class="GtkListBoxRow">
Expand Down
2 changes: 1 addition & 1 deletion gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export function update(space, dx, t) {
let target = Math.round(space.targetX - d);

space.targetX = target;
let selected = findTargetWindow(space, direction, start - space.targetX > 0);
const selected = findTargetWindow(space, start - space.targetX > 0);
space.targetX = space.cloneContainer.x;
Tiling.updateSelection(space, selected);
space.selectedWindow = selected;
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "https://github.com/paperwm/PaperWM",
"settings-schema": "org.gnome.shell.extensions.paperwm",
"shell-version": [ "45", "46" ],
"version-name": "46.10.2",
"version-name": "46.11.1",
"donations": {
"buymeacoffee": "jaytaala",
"patreon": "valpackett"
Expand Down
1 change: 1 addition & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ class SettingsWidget {
// disabled since opposite of gnome-pill
// booleanSetState('show-workspace-indicator');
percentValueChanged('maximize-width-percent', 'maximize-width-percent');
booleanStateChanged('maximize-within-tiling');

// About
// build version information
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
5 changes: 5 additions & 0 deletions schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,11 @@
<summary>Percent of workspace width the horizontal window maximise function (Super+F) will use.</summary>
</key>

<key type="b" name="maximize-within-tiling">
<default>true</default>
<summary>Handle maximize events from windows (e.g. header bar double click) by maximizing their width without going beyond the margins.</summary>
</key>

<key type="as" name="workspace-colors">
<default><![CDATA[['#314E6C', '#565248', '#445632', '#663822',
'#494066', '#826647', '#4B6983', '#807D74', '#5D7555', '#884631',
Expand Down
1 change: 1 addition & 0 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function enable(extension) {
'cycle-width-steps',
'cycle-height-steps',
'maximize-width-percent',
'maximize-within-tiling',
'minimap-scale',
'edge-preview-enable',
'edge-preview-scale',
Expand Down
67 changes: 49 additions & 18 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,12 @@ export class Space extends Array {
}

callback && callback();

// save the last size frame (for use in restoring)
this.getWindows().forEach(w => {
w._last_layout_frame = w.get_frame_rect();
});

this.emit('layout', this);
}

Expand Down Expand Up @@ -894,26 +900,26 @@ export class Space extends Array {
// check if mismatch tracking needed, otherwise leave
if (f.x === x && f.y === y) {
// delete any mismatch counter (e.g. from previous attempt)
delete w.pos_mismatch_count;
delete w._pos_mismatch_count;
return;
}

// guard against recursively calling this method
// see https://github.com/paperwm/PaperWM/issues/769
if (w.pos_mismatch_count &&
w.pos_mismatch_count > 1) {
if (w._pos_mismatch_count &&
w._pos_mismatch_count > 1) {
console.warn(`clone/window position-changed recursive call: ${w.title}`);
return;
}

// mismatch detected
// move frame to ensure window position matches clone
try {
if (!w.pos_mismatch_count) {
w.pos_mismatch_count = 0;
if (!w._pos_mismatch_count) {
w._pos_mismatch_count = 0;
}
else {
w.pos_mismatch_count += 1;
w._pos_mismatch_count += 1;
}
w.move_frame(true, x, y);
}
Expand Down Expand Up @@ -2013,9 +2019,9 @@ border-radius: ${borderWidth}px;

destroy() {
this.getWindows().forEach(w => {
removeHandlerFlags(w);
delete w.pos_mismatch_count;
delete w.tiled_on_minimize;


removePaperWMFlags(w);
});
this.signals.destroy();
this.signals = null;
Expand Down Expand Up @@ -2101,8 +2107,8 @@ export const Spaces = class Spaces extends Map {
// Clone and hook up existing windows
display.get_tab_list(Meta.TabList.NORMAL_ALL, null)
.forEach(w => {
// remove handler flags
removeHandlerFlags(w);
// remove flags
removePaperWMFlags(w);

registerWindow(w);
// Fixup allocations on reload
Expand Down Expand Up @@ -3339,9 +3345,28 @@ export function registerWindow(metaWindow) {
signals.connect(metaWindow, 'notify::minimized', metaWindow => {
minimizeHandler(metaWindow);
});

signals.connect(metaWindow, 'notify::maximized-horizontally', metaWindow => {
if (
Settings.prefs.maximize_within_tiling &&
metaWindow.get_maximized() === Meta.MaximizeFlags.BOTH) {
metaWindow.unmaximize(Meta.MaximizeFlags.BOTH);

// restore last layout frame
if (metaWindow._last_layout_frame) {
const lsf = metaWindow._last_layout_frame;
metaWindow.move_resize_frame(true, lsf.x, lsf.y, lsf.width, lsf.height);
}

toggleMaximizeHorizontally(metaWindow);
// spaces.spaceOfWindow(metaWindow)?.layout();
}
});

signals.connect(actor, 'show', actor => {
showHandler(actor);
});

signals.connect(actor, 'destroy', destroyHandler);

return true;
Expand Down Expand Up @@ -3397,12 +3422,18 @@ export function destroyHandler(actor) {
}

/**
* Removes resize and position handler flags.
* Removes resize, position, and other flags. Used during cleanup etc.
* @param {Meta.Window} metaWindow
*/
export function removeHandlerFlags(metaWindow) {
delete metaWindow._resizeHandlerAdded;
delete metaWindow._positionHandlerAdded;
export function removePaperWMFlags(w) {
delete w._targetWidth;
delete w._targetHeight;
delete w._resizeHandlerAdded;
delete w._positionHandlerAdded;
delete w._pos_mismatch_count;
delete w._tiled_on_minimize;
delete w._fullscreen_frame;
delete w._last_layout_frame;
}

export function addPositionHandler(metaWindow) {
Expand Down Expand Up @@ -4380,14 +4411,14 @@ export function minimizeHandler(metaWindow) {
console.debug('minimized', metaWindow?.title);
// check if was tiled
if (isTiled(metaWindow)) {
metaWindow.tiled_on_minimize = true;
metaWindow._tiled_on_minimize = true;
}
Scratch.makeScratch(metaWindow);
}
else {
console.debug('unminimized', metaWindow?.title);
if (metaWindow.tiled_on_minimize) {
delete metaWindow.tiled_on_minimize;
if (metaWindow._tiled_on_minimize) {
delete metaWindow._tiled_on_minimize;
Utils.later_add(Meta.LaterType.IDLE, () => {
Scratch.unmakeScratch(metaWindow);
});
Expand Down

0 comments on commit 43f0339

Please sign in to comment.