Skip to content

Commit 2a3560a

Browse files
committed
fix(exceptions): Dialog selecting window too soon
1 parent 0fbf86c commit 2a3560a

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

src/dialog_add_exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class AddExceptionDialog {
6161
}
6262

6363
show() {
64-
this.dialog.show_all();
64+
this.dialog.show();
6565
}
6666

6767
open() {

src/extension.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const Tags = Me.imports.tags;
4646

4747
const STYLESHEET_PATHS = ['light', 'dark'].map(stylesheet_path);
4848
const STYLESHEETS = STYLESHEET_PATHS.map((path) => Gio.File.new_for_path(path));
49+
const GNOME_VERSION = utils.gnome_version()
4950

5051
enum Style { Light, Dark }
5152

@@ -516,9 +517,20 @@ export class Ext extends Ecs.System<ExtEvent> {
516517
}
517518

518519
exception_select() {
519-
log.debug('select a window plz')
520-
overview.show()
521-
this.exception_selecting = true;
520+
if (GNOME_VERSION?.startsWith("3.36")) {
521+
// 3.36 required a delay to work
522+
GLib.timeout_add(GLib.PRIORITY_LOW, 500, () => {
523+
this.exception_selecting = true
524+
overview.show()
525+
return false
526+
})
527+
} else {
528+
GLib.idle_add(GLib.PRIORITY_LOW, () => {
529+
this.exception_selecting = true
530+
overview.show()
531+
return false
532+
})
533+
}
522534
}
523535

524536
exit_modes() {
@@ -653,7 +665,7 @@ export class Ext extends Ecs.System<ExtEvent> {
653665
this.size_signals_unblock(win);
654666

655667
if (this.exception_selecting) {
656-
this.exception_add(win);
668+
this.exception_add(win)
657669
}
658670

659671
// Keep the last-focused window from being shifted too quickly. 300ms debounce

src/mod.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ declare interface GLib {
4242

4343
find_program_in_path(prog: string): string | null;
4444
get_current_dir(): string;
45+
get_monotonic_time(): number;
4546

4647
idle_add(priority: any, callback: () => boolean): number;
4748

src/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,11 @@ export function async_process_ipc(argv: Array<string>): AsyncIPC | null {
135135
})
136136

137137
return { stdin, stdout }
138+
}
139+
140+
export function gnome_version(): null | string {
141+
let [,out] = GLib.spawn_command_line_sync("gnome-shell --version");
142+
if (!out) return null;
143+
144+
return imports.byteArray.toString(out).split(' ')[2]
138145
}

0 commit comments

Comments
 (0)