[gtk+/client-side-windows: 56/284] Add _gdk_windowing_window_get_shape



commit 062da50b9f5822a9fdd64791701eb3f5720c321d
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Dec 16 14:38:10 2008 +0100

    Add _gdk_windowing_window_get_shape
---
 gdk/gdkinternals.h      |    3 ++-
 gdk/gdkregion-generic.c |   26 ++++++++++++++++++++++++++
 gdk/gdkwindow.c         |    1 +
 gdk/x11/gdkwindow-x11.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 73 insertions(+), 1 deletions(-)

diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 65f426b..2766c8d 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -335,6 +335,7 @@ gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
 void     _gdk_windowing_window_get_offsets      (GdkWindow  *window,
 						 gint       *x_offset,
 						 gint       *y_offset);
+GdkRegion *_gdk_windowing_window_get_shape      (GdkWindow  *window);
 
 void       _gdk_windowing_get_pointer        (GdkDisplay       *display,
 					      GdkScreen       **screen,
@@ -521,7 +522,7 @@ GdkRegion *_gdk_window_calculate_full_clip_region    (GdkWindow     *window,
                                                       gint          *base_y_offset);
 gboolean    _gdk_window_has_impl (GdkWindow *window);
 GdkWindow * _gdk_window_get_impl_window (GdkWindow *window);
-
+GdkRegion  *_gdk_region_new_from_yxbanded_rects (GdkRectangle *rects, int n_rects);
 
 /*****************************
  * offscreen window routines *
diff --git a/gdk/gdkregion-generic.c b/gdk/gdkregion-generic.c
index f835ab7..19e03e4 100644
--- a/gdk/gdkregion-generic.c
+++ b/gdk/gdkregion-generic.c
@@ -96,6 +96,7 @@ static void miRegionOp   (GdkRegion       *newReg,
 			  overlapFunc      overlapFn,
 			  nonOverlapFunc   nonOverlap1Fn,
 			  nonOverlapFunc   nonOverlap2Fn);
+static void miSetExtents (GdkRegion       *pReg);
 
 /**
  * gdk_region_new:
@@ -122,6 +123,31 @@ gdk_region_new (void)
   return temp;
 }
 
+GdkRegion *
+_gdk_region_new_from_yxbanded_rects (GdkRectangle *rects,
+				     int num_rects)
+{
+  GdkRegion *temp;
+  int i;
+
+  temp = g_slice_new (GdkRegion);
+
+  temp->rects = g_new (GdkRegionBox, num_rects);
+  temp->size = num_rects;
+  temp->numRects = num_rects;
+  for (i = 0; i < num_rects; i++)
+    {
+      temp->rects[i].x1 = rects[i].x;
+      temp->rects[i].y1 = rects[i].y;
+      temp->rects[i].x2 = rects[i].x + rects[i].width;
+      temp->rects[i].y2 = rects[i].y + rects[i].height;
+    }
+  miSetExtents (temp);  
+  
+  return temp;
+}
+
+
 /**
  * gdk_region_rectangle:
  * @rectangle: a #GdkRectangle
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 843116b..9655e31 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -6650,6 +6650,7 @@ static gboolean
 point_in_window (GdkWindowObject *window,
 		 double x, double y)
 {
+  /* TODO: Input Shape */
   return
     x >= 0 &&  x < window->width &&
     y >= 0 && y < window->height;
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 6a51cf7..2b00d95 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -4757,6 +4757,50 @@ gdk_add_to_span (struct _gdk_span **s,
   return;
 }
 
+GdkRegion *
+_gdk_windowing_window_get_shape (GdkWindow *window)
+{
+  GdkRegion *shape;
+
+  shape = NULL;
+  
+#if defined(HAVE_SHAPE_EXT)
+  if (!GDK_WINDOW_DESTROYED (window) &&
+      gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
+    {
+      GdkRectangle *rl;
+      XRectangle *xrl;
+      gint rn, ord, i;
+      
+      xrl = XShapeGetRectangles (GDK_WINDOW_XDISPLAY (window),
+				 GDK_WINDOW_XID (window),
+				 ShapeBounding, &rn, &ord);
+      
+      if (ord != YXBanded)
+	{
+	  /* This really shouldn't happen with any xserver, as they
+	     generally convert regions to YXBanded internally */
+	  g_warning ("non YXBanded shape masks not supported");
+	  XFree (rl);
+	  return NULL;
+	}
+
+      rl = g_new (GdkRectangle, rn);
+      for (i = 0; i < rn; i++)
+	{
+	  rl[i].x = xrl[i].x;
+	  rl[i].y = xrl[i].y;
+	  rl[i].width = xrl[i].width;
+	  rl[i].height = xrl[i].height;
+	}
+      
+      shape = _gdk_region_new_from_yxbanded_rects (rl, rn);
+      g_free (rl);
+      XFree (rl);
+    }
+#endif
+}
+
 static void
 gdk_add_rectangles (Display           *disp,
 		    Window             win,



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