[evolution] I#1328 - Calendar: Event tooltip can be misplaced
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#1328 - Calendar: Event tooltip can be misplaced
- Date: Wed, 20 Jan 2021 14:20:14 +0000 (UTC)
commit 8b66c7049379f0954a5462fa12a73420fcf736d8
Author: Milan Crha <mcrha redhat com>
Date: Wed Jan 20 15:18:56 2021 +0100
I#1328 - Calendar: Event tooltip can be misplaced
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1328
src/calendar/gui/e-calendar-view.c | 27 ++++++++++++++++++---------
src/calendar/gui/e-calendar-view.h | 2 ++
src/calendar/gui/e-day-view.c | 2 +-
src/calendar/gui/e-week-view.c | 4 ++--
4 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/src/calendar/gui/e-calendar-view.c b/src/calendar/gui/e-calendar-view.c
index 16a6eeae4d..95211fb39b 100644
--- a/src/calendar/gui/e-calendar-view.c
+++ b/src/calendar/gui/e-calendar-view.c
@@ -1785,7 +1785,6 @@ e_calendar_view_move_tip (GtkWidget *widget,
gint y)
{
GtkAllocation allocation;
- GtkRequisition requisition;
GdkDisplay *display;
GdkScreen *screen;
GdkScreen *pointer_screen;
@@ -1795,9 +1794,9 @@ e_calendar_view_move_tip (GtkWidget *widget,
gint monitor_num, px, py;
gint w, h;
- gtk_widget_get_preferred_size (widget, &requisition, NULL);
- w = requisition.width;
- h = requisition.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ w = allocation.width;
+ h = allocation.height;
screen = gtk_widget_get_screen (widget);
display = gdk_screen_get_display (screen);
@@ -1812,15 +1811,25 @@ e_calendar_view_move_tip (GtkWidget *widget,
monitor_num = gdk_screen_get_monitor_at_point (screen, px, py);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ x += E_CALENDAR_VIEW_TOOLTIP_OFFSET;
+
if ((x + w) > monitor.x + monitor.width)
x -= (x + w) - (monitor.x + monitor.width);
else if (x < monitor.x)
x = monitor.x;
- gtk_widget_get_allocation (widget, &allocation);
+ if (x < monitor.x)
+ x = monitor.x;
+
+ y += E_CALENDAR_VIEW_TOOLTIP_OFFSET;
+
+ /* Place above the cursor only if it cannot fit below it and there's enough space above */
+
+ if (y + h > monitor.y + monitor.height && y - 2 * E_CALENDAR_VIEW_TOOLTIP_OFFSET - monitor.y > h)
+ y = y - h - 2 * E_CALENDAR_VIEW_TOOLTIP_OFFSET;
- if ((y + h + allocation.height + 4) > monitor.y + monitor.height)
- y = y - h - 36;
+ if (y < monitor.y)
+ y = monitor.y;
gtk_window_move (GTK_WINDOW (widget), x, y);
gtk_widget_show (widget);
@@ -2128,13 +2137,13 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data)
gtk_frame_set_shadow_type ((GtkFrame *) frame, GTK_SHADOW_IN);
gtk_window_set_type_hint (GTK_WINDOW (pevent->tooltip), GDK_WINDOW_TYPE_HINT_TOOLTIP);
- gtk_window_move ((GtkWindow *) pevent->tooltip, pevent->x +16, pevent->y + 16);
+ gtk_window_move ((GtkWindow *) pevent->tooltip, pevent->x + E_CALENDAR_VIEW_TOOLTIP_OFFSET, pevent->y
+ E_CALENDAR_VIEW_TOOLTIP_OFFSET);
gtk_container_add ((GtkContainer *) frame, box);
gtk_container_add ((GtkContainer *) pevent->tooltip, frame);
gtk_widget_show_all (pevent->tooltip);
- e_calendar_view_move_tip (pevent->tooltip, pevent->x +16, pevent->y + 16);
+ e_calendar_view_move_tip (pevent->tooltip, pevent->x, pevent->y);
window = gtk_widget_get_window (pevent->tooltip);
display = gdk_window_get_display (window);
diff --git a/src/calendar/gui/e-calendar-view.h b/src/calendar/gui/e-calendar-view.h
index 03c56401ab..3ec133d1ed 100644
--- a/src/calendar/gui/e-calendar-view.h
+++ b/src/calendar/gui/e-calendar-view.h
@@ -49,6 +49,8 @@
G_BEGIN_DECLS
+#define E_CALENDAR_VIEW_TOOLTIP_OFFSET 16
+
typedef enum {
E_CALENDAR_VIEW_POS_OUTSIDE,
E_CALENDAR_VIEW_POS_NONE,
diff --git a/src/calendar/gui/e-day-view.c b/src/calendar/gui/e-day-view.c
index 2daae20f93..8a4bee78b6 100644
--- a/src/calendar/gui/e-day-view.c
+++ b/src/calendar/gui/e-day-view.c
@@ -7561,7 +7561,7 @@ e_day_view_on_text_item_event (GnomeCanvasItem *item,
pevent->tooltip = (GtkWidget *) g_object_get_data (G_OBJECT (day_view),
"tooltip-window");
if (pevent->tooltip) {
- e_calendar_view_move_tip (pevent->tooltip, pevent->x + 16, pevent->y + 16);
+ e_calendar_view_move_tip (pevent->tooltip, pevent->x, pevent->y);
}
return TRUE;
diff --git a/src/calendar/gui/e-week-view.c b/src/calendar/gui/e-week-view.c
index 31644a6004..8aac9753a2 100644
--- a/src/calendar/gui/e-week-view.c
+++ b/src/calendar/gui/e-week-view.c
@@ -3663,7 +3663,7 @@ tooltip_event_cb (GnomeCanvasItem *item,
pevent->tooltip = (GtkWidget *) g_object_get_data (G_OBJECT (view), "tooltip-window");
if (pevent->tooltip) {
- e_calendar_view_move_tip (pevent->tooltip, pevent->x + 16, pevent->y + 16);
+ e_calendar_view_move_tip (pevent->tooltip, pevent->x, pevent->y);
}
return TRUE;
@@ -4391,7 +4391,7 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item,
pevent->tooltip = (GtkWidget *) g_object_get_data (G_OBJECT (week_view), "tooltip-window");
if (pevent->tooltip) {
- e_calendar_view_move_tip (pevent->tooltip, pevent->x + 16, pevent->y + 16);
+ e_calendar_view_move_tip (pevent->tooltip, pevent->x, pevent->y);
}
return TRUE;
case GDK_FOCUS_CHANGE:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]