Skip to content

Commit

Permalink
fix(exceptions): Dialog selecting window too soon
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Dec 16, 2020
1 parent 0fbf86c commit 2a3560a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/dialog_add_exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class AddExceptionDialog {
}

show() {
this.dialog.show_all();
this.dialog.show();
}

open() {
Expand Down
20 changes: 16 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

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

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() {
Expand Down Expand Up @@ -653,7 +665,7 @@ export class Ext extends Ecs.System<ExtEvent> {
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
Expand Down
1 change: 1 addition & 0 deletions src/mod.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 7 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,11 @@ export function async_process_ipc(argv: Array<string>): 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]
}

0 comments on commit 2a3560a

Please sign in to comment.