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 May 17, 2024
2 parents 3f30622 + a6eaa48 commit 359daed
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 70 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ Swiping the trackpad horizontally with three fingers (only available in Wayland)
| <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 |
| <kbd>Super</kbd><kbd>Ctrl</kbd><kbd>Up</kbd> or <kbd>Super</kbd><kbd>Ctrl</kbd><kbd>Down</kbd> | Move the current window up or down |
| <kbd>Super</kbd><kbd>I</kbd> | Absorb the window to the right into the active column |
| <kbd>Super</kbd><kbd>O</kbd> | Expel the bottom window out to the right |
| <kbd>Super</kbd><kbd>I</kbd> | Absorb window into the active column |
| <kbd>Super</kbd><kbd>O</kbd> | Expel the bottom window from vertically tiled windows |
| <kbd>Shift</kbd><kbd>Super</kbd><kbd>O</kbd> | Expel the active window from vertically tiled windows |
| <kbd>Super</kbd><kbd>C</kbd> | Center windows horizontally |
| <kbd>Shift</kbd><kbd>Super</kbd><kbd>F</kbd> | Toggle fullscreen |
| <kbd>Super</kbd><kbd>F</kbd> | Maximize the width of a window |
Expand Down
6 changes: 5 additions & 1 deletion keybindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ export function setupActions(settings) {
Meta.KeyBindingFlags.PER_WINDOW);

registerPaperAction('barf-out',
Tiling.barf,
(mw, _space) => Tiling.barf(mw),
Meta.KeyBindingFlags.PER_WINDOW);

registerPaperAction('barf-out-active',
(mw, _space) => Tiling.barf(mw, mw),
Meta.KeyBindingFlags.PER_WINDOW);

registerPaperAction('toggle-maximize-width',
Expand Down
2 changes: 1 addition & 1 deletion liveAltTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import GObject from 'gi://GObject';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as AltTab from 'resource:///org/gnome/shell/ui/altTab.js';

import { Utils, Settings, Keybindings, Tiling, Scratch } from './imports.js';
import { Settings, Keybindings, Tiling, Scratch } from './imports.js';
import { Easer } from './utils.js';

let switcherSettings;
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.9.0",
"version-name": "46.9.1",
"donations": {
"buymeacoffee": "jaytaala",
"patreon": "valpackett"
Expand Down
1 change: 1 addition & 0 deletions prefsKeybinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const actions = {
'move-down',
'slurp-in',
'barf-out',
'barf-out-active',
'center-horizontally',
'paper-toggle-fullscreen',
'toggle-maximize-width',
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
6 changes: 5 additions & 1 deletion schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,16 @@

<key type="as" name="slurp-in">
<default><![CDATA[['<Super>i']]]></default>
<summary>Consume the window to right into the active column</summary>
<summary>Consume window into the active column</summary>
</key>
<key type="as" name="barf-out">
<default><![CDATA[['<Super>o']]]></default>
<summary>Expel the bottom window into its own column</summary>
</key>
<key type="as" name="barf-out-active">
<default><![CDATA[['<Super><Shift>o']]]></default>
<summary>Expel the active window into its own column</summary>
</key>

<key type="as" name="resize-h-inc">
<default><![CDATA[['<Super><Shift>plus']]]></default>
Expand Down
154 changes: 91 additions & 63 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ export function enable(extension) {
gsettings.connect('changed::vertical-margin-bottom', marginsGapChanged);
gsettings.connect('changed::window-gap', marginsGapChanged);
gsettings.connect('changed::selection-border-size', () => {
const selected = spaces.activeSpace?.selectedWindow;
allocateClone(selected);
spaces.forEach(s => {
Settings.prefs.selection_border_size <= 0 ? s.hideSelection() : s.showSelection();
if (s.selectedWindow) {
allocateClone(s.selectedWindow);
}
});
});

backgroundGroup = Main.layoutManager._backgroundGroup;
Expand Down Expand Up @@ -498,7 +502,7 @@ export class Space extends Array {
windows.map(mw => mw.get_frame_rect().height),
height
);
let [w, relayout, y] = space.layoutColumnSimple(windows, x, y0, targetWidth, targetHeights, time);
let [, relayout, y] = space.layoutColumnSimple(windows, x, y0, targetWidth, targetHeights, time);
needRelayout = needRelayout || relayout;
return y;
}
Expand Down Expand Up @@ -1234,7 +1238,7 @@ export class Space extends Array {
}

globalToViewport(gx, gy) {
let [ok, vx, vy] = this.actor.transform_stage_point(gx, gy);
let [, vx, vy] = this.actor.transform_stage_point(gx, gy);
return [Math.round(vx), Math.round(vy)];
}

Expand Down Expand Up @@ -1337,6 +1341,7 @@ export class Space extends Array {

if (this.selectedWindow && this.selectedWindow === display.focus_window) {
let index = this.indexOf(this.selectedWindow);
// eslint-disable-next-line no-return-assign
this[index].forEach(w => w.lastFrame = w.get_frame_rect());

// callback on display.focusWindow window
Expand All @@ -1348,7 +1353,7 @@ export class Space extends Array {

/**
* Applies clipping to metaWindow's clone.
* @param {MetaWindow} metaWindow
* @param {Meta.Window} metaWindow
*/
applyClipToClone(metaWindow) {
if (!metaWindow) {
Expand Down Expand Up @@ -1431,6 +1436,9 @@ export class Space extends Array {
}

showSelection() {
if (Settings.prefs.selection_border_size <= 0) {
return;
}
this.selection.set_style_class_name('paperwm-selection tile-preview');
}

Expand Down Expand Up @@ -1795,8 +1803,8 @@ border-radius: ${borderWidth}px;
/**
* if user clicks on window, then ensureViewport on that window before exiting
*/
let [gx, gy, $] = global.get_pointer();
let [ok, x, y] = this.actor.transform_stage_point(gx, gy);
let [gx, gy] = global.get_pointer();
let [, x, y] = this.actor.transform_stage_point(gx, gy);
let windowAtPoint = !Gestures.gliding && this.getWindowAtPoint(x, y);
if (windowAtPoint) {
ensureViewport(windowAtPoint, this);
Expand All @@ -1820,7 +1828,7 @@ border-radius: ${borderWidth}px;
if (dir === Clutter.ScrollDirection.SMOOTH)
return;

let [gx, gy] = event.get_coords();
let [gx] = event.get_coords();
if (!gx) {
return;
}
Expand Down Expand Up @@ -1966,7 +1974,7 @@ border-radius: ${borderWidth}px;
let windows = workspace.list_windows()
.sort(xz_comparator(workspace.list_windows()));

windows.forEach((meta_window, i) => {
windows.forEach((meta_window, _i) => {
if (meta_window.above || meta_window.minimized) {
// Rough heuristic to figure out if a window should float
Scratch.makeScratch(meta_window);
Expand Down Expand Up @@ -3315,7 +3323,7 @@ export function registerWindow(metaWindow) {
// Note: runs before gnome-shell's minimize handling code
signals.connect(metaWindow, 'notify::fullscreen', () => {
// if window is in a column, expel it
barfThis(metaWindow);
barf(metaWindow, metaWindow);

Topbar.fixTopBar();
spaces.spaceOfWindow(metaWindow)?.setSpaceTopbarElementsVisible(true);
Expand Down Expand Up @@ -3378,7 +3386,7 @@ export function destroyHandler(actor) {

/**
* Removes resize and position handler flags.
* @param {MetaWindow} metaWindow
* @param {Meta.Window} metaWindow
*/
export function removeHandlerFlags(metaWindow) {
delete metaWindow._resizeHandlerAdded;
Expand Down Expand Up @@ -3531,7 +3539,7 @@ export function nonTiledSizeHandler(metaWindow) {
/**
* Saves a metaWindow's frame x, y ,width, and height for restoring
* after exiting fullscreen mode.
* @param {MetaWindow} metaWindow
* @param {Meta.Window} metaWindow
*/
export function saveFullscreenFrame(metaWindow, tiled) {
const f = metaWindow.get_frame_rect();
Expand Down Expand Up @@ -4682,7 +4690,7 @@ export function centerWindowHorizontally(metaWindow) {
*/
export function activateWindowUnderCursor(metaWindow, space) {
const [gx, gy] = global.get_pointer();
const [ok, x, y] = space.actor.transform_stage_point(gx, gy);
const [, x, y] = space.actor.transform_stage_point(gx, gy);
const mw = space?.getWindowAtPoint(x, y);
if (mw) {
ensureViewport(mw, space);
Expand Down Expand Up @@ -4831,27 +4839,42 @@ export function allocateEqualHeight(column, available) {
* this allows freshly created windows to be stacked without
* having to change focus
*/
/**
* "Slurps" a window into the currently active column, vertically
* stacking it.
* @param {Meta.Window} metaWindow
* @returns
*/
export function slurp(metaWindow) {
let space = spaces.spaceOfWindow(metaWindow);
let index = space.indexOf(metaWindow);

let to, from;
let metaWindowToSlurp;
let to, from, metaWindowToSlurp;

if (index + 1 < space.length) {
if (space.length < 2) {
return;
}

// if here, we have at least 2 columns

// get current direction mode
const direction = Settings.prefs.open_window_position;
switch (direction) {
case Settings.OpenWindowPositions.LEFT:
case Settings.OpenWindowPositions.START:
to = index;
from = to + 1;
metaWindowToSlurp = space[from][0];
} else if (index + 1 === space.length) {
if (space[index].length > 1)
return;
metaWindowToSlurp = metaWindow;
to = index - 1;
from = index;
from = index - 1;
break;
case Settings.OpenWindowPositions.RIGHT:
case Settings.OpenWindowPositions.END:
default:
to = index;
from = index + 1;
break;
}

// slurping fullscreen windows is trouble
if (!metaWindowToSlurp || space.length < 2) {
metaWindowToSlurp = space[from]?.[0];
if (!metaWindowToSlurp) {
return;
}

Expand All @@ -4863,50 +4886,34 @@ export function slurp(metaWindow) {
space[to].push(metaWindowToSlurp);

{ // Remove the slurped window
let column = space[from];
let row = column.indexOf(metaWindowToSlurp);
const column = space[from];
const row = column.indexOf(metaWindowToSlurp);
column.splice(row, 1);
if (column.length === 0)
space.splice(from, 1);
}

space.layout(true, {
customAllocators: { [to]: allocateEqualHeight, ensure: false },
});
}

/**
* Barfs the bottom window from a column.
* @param {MetaWindow} metaWindow
* @returns
*/
export function barf(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;
// if from column is now empty, remove column from space
if (column.length === 0) {
space.splice(from, 1);
}

let bottom = column.splice(-1, 1)[0];
space.splice(index + 1, 0, [bottom]);
// with column removed, `to` column may have changed
to = space.indexOf(metaWindow);
}

// after columns have slurped, "to" index may have changed
space.layout(true, {
customAllocators: { [index]: allocateEqualHeight, ensure: false },
customAllocators: {
[to]: allocateEqualHeight,
},
ensure: false,
});
}

/**
* Barfs (expels) a specific window from a column.
* @param {MetaWindow} metaWindow
* @param {Meta.Window} metaWindow
* @returns
*/
export function barfThis(metaWindow) {
export function barf(metaWindow, expelWindow) {
if (!metaWindow)
return;

Expand All @@ -4919,13 +4926,34 @@ export function barfThis(metaWindow) {
if (column.length < 2)
return;

// remove metawindow from column
const indexOfWindow = column.indexOf(metaWindow);
column.splice(indexOfWindow, 1);
space.splice(index + 1, 0, [metaWindow]);
let to;
const direction = Settings.prefs.open_window_position;
switch (direction) {
case Settings.OpenWindowPositions.LEFT:
case Settings.OpenWindowPositions.START:
to = index; // if left then current index will increment
break;
case Settings.OpenWindowPositions.RIGHT:
case Settings.OpenWindowPositions.END:
default:
to = index + 1;
break;
}

// // remove metawindow from column
if (expelWindow) {
// remove expelWindow from current column
const indexOfWindow = column.indexOf(expelWindow);
column.splice(indexOfWindow, 1);
}
else {
// remove from bottom
expelWindow = column.splice(-1, 1)[0];
}
space.splice(to, 0, [expelWindow]);

space.layout(true, {
customAllocators: { [index]: allocateEqualHeight, ensure: false },
customAllocators: { [space.indexOf(metaWindow)]: allocateEqualHeight, ensure: false },
});
}

Expand Down
1 change: 0 additions & 1 deletion topbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import * as panelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import * as popupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';

import { Settings, Utils, Tiling, Navigator, Scratch } from './imports.js';
import { Easer } from './utils.js';

// eslint-disable-next-line no-undef
const workspaceManager = global.workspace_manager;
Expand Down

0 comments on commit 359daed

Please sign in to comment.