[gtk/wip/matthiasc/popup4: 22/105] main: Use root pointer focus apis



commit c94e9961f6006038a89014cbb41b2ec6943c2b97
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 17 09:25:56 2019 -0400

    main: Use root pointer focus apis

 gtk/gtkmain.c | 46 +++++++++++++++++++---------------------------
 1 file changed, 19 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 261015a0f0..fd2a443a6f 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1593,7 +1593,7 @@ gtk_synthesize_crossing_events (GtkRoot         *toplevel,
 
 
 static GtkWidget *
-update_pointer_focus_state (GtkWindow *toplevel,
+update_pointer_focus_state (GtkRoot   *root,
                             GdkEvent  *event,
                             GtkWidget *new_target)
 {
@@ -1604,13 +1604,12 @@ update_pointer_focus_state (GtkWindow *toplevel,
 
   device = gdk_event_get_device (event);
   sequence = gdk_event_get_event_sequence (event);
-  old_target = gtk_window_lookup_pointer_focus_widget (toplevel, device, sequence);
+  old_target = gtk_root_lookup_pointer_focus (root, device, sequence);
   if (old_target == new_target)
     return old_target;
 
   gdk_event_get_coords (event, &x, &y);
-  gtk_window_update_pointer_focus (toplevel, device, sequence,
-                                   new_target, x, y);
+  gtk_root_update_pointer_focus (root, device, sequence, new_target, x, y);
 
   return old_target;
 }
@@ -1661,7 +1660,7 @@ static GtkWidget *
 handle_pointing_event (GdkEvent *event)
 {
   GtkWidget *target = NULL, *old_target = NULL, *event_widget;
-  GtkWindow *toplevel;
+  GtkRoot *toplevel;
   GtkWidget *toplevel_widget;
   GdkEventSequence *sequence;
   GdkDevice *device;
@@ -1673,10 +1672,10 @@ handle_pointing_event (GdkEvent *event)
     return event_widget;
 
   toplevel_widget = gtk_widget_get_toplevel (event_widget);
-  if (!GTK_IS_WINDOW (toplevel_widget))
+  if (!GTK_IS_ROOT (toplevel_widget))
     return event_widget;
 
-  toplevel = GTK_WINDOW (toplevel_widget);
+  toplevel = GTK_ROOT (toplevel_widget);
 
   sequence = gdk_event_get_event_sequence (event);
 
@@ -1692,7 +1691,7 @@ handle_pointing_event (GdkEvent *event)
       old_target = update_pointer_focus_state (toplevel, event, NULL);
 
       if (event->any.type == GDK_LEAVE_NOTIFY)
-        gtk_synthesize_crossing_events (GTK_ROOT (toplevel), old_target, NULL,
+        gtk_synthesize_crossing_events (toplevel, old_target, NULL,
                                         event, event->crossing.mode);
       break;
     case GDK_ENTER_NOTIFY:
@@ -1703,7 +1702,7 @@ handle_pointing_event (GdkEvent *event)
     case GDK_TOUCH_BEGIN:
     case GDK_TOUCH_UPDATE:
     case GDK_MOTION_NOTIFY:
-      target = gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device, sequence);
+      target = gtk_root_lookup_pointer_focus_implicit_grab (toplevel, device, sequence);
 
       if (!target)
         target = gtk_widget_pick (toplevel_widget, x, y, GTK_PICK_DEFAULT);
@@ -1715,18 +1714,16 @@ handle_pointing_event (GdkEvent *event)
 
       if (event->any.type == GDK_MOTION_NOTIFY || event->any.type == GDK_ENTER_NOTIFY)
         {
-          if (!gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device,
-                                                              sequence))
+          if (!gtk_root_lookup_pointer_focus_implicit_grab (toplevel, device, sequence))
             {
-              gtk_synthesize_crossing_events (GTK_ROOT (toplevel), old_target, target,
-                                              event, GDK_CROSSING_NORMAL);
+              gtk_synthesize_crossing_events (toplevel, old_target, target, event, GDK_CROSSING_NORMAL);
             }
 
-          gtk_window_maybe_update_cursor (toplevel, NULL, device);
+          gtk_root_maybe_update_cursor (toplevel, NULL, device);
         }
 
       if (event->any.type == GDK_TOUCH_BEGIN)
-        gtk_window_set_pointer_focus_grab (toplevel, device, sequence, target);
+        gtk_root_set_pointer_focus_grab (toplevel, device, sequence, target);
 
       /* Let it take the effective pointer focus anyway, as it may change due
        * to implicit grabs.
@@ -1735,12 +1732,10 @@ handle_pointing_event (GdkEvent *event)
       break;
     case GDK_BUTTON_PRESS:
     case GDK_BUTTON_RELEASE:
-      target = gtk_window_lookup_effective_pointer_focus_widget (toplevel,
-                                                                 device,
-                                                                 sequence);
-      gtk_window_set_pointer_focus_grab (toplevel, device, sequence,
-                                         event->any.type == GDK_BUTTON_PRESS ?
-                                         target : NULL);
+      target = gtk_root_lookup_effective_pointer_focus (toplevel, device, sequence);
+      gtk_root_set_pointer_focus_grab (toplevel, device, sequence,
+                                       event->any.type == GDK_BUTTON_PRESS ?
+                                       target : NULL);
 
       if (event->any.type == GDK_BUTTON_RELEASE)
         {
@@ -1748,9 +1743,8 @@ handle_pointing_event (GdkEvent *event)
           new_target = gtk_widget_pick (GTK_WIDGET (toplevel), x, y, GTK_PICK_DEFAULT);
           if (new_target == NULL)
             new_target = GTK_WIDGET (toplevel);
-          gtk_synthesize_crossing_events (GTK_ROOT (toplevel), target, new_target, event,
-                                          GDK_CROSSING_UNGRAB);
-          gtk_window_maybe_update_cursor (toplevel, NULL, device);
+          gtk_synthesize_crossing_events (toplevel, target, new_target, event, GDK_CROSSING_UNGRAB);
+          gtk_root_maybe_update_cursor (toplevel, NULL, device);
         }
 
       set_widget_active_state (target, event->any.type == GDK_BUTTON_RELEASE);
@@ -1765,9 +1759,7 @@ handle_pointing_event (GdkEvent *event)
     }
 
   if (!target)
-    target = gtk_window_lookup_effective_pointer_focus_widget (toplevel,
-                                                               device,
-                                                               sequence);
+    target = gtk_root_lookup_effective_pointer_focus (toplevel, device, sequence);
   return target ? target : old_target;
 }
 


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