From a2027f6fe5c881adfb085efe4b086bfe4150fc2a Mon Sep 17 00:00:00 2001 From: fhackenberger Date: Thu, 10 Mar 2022 11:30:20 +0100 Subject: [PATCH] Re-apply window title on/off after screen unlocking Before this change the window titles were still visible after unlocking the screen, even if the setting was to off. --- src/dbus_service.ts | 14 ++++++++++++++ src/events.ts | 2 +- src/extension.ts | 9 +++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/dbus_service.ts b/src/dbus_service.ts index 4a620ec6..4185a817 100644 --- a/src/dbus_service.ts +++ b/src/dbus_service.ts @@ -25,6 +25,7 @@ const IFACE: string = ` export class Service { dbus: any id: any + handlerScsvWakeUp: any; // Handler id from DBus signal subscription (need to unsubscribe on destroy) FocusLeft: () => void = () => {} FocusRight: () => void = () => {} @@ -34,6 +35,7 @@ export class Service { WindowFocus: (window: [number, number]) => void = () => {} WindowList: () => Array<[[number, number], string, string, string]> = () => [] WindowQuit: (window: [number, number]) => void = () => {} + onScsvActiveChanged: (params: any) => void = () => {} constructor() { this.dbus = Gio.DBusExportedObject.wrapJSObject(IFACE, this) @@ -54,9 +56,21 @@ export class Service { onNameAcquired, onNameLost ) + + try { + this.handlerScsvWakeUp = Gio.DBus.session.signal_subscribe('org.gnome.ScreenSaver', 'org.gnome.ScreenSaver', 'ActiveChanged', '/org/gnome/ScreenSaver', null, Gio.DBusSignalFlags.NONE, + (_conn:any, _sender:any, _path:any, _iface:any, _signal:any, params:any) => this.onScsvActiveChanged(params)); + }catch(e) { + log.error(e, 'failed to subscribe to Screensaver ActiveChanged signal'); + } } destroy() { + try { + Gio.DBus.session.signal_unsubscribe(this.handlerScsvWakeUp); + }catch(e) { + log.error(e, 'failed to unsubscribe from Screensaver ActiveChanged signal'); + } Gio.bus_unown_name(this.id) } } \ No newline at end of file diff --git a/src/events.ts b/src/events.ts index 65837af1..f1615da1 100644 --- a/src/events.ts +++ b/src/events.ts @@ -11,7 +11,7 @@ export type ExtEvent = GenericCallback | CreateWindow | GlobalEventTag; -/** Eevnt with generic callback */ +/** Event with generic callback */ export interface GenericCallback { tag: 1; callback: () => void; diff --git a/src/extension.ts b/src/extension.ts index df38bdf3..7106c20e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -74,6 +74,7 @@ interface Injection { func: any; } +/** The pop-shell Gnome extension class */ export class Ext extends Ecs.System { /** Mechanism for managing keybindings */ keybindings: Keybindings.Keybindings = new Keybindings.Keybindings(this); @@ -263,6 +264,14 @@ export class Ext extends Ecs.System { this.windows.get(win)?.meta.delete(global.get_current_time()) this.window_search.close() } + + this.dbus.onScsvActiveChanged = (params) => { + const value = params.get_child_value(0); + const locked = value.get_boolean(); + log.debug(`Screen Locked: ${locked}`); + if(!locked) + this.on_show_window_titles(); // Window titles on/off is lost after screensaver unlocking, re-apply it + } } // System interface