Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions src/AbstractBubble.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 elementary, Inc. (https://elementary.io)
* Copyright 2020-2025 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
Expand Down Expand Up @@ -31,6 +31,7 @@ public class Notifications.AbstractBubble : Gtk.Window {

private Gtk.Revealer close_revealer;
private Gtk.Box draw_area;
private Gtk.Overlay overlay;

private uint timeout_id;

Expand Down Expand Up @@ -72,7 +73,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
overflow = VISIBLE
};

var overlay = new Gtk.Overlay () {
overlay = new Gtk.Overlay () {
child = draw_area
};
overlay.add_overlay (close_revealer);
Expand All @@ -92,11 +93,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
can_focus = false;
set_titlebar (new Gtk.Grid ());

carousel.page_changed.connect ((index) => {
if (index == 0) {
closed (Notifications.Server.CloseReason.DISMISSED);
}
});
carousel.page_changed.connect (on_page_changed);
close_button.clicked.connect (() => closed (Notifications.Server.CloseReason.DISMISSED));

var motion_controller = new Gtk.EventControllerMotion ();
Expand All @@ -114,18 +111,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
}
});

carousel.notify["position"].connect (() => {
current_swipe_progress = carousel.position;

if (desktop_panel != null) {
int left, right;
get_blur_margins (out left, out right);

desktop_panel.add_blur (left, right, 16, 16, 9);
} else if (Gdk.Display.get_default () is Gdk.X11.Display) {
x11_update_mutter_hints ();
}
});
carousel.notify["position"].connect (update_swipe_progress);

transparency_settings.changed["use-transparency"].connect (update_transparency);
update_transparency ();
Expand All @@ -139,6 +125,27 @@ public class Notifications.AbstractBubble : Gtk.Window {
}
}

private void on_page_changed (Adw.Carousel carousel, uint index) {
if (carousel.get_nth_page (index) != overlay) {
closed (Notifications.Server.CloseReason.DISMISSED);
}
}

private void update_swipe_progress (Object obj, ParamSpec pspec) {
var carousel = (Adw.Carousel) obj;

current_swipe_progress = carousel.position;

if (desktop_panel != null) {
int left, right;
get_blur_margins (out left, out right);

desktop_panel.add_blur (left, right, 16, 16, 9);
} else if (Gdk.Display.get_default () is Gdk.X11.Display) {
x11_update_mutter_hints ();
}
}

public new void present () {
if (timeout_id != 0) {
Source.remove (timeout_id);
Expand Down