From a3a3c446a076bfedd3fc9e72ff7c5981a72357e3 Mon Sep 17 00:00:00 2001 From: Leo Date: Tue, 17 Sep 2024 01:18:06 +0300 Subject: [PATCH] Unify notifications check (#2050) --- src/NotificationStack.vala | 8 ++++++-- src/Widgets/MultitaskingView.vala | 2 +- src/Widgets/WindowOverview.vala | 6 ++---- src/WindowManager.vala | 10 +++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/NotificationStack.vala b/src/NotificationStack.vala index 5cdfb10a1..7a1bb3a14 100644 --- a/src/NotificationStack.vala +++ b/src/NotificationStack.vala @@ -17,8 +17,8 @@ */ public class Gala.NotificationStack : Object { - public const string TRANSITION_ENTRY_NAME = "entry"; - public const string TRANSITION_MOVE_STACK_ID = "move-stack"; + private const string TRANSITION_ENTRY_NAME = "entry"; + private const string TRANSITION_MOVE_STACK_ID = "move-stack"; // we need to keep a small offset to the top, because we clip the container to // its allocations and the close button would be off for the first notification @@ -207,4 +207,8 @@ public class Gala.NotificationStack : Object { rect = window.get_buffer_rect (); actor.set_position (rect.x - ((actor.width - rect.width) / 2), rect.y - ((actor.height - rect.height) / 2)); } + + public static bool is_notification (Meta.Window window) { + return window.window_type == NOTIFICATION || window.get_data (NOTIFICATION_DATA_KEY); + } } diff --git a/src/Widgets/MultitaskingView.vala b/src/Widgets/MultitaskingView.vala index e68b5c7fa..50deea0a9 100644 --- a/src/Widgets/MultitaskingView.vala +++ b/src/Widgets/MultitaskingView.vala @@ -799,7 +799,7 @@ namespace Gala { continue; } - if (window.get_data (NOTIFICATION_DATA_KEY)) { + if (NotificationStack.is_notification (window)) { continue; } diff --git a/src/Widgets/WindowOverview.vala b/src/Widgets/WindowOverview.vala index 95213708a..8618263c7 100644 --- a/src/Widgets/WindowOverview.vala +++ b/src/Widgets/WindowOverview.vala @@ -76,8 +76,7 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent { var windows = new List (); foreach (var workspace in workspaces) { foreach (unowned var window in workspace.list_windows ()) { - if (window.window_type == Meta.WindowType.DOCK - || window.window_type == Meta.WindowType.NOTIFICATION) { + if (window.window_type == Meta.WindowType.DOCK || NotificationStack.is_notification (window) ) { continue; } @@ -204,8 +203,7 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent { if (!visible) { return; } - if (window.window_type == Meta.WindowType.DOCK - || window.window_type == Meta.WindowType.NOTIFICATION) { + if (window.window_type == Meta.WindowType.DOCK || NotificationStack.is_notification (window)) { return; } if (window.window_type != Meta.WindowType.NORMAL && diff --git a/src/WindowManager.vala b/src/WindowManager.vala index 1e67d8fe0..8d1122132 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -1098,7 +1098,7 @@ namespace Gala { public override void show_window_menu (Meta.Window window, Meta.WindowMenuType menu, int x, int y) { switch (menu) { case Meta.WindowMenuType.WM: - if (window.get_window_type () == Meta.WindowType.NOTIFICATION) { + if (NotificationStack.is_notification (window)) { return; } @@ -1528,7 +1528,7 @@ namespace Gala { // Notifications are a special case and have to be always be handled // (also regardless of the animation setting) - if (window.get_data (NOTIFICATION_DATA_KEY) || window.window_type == NOTIFICATION) { + if (NotificationStack.is_notification (window)) { clutter_actor_reparent (actor, notification_group); notification_stack.show_notification (actor, enable_animations); @@ -1656,7 +1656,7 @@ namespace Gala { actor.remove_all_transitions (); - if (window.get_data (NOTIFICATION_DATA_KEY) || window.window_type == NOTIFICATION) { + if (NotificationStack.is_notification (window)) { if (enable_animations) { destroying.add (actor); } @@ -2054,7 +2054,7 @@ namespace Gala { if (window.on_all_workspaces) { // notifications use their own group and are always on top - if (window.window_type == NOTIFICATION) { + if (NotificationStack.is_notification (window)) { continue; } @@ -2165,7 +2165,7 @@ namespace Gala { // while a workspace is being switched mutter doesn't map windows // TODO: currently only notifications are handled here, other windows should be too switch_workspace_window_created_id = window_created.connect ((window) => { - if (window.window_type == Meta.WindowType.NOTIFICATION) { + if (NotificationStack.is_notification (window)) { unowned var actor = (Meta.WindowActor) window.get_compositor_private (); clutter_actor_reparent (actor, notification_group); notification_stack.show_notification (actor, enable_animations);