From 2a3560ac4b273225a67c939933536655a50ab14c Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Fri, 13 Nov 2020 09:03:21 -0700 Subject: [PATCH] fix(exceptions): Dialog selecting window too soon --- src/dialog_add_exception.ts | 2 +- src/extension.ts | 20 ++++++++++++++++---- src/mod.d.ts | 1 + src/utils.ts | 7 +++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/dialog_add_exception.ts b/src/dialog_add_exception.ts index 4625b94f..e57d5d90 100644 --- a/src/dialog_add_exception.ts +++ b/src/dialog_add_exception.ts @@ -61,7 +61,7 @@ export class AddExceptionDialog { } show() { - this.dialog.show_all(); + this.dialog.show(); } open() { diff --git a/src/extension.ts b/src/extension.ts index 3e1af893..4fb3c27b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -46,6 +46,7 @@ const Tags = Me.imports.tags; const STYLESHEET_PATHS = ['light', 'dark'].map(stylesheet_path); const STYLESHEETS = STYLESHEET_PATHS.map((path) => Gio.File.new_for_path(path)); +const GNOME_VERSION = utils.gnome_version() enum Style { Light, Dark } @@ -516,9 +517,20 @@ export class Ext extends Ecs.System { } exception_select() { - log.debug('select a window plz') - overview.show() - this.exception_selecting = true; + if (GNOME_VERSION?.startsWith("3.36")) { + // 3.36 required a delay to work + GLib.timeout_add(GLib.PRIORITY_LOW, 500, () => { + this.exception_selecting = true + overview.show() + return false + }) + } else { + GLib.idle_add(GLib.PRIORITY_LOW, () => { + this.exception_selecting = true + overview.show() + return false + }) + } } exit_modes() { @@ -653,7 +665,7 @@ export class Ext extends Ecs.System { this.size_signals_unblock(win); if (this.exception_selecting) { - this.exception_add(win); + this.exception_add(win) } // Keep the last-focused window from being shifted too quickly. 300ms debounce diff --git a/src/mod.d.ts b/src/mod.d.ts index b29165bc..62de8ab4 100644 --- a/src/mod.d.ts +++ b/src/mod.d.ts @@ -42,6 +42,7 @@ declare interface GLib { find_program_in_path(prog: string): string | null; get_current_dir(): string; + get_monotonic_time(): number; idle_add(priority: any, callback: () => boolean): number; diff --git a/src/utils.ts b/src/utils.ts index f6c40f02..40359bf3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -135,4 +135,11 @@ export function async_process_ipc(argv: Array): AsyncIPC | null { }) return { stdin, stdout } +} + +export function gnome_version(): null | string { + let [,out] = GLib.spawn_command_line_sync("gnome-shell --version"); + if (!out) return null; + + return imports.byteArray.toString(out).split(' ')[2] } \ No newline at end of file