gui/event-widget: Position event popover to the pointer's
Currently, the event popover will always set its position to the center of the event widget. This becomes an undesirable behavior with long(er) event widgets, as clicking the edges will require the user to physically move their pointer all the way to the popover, which may be challenging depending on the distance. This addresses this problematic behavior by positioning the popover right above the pointer only when the event is a multi-day event, and when the event widget is not inside a GtkListBox widget. Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/677>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "gcal-event-popover.h"
|
||||
#include "gcal-event-widget.h"
|
||||
#include "gcal-overflow-bin.h"
|
||||
#include "gcal-view.h"
|
||||
#include "gcal-utils.h"
|
||||
|
||||
#define LOCATION_MAX_LEN 50
|
||||
@@ -583,8 +584,24 @@ on_click_gesture_release_cb (GtkGestureClick *click_gesture,
|
||||
gdouble y,
|
||||
GcalEventWidget *self)
|
||||
{
|
||||
GdkRectangle rect;
|
||||
gboolean not_inside_list_box;
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (click_gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
g_signal_emit (self, signals[ACTIVATE], 0);
|
||||
|
||||
g_assert (GCAL_IS_EVENT_POPOVER (self->preview_popover));
|
||||
|
||||
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.y = 0;
|
||||
rect.width = 1;
|
||||
rect.height = 1;
|
||||
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (self->preview_popover), &rect);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user