Skip to content

Commit

Permalink
Unify notifications check (#2050)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter authored Sep 16, 2024
1 parent 481fa89 commit a3a3c44
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/NotificationStack.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/Widgets/MultitaskingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ namespace Gala {
continue;
}

if (window.get_data (NOTIFICATION_DATA_KEY)) {
if (NotificationStack.is_notification (window)) {
continue;
}

Expand Down
6 changes: 2 additions & 4 deletions src/Widgets/WindowOverview.vala
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public class Gala.WindowOverview : Clutter.Actor, ActivatableComponent {
var windows = new List<Meta.Window> ();
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;
}

Expand Down Expand Up @@ -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 &&
Expand Down
10 changes: 5 additions & 5 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a3a3c44

Please sign in to comment.