From fa7756d35f4019b72742ffb94c5c0f7581b1ed15 Mon Sep 17 00:00:00 2001 From: Angelo Steinbach Date: Sat, 11 Nov 2023 01:44:31 +0100 Subject: [PATCH 1/3] Fixed isHolding function for Super modifier --- src/extension/modifiers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extension/modifiers.ts b/src/extension/modifiers.ts index e34ebc4..40ea3fd 100644 --- a/src/extension/modifiers.ts +++ b/src/extension/modifiers.ts @@ -65,7 +65,7 @@ export default class ModifiersManager { this.modifiers = []; - for (let i = 0; i < 6; i++) { + for (let i = 0; i < 7; i++) { if (this.state & 1 << i && MODIFIERS[i] !== undefined) { this.modifiers.push(MODIFIERS[i]); } From 9d379c1a344c64d1406585d0c6e8e8748677983d Mon Sep 17 00:00:00 2001 From: Angelo Steinbach Date: Sat, 11 Nov 2023 01:44:51 +0100 Subject: [PATCH 2/3] Added option to prevent snapping windows with holding down Super key. --- src/extension/app.ts | 5 +++++ src/extension/prefs_builder.ts | 1 + src/extension/settings_data.ts | 6 ++++++ src/schemas/gschemas.compiled | Bin 3744 -> 3812 bytes ...g.gnome.shell.extensions.gsnap.gschema.xml | 4 ++++ 5 files changed, 16 insertions(+) diff --git a/src/extension/app.ts b/src/extension/app.ts index 2848865..076f0a4 100644 --- a/src/extension/app.ts +++ b/src/extension/app.ts @@ -351,11 +351,16 @@ export default class App extends Extension { const spanMultipleZones = this.canSpanMultipleZones(); const useModifier = getBoolSetting(SETTINGS.USE_MODIFIER); + const preventSnapping = getBoolSetting(SETTINGS.PREVENT_SNAPPING); this.isGrabbing = true; if (useModifier && !this.modifiersManager.isHolding(MODIFIERS_ENUM.CONTROL)) return; + + if (preventSnapping && + this.modifiersManager.isHolding(MODIFIERS_ENUM.SUPER)) + return; activeMonitors().forEach(m => { this.tabManager[m.index]?.allow_multiple_zones_selection(spanMultipleZones); diff --git a/src/extension/prefs_builder.ts b/src/extension/prefs_builder.ts index 2999861..e140465 100644 --- a/src/extension/prefs_builder.ts +++ b/src/extension/prefs_builder.ts @@ -77,6 +77,7 @@ export default class GSnapPreferences extends ExtensionPreferences { const span_multiple_zones_check = this.add_check(group, SETTINGS.SPAN_MULTIPLE_ZONES, "Hold ALT to span multiple zones", "This feature is not supported if you have the \"Show tabs\" feature enabled"); + this.add_check(group, SETTINGS.PREVENT_SNAPPING, "Hold Super to prevent snapping windows"); // disable "Span multiple zones" setting if "Show tabs" setting was already enabled if (this.settings.get_boolean(SETTINGS.SHOW_TABS)) { diff --git a/src/extension/settings_data.ts b/src/extension/settings_data.ts index fd788d9..20b4c0a 100644 --- a/src/extension/settings_data.ts +++ b/src/extension/settings_data.ts @@ -9,6 +9,7 @@ export type BoolSettingName = ( "debug" | "global-presets" | "moveresize-enabled" | + "prevent-snapping" | "show-icon" | "show-tabs" | "span-multiple-zones" | @@ -115,6 +116,7 @@ export type AnySettingName = ( "preset-resize-7" | "preset-resize-8" | "preset-resize-9" | + "prevent-snapping" | "show-icon" | "show-tabs" | "span-multiple-zones" | @@ -260,6 +262,9 @@ export class ParsedSettings { /** Preset resize 9. */ ["preset-resize-9"]: string[] = ['KP_9']; + /** Hold Super to prevent snapping windows */ + ["prevent-snapping"]: boolean = false; + /** Show gSnap icon on a panel. */ ["show-icon"]: boolean = true; @@ -322,6 +327,7 @@ export const PRESET_RESIZE_6 = "preset-resize-6"; export const PRESET_RESIZE_7 = "preset-resize-7"; export const PRESET_RESIZE_8 = "preset-resize-8"; export const PRESET_RESIZE_9 = "preset-resize-9"; +export const PREVENT_SNAPPING = "prevent-snapping"; export const SHOW_ICON = "show-icon"; export const SHOW_TABS = "show-tabs"; export const SPAN_MULTIPLE_ZONES = "span-multiple-zones"; diff --git a/src/schemas/gschemas.compiled b/src/schemas/gschemas.compiled index 34c55d5d23d717c018380a02069d09a39af615ba..f6ce4a2c7913e172fec906c7a878a523b2361b78 100644 GIT binary patch literal 3812 zcmaKvU2GIp9K{Ev&=v}m@+pc11-6#m((Sh*+8}}vm5)doqmf-Y?M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}#GWar3D?T;-4e;MU zo%q!BxjD82SHhd)>=$(#{0R6kP%rV+j2{EP0yKzEO@9H*{Xb^tGqEi9cvUlElPN9E zz1=g}ts9n>wbXP5?=vUVtjX;kKabvRrDKLVGn>ll>6E65KZjQVEGg$*9rF`BKc#d}icLQAdyg#tL9RRm#p3`0c z%gw$g;JC2w2Rzpw06ahs&9 zI0&=?yw~tP#rp-0TgB1!P+7l2?&BQBxBQjGhb7)#2|BVjA7`%zM`Z(U-w(Lg7s(e> zUSGsLKDtwURN}qqST>0<#|6=6Ul4uv1<_Z$Ao}bJA|}PcB2{P1xIV3G87UXDSGJ#Q zEf1`l?OiSA`%p@i{mMA0VJ90cCb|!+f!CwaBG~ToS>Amy;(@~!u&~GziS*W z$d0&>YaEio5f|R6{abslYy16uvY&2mFA~O4{(x&ckSvb4h-;j`I4_TyMmA%n@;gyW z>6jNzi%Bz^HD~PUFB@-vpio~)IRPBbKM6T9<^TWy diff --git a/src/schemas/org.gnome.shell.extensions.gsnap.gschema.xml b/src/schemas/org.gnome.shell.extensions.gsnap.gschema.xml index 4b79b0d..689a65b 100644 --- a/src/schemas/org.gnome.shell.extensions.gsnap.gschema.xml +++ b/src/schemas/org.gnome.shell.extensions.gsnap.gschema.xml @@ -149,6 +149,10 @@ false Hold CTRL to snap windows + + false + Hold Super to prevent snapping windows + false Hold ALT to span multiple zones From f4413b4c76d397bb0a6812578d99a1ffd9332a3a Mon Sep 17 00:00:00 2001 From: Angelo Steinbach Date: Sat, 11 Nov 2023 02:07:45 +0100 Subject: [PATCH 3/3] Allow preventing with Super key even when snapping overlay is already shown. --- src/extension/app.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/extension/app.ts b/src/extension/app.ts index 076f0a4..c42c9ad 100644 --- a/src/extension/app.ts +++ b/src/extension/app.ts @@ -403,7 +403,8 @@ export default class App extends Extension { }); }); - if (getBoolSetting(SETTINGS.USE_MODIFIER) || getBoolSetting(SETTINGS.SPAN_MULTIPLE_ZONES)) { + if (getBoolSetting(SETTINGS.USE_MODIFIER) || getBoolSetting(SETTINGS.SPAN_MULTIPLE_ZONES) + || getBoolSetting(SETTINGS.PREVENT_SNAPPING)) { // callback run when a modifier change state (e.g from not pressed to pressed) this.modifiersManager.connect("changed", () => { if (!this.isGrabbing) { @@ -418,15 +419,21 @@ export default class App extends Extension { }); } - if (!getBoolSetting(SETTINGS.USE_MODIFIER)) return; - if (this.modifiersManager.isHolding(MODIFIERS_ENUM.CONTROL)) { + const useModifier = getBoolSetting(SETTINGS.USE_MODIFIER); + if (useModifier && this.modifiersManager.isHolding(MODIFIERS_ENUM.CONTROL)) { activeMonitors().forEach(m => { this.tabManager[m.index]?.show() }); - } else { - activeMonitors().forEach(m => this.tabManager[m.index]?.hide()); + return; } + + const preventSnapping = getBoolSetting(SETTINGS.PREVENT_SNAPPING); + if(preventSnapping && !this.modifiersManager.isHolding(MODIFIERS_ENUM.SUPER)) { + return + } + + activeMonitors().forEach(m => this.tabManager[m.index]?.hide()); }); }