From 469213e98726a6e4ddf66980d103f1b4035d8292 Mon Sep 17 00:00:00 2001 From: LuoYi Date: Tue, 2 Aug 2022 16:07:53 +0800 Subject: [PATCH] Restore windows when gnome-shell is unlocked --- resources/metadata.json | 2 +- src/app.ts | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/resources/metadata.json b/resources/metadata.json index 3668686..cc070d7 100644 --- a/resources/metadata.json +++ b/resources/metadata.json @@ -2,7 +2,7 @@ "name": "Rounded Window Corners", "description": "Add rounded corners for all windows", "uuid": "rounded-window-corners@yilozt", - "version": "v1", + "version": "4", "url": "https://github.com/yilozt/rounded-window-corners", "shell-version": ["40", "41", "42"] } diff --git a/src/app.ts b/src/app.ts index adb5b09..77ea365 100644 --- a/src/app.ts +++ b/src/app.ts @@ -29,6 +29,7 @@ import { WM } from '@gi/Shell' import { WindowPreview } from '@imports/ui/windowPreview' import { RoundedCornersCfg } from './utils/types' import { Window, WindowActor } from '@gi/Meta' +import { global } from '@global' // --------------------------------------------------------------- [end imports] export class Extension { @@ -70,12 +71,14 @@ export class Extension { // solve this problem. const monitor_manager = MonitorManager.get () + type _Window = Window & { __extensions_rounded_window_fs?: 1 } + Connections.get ().connect (monitor_manager, 'monitors-changed', () => { if (sessionMode.isLocked || sessionMode.isGreeter) { return } for (const win of this._rounded_corners_manager?.windows () ?? []) { - (win as Window & { __fs?: 1 }).__fs = 1 + (win as _Window).__extensions_rounded_window_fs = 1 win.make_fullscreen () } @@ -83,16 +86,26 @@ export class Extension { this._timeout_handler = timeout_add_seconds (0, 3, () => { for (const _win of this._rounded_corners_manager?.windows () ?? []) { - const win = _win as Window & { __fs?: 1 } - if (win && win.__fs == 1) { + const win = _win as _Window + if (win && win.__extensions_rounded_window_fs == 1) { win.unmake_fullscreen () - delete win.__fs + delete win.__extensions_rounded_window_fs } } return false }) }) + // Restore window that have __extensions_rounded_window_fs props when + // unlocked + for (const win_actor of global.get_window_actors ()) { + const win = win_actor.meta_window as _Window + if (win.__extensions_rounded_window_fs === 1) { + win.unmake_fullscreen () + delete win.__extensions_rounded_window_fs + } + } + const self = this // When there is new window added into overview, this function will be