[libgd/wip/ernestask/gtk4: 18/22] notification: override generic event vfunc



commit 3e252f4c14b504f2816bdb8fa4dc58ecf3a3517a
Author: Ernestas Kulik <ernestask gnome org>
Date:   Sun Mar 11 10:08:53 2018 +0200

    notification: override generic event vfunc

 libgd/gd-notification.c |   42 ++++++++++++++++++++++++++++++++----------
 1 files changed, 32 insertions(+), 10 deletions(-)
---
diff --git a/libgd/gd-notification.c b/libgd/gd-notification.c
index 1697e8d..0ae8fb1 100644
--- a/libgd/gd-notification.c
+++ b/libgd/gd-notification.c
@@ -430,14 +430,18 @@ gd_notification_visibility_notify_event (GtkWidget          *widget,
 }
 
 static gboolean
-gd_notification_enter_notify (GtkWidget        *widget,
-                              GdkEventCrossing *event)
+gd_notification_enter_notify (GtkWidget *widget,
+                              GdkEvent  *event)
 {
   GdNotification *notification = GD_NOTIFICATION (widget);
   GdNotificationPrivate *priv = notification->priv;
+  GdkNotifyType detail;
 
-  if ((event->window == priv->bin_window) &&
-      (event->detail != GDK_NOTIFY_INFERIOR))
+  if (!gdk_event_get_crossing_detail (event, &detail))
+    return GDK_EVENT_PROPAGATE;
+
+  if ((gdk_event_get_window (event) == priv->bin_window) &&
+      (detail != GDK_NOTIFY_INFERIOR))
     {
       unqueue_autohide (notification);
     }
@@ -446,14 +450,18 @@ gd_notification_enter_notify (GtkWidget        *widget,
 }
 
 static gboolean
-gd_notification_leave_notify (GtkWidget        *widget,
-                              GdkEventCrossing *event)
+gd_notification_leave_notify (GtkWidget *widget,
+                              GdkEvent  *event)
 {
   GdNotification *notification = GD_NOTIFICATION (widget);
   GdNotificationPrivate *priv = notification->priv;
+  GdkNotifyType detail;
+
+  if (!gdk_event_get_crossing_detail (event, &detail))
+    return GDK_EVENT_PROPAGATE;
 
-  if ((event->window == priv->bin_window) &&
-      (event->detail != GDK_NOTIFY_INFERIOR))
+  if ((gdk_event_get_window (event) == priv->bin_window) &&
+      (detail != GDK_NOTIFY_INFERIOR))
     {
       queue_autohide (notification);
     }
@@ -461,6 +469,21 @@ gd_notification_leave_notify (GtkWidget        *widget,
   return FALSE;
 }
 
+static gboolean
+gd_notification_event (GtkWidget *widget,
+                       GdkEvent  *event)
+{
+  GdkEventType event_type;
+
+  event_type = gdk_event_get_event_type (event);
+  if (event_type == GDK_ENTER_NOTIFY)
+    return gd_notification_enter_notify (widget, event);
+  if (event_type == GDK_LEAVE_NOTIFY)
+    return gd_notification_leave_notify (widget, event);
+
+  return GDK_EVENT_PROPAGATE;
+}
+
 static void
 gd_notification_class_init (GdNotificationClass *klass)
 {
@@ -480,8 +503,7 @@ 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;
+  widget_class->event = gd_notification_event;
 
   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]