Skip to content

Commit faaf59e

Browse files
authored
Enhancement #672: allow users to change overview exit transition animation (#715)
This PR fixes #672. Namely, it now allows users to select from PaperWM settings the animation used to ensure the selected window (after exiting Gnome Overview) is brought into view: ![image](https://github.com/paperwm/PaperWM/assets/30424662/08bf7c1a-b070-41b9-9301-62eec8d3ed4c)
2 parents e48a707 + 1512c70 commit faaf59e

File tree

8 files changed

+138
-37
lines changed

8 files changed

+138
-37
lines changed

Settings.ui

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,48 @@
11141114
</child>
11151115
</object>
11161116
</child>
1117+
<child>
1118+
<object class="GtkListBoxRow">
1119+
<property name="activatable">False</property>
1120+
<property name="focusable">False</property>
1121+
<child>
1122+
<object class="GtkGrid">
1123+
<property name="focusable">False</property>
1124+
<property name="tooltip_text" translatable="yes">Sets the animation when exiting GNOME overview and ensuring selected window is in view</property>
1125+
<property name="margin_start">12</property>
1126+
<property name="margin_end">12</property>
1127+
<property name="margin_top">6</property>
1128+
<property name="margin_bottom">6</property>
1129+
<property name="column_spacing">32</property>
1130+
<child>
1131+
<object class="GtkLabel">
1132+
<property name="focusable">False</property>
1133+
<property name="hexpand">1</property>
1134+
<property name="label" translatable="yes">GNOME overview exit &lt;i&gt;select window&lt;/i&gt; animation </property>
1135+
<property name="use_markup">1</property>
1136+
<property name="xalign">0</property>
1137+
<layout>
1138+
<property name="column">0</property>
1139+
<property name="row">0</property>
1140+
</layout>
1141+
</object>
1142+
</child>
1143+
<child>
1144+
<object class="GtkComboBoxText" id="overview-ensure-viewport-animation">
1145+
<property name="focusable">False</property>
1146+
<property name="hexpand">0</property>
1147+
<property name="width-request">106</property>
1148+
<items>
1149+
<item id="none" translatable="yes">None</item>
1150+
<item id="translate" translatable="yes">Translate</item>
1151+
<item id="fade" translatable="yes">Fade</item>
1152+
</items>
1153+
</object>
1154+
</child>
1155+
</object>
1156+
</child>
1157+
</object>
1158+
</child>
11171159
</object>
11181160
</child>
11191161
<child>

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"url": "https://github.com/paperwm/PaperWM",
66
"settings-schema": "org.gnome.shell.extensions.paperwm",
77
"shell-version": [ "45" ],
8-
"version-name": "45.4.1"
8+
"version-name": "45.4.2"
99
}

patches.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Clutter from 'gi://Clutter';
22
import Gio from 'gi://Gio';
33
import GLib from 'gi://GLib';
4-
import GObject from 'gi://GObject';
54
import Meta from 'gi://Meta';
65
import Shell from 'gi://Shell';
76
import St from 'gi://St';

prefs.js

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,20 @@ class SettingsWidget {
112112
});
113113
};
114114

115+
const enumOptionsChanged = (settingKey, optionNumberEnum, defaultOption, defaultNumber) => {
116+
const builder = this.builder.get_object(settingKey);
117+
const setting = this._settings.get_int(settingKey);
118+
const numberOptionEnum = Object.fromEntries(
119+
Object.entries(optionNumberEnum).map(a => a.reverse())
120+
);
121+
122+
builder.set_active_id(numberOptionEnum[setting] ?? defaultOption);
123+
builder.connect('changed', obj => {
124+
const value = optionNumberEnum[obj.get_active_id()] ?? defaultNumber;
125+
this._settings.set_int(settingKey, value);
126+
});
127+
};
128+
115129
const gestureFingersChanged = key => {
116130
const builder = this.builder.get_object(key);
117131
const setting = this._settings.get_int(key);
@@ -388,27 +402,34 @@ class SettingsWidget {
388402

389403
// Advanced
390404
booleanStateChanged('gesture-enabled');
391-
gestureFingersChanged('gesture-horizontal-fingers');
392-
gestureFingersChanged('gesture-workspace-fingers');
393-
394-
const defaultFocusMode = this.builder.get_object('default-focus-mode');
395-
const dfmSetting = this._settings.get_int('default-focus-mode');
396-
switch (dfmSetting) {
397-
case 1:
398-
defaultFocusMode.set_active_id('center');
399-
break;
400-
default:
401-
defaultFocusMode.set_active_id('default');
402-
}
403-
defaultFocusMode.connect('changed', obj => {
404-
switch (obj.get_active_id()) {
405-
case 'center':
406-
this._settings.set_int('default-focus-mode', 1);
407-
break;
408-
default:
409-
this._settings.set_int('default-focus-mode', 0);
410-
}
411-
});
405+
406+
const fingerOptions = {
407+
'fingers-disabled': 0,
408+
'three-fingers': 3,
409+
'four-fingers': 4,
410+
};
411+
const fingerOptionDefault = 'fingers-disabled';
412+
const fingerNumberDefault = 0;
413+
enumOptionsChanged('gesture-horizontal-fingers', fingerOptions, fingerOptionDefault, fingerNumberDefault);
414+
enumOptionsChanged('gesture-workspace-fingers', fingerOptions, fingerOptionDefault, fingerNumberDefault);
415+
enumOptionsChanged(
416+
'default-focus-mode',
417+
{
418+
'default': 0,
419+
'center': 1,
420+
},
421+
'default',
422+
0);
423+
424+
enumOptionsChanged(
425+
'overview-ensure-viewport-animation',
426+
{
427+
'none': 0,
428+
'translate': 1,
429+
'fade': 2,
430+
},
431+
'translate',
432+
1);
412433

413434
booleanStateChanged('show-focus-mode-icon');
414435
booleanStateChanged('disable-topbar-styling', true);

schemas/gschemas.compiled

96 Bytes
Binary file not shown.

schemas/org.gnome.shell.extensions.paperwm.gschema.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@
449449
<summary>Duration of animations in seconds</summary>
450450
</key>
451451

452+
<key type="i" name="overview-ensure-viewport-animation">
453+
<default>1</default>
454+
<summary>Sets the animation when exiting GNOME overview and ensuring selected window is in view. 0:NONE, 1:TRANSLATE, 2:FADE</summary>
455+
</key>
456+
452457
<key type="as" name="winprops">
453458
<default><![CDATA[[]]]></default>
454459
<summary>Array of winprops as (JSON) string objects</summary>

settings.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const META_KEY_ABOVE_TAB = 0x2f7259c9;
1818
// position to open window at (e.g. to the right of current window)
1919
export const OpenWindowPositions = { RIGHT: 0, LEFT: 1, START: 2, END: 3 };
2020

21+
// Animation used when ensuring viewport on a window
22+
export const EnsureViewportAnimation = { NONE: 0, TRANSLATE: 1, FADE: 2 };
23+
2124
export let prefs;
2225
let gsettings, keybindSettings, _overriddingConflicts;
2326
let acceleratorParse;
@@ -35,7 +38,8 @@ export function enable(extension) {
3538
'window-switcher-preview-scale', 'winprops', 'show-workspace-indicator',
3639
'show-window-position-bar', 'show-focus-mode-icon', 'disable-topbar-styling',
3740
'default-focus-mode', 'gesture-enabled', 'gesture-horizontal-fingers',
38-
'gesture-workspace-fingers', 'open-window-position']
41+
'gesture-workspace-fingers', 'open-window-position',
42+
'overview-ensure-viewport-animation']
3943
.forEach(k => setState(null, k));
4044
prefs.__defineGetter__("minimum_margin", () => {
4145
return Math.min(15, prefs.horizontal_margin);

tiling.js

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,11 @@ export class Space extends Array {
362362
Utils.warpPointerToMonitor(this.monitor);
363363
Utils.later_add(Meta.LaterType.IDLE, () => {
364364
this.moveDone(() => {
365-
ensureViewport(display.focus_window, this, { moveto: true, force: true });
365+
ensureViewport(display.focus_window, this, {
366+
moveto: true,
367+
force: true,
368+
ensureAnimation: Settings.prefs.overview_ensure_viewport_animation,
369+
});
366370
});
367371
});
368372
});
@@ -3501,6 +3505,8 @@ export function ensureViewport(meta_window, space, options = {}) {
35013505
space = space || spaces.spaceOfWindow(meta_window);
35023506
let force = options?.force ?? false;
35033507
let moveto = options?.moveto ?? true;
3508+
let animate = options?.animate ?? true;
3509+
let ensureAnimation = options.ensureAnimation ?? Settings.EnsureViewportAnimation.TRANSLATE;
35043510

35053511
let index = space.indexOf(meta_window);
35063512
if (index === -1 || space.length === 0)
@@ -3531,7 +3537,7 @@ export function ensureViewport(meta_window, space, options = {}) {
35313537

35323538
if (moveto) {
35333539
move_to(space, meta_window, {
3534-
x, force,
3540+
x, force, animate, ensureAnimation,
35353541
});
35363542
}
35373543

@@ -3582,8 +3588,11 @@ export function updateSelection(space, metaWindow) {
35823588
* Move the column containing @meta_window to x, y and propagate the change
35833589
* in @space. Coordinates are relative to monitor and y is optional.
35843590
*/
3585-
export function move_to(space, metaWindow, { x, force, animate }) {
3586-
animate = animate ?? true;
3591+
export function move_to(space, metaWindow, options = {}) {
3592+
let x = options.x ?? 0;
3593+
let force = options.force ?? false;
3594+
let animate = options.animate ?? true;
3595+
let ensureAnimation = options.ensureAnimation ?? Settings.EnsureViewportAnimation.TRANSLATE;
35873596
if (space.indexOf(metaWindow) === -1)
35883597
return;
35893598

@@ -3594,25 +3603,46 @@ export function move_to(space, metaWindow, { x, force, animate }) {
35943603
return;
35953604
}
35963605

3597-
space.targetX = target;
3606+
const done = () => {
3607+
space.moveDone();
3608+
space.fixOverlays(metaWindow);
3609+
};
35983610

3599-
if (Main.overview.visible) {
3611+
space.targetX = target;
3612+
if (space.cloneContainer.x === target ||
3613+
Main.overview.visible) {
36003614
// Do the move immediately, and let the overview take care of animation
36013615
space.cloneContainer.x = target;
3602-
space.moveDone();
3616+
done();
36033617
return;
36043618
}
36053619

3620+
// if here need to animate
36063621
space.startAnimate();
3607-
Easer.addEase(space.cloneContainer,
3608-
{
3622+
if (!animate ||
3623+
ensureAnimation === Settings.EnsureViewportAnimation.NONE) {
3624+
space.cloneContainer.x = target;
3625+
Easer.addEase(space.cloneContainer, {
3626+
instant: true,
3627+
onComplete: () => done(),
3628+
});
3629+
}
3630+
else if (ensureAnimation === Settings.EnsureViewportAnimation.FADE) {
3631+
space.cloneContainer.x = target;
3632+
space.cloneContainer.opacity = 0;
3633+
Easer.addEase(space.cloneContainer, {
3634+
opacity: 255,
3635+
time: Settings.prefs.animation_time,
3636+
onComplete: () => done(),
3637+
});
3638+
}
3639+
else {
3640+
Easer.addEase(space.cloneContainer, {
36093641
x: target,
36103642
time: Settings.prefs.animation_time,
3611-
instant: !animate,
3612-
onComplete: () => space.moveDone(),
3643+
onComplete: () => done(),
36133644
});
3614-
3615-
space.fixOverlays(metaWindow);
3645+
}
36163646
}
36173647

36183648
export function grabBegin(metaWindow, type) {

0 commit comments

Comments
 (0)