11/*
2- * Copyright 2020 elementary, Inc. (https://elementary.io)
2+ * Copyright 2020-2025 elementary, Inc. (https://elementary.io)
33*
44* This program is free software; you can redistribute it and/or
55* modify it under the terms of the GNU General Public
@@ -31,6 +31,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
3131
3232 private Gtk . Revealer close_revealer;
3333 private Gtk . Box draw_area;
34+ private Gtk . Overlay overlay;
3435
3536 private uint timeout_id;
3637
@@ -72,7 +73,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
7273 overflow = VISIBLE
7374 };
7475
75- var overlay = new Gtk .Overlay () {
76+ overlay = new Gtk .Overlay () {
7677 child = draw_area
7778 };
7879 overlay. add_overlay (close_revealer);
@@ -92,11 +93,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
9293 can_focus = false ;
9394 set_titlebar (new Gtk .Grid ());
9495
95- carousel. page_changed. connect ((index) = > {
96- if (index == 0 ) {
97- closed (Notifications . Server . CloseReason . DISMISSED );
98- }
99- });
96+ carousel. page_changed. connect (on_page_changed);
10097 close_button. clicked. connect (() = > closed (Notifications . Server . CloseReason . DISMISSED ));
10198
10299 var motion_controller = new Gtk .EventControllerMotion ();
@@ -114,18 +111,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
114111 }
115112 });
116113
117- carousel. notify[" position" ]. connect (() = > {
118- current_swipe_progress = carousel. position;
119-
120- if (desktop_panel != null ) {
121- int left, right;
122- get_blur_margins (out left, out right);
123-
124- desktop_panel. add_blur (left, right, 16 , 16 , 9 );
125- } else if (Gdk . Display . get_default () is Gdk . X11. Display ) {
126- x11_update_mutter_hints ();
127- }
128- });
114+ carousel. notify[" position" ]. connect (update_swipe_progress);
129115
130116 transparency_settings. changed[" use-transparency" ]. connect (update_transparency);
131117 update_transparency ();
@@ -139,6 +125,27 @@ public class Notifications.AbstractBubble : Gtk.Window {
139125 }
140126 }
141127
128+ private void on_page_changed (Adw .Carousel carousel , uint index ) {
129+ if (carousel. get_nth_page (index) != overlay) {
130+ closed (Notifications . Server . CloseReason . DISMISSED );
131+ }
132+ }
133+
134+ private void update_swipe_progress (Object obj , ParamSpec pspec ) {
135+ var carousel = (Adw . Carousel ) obj;
136+
137+ current_swipe_progress = carousel. position;
138+
139+ if (desktop_panel != null ) {
140+ int left, right;
141+ get_blur_margins (out left, out right);
142+
143+ desktop_panel. add_blur (left, right, 16 , 16 , 9 );
144+ } else if (Gdk . Display . get_default () is Gdk . X11. Display ) {
145+ x11_update_mutter_hints ();
146+ }
147+ }
148+
142149 public new void present () {
143150 if (timeout_id != 0 ) {
144151 Source . remove (timeout_id);
0 commit comments