Skip to content

Commit

Permalink
Persistent centered mode (aka "Sticky Centering") (#482)
Browse files Browse the repository at this point in the history
Fixes #332, #299.

Implements focus modes (refer to README.md for more informatin) and adds a CENTER mode, which when applied causes all windows to center horizontally on window selection.

Focus modes can be toggled via keybinding or a new focus mode icon in the topbar.
  • Loading branch information
jtaala committed Mar 16, 2023
2 parents bc524a9 + 0153216 commit d5e45a3
Show file tree
Hide file tree
Showing 15 changed files with 459 additions and 55 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ Keybindings.bindkey("<Super>j", "my-favorite-width",

See `examples/keybindings.js` for more examples.

### Window Position Bar (colored bar segment added to Gnome Top Bar)
## Window Position Bar (colored bar segment in Top Bar)



[#476](https://github.com/paperwm/PaperWM/pull/476) added a coloured window position bar to the Gnome Top Bar. This allows users to visually identify the current selected window position of the scrollable viewport in the current workspace. This is demonstrated in the following video:

https://user-images.githubusercontent.com/30424662/221416159-464d7512-5174-451b-9035-0ee84f9eb4ec.mp4

The the window position bar can be _disabled_ from `PaperWM extension settings` or via `dconf`, e.g. by executing the following command a terminal:
The the window position bar can be _disabled_ from `PaperWM extension settings` or via `dconf`, e.g. by executing the following command in a terminal:

```
dconf write /org/gnome/shell/extensions/paperwm/show-window-position-bar false
Expand All @@ -292,6 +292,21 @@ You can style both the coloured position bar and the dimmed "position bar backdr

_Note: PaperWM overrides the default Gnome Top Bar style to be completely transparent so that the dimmed `window-position-bar-backdrop` and`window-position-bar` elements are visible._

## Window Focus Mode ##

[#482](https://github.com/paperwm/PaperWM/pull/482) added the concept of `window focus modes` to PaperWM. A `focus mode` controls how windows are "focused". For example, the `CENTER` focus mode causes all windows to be centered horizontally on selection, whereas the `DEFAULT` focus mode is the traditional PaperWM behaviour.

Focus modes can be toggled by user-settable keybinding (default is `Super`+`Shift`+`c`), or by clicking the new focus-mode button in the topbar:

![Focus mode button](media/focus-mode-button.png)

You may prefer to hide the focus mode icon. You can do so by executing the following command in a terminal:

```
dconf write /org/gnome/shell/extensions/paperwm/show-focus-mode-icon false
```


## Fixed Window Size ##

See the [Winprops](#winprops) section for a way to set the default _width_ of windows identified by their `wm_class` window property.
Expand Down
4 changes: 4 additions & 0 deletions keybindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ function init() {
Scratch),
Meta.KeyBindingFlags.PER_WINDOW);

registerPaperAction("switch-focus-mode",
dynamic_function_ref("switchToNextFocusMode",
Tiling));

registerPaperAction("develop-set-globals",
dynamic_function_ref("setDevGlobals",
Utils));
Expand Down
Binary file added media/focus-mode-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions minimap.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ var Minimap = class Minimap extends Array {
}

this.layout();
let time = animate ? 0.25 : 0;
let time = animate ? prefs.animation_time : 0;
this.actor.show();
Tweener.addTween(this.actor,
{opacity: 255, time, mode: Clutter.AnimationMode.EASE_OUT_EXPO});
Expand All @@ -131,7 +131,7 @@ var Minimap = class Minimap extends Array {
hide(animate) {
if (this.destroyed)
return;
let time = animate ? 0.25 : 0;
let time = animate ? prefs.animation_time : 0;
Tweener.addTween(this.actor,
{opacity: 0, time, mode: Clutter.AnimationMode.EASE_OUT_EXPO,
onComplete: () => this.actor.hide() });
Expand Down
2 changes: 1 addition & 1 deletion navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class NavigatorClass {
this._block = Main.wm._blockAnimations;
Main.wm._blockAnimations = true;
// Meta.disable_unredirect_for_screen(screen);
this.space = Tiling.spaces.spaceOf(workspaceManager.get_active_workspace());
this.space = Tiling.spaces.getActiveSpace();

this._startWindow = this.space.selectedWindow;
this.from = this.space;
Expand Down
1 change: 1 addition & 0 deletions prefsKeybinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const actions = {
'switch-last',
'live-alt-tab',
'live-alt-tab-backward',
'switch-focus-mode',
'move-left',
'move-right',
'move-up',
Expand Down
9 changes: 9 additions & 0 deletions resources/ICONS.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SVG icons adapted from `sidebar-show-right-symbolic.svg` and `preferences-desktop-multitasking-symbolic.svg` icons from "GNOME Project" adwaita-icon-theme (https://github.com/GNOME/adwaita-icon-theme).

See http://www.gnome.org for more information.

The icons are licensed under Creative Commons Attribution-Share Alike 3.0 United States License.

To view a copy of the CC-BY-SA licence, visit
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA.
4 changes: 4 additions & 0 deletions resources/focus-mode-center-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions resources/focus-mode-default-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified schemas/gschemas.compiled
Binary file not shown.
12 changes: 11 additions & 1 deletion schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
<default><![CDATA[['<Super>t']]]></default>
<summary>Take the window, dropping it when finished navigating</summary>
</key>

<key type="as" name="switch-focus-mode">
<default><![CDATA[['<Super><Shift>c']]]></default>
<summary>Switch between Window Focus Modes (e.g. default, center)</summary>
</key>

<key type="as" name="switch-next">
<default><![CDATA[['<Super>period']]]></default>
Expand Down Expand Up @@ -243,7 +248,7 @@
</key>
<key type="b" name="show-top-bar">
<default>true</default>
<summary>Wether to hide the top bar or not</summary>
<summary>Show the topbar</summary>
</key>
<key type="s" name="color">
<default>''</default>
Expand Down Expand Up @@ -374,6 +379,11 @@
<summary>Show the window position bar in the topbar</summary>
</key>

<key type="b" name="show-focus-mode-icon">
<default>true</default>
<summary>Show the focus mode icon in the topbar</summary>
</key>

<key type="d" name="animation-time">
<default>0.25</default>
<summary>Duration of animations in seconds</summary>
Expand Down
2 changes: 1 addition & 1 deletion settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var prefs = {};
'workspace-colors', 'default-background', 'animation-time', 'use-workspace-name',
'pressure-barrier', 'default-show-top-bar', 'swipe-sensitivity', 'swipe-friction',
'cycle-width-steps', 'cycle-height-steps', 'topbar-follow-focus', 'minimap-scale',
'winprops', 'show-window-position-bar']
'winprops', 'show-window-position-bar', 'show-focus-mode-icon']
.forEach((k) => setState(null, k));

prefs.__defineGetter__("minimum_margin", function() { return Math.min(15, this.horizontal_margin) });
Expand Down
22 changes: 22 additions & 0 deletions stylesheet.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
.space-label-wrapper {
padding: 0 10px 0 0;
background-color: transparent;
border-image: none;
background-image: none;
border: none;
}

.space-focus-mode-icon {
icon-size: 16px;
padding: 0 18px 0 18px;
margin-left: 3px;
background-color: transparent;
}

.focus-button-tooltip {
background-color: rgba(0, 0, 0, 0.7);
padding: 8px;
border-radius: 8px;
font-weight: 600;
}

.topbar-clear {
background-color: rgba(0, 0, 0, 0);
}
Expand Down
Loading

0 comments on commit d5e45a3

Please sign in to comment.