[gtk+] csd: Fix invisible border/shadow confusion



commit 5b341e8e6e2175917cc4d7c0f3fc43304cf51b0c
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Mar 12 00:15:02 2014 -0400

    csd: Fix invisible border/shadow confusion
    
    We did not set an input shape on the window, so the region outside
    the invisible border where we draw the outer edges of the shadow
    were still part of the window, as far as clicks and cursors were
    concerned. Fix this by setting an input shape that makes all clicks
    outside of the resize borders go through to the underlying window.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726125

 gtk/gtkwindow.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 56955e4..59d2a03 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6513,6 +6513,16 @@ max_borders (GtkBorder *one,
 }
 
 static void
+subtract_borders (GtkBorder *one,
+                  GtkBorder *two)
+{
+  one->top -= two->top;
+  one->right -= two->right;
+  one->bottom -= two->bottom;
+  one->left -= two->left;
+}
+
+static void
 add_window_frame_style_class (GtkStyleContext *context)
 {
   gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BACKGROUND);
@@ -6834,6 +6844,19 @@ update_border_windows (GtkWindow *window)
       gdk_window_hide (priv->border_window[GDK_WINDOW_EDGE_WEST]);
       gdk_window_hide (priv->border_window[GDK_WINDOW_EDGE_EAST]);
     }
+
+  /* we also update the input shape, which makes it so that clicks
+   * outside the border windows go through
+   */
+
+  subtract_borders (&window_border, &border);
+  rect.x = window_border.left;
+  rect.y = window_border.top;
+  rect.width = gtk_widget_get_allocated_width (widget) - window_border.left - window_border.right;
+  rect.height = gtk_widget_get_allocated_height (widget) - window_border.top - window_border.bottom;
+  region = cairo_region_create_rectangle (&rect);
+  gtk_widget_input_shape_combine_region (widget, region);
+  cairo_region_destroy (region);
 }
 
 static void


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