[libgd] notification: Don't timeout if a pointer is above the notification



commit b33b9a06067a21fbca7b8c1dc6c6bb8aee4ac5f7
Author: Kalev Lember <kalevlember gmail com>
Date:   Sun Mar 1 18:40:08 2015 +0100

    notification: Don't timeout if a pointer is above the notification
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710297

 libgd/gd-notification.c |   40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/libgd/gd-notification.c b/libgd/gd-notification.c
index 38f047d..8153436 100644
--- a/libgd/gd-notification.c
+++ b/libgd/gd-notification.c
@@ -218,7 +218,11 @@ gd_notification_realize (GtkWidget *widget)
 
   attributes.x = 0;
   attributes.y = attributes.height + priv->animate_y;
-  attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_VISIBILITY_NOTIFY_MASK;
+  attributes.event_mask = gtk_widget_get_events (widget) |
+                          GDK_EXPOSURE_MASK |
+                          GDK_VISIBILITY_NOTIFY_MASK |
+                          GDK_ENTER_NOTIFY_MASK |
+                          GDK_LEAVE_NOTIFY_MASK;
 
   priv->bin_window = gdk_window_new (window, &attributes, attributes_mask);
   gtk_widget_register_window (widget, priv->bin_window);
@@ -440,6 +444,38 @@ gd_notification_visibility_notify_event (GtkWidget          *widget,
   return FALSE;
 }
 
+static gboolean
+gd_notification_enter_notify (GtkWidget        *widget,
+                              GdkEventCrossing *event)
+{
+  GdNotification *notification = GD_NOTIFICATION (widget);
+  GdNotificationPrivate *priv = notification->priv;
+
+  if ((event->window == priv->bin_window) &&
+      (event->detail != GDK_NOTIFY_INFERIOR))
+    {
+      unqueue_autohide (notification);
+    }
+
+  return FALSE;
+}
+
+static gboolean
+gd_notification_leave_notify (GtkWidget        *widget,
+                              GdkEventCrossing *event)
+{
+  GdNotification *notification = GD_NOTIFICATION (widget);
+  GdNotificationPrivate *priv = notification->priv;
+
+  if ((event->window == priv->bin_window) &&
+      (event->detail != GDK_NOTIFY_INFERIOR))
+    {
+      queue_autohide (notification);
+    }
+
+  return FALSE;
+}
+
 static void
 gd_notification_class_init (GdNotificationClass *klass)
 {
@@ -463,6 +499,8 @@ gd_notification_class_init (GdNotificationClass *klass)
   widget_class->realize = gd_notification_realize;
   widget_class->unrealize = gd_notification_unrealize;
   widget_class->visibility_notify_event = gd_notification_visibility_notify_event;
+  widget_class->enter_notify_event = gd_notification_enter_notify;
+  widget_class->leave_notify_event = gd_notification_leave_notify;
 
   container_class->add = gd_notification_add;
   container_class->forall = gd_notification_forall;


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