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 Aug 13, 2024
2 parents 80666c0 + 9721269 commit 2c3e76a
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 45 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ Swiping the trackpad horizontally with three fingers (only available in Wayland)
| <kbd>Ctrl</kbd><kbd>Alt</kbd><kbd>Tab</kbd> | Cycle through previously active scratch windows |
| <kbd>Shift</kbd><kbd>Ctrl</kbd><kbd>Alt</kbd><kbd>Tab</kbd> | Cycle through previously active scratch windows (backward order) |
| <kbd>Shift</kbd><kbd>Super</kbd><kbd>C</kbd> | Switch between window focus modes |
| <kbd>Shift</kbd><kbd>Super</kbd><kbd>W</kbd> | Switch between positions for creating new windows |
| _Not set by default (set in extension settings)_ | Create new windows to the right of current window |
| _Not set by default (set in extension settings)_ | Create new windows to the left of current window |
| _Not set by default (set in extension settings)_ | Create new windows in vertical stack (down) |
| _Not set by default (set in extension settings)_ | Create new windows in vertical stack (up) |
| _Not set by default (set in extension settings)_ | Create new windows at start position |
| _Not set by default (set in extension settings)_ | Create new windows at end position |
| <kbd>Shift</kbd><kbd>Super</kbd><kbd>W</kbd> | Switch between positions for creating/dropping new windows |
| _Not set by default (set in extension settings)_ | Create/drop windows to the right of current window |
| _Not set by default (set in extension settings)_ | Create/drop windows to the left of current window |
| _Not set by default (set in extension settings)_ | Create/drop windows in vertical stack (down) |
| _Not set by default (set in extension settings)_ | Create/drop windows in vertical stack (up) |
| _Not set by default (set in extension settings)_ | Create/drop windows at start position |
| _Not set by default (set in extension settings)_ | Create/drop windows at end position |
| <kbd>Super</kbd><kbd>Ctrl</kbd><kbd>,</kbd> or <kbd>Super</kbd><kbd>Ctrl</kbd><kbd>.</kbd> | Move the current window to the left or right |
| <kbd>Shift</kbd><kbd>Super</kbd><kbd>,</kbd> or <kbd>Shift</kbd><kbd>Super</kbd><kbd>.</kbd> | Move the current window to the left or right |
| <kbd>Super</kbd><kbd>Ctrl</kbd><kbd>Left</kbd> or <kbd>Super</kbd><kbd>Ctrl</kbd><kbd>Right</kbd> | Move the current window to the left or right |
Expand Down Expand Up @@ -280,9 +280,9 @@ You do this by using the special "match all" operator `*` as an input for `wm_cl
This special operator is at a lower precedence, so more specific properties that match a window will always take precedence and be applied.
## Window insertion position for new windows
## Window insertion position for new windows (and dropped windows in `take` mode)
By default PaperWM inserts new windows to the right of the currently active window. This behaviour can be changed via PaperWM settings, or with the `Open Window Position` button/icon (which is to the right of the focus mode icon):
By default PaperWM inserts new windows (and drops windows in `take` mode, see [Managing multiple windows at once](#managing-multiple-windows-at-once)) to the right of the currently active window. This behaviour can be changed via PaperWM settings, or with the `Open Window Position` button/icon (which is to the right of the focus mode icon):
![Open positions button](media/open-position-button.png)
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.16.1",
"version-name": "46.17.0",
"donations": {
"buymeacoffee": "jaytaala",
"patreon": "valpackett"
Expand Down
14 changes: 7 additions & 7 deletions schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,31 +182,31 @@

<key type="as" name="switch-open-window-position">
<default><![CDATA[['<Super><Shift>w']]]></default>
<summary>Switch between positions for creating windows (e.g. right, left)</summary>
<summary>Switch between positions for creating/dropping windows</summary>
</key>
<key type="as" name="open-window-position-right">
<default><![CDATA[[]]]></default>
<summary>Create new windows to the right</summary>
<summary>Create/drop windows to the right</summary>
</key>
<key type="as" name="open-window-position-left">
<default><![CDATA[[]]]></default>
<summary>Create new windows to the left</summary>
<summary>Create/drop windows to the left</summary>
</key>
<key type="as" name="open-window-position-down">
<default><![CDATA[[]]]></default>
<summary>Create new windows in vertical stack (down)</summary>
<summary>Create/drop windows in vertical stack (down)</summary>
</key>
<key type="as" name="open-window-position-up">
<default><![CDATA[[]]]></default>
<summary>Create new windows in vertical stack (up)</summary>
<summary>Create/drop windows in vertical stack (up)</summary>
</key>
<key type="as" name="open-window-position-start">
<default><![CDATA[[]]]></default>
<summary>Create new windows at start position</summary>
<summary>Create/drop windows at start position</summary>
</key>
<key type="as" name="open-window-position-end">
<default><![CDATA[[]]]></default>
<summary>Create new windows at end position</summary>
<summary>Create/drop windows at end position</summary>
</key>

<key type="as" name="switch-next">
Expand Down
90 changes: 62 additions & 28 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -3964,7 +3964,11 @@ export function add_handler(_ws, metaWindow) {
and `Display::window-created` through `WindowActor::show` if window is newly
created to ensure that the WindowActor exists.
*/
export function insertWindow(metaWindow, { existing }) {
export function insertWindow(metaWindow, options = {}) {
const existing = options?.existing ?? false;
const dropping = options?.dropping ?? false;
const dropCallback = options?.dropCallback ?? function() {};

// Add newly created windows to the space being previewed
if (!existing &&
!metaWindow.is_on_all_workspaces() &&
Expand Down Expand Up @@ -4096,6 +4100,40 @@ export function insertWindow(metaWindow, { existing }) {
// run a simple layout in pre-prepare layout
space.layout(false);

const slurpCheck = timeout => {
let slurpPosition;
switch (Settings.prefs.open_window_position) {
case Settings.OpenWindowPositions.DOWN:
slurpPosition = SlurpInsertPosition.BELOW;
break;
case Settings.OpenWindowPositions.UP:
slurpPosition = SlurpInsertPosition.ABOVE;
break;
}

if (!slurpPosition) {
dropCallback(metaWindow);
return;
}

// has slurpPosition but no timeout
if (!timeout) {
slurp(active, slurpPosition);
dropCallback(metaWindow);
return;
}

// if need to slurp (i.e. vertical stack)
stackSlurpTimeout = GLib.timeout_add(
GLib.PRIORITY_DEFAULT,
100,
() => {
slurp(active, slurpPosition);
dropCallback(metaWindow);
return false; // on return false destroys timeout
});
};

/**
* If window is new, then setup and ensure is in view
* after actor is shown on stage.
Expand All @@ -4118,26 +4156,7 @@ export function insertWindow(metaWindow, { existing }) {
ensureViewport(space.selectedWindow, space);
space.setSpaceTopbarElementsVisible(true);

let slurpPosition;
switch (Settings.prefs.open_window_position) {
case Settings.OpenWindowPositions.DOWN:
slurpPosition = SlurpInsertPosition.BELOW;
break;
case Settings.OpenWindowPositions.UP:
slurpPosition = SlurpInsertPosition.ABOVE;
break;
}

// if need to slurp (i.e. vertical stack)
if (slurpPosition) {
stackSlurpTimeout = GLib.timeout_add(
GLib.PRIORITY_DEFAULT,
100,
() => {
slurp(active, slurpPosition);
return false; // on return false destroys timeout
});
}
slurpCheck(true);
});

return;
Expand All @@ -4152,6 +4171,10 @@ export function insertWindow(metaWindow, { existing }) {
} else {
ensureViewport(space.selectedWindow, space);
}

if (dropping) {
slurpCheck(false);
}
}

/**
Expand Down Expand Up @@ -5130,6 +5153,10 @@ export function slurp(metaWindow, insertAt = SlurpInsertPosition.BOTTOM) {
}

const space = spaces.spaceOfWindow(metaWindow);
if (!space) {
return;
}

const index = space.indexOf(metaWindow);
let to, from, metaWindowToSlurp;

Expand Down Expand Up @@ -5299,11 +5326,11 @@ export function moveUpSpace(_mw, _space) {
Detach the @metaWindow, storing it at the bottom right corner while
navigating. When done, insert all the detached windows again.
*/
export function takeWindow(metaWindow, space, params) {
export function takeWindow(metaWindow, space, options = {}) {
space = space ?? spaces.selectedSpace;
metaWindow = metaWindow ?? space.selectedWindow;
const navigator = params?.navigator ?? Navigator.getNavigator();
const existing = params?.existing ?? false;
const navigator = options?.navigator ?? Navigator.getNavigator();
const existing = options?.existing ?? false;

if (!existing && !space.removeWindow(metaWindow))
return;
Expand Down Expand Up @@ -5375,7 +5402,7 @@ export function takeWindow(metaWindow, space, params) {
const pop = navigator._moving.pop();
if (pop) {
changeSpace(pop);
insertWindow(pop, { existing: true });
insertWindow(pop, { existing: true, dropping: true });
// make space selectedWindow (keeps index for next insert)
selectedSpace().selectedWindow = pop;
ensureViewport(pop);
Expand All @@ -5400,8 +5427,15 @@ export function takeWindow(metaWindow, space, params) {
case Clutter.KEY_q: {
navigator._moving.forEach(w => {
changeSpace(w);
insertWindow(w, { existing: true });
w.delete(global.get_current_time());
insertWindow(
w,
{
existing: true,
dropping: true,
dropCallback: mw => {
mw.delete(global.get_current_time());
},
});
});

navigator._moving = [];
Expand All @@ -5421,7 +5455,7 @@ export function takeWindow(metaWindow, space, params) {
let selectedSpace = spaces.selectedSpace;
navigator._moving.forEach(w => {
changeSpace(w);
insertWindow(w, { existing: true });
insertWindow(w, { existing: true, dropping: true });

// make space selectedWindow (keeps index for next insert)
selectedSpace.selectedWindow = w;
Expand Down

0 comments on commit 2c3e76a

Please sign in to comment.