[evolution/evolution-3-12] Bug 607753 - Appointment tooltip sometimes 'stick' to screen



commit 25b6704a4b20749de653776d3fb58d2ff9ccb0d0
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jun 25 10:16:17 2014 +0200

    Bug 607753 - Appointment tooltip sometimes 'stick' to screen

 calendar/gui/e-calendar-view.c |   42 +++++++++++++++++++++++++++------------
 calendar/gui/e-day-view.c      |    6 ++++-
 calendar/gui/e-week-view.c     |    8 +++++++
 3 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index f51506b..1fac6e7 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -1907,26 +1907,31 @@ e_calendar_view_send (ECalendarView *cal_view,
                g_object_unref (send_comp);
 }
 
-static gboolean
-tooltip_grab (GtkWidget *tooltip,
-              GdkEvent *key_event,
-              ECalendarView *view)
+static void
+tooltip_ungrab (ECalendarView *view,
+               guint32 event_time)
 {
-       GtkWidget *widget;
        GdkDevice *keyboard;
-       guint32 event_time;
-
-       widget = g_object_get_data (G_OBJECT (view), "tooltip-window");
-       if (widget == NULL)
-               return TRUE;
-
-       event_time = gdk_event_get_time (key_event);
 
        while (!g_queue_is_empty (&view->priv->grabbed_keyboards)) {
                keyboard = g_queue_pop_head (&view->priv->grabbed_keyboards);
                gdk_device_ungrab (keyboard, event_time);
                g_object_unref (keyboard);
        }
+}
+
+static gboolean
+tooltip_key_event (GtkWidget *tooltip,
+                  GdkEvent *key_event,
+                  ECalendarView *view)
+{
+       GtkWidget *widget;
+
+       widget = g_object_get_data (G_OBJECT (view), "tooltip-window");
+       if (widget == NULL)
+               return TRUE;
+
+       tooltip_ungrab (view, gdk_event_get_time (key_event));
 
        gtk_widget_destroy (widget);
        g_object_set_data (G_OBJECT (view), "tooltip-window", NULL);
@@ -1993,6 +1998,16 @@ e_calendar_view_move_tip (GtkWidget *widget,
        gtk_widget_show (widget);
 }
 
+static void
+tooltip_window_destroyed_cb (gpointer user_data,
+                            GObject *gone)
+{
+       ECalendarView *view = user_data;
+
+       tooltip_ungrab (view, GDK_CURRENT_TIME);
+       g_object_unref (view);
+}
+
 /*
  * It is expected to show the tooltips in this below format
  *
@@ -2237,9 +2252,10 @@ e_calendar_view_get_tooltips (const ECalendarViewEventData *data)
 
        g_signal_connect (
                pevent->tooltip, "key-press-event",
-               G_CALLBACK (tooltip_grab), data->cal_view);
+               G_CALLBACK (tooltip_key_event), data->cal_view);
        pevent->timeout = -1;
 
+       g_object_weak_ref (G_OBJECT (pevent->tooltip), tooltip_window_destroyed_cb, g_object_ref 
(data->cal_view));
        g_object_set_data (G_OBJECT (data->cal_view), "tooltip-window", pevent->tooltip);
        g_object_unref (newcomp);
 
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 45bb819..eb73b8a 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -465,6 +465,7 @@ static void e_day_view_queue_layout (EDayView *day_view);
 static void e_day_view_cancel_layout (EDayView *day_view);
 static gboolean e_day_view_layout_timeout_cb (gpointer data);
 static void tooltip_destroy (EDayView *day_view, GnomeCanvasItem *item);
+static EDayViewEvent *tooltip_get_view_event (EDayView *day_view, gint day, gint event_num);
 
 enum {
        PROP_0,
@@ -4488,7 +4489,10 @@ e_day_view_show_popup_menu (EDayView *day_view,
                             gint day,
                             gint event_num)
 {
-       tooltip_destroy (day_view, NULL);
+       EDayViewEvent *pevent = tooltip_get_view_event (day_view, day, event_num);
+
+       if (pevent && pevent->canvas_item)
+               tooltip_destroy (day_view, pevent->canvas_item);
 
        day_view->popup_event_day = day;
        day_view->popup_event_num = event_num;
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index f3343d9..93d40cd 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -4767,6 +4767,14 @@ e_week_view_show_popup_menu (EWeekView *week_view,
                              GdkEvent *button_event,
                              gint event_num)
 {
+       guint timeout;
+
+       timeout = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (week_view), "tooltip-timeout"));
+       if (timeout) {
+               g_source_remove (timeout);
+               g_object_set_data (G_OBJECT (week_view), "tooltip-timeout", NULL);
+       }
+
        week_view->popup_event_num = event_num;
 
        e_calendar_view_popup_event (E_CALENDAR_VIEW (week_view), button_event);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]