Skip to content

Commit b48e1eb

Browse files
committed
Improve gesture tracking
1 parent 6d9d6fd commit b48e1eb

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/AbstractBubble.vala

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public class Notifications.AbstractBubble : Gtk.Window {
2525

2626
protected Gtk.Stack content_area;
2727

28-
private Hdy.Carousel carousel;
2928
private Gtk.Revealer close_revealer;
3029
private Gtk.Revealer revealer;
3130
private Gtk.Grid draw_area;
3231

3332
private Gtk.EventControllerMotion motion_controller;
3433
private uint timeout_id;
3534

35+
private double current_swipe_progress = 1.0;
3636
private Pantheon.Desktop.Shell? desktop_shell;
3737
private Pantheon.Desktop.Panel? desktop_panel;
3838

@@ -74,7 +74,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
7474
child = overlay
7575
};
7676

77-
carousel = new Hdy.Carousel () {
77+
var carousel = new Hdy.Carousel () {
7878
allow_mouse_drag = true,
7979
interactive = true,
8080
halign = Gtk.Align.END,
@@ -99,12 +99,13 @@ public class Notifications.AbstractBubble : Gtk.Window {
9999
close_button.clicked.connect (() => closed (Notifications.Server.CloseReason.DISMISSED));
100100
closed.connect (close);
101101

102-
carousel.notify["position"].connect (() => {
102+
carousel.get_swipe_tracker ().update_swipe.connect ((progress) => {
103+
current_swipe_progress = progress;
104+
103105
if (Gdk.Display.get_default () is Gdk.Wayland.Display) {
104106
int left, right;
105107
get_blur_margins (out left, out right);
106108

107-
// TODO: Use same approach for radius as dock
108109
desktop_panel.add_blur (left, right, 16, 16, 9);
109110
} else {
110111
init_x ();
@@ -178,9 +179,10 @@ public class Notifications.AbstractBubble : Gtk.Window {
178179
}
179180

180181
private void get_blur_margins (out int left, out int right) {
181-
var distance = carousel.position * width_request;
182-
left = (int) (16 + distance).clamp (0, width_request);
183-
right = (int) (16 - distance).clamp (0, width_request);
182+
var width = get_allocated_width ();
183+
var distance = (1 - current_swipe_progress) * width;
184+
left = (int) (16 + distance).clamp (0, width);
185+
right = (int) (16 - distance).clamp (0, width);
184186
}
185187

186188
private void init_x () {
@@ -225,7 +227,6 @@ public class Notifications.AbstractBubble : Gtk.Window {
225227
if (window is Gdk.Wayland.Window) {
226228
unowned var wl_surface = ((Gdk.Wayland.Window) window).get_wl_surface ();
227229
desktop_panel = desktop_shell.get_panel (wl_surface);
228-
// TODO: Use same approach for radius as dock
229230
desktop_panel.add_blur (16, 16, 16, 16, 9);
230231
}
231232
}

0 commit comments

Comments
 (0)