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 7, 2024
2 parents 797cf26 + 6cc99b4 commit ca81d2a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Users are enouraged to submit [issues](https://github.com/paperwm/PaperWM/issues
Most functionality is available using a mouse, eg. activating a window at the edge of the monitor by clicking on it. Wayland support gestures (See the [Touchpad Gestures](#touchpad-gestures) section). PaperWM is designed to work work well with keyboard + mouse, trackpads etc.
Most keybindings start with the <kbd>Super</kbd> modifier (by default), which is usually the Windows key, or on mac keyboards it's the Command key. It's possible to modify the keyboard layout so that <kbd>Super</kbd> is switched with <kbd>Alt</kbd> making all the keybindings easier to reach. This can be done through Gnome Tweaks under `Keybard & Mouse` ⟶ `Additional Layout Options` ⟶ `Alt/Win key behavior` ⟶ `Left Alt is swapped with Left Win`.
Most keybindings start with the <kbd>Super</kbd> modifier (by default), which is usually the Windows key, or on mac keyboards it's the Command key. It's possible to modify the keyboard layout so that <kbd>Super</kbd> is switched with <kbd>Alt</kbd> making all the keybindings easier to reach. This can be done through Gnome Tweaks under `Keyboard & Mouse` ⟶ `Additional Layout Options` ⟶ `Alt/Win key behavior` ⟶ `Left Alt is swapped with Left Win`.
Most keybindings will grab the keyboard while <kbd>Super</kbd> is held down, only switching focus when <kbd>Super</kbd> is released. <kbd>Escape</kbd> will abort the navigation taking you back to the previously active window.
Expand Down
10 changes: 9 additions & 1 deletion keybindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,15 @@ export function setupActions(settings) {
Meta.KeyBindingFlags.PER_WINDOW);

registerPaperAction("center-horizontally",
Tiling.centerWindowHorizontally,
(mw, _space) => Tiling.centerWindow(mw, true, false),
Meta.KeyBindingFlags.PER_WINDOW);

registerPaperAction("center-vertically",
(mw, _space) => Tiling.centerWindow(mw, false, true),
Meta.KeyBindingFlags.PER_WINDOW);

registerPaperAction("center",
(mw, _space) => Tiling.centerWindow(mw, true, true),
Meta.KeyBindingFlags.PER_WINDOW);

registerPaperAction('new-window',
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.15.1",
"version-name": "46.16.0",
"donations": {
"buymeacoffee": "jaytaala",
"patreon": "valpackett"
Expand Down
2 changes: 2 additions & 0 deletions prefsKeybinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const actions = {
'barf-out',
'barf-out-active',
'center-horizontally',
'center-vertically',
'center',
'paper-toggle-fullscreen',
'toggle-maximize-width',
'resize-h-inc',
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
10 changes: 10 additions & 0 deletions schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,16 @@
<summary>Center window horizontally</summary>
</key>

<key type="as" name="center-vertically">
<default><![CDATA[['<Super>v']]]></default>
<summary>Center window vertically (non-tiled window)</summary>
</key>

<key type="as" name="center">
<default><![CDATA[[]]]></default>
<summary>Center window</summary>
</key>

<key type="as" name="toggle-maximize-width">
<default><![CDATA[['<Super>f']]]></default>
<summary>Maximize the width of the active window</summary>
Expand Down
16 changes: 11 additions & 5 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ export class Space extends Array {
// if only one column on space, then center it
if (centerIfOne && this.length === 1) {
const mw = this.getWindows()[0];
centerWindowHorizontally(mw);
centerWindow(mw);
}

callback && callback();
Expand Down Expand Up @@ -3746,6 +3746,10 @@ export function resizeHandler(metaWindow) {
// Resizing from within a size-changed signal is troube (#73). Queue instead.
space.queueLayout(true, { callback, centerIfOne: false });
}

if (space.length === 1) {
centerWindow(metaWindow);
}
}

/**
Expand Down Expand Up @@ -4947,15 +4951,17 @@ function activateWindowAfterRendered(actor, mw) {
/**
* Centers the currently selected window.
*/
export function centerWindowHorizontally(metaWindow) {
export function centerWindow(metaWindow, horizontal = true, vertical = false) {
const frame = metaWindow.get_frame_rect();
const space = spaces.spaceOfWindow(metaWindow);
const monitor = space.monitor;
const workArea = space.workArea();

const targetX = workArea.x + Math.round((workArea.width - frame.width) / 2);
const targetX = horizontal ? workArea.x + Math.round((workArea.width - frame.width) / 2) : frame.x;
let targetY = vertical ? workArea.y + Math.round((workArea.height - frame.height) / 2) : frame.y;
targetY = Math.max(targetY, workArea.y);
if (space.indexOf(metaWindow) === -1) {
Scratch.easeScratch(metaWindow, targetX + monitor.x, frame.y);
Scratch.easeScratch(metaWindow, targetX + monitor.x, targetY);
} else {
move_to(space, metaWindow, {
x: targetX,
Expand Down Expand Up @@ -5003,7 +5009,7 @@ export function setFocusMode(mode, space) {
} else {
space.unfocusXPosition = workArea.width;
}
centerWindowHorizontally(selectedWin);
centerWindow(selectedWin);
}
break;
default:
Expand Down

0 comments on commit ca81d2a

Please sign in to comment.