[nautilus] floating-bar: Fix hiding on hover



commit 5d7e77fcd150b8f23699041b0dd94415622668b8
Author: Ignacy Kuchciński <ignacykuchcinski gmail com>
Date:   Sat Feb 26 19:08:42 2022 +0100

    floating-bar: Fix hiding on hover
    
    Since switching to GTK4 the floating bar no longer automatically hides
    while hovering the pointer over it.
    
    This is because in GTK 4 entering the child area (floating bar in our
    case) isn't treated as leaving the parent, so fix this situation by
    moving the relevant code to the on_event_controller_motion_motion() that
    is called on every motion inside the parent of the floating bar.
    
    Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2100

 src/nautilus-floating-bar.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
---
diff --git a/src/nautilus-floating-bar.c b/src/nautilus-floating-bar.c
index ef545e6f3..c2df8dd5f 100644
--- a/src/nautilus-floating-bar.c
+++ b/src/nautilus-floating-bar.c
@@ -237,10 +237,10 @@ check_pointer_timeout (gpointer user_data)
 }
 
 static void
-on_event_controller_motion_enter (GtkEventControllerMotion *controller,
-                                  double                    x,
-                                  double                    y,
-                                  gpointer                  user_data)
+on_event_controller_motion_motion (GtkEventControllerMotion *controller,
+                                   double                    x,
+                                   double                    y,
+                                   gpointer                  user_data)
 {
     NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (user_data);
     GtkWidget *parent;
@@ -264,7 +264,7 @@ on_event_controller_motion_enter (GtkEventControllerMotion *controller,
 
     if (self->hover_timeout_id != 0)
     {
-        g_source_remove (self->hover_timeout_id);
+        return;
     }
 
     data = g_slice_new (CheckPointerData);
@@ -276,7 +276,7 @@ on_event_controller_motion_enter (GtkEventControllerMotion *controller,
                                                  check_pointer_timeout, data,
                                                  check_pointer_data_free);
 
-    g_source_set_name_by_id (self->hover_timeout_id, "[nautilus-floating-bar] 
on_event_controller_motion_enter");
+    g_source_set_name_by_id (self->hover_timeout_id, "[nautilus-floating-bar] 
on_event_controller_motion_motion");
 }
 
 static void
@@ -288,17 +288,6 @@ on_event_controller_motion_leave (GtkEventControllerMotion *controller,
     self->pointer_y_in_parent_coordinates = -1;
 }
 
-static void
-on_event_controller_motion_motion (GtkEventControllerMotion *controller,
-                                   double                    x,
-                                   double                    y,
-                                   gpointer                  user_data)
-{
-    NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (user_data);
-
-    self->pointer_y_in_parent_coordinates = y;
-}
-
 static void
 on_parent_changed (GObject    *object,
                    GParamSpec *pspec,
@@ -331,8 +320,6 @@ on_parent_changed (GObject    *object,
 
         gtk_event_controller_set_propagation_phase (self->motion_controller,
                                                     GTK_PHASE_CAPTURE);
-        g_signal_connect (self->motion_controller, "enter",
-                          G_CALLBACK (on_event_controller_motion_enter), self);
         g_signal_connect (self->motion_controller, "leave",
                           G_CALLBACK (on_event_controller_motion_leave), self);
         g_signal_connect (self->motion_controller, "motion",


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