@@ -41,6 +41,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
4141
4242 private Gtk . Revealer close_revealer;
4343 private Gtk . Box draw_area;
44+ private Gtk . Overlay overlay;
4445
4546 private uint timeout_id;
4647
@@ -82,7 +83,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
8283 overflow = VISIBLE
8384 };
8485
85- var overlay = new Gtk .Overlay () {
86+ overlay = new Gtk .Overlay () {
8687 child = draw_area
8788 };
8889 overlay. add_overlay (close_revealer);
@@ -102,11 +103,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
102103 can_focus = false ;
103104 set_titlebar (new Gtk .Grid ());
104105
105- carousel. page_changed. connect ((index) = > {
106- if (index == 0 ) {
107- closed (CloseReason . DISMISSED );
108- }
109- });
106+ carousel. page_changed. connect (on_page_changed);
110107 close_button. clicked. connect (() = > closed (CloseReason . DISMISSED ));
111108
112109 var motion_controller = new Gtk .EventControllerMotion ();
@@ -124,18 +121,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
124121 }
125122 });
126123
127- carousel. notify[" position" ]. connect (() = > {
128- current_swipe_progress = carousel. position;
129-
130- if (desktop_panel != null ) {
131- int left, right;
132- get_blur_margins (out left, out right);
133-
134- desktop_panel. add_blur (left, right, 16 , 16 , 9 );
135- } else if (Gdk . Display . get_default () is Gdk . X11. Display ) {
136- x11_update_mutter_hints ();
137- }
138- });
124+ carousel. notify[" position" ]. connect (update_swipe_progress);
139125
140126 transparency_settings. changed[" use-transparency" ]. connect (update_transparency);
141127 update_transparency ();
@@ -149,6 +135,27 @@ public class Notifications.AbstractBubble : Gtk.Window {
149135 }
150136 }
151137
138+ private void on_page_changed (Adw .Carousel carousel , uint index ) {
139+ if (carousel. get_nth_page (index) != overlay) {
140+ closed (CloseReason . DISMISSED );
141+ }
142+ }
143+
144+ private void update_swipe_progress (Object obj , ParamSpec pspec ) {
145+ var carousel = (Adw . Carousel ) obj;
146+
147+ current_swipe_progress = carousel. position;
148+
149+ if (desktop_panel != null ) {
150+ int left, right;
151+ get_blur_margins (out left, out right);
152+
153+ desktop_panel. add_blur (left, right, 16 , 16 , 9 );
154+ } else if (Gdk . Display . get_default () is Gdk . X11. Display ) {
155+ x11_update_mutter_hints ();
156+ }
157+ }
158+
152159 public new void present () {
153160 if (timeout_id != 0 ) {
154161 Source . remove (timeout_id);
0 commit comments