[gtk/wip/otte/matthiasc/popup2: 25/92] root: Add pointer focus apis



commit 375543b68e709c1e8fd3e95a03657b41794fe6df
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 17 09:24:49 2019 -0400

    root: Add pointer focus apis
    
    This copies all the private GtkWindow apis for
    handling pointer focus.

 gtk/gtkpointerfocus.c        |  2 +-
 gtk/gtkpointerfocusprivate.h |  4 +--
 gtk/gtkroot.c                | 86 ++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkroot.h                | 29 +++++++++++++++
 gtk/gtkrootprivate.h         | 25 +++++++++++++
 5 files changed, 143 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkpointerfocus.c b/gtk/gtkpointerfocus.c
index 6c2c90f455..4744f2f9b0 100644
--- a/gtk/gtkpointerfocus.c
+++ b/gtk/gtkpointerfocus.c
@@ -31,7 +31,7 @@ target_destroyed (gpointer  data,
 }
 
 GtkPointerFocus *
-gtk_pointer_focus_new (GtkWindow        *toplevel,
+gtk_pointer_focus_new (GtkRoot          *toplevel,
                        GtkWidget        *widget,
                        GdkDevice        *device,
                        GdkEventSequence *sequence,
diff --git a/gtk/gtkpointerfocusprivate.h b/gtk/gtkpointerfocusprivate.h
index 02ab6e5c82..ac39a33b16 100644
--- a/gtk/gtkpointerfocusprivate.h
+++ b/gtk/gtkpointerfocusprivate.h
@@ -27,13 +27,13 @@ struct _GtkPointerFocus
   gint ref_count;
   GdkDevice *device;
   GdkEventSequence *sequence;
-  GtkWindow *toplevel;
+  GtkRoot *toplevel;
   GtkWidget *target; /* Unaffected by the implicit grab */
   GtkWidget *grab_widget;
   gdouble x, y; /* In toplevel coordinates */
 };
 
-GtkPointerFocus * gtk_pointer_focus_new  (GtkWindow        *toplevel,
+GtkPointerFocus * gtk_pointer_focus_new  (GtkRoot          *toplevel,
                                           GtkWidget        *widget,
                                           GdkDevice        *device,
                                           GdkEventSequence *sequence,
diff --git a/gtk/gtkroot.c b/gtk/gtkroot.c
index ea1edef293..d2821226a1 100644
--- a/gtk/gtkroot.c
+++ b/gtk/gtkroot.c
@@ -89,6 +89,30 @@ gtk_root_default_activate_key (GtkRoot     *self,
   return FALSE;
 }
 
+static void
+gtk_root_default_update_pointer_focus (GtkRoot          *root,
+                                       GdkDevice        *device,
+                                       GdkEventSequence *sequence,
+                                       GtkWidget        *target,
+                                       double            x,
+                                       double            y)
+{
+}
+
+static void
+gtk_root_default_update_pointer_focus_on_state_change (GtkRoot   *root,
+                                                       GtkWidget *widget)
+{
+}
+
+static GtkWidget *
+gtk_root_default_lookup_pointer_focus (GtkRoot          *root,
+                                       GdkDevice        *device,
+                                       GdkEventSequence *sequence)
+{
+  return NULL;
+}
+
 static void
 gtk_root_default_init (GtkRootInterface *iface)
 {
@@ -99,6 +123,9 @@ gtk_root_default_init (GtkRootInterface *iface)
   iface->add_mnemonic = gtk_root_default_add_mnemonic;
   iface->remove_mnemonic = gtk_root_default_remove_mnemonic;
   iface->activate_key = gtk_root_default_activate_key;
+  iface->update_pointer_focus = gtk_root_default_update_pointer_focus;
+  iface->update_pointer_focus_on_state_change = gtk_root_default_update_pointer_focus_on_state_change;
+  iface->lookup_pointer_focus = gtk_root_default_lookup_pointer_focus;
 
   g_object_interface_install_property (iface,
       g_param_spec_object ("focus-widget",
@@ -478,3 +505,62 @@ gtk_root_activate_key (GtkRoot     *root,
 
   return GTK_ROOT_GET_IFACE (root)->activate_key (root, event); 
 }
+
+void
+gtk_root_update_pointer_focus (GtkRoot          *root,
+                               GdkDevice        *device,
+                               GdkEventSequence *sequence,
+                               GtkWidget        *target,
+                               double            x,
+                               double            y)
+{
+  GTK_ROOT_GET_IFACE (root)->update_pointer_focus (root, device, sequence, target, x, y);
+}
+
+void
+gtk_root_update_pointer_focus_on_state_change (GtkRoot   *root,
+                                               GtkWidget *widget)
+{
+  GTK_ROOT_GET_IFACE (root)->update_pointer_focus_on_state_change (root, widget);
+}
+
+GtkWidget *
+gtk_root_lookup_pointer_focus (GtkRoot          *root,
+                               GdkDevice        *device,
+                               GdkEventSequence *sequence)
+{
+  return GTK_ROOT_GET_IFACE (root)->lookup_pointer_focus (root, device, sequence);
+}
+
+GtkWidget *
+gtk_root_lookup_pointer_focus_implicit_grab (GtkRoot          *root,
+                                             GdkDevice        *device,
+                                             GdkEventSequence *sequence)
+{
+  return GTK_ROOT_GET_IFACE (root)->lookup_pointer_focus_implicit_grab (root, device, sequence);
+}
+
+GtkWidget *
+gtk_root_lookup_effective_pointer_focus (GtkRoot          *root,
+                                         GdkDevice        *device,
+                                         GdkEventSequence *sequence)
+{
+  return GTK_ROOT_GET_IFACE (root)->lookup_effective_pointer_focus (root, device, sequence);
+}
+
+void
+gtk_root_set_pointer_focus_grab (GtkRoot          *root,
+                                 GdkDevice        *device,
+                                 GdkEventSequence *sequence,
+                                 GtkWidget        *target)
+{
+  GTK_ROOT_GET_IFACE (root)->set_pointer_focus_grab (root, device, sequence, target);
+}
+
+void
+gtk_root_maybe_update_cursor (GtkRoot   *root,
+                              GtkWidget *widget,
+                              GdkDevice *device)
+{
+  GTK_ROOT_GET_IFACE (root)->maybe_update_cursor (root, widget, device);
+}
diff --git a/gtk/gtkroot.h b/gtk/gtkroot.h
index 77ad31f7e5..353992b326 100644
--- a/gtk/gtkroot.h
+++ b/gtk/gtkroot.h
@@ -51,8 +51,11 @@ struct _GtkRootInterface
   void                  (* get_surface_transform)       (GtkRoot                *root,
                                                          int                    *x,
                                                          int                    *y);
+
+  /* size allocation */
   void                  (* check_resize)                (GtkRoot                *root);
 
+  /* mnemonics */
   void                  (* add_mnemonic)                (GtkRoot                *root,
                                                          guint                   keyval,
                                                          GtkWidget              *target);
@@ -61,6 +64,32 @@ struct _GtkRootInterface
                                                          GtkWidget              *target);
   gboolean              (* activate_key)                (GtkRoot                *root,
                                                          GdkEventKey            *event);
+
+  /* pointer focus */
+  void                  (* update_pointer_focus)        (GtkRoot                *root,
+                                                         GdkDevice              *device,
+                                                         GdkEventSequence       *sequence,
+                                                         GtkWidget              *target,
+                                                         double                  x,
+                                                         double                  y);
+  void                  (* update_pointer_focus_on_state_change) (GtkRoot       *root,
+                                                                  GtkWidget     *widget);
+  GtkWidget *           (* lookup_pointer_focus)        (GtkRoot                *root,
+                                                         GdkDevice              *device,
+                                                         GdkEventSequence       *sequence);
+  GtkWidget *           (* lookup_pointer_focus_implicit_grab) (GtkRoot          *root,
+                                                                GdkDevice        *device,
+                                                                GdkEventSequence *sequence);
+  GtkWidget *           (* lookup_effective_pointer_focus) (GtkRoot          *root,
+                                                            GdkDevice        *device,
+                                                            GdkEventSequence *sequence);
+  void                  (* set_pointer_focus_grab)      (GtkRoot                *root,
+                                                         GdkDevice        *device,
+                                                         GdkEventSequence *sequence,
+                                                         GtkWidget        *target);
+  void                  (* maybe_update_cursor)         (GtkRoot          *root,
+                                                         GtkWidget        *widget,
+                                                         GdkDevice        *device); 
 };
 
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkrootprivate.h b/gtk/gtkrootprivate.h
index af3b35c82f..41906a1e85 100644
--- a/gtk/gtkrootprivate.h
+++ b/gtk/gtkrootprivate.h
@@ -19,6 +19,31 @@ void                    gtk_root_stop_layout_phase      (GtkRoot
 gboolean                gtk_root_activate_key           (GtkRoot                *self,
                                                          GdkEventKey            *event);
 
+void                    gtk_root_update_pointer_focus   (GtkRoot                *root,
+                                                         GdkDevice              *device,
+                                                         GdkEventSequence       *sequence,
+                                                         GtkWidget              *target,
+                                                         double                  x,
+                                                         double                  y);
+void                    gtk_root_update_pointer_focus_on_state_change (GtkRoot   *root,
+                                                                       GtkWidget *widget);
+GtkWidget *             gtk_root_lookup_pointer_focus   (GtkRoot                 *root,
+                                                         GdkDevice              *device,
+                                                         GdkEventSequence       *sequence);
+GtkWidget *             gtk_root_lookup_pointer_focus_implicit_grab (GtkRoot          *root,
+                                                                     GdkDevice        *device,
+                                                                     GdkEventSequence *sequence);
+GtkWidget *             gtk_root_lookup_effective_pointer_focus (GtkRoot          *root,
+                                                                 GdkDevice        *device,
+                                                                 GdkEventSequence *sequence);
+void                    gtk_root_set_pointer_focus_grab  (GtkRoot                *root,
+                                                          GdkDevice              *device,
+                                                          GdkEventSequence       *sequence,
+                                                          GtkWidget              *target);
+void                    gtk_root_maybe_update_cursor     (GtkRoot                *root,
+                                                          GtkWidget              *widget,
+                                                          GdkDevice              *device);
+
 enum {
   GTK_ROOT_PROP_FOCUS_WIDGET,
   GTK_ROOT_PROP_DEFAULT_WIDGET,


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