From 1b10e66078f3c61638190c21586c52614113014c Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Wed, 11 Feb 2026 10:04:54 -0500 Subject: [PATCH] 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: --- src/gui/gcal-event-widget.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/gcal-event-widget.c b/src/gui/gcal-event-widget.c index 89e82299..06e432f3 100644 --- a/src/gui/gcal-event-widget.c +++ b/src/gui/gcal-event-widget.c @@ -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); }