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 Apr 8, 2024
2 parents 060c2d6 + fa3834e commit c8e6dbe
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ['https://buymeacoffee.com/jaytaala', 'https://github.com/paperwm/PaperWM/discussions/723#discussioncomment-8290949'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
custom: ['https://buymeacoffee.com/jaytaala', 'https://www.patreon.com/valpackett'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@ _Note: PaperWM overrides the default Gnome Top Bar style to be completely transp
## 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.
[#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". The following modes are currently available:
- the `DEFAULT` focus mode is the traditional PaperWM behaviour (no snapping, just free scrolling)
- the `CENTER` focus mode causes all windows to be centered horizontally on selection
- the `EDGE` focus mode causes windows to snap to the closest edge horizontally on selection (but while there is only one window, it is centered)
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:
Expand Down
83 changes: 42 additions & 41 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,48 @@
</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="tooltip_text" translatable="yes">Sets default focus mode used in workspaces</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="hexpand">1</property>
<property name="label" translatable="yes">Default &lt;i&gt;window focus mode&lt;/i&gt; for workspaces</property>
<property name="use_markup">1</property>
<property name="xalign">0</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="default-focus-mode">
<property name="focusable">False</property>
<property name="hexpand">0</property>
<property name="width-request">106</property>
<items>
<item id="default" translatable="yes">Default</item>
<item id="center" translatable="yes">Center</item>
<item id="edge" translatable="yes">Edge</item>
</items>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="activatable">False</property>
Expand Down Expand Up @@ -1478,47 +1520,6 @@
<style>
<class name="frame" />
</style>
<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="tooltip_text" translatable="yes">Sets default focus mode used in workspaces</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="hexpand">1</property>
<property name="label" translatable="yes">Default focus mode for workspaces</property>
<property name="use_markup">1</property>
<property name="xalign">0</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="default-focus-mode">
<property name="focusable">False</property>
<property name="hexpand">0</property>
<property name="width-request">106</property>
<items>
<item id="default" translatable="yes">Default</item>
<item id="center" translatable="yes">Center</item>
</items>
</object>
</child>
</object>
</child>
</object>
</child>
<!--<child>
<object class="GtkListBoxRow">
<property name="activatable">False</property>
Expand Down
5 changes: 3 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"url": "https://github.com/paperwm/PaperWM",
"settings-schema": "org.gnome.shell.extensions.paperwm",
"shell-version": [ "45", "46" ],
"version-name": "46.3.2",
"version-name": "46.4.0",
"donations": {
"buymeacoffee": "jaytaala"
"buymeacoffee": "jaytaala",
"patreon": "valpackett"
}
}
1 change: 1 addition & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ class SettingsWidget {
{
'default': 0,
'center': 1,
'edge': 2,
},
'default',
0);
Expand Down
8 changes: 6 additions & 2 deletions resources/ICONS.info
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
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).
SVG icons adapted from "GNOME Project" adwaita-icon-theme (https://github.com/GNOME/adwaita-icon-theme):

- `sidebar-show-right-symbolic.svg`
- `preferences-desktop-multitasking-symbolic.svg`
- `zoom-fit-best-symbolic.svg`

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.
Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA.
4 changes: 4 additions & 0 deletions resources/focus-mode-edge-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@

<key type="i" name="default-focus-mode">
<default>0</default>
<summary>Set the default focus mode. 0:DEFAULT 1:CENTER</summary>
<summary>Set the default focus mode. 0:DEFAULT 1:CENTER 2:EDGE</summary>
</key>

<key type="i" name="open-window-position">
Expand Down
27 changes: 23 additions & 4 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const PreviewMode = { NONE: 0, STACK: 1, SEQUENTIAL: 2 }; // export
export let inPreview = PreviewMode.NONE; // export

// DEFAULT mode is normal/original PaperWM window focus behaviour
export const FocusModes = { DEFAULT: 0, CENTER: 1 }; // export
export const FocusModes = { DEFAULT: 0, CENTER: 1, EDGE: 2 }; // export

export const CycleWindowSizesDirection = { FORWARD: 0, BACKWARDS: 1 };

Expand Down Expand Up @@ -343,6 +343,9 @@ export class Space extends Array {
let workspace = this.workspace;
let prevSpace = saveState.getPrevSpaceByUUID(this.uuid);
console.info(`restore by uuid: ${this.uuid}, prevSpace name: ${prevSpace?.name}`);

// get previous focus mode (if exists)
const focusMode = prevSpace?.focusMode;
this.addAll(prevSpace);
saveState.prevSpaces.delete(workspace);
this._populated = true;
Expand All @@ -352,7 +355,7 @@ export class Space extends Array {
this.setSpaceTopbarElementsVisible();

// apply default focus mode
setFocusMode(getDefaultFocusMode(), this);
setFocusMode(focusMode ?? getDefaultFocusMode(), this);

this.getWindows().forEach(w => {
animateWindow(w);
Expand Down Expand Up @@ -3807,11 +3810,21 @@ export function ensuredX(meta_window, space) {
let min = workArea.x;
let max = min + workArea.width;

if (space.focusMode == FocusModes.CENTER) {
if (space.focusMode === FocusModes.CENTER) {
// window switching should centre focus
x = workArea.x + Math.round(workArea.width / 2 - frame.width / 2);
} else if (meta_window.fullscreen) {
x = 0;
} else if (space.focusMode === FocusModes.EDGE) {
// Align to the closest edge, with special cases for
// only (center), first (left), and last (right) windows
if (index === 0 && space.length === 1)
x = min + Math.round((workArea.width - frame.width) / 2);
else if (index === 0 || (Math.abs(x - min) < Math.abs(x + frame.width - max) &&
index !== space.length - 1))
x = min + Settings.prefs.horizontal_margin;
else
x = max - Settings.prefs.horizontal_margin - frame.width;
} else if (frame.width > workArea.width * 0.9 - 2 * (Settings.prefs.horizontal_margin + Settings.prefs.window_gap)) {
// Consider the window to be wide and center it
x = min + Math.round((workArea.width - frame.width) / 2);
Expand Down Expand Up @@ -4546,7 +4559,8 @@ export function setFocusMode(mode, space) {
const workArea = space.workArea();
const selectedWin = space.selectedWindow;
// if centre also center selectedWindow
if (mode === FocusModes.CENTER) {
switch (mode) {
case FocusModes.CENTER:
if (selectedWin) {
// check it closer to min or max of workArea
const frame = selectedWin.get_frame_rect();
Expand All @@ -4559,6 +4573,11 @@ export function setFocusMode(mode, space) {
}
centerWindowHorizontally(selectedWin);
}
break;
default:
// for other modes run a `layout` call to action the mode
space.layout();
break;
}

// if normal and has saved x position from previous
Expand Down
11 changes: 7 additions & 4 deletions topbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export const FocusIcon = GObject.registerClass(
const pather = relativePath => GLib.uri_resolve_relative(import.meta.url, relativePath, GLib.UriFlags.NONE);
this.gIconDefault = Gio.icon_new_for_string(pather('./resources/focus-mode-default-symbolic.svg'));
this.gIconCenter = Gio.icon_new_for_string(pather('./resources/focus-mode-center-symbolic.svg'));
this.gIconEdge = Gio.icon_new_for_string(pather('./resources/focus-mode-edge-symbolic.svg'));

this._initToolTip();
this.setMode();
Expand Down Expand Up @@ -335,9 +336,10 @@ Current mode: <span foreground="${color}"><b>${mode}</b></span>`);
};
if (this.mode === Tiling.FocusModes.DEFAULT) {
markup('#6be67b', 'DEFAULT');
}
else if (this.mode === Tiling.FocusModes.CENTER) {
} else if (this.mode === Tiling.FocusModes.CENTER) {
markup('#6be6cb', 'CENTER');
} else if (this.mode === Tiling.FocusModes.EDGE) {
markup('#abe67b', 'EDGE');
} else {
this.tooltip.set_text('');
}
Expand All @@ -352,9 +354,10 @@ Current mode: <span foreground="${color}"><b>${mode}</b></span>`);
this.mode = mode;
if (mode === Tiling.FocusModes.DEFAULT) {
this.gicon = this.gIconDefault;
}
else if (mode === Tiling.FocusModes.CENTER) {
} else if (mode === Tiling.FocusModes.CENTER) {
this.gicon = this.gIconCenter;
} else if (mode === Tiling.FocusModes.EDGE) {
this.gicon = this.gIconEdge;
}
this._updateTooltipText();
return this;
Expand Down

0 comments on commit c8e6dbe

Please sign in to comment.