gui/event-widget: Guard event popover's pointing coordinates on multi-day events

A follow-up on https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/677#note_2628484,
which prevents the event popover from pointing outside the event
widget's boundaries on multi-day events when activated before exceeding
the drag threshold:
https://docs.gtk.org/gtk4/property.Settings.gtk-dnd-drag-threshold.html

This is mainly useful for people who fidget and may sloppily
click and drag event widgets (before triggering the drag operation),
causing the popover to place itself in unpredictable locations.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/697>
This commit is contained in:
Hari Rana
2026-08-28 21:55:35 +00:00
committed by Marge Bot
parent fbbf6d854c
commit 1b10e66078
+8 -4
View File
@@ -514,8 +514,9 @@ on_click_gesture_release_cb (GtkGestureClick *click_gesture,
gdouble y,
GcalEventWidget *self)
{
GdkRectangle rect;
gboolean not_inside_list_box;
GdkRectangle rect;
gint half_width;
gtk_gesture_set_state (GTK_GESTURE (click_gesture), GTK_EVENT_SEQUENCE_CLAIMED);
g_signal_emit (self, signals[ACTIVATE], 0);
@@ -525,10 +526,13 @@ on_click_gesture_release_cb (GtkGestureClick *click_gesture,
not_inside_list_box = !gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_LIST_BOX);
if (not_inside_list_box && gcal_event_is_multiday (self->event))
{
rect.x = x;
rect.width = gtk_widget_get_width (GTK_WIDGET (self));
rect.height = gtk_widget_get_height (GTK_WIDGET (self));
half_width = rect.width / 2;
rect.x = CLAMP (x - half_width, -half_width, half_width);
rect.y = 0;
rect.width = 1;
rect.height = 1;
gtk_popover_set_pointing_to (GTK_POPOVER (self->preview_popover), &rect);
}