[gtk/wip/baedert/for-master: 19/24] window: Carry an extra input region



commit 5e588ea6a6be26f69e5ea908144fc911a5cf491c
Author: Timm Bäder <mail baedert org>
Date:   Sat Feb 22 16:05:35 2020 +0100

    window: Carry an extra input region
    
    This will be used in the inspector to make it possible to click through
    the inspector window.

 gtk/gtkwindow.c        | 17 +++++++++++++++++
 gtk/gtkwindowprivate.h |  3 +++
 2 files changed, 20 insertions(+)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 2f93d4ee9e..b1943221b0 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -273,6 +273,8 @@ typedef struct
   GdkSurface  *surface;
   GskRenderer *renderer;
 
+  cairo_region_t *extra_input_region;
+
   GList *foci;
 
   GtkConstraintSolver *constraint_solver;
@@ -4670,6 +4672,7 @@ gtk_window_finalize (GObject *object)
   GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
   GtkMnemonicHash *mnemonic_hash;
 
+  g_clear_pointer (&priv->extra_input_region, cairo_region_destroy);
   g_free (priv->title);
   gtk_window_release_application (window);
 
@@ -5336,11 +5339,25 @@ update_csd_shape (GtkWindow *window)
     {
       cairo_region_t *region = cairo_region_create_rectangle (&rect);
 
+      if (priv->extra_input_region)
+        cairo_region_intersect (region, priv->extra_input_region);
+
       gdk_surface_input_shape_combine_region (priv->surface, region, 0, 0);
       cairo_region_destroy (region);
     }
 }
 
+void
+gtk_window_set_extra_input_region (GtkWindow      *window,
+                                   cairo_region_t *region)
+{
+  GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
+
+  g_clear_pointer (&priv->extra_input_region, cairo_region_destroy);
+  priv->extra_input_region = cairo_region_copy (region);
+  update_csd_shape (window);
+}
+
 static void
 corner_rect (cairo_rectangle_int_t *rect,
              const GtkCssValue     *value)
diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h
index 6e6f8a6881..5fc156f8f9 100644
--- a/gtk/gtkwindowprivate.h
+++ b/gtk/gtkwindowprivate.h
@@ -161,6 +161,9 @@ GtkWidget *      gtk_window_pick_popover (GtkWindow   *window,
                                           double       y,
                                           GtkPickFlags flags);
 
+void             gtk_window_set_extra_input_region (GtkWindow      *window,
+                                                    cairo_region_t *region);
+
 G_END_DECLS
 
 #endif /* __GTK_WINDOW_PRIVATE_H__ */


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