Skip to content

Commit 563a14d

Browse files
committed
fix: Unlock of screen will update work areas
Closes #973
1 parent 8c4d4de commit 563a14d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/extension.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const { Gio, Meta, St } = imports.gi;
4444
const { GlobalEvent, WindowEvent } = Events;
4545
const { cursor_rect, is_move_op } = Lib;
4646
const { layoutManager, loadTheme, overview, panel, setThemeStylesheet, screenShield, sessionMode } = imports.ui.main;
47+
const { ScreenShield } = imports.ui.screenShield;
4748
const Tags = Me.imports.tags;
4849

4950
const STYLESHEET_PATHS = ['light', 'dark'].map(stylesheet_path);
@@ -61,6 +62,12 @@ interface Monitor extends Rectangular {
6162
index: number;
6263
}
6364

65+
interface Injection {
66+
object: any;
67+
method: string;
68+
func: any;
69+
}
70+
6471
export class Ext extends Ecs.System<ExtEvent> {
6572
/** Mechanism for managing keybindings */
6673
keybindings: Keybindings.Keybindings = new Keybindings.Keybindings(this);
@@ -136,6 +143,9 @@ export class Ext extends Ecs.System<ExtEvent> {
136143
/** A display config update is triggered on a workspace addition */
137144
ignore_display_update: boolean = false;
138145

146+
/** Functions replaced in GNOME */
147+
injections: Array<Injection> = new Array();
148+
139149
/** The last window that was focused */
140150
last_focused: Entity | null = null;
141151

@@ -669,6 +679,26 @@ export class Ext extends Ecs.System<ExtEvent> {
669679
return entity ? this.windows.get(entity) : null;
670680
}
671681

682+
inject(object: any, method: string, func: any) {
683+
const prev = object[method];
684+
this.injections.push({ object, method, func: prev })
685+
object[method] = func;
686+
}
687+
688+
injections_add() {
689+
const screen_unlock_fn = ScreenShield.prototype['deactivate'];
690+
this.inject(ScreenShield.prototype, 'deactivate', (args: any) => {
691+
screen_unlock_fn.apply(screenShield, [args]);
692+
this.update_display_configuration(true);
693+
})
694+
}
695+
696+
injections_remove() {
697+
for (const { object, method, func } of this.injections.splice(0)) {
698+
object[method] = func
699+
}
700+
}
701+
672702
load_settings() {
673703
this.set_gap_inner(this.settings.gap_inner());
674704
this.set_gap_outer(this.settings.gap_outer());
@@ -1977,6 +2007,10 @@ export class Ext extends Ecs.System<ExtEvent> {
19772007
this.moved_by_mouse = false
19782008
}
19792009

2010+
update_display_configuration_before() {
2011+
2012+
}
2013+
19802014
update_display_configuration(workareas_only: boolean) {
19812015
if (!this.auto_tiler || sessionMode.isLocked) return
19822016

@@ -2339,6 +2373,7 @@ function enable() {
23392373
return;
23402374
}
23412375

2376+
ext.injections_add();
23422377
ext.signals_attach();
23432378

23442379
layoutManager.addChrome(ext.overlay);
@@ -2366,6 +2401,7 @@ function disable() {
23662401
return;
23672402
}
23682403

2404+
ext.injections_remove();
23692405
ext.signals_remove();
23702406
ext.exit_modes();
23712407
ext.stop_launcher_services();

0 commit comments

Comments
 (0)