[gtk+/wip/carlosg/event-delivery: 33/105] gtkpointerfocus: Add methods to handle implicit grabs on widgets



commit 41058edc66a1bd1a60886ff29f9c6eda41fcb5ba
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Mar 31 17:57:44 2017 +0200

    gtkpointerfocus: Add methods to handle implicit grabs on widgets
    
    Just a basic setter/getter, plus a method to obtain the right logical target
    in the presence or absence of these.

 gtk/gtkpointerfocus.c        |   28 ++++++++++++++++++++++++++++
 gtk/gtkpointerfocusprivate.h |    6 ++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkpointerfocus.c b/gtk/gtkpointerfocus.c
index 7c522a0..3a4026d 100644
--- a/gtk/gtkpointerfocus.c
+++ b/gtk/gtkpointerfocus.c
@@ -79,6 +79,19 @@ gtk_pointer_focus_get_target (GtkPointerFocus *focus)
 }
 
 void
+gtk_pointer_focus_set_implicit_grab (GtkPointerFocus *focus,
+                                     GtkWidget       *grab_widget)
+{
+  focus->grab_widget = grab_widget;
+}
+
+GtkWidget *
+gtk_pointer_focus_get_implicit_grab (GtkPointerFocus *focus)
+{
+  return focus->grab_widget;
+}
+
+void
 gtk_pointer_focus_set_coordinates (GtkPointerFocus *focus,
                                    gdouble          x,
                                    gdouble          y)
@@ -87,6 +100,21 @@ gtk_pointer_focus_set_coordinates (GtkPointerFocus *focus,
   focus->y = y;
 }
 
+GtkWidget *
+gtk_pointer_focus_get_effective_target (GtkPointerFocus *focus)
+{
+  GtkWidget *target;
+
+  target = focus->target;
+
+  if (focus->grab_widget &&
+      focus->grab_widget != target &&
+      !gtk_widget_is_ancestor (target, focus->grab_widget))
+    target = focus->grab_widget;
+
+  return target;
+}
+
 void
 gtk_pointer_focus_repick_target (GtkPointerFocus *focus)
 {
diff --git a/gtk/gtkpointerfocusprivate.h b/gtk/gtkpointerfocusprivate.h
index 56735d8..5d5be95 100644
--- a/gtk/gtkpointerfocusprivate.h
+++ b/gtk/gtkpointerfocusprivate.h
@@ -47,6 +47,12 @@ void              gtk_pointer_focus_set_target      (GtkPointerFocus *focus,
                                                      GtkWidget       *target);
 GtkWidget *       gtk_pointer_focus_get_target      (GtkPointerFocus *focus);
 
+void              gtk_pointer_focus_set_implicit_grab (GtkPointerFocus *focus,
+                                                       GtkWidget       *grab_widget);
+GtkWidget *       gtk_pointer_focus_get_implicit_grab (GtkPointerFocus *focus);
+
+GtkWidget *       gtk_pointer_focus_get_effective_target (GtkPointerFocus *focus);
+
 void              gtk_pointer_focus_repick_target (GtkPointerFocus *focus);
 
 #endif /* _GTK_POINTER_FOCUS_PRIVATE_H_ */


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