Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-apply window title on/off after screen unlocking #1370

Open
wants to merge 1 commit into
base: master_focal
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/dbus_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const IFACE: string = `<node>
export class Service {
dbus: any
id: any
handlerScsvWakeUp: any; // Handler id from DBus signal subscription (need to unsubscribe on destroy)

FocusLeft: () => void = () => {}
FocusRight: () => void = () => {}
Expand All @@ -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)
Expand All @@ -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)
}
}
2 changes: 1 addition & 1 deletion src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ interface Injection {
func: any;
}

/** The pop-shell Gnome extension class */
export class Ext extends Ecs.System<ExtEvent> {
/** Mechanism for managing keybindings */
keybindings: Keybindings.Keybindings = new Keybindings.Keybindings(this);
Expand Down Expand Up @@ -263,6 +264,14 @@ export class Ext extends Ecs.System<ExtEvent> {
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
Expand Down