From cd77b23872e11938c4f47daa13863c481e636ab3 Mon Sep 17 00:00:00 2001 From: Luo Yi <32430186+yilozt@users.noreply.github.com> Date: Mon, 13 Mar 2023 15:34:20 +0800 Subject: [PATCH] Fix blurry text when un-minimized window Reproduce this issues in Gnome 43.3 (Wayland) When minimized Matlab then un-minimized it in Wayland, application will be blurry until you have move mouse over application to update elements. Now, extensions will try to call queue_relayout() after 300ms timeout to active window then remove blurry glitch. See #104, #111 --- src/manager/rounded_corners_manager.ts | 27 +++++++++++++++++++++++++- src/utils/types.ts | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/manager/rounded_corners_manager.ts b/src/manager/rounded_corners_manager.ts index 6133250..8cdf7c7 100644 --- a/src/manager/rounded_corners_manager.ts +++ b/src/manager/rounded_corners_manager.ts @@ -1,5 +1,6 @@ // imports.gi import * as Clutter from '@gi/Clutter' +import * as GLib from '@gi/GLib' import { ShadowMode, WindowType } from '@gi/Meta' import { WindowClientType } from '@gi/Meta' import { Bin } from '@gi/St' @@ -76,7 +77,11 @@ export class RoundedCornersManager implements EffectManager { const visible_binding = actor.bind_property (prop, shadow, prop, flag) // Store shadow, app type, visible binding, so that we can query them later - actor.__rwc_rounded_window_info = { shadow, visible_binding } + actor.__rwc_rounded_window_info = { + shadow, + visible_binding, + unminimized_timeout_id: 0, + } } on_remove_effect (actor: ExtensionsWindowActor): void { @@ -96,6 +101,10 @@ export class RoundedCornersManager implements EffectManager { shadow.clear_effects () shadow.destroy () } + + // Remove all timeout handler + const timeout_id = actor.__rwc_rounded_window_info?.unminimized_timeout_id + if (timeout_id) GLib.source_remove (timeout_id) delete actor.__rwc_rounded_window_info } @@ -111,6 +120,22 @@ export class RoundedCornersManager implements EffectManager { on_unminimize (actor: ExtensionsWindowActor): void { this._restore_shadow (actor) + + // Requeue layout after 300ms + if (actor.first_child && actor.__rwc_rounded_window_info) { + const info = actor.__rwc_rounded_window_info + + // Clear prev handler + let id = info.unminimized_timeout_id + if (id) GLib.source_remove (id) + id = GLib.timeout_add (GLib.PRIORITY_DEFAULT, 300, () => { + actor.first_child.queue_relayout () + return false + }) + + // update handler, it will be clear when window is closed + info.unminimized_timeout_id = id + } } on_switch_workspace (actor: types.ExtensionsWindowActor) { diff --git a/src/utils/types.ts b/src/utils/types.ts index 219444b..62df1e3 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -69,6 +69,7 @@ export type ExtensionsWindowActor = WindowActor & { __rwc_rounded_window_info?: { shadow: Bin visible_binding: Binding + unminimized_timeout_id: number } __rwc_blurred_window_info?: { blur_actor: Actor