[gtk+/wip/shadow-shape: 1/2] Add a function to set the shadow region of a window



commit ed59f37f411e3882105f9b806665f43105272a25
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jul 18 00:30:14 2013 -0400

    Add a function to set the shadow region of a window
    
    The shadow region is the 'outline' of the window that we expect
    the window manager to draw a shadow around (of course, window
    managers are free to not draw shadows). For X11, this sets the
    _MUTTER_SHADOW_SHAPE property on the window.

 gdk/gdkwindow.c         |   17 +++++++++++++++++
 gdk/gdkwindow.h         |    4 ++++
 gdk/gdkwindowimpl.h     |    3 +++
 gdk/x11/gdkwindow-x11.c |   33 +++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 40519a3..077b61f 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -10786,3 +10786,20 @@ gdk_window_get_scale_factor (GdkWindow *window)
 
   return 1;
 }
+
+void
+gdk_window_set_shadow_region (GdkWindow      *window,
+                              cairo_region_t *region)
+{
+  GdkWindowImplClass *impl_class;
+
+  g_return_if_fail (GDK_IS_WINDOW (window));
+
+  if (GDK_WINDOW_DESTROYED (window))
+    return;
+
+  impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
+
+  if (impl_class->set_shadow_region)
+    impl_class->set_shadow_region (window, region);
+}
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index eff7178..b4f41e4 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -1086,6 +1086,10 @@ gboolean   gdk_window_get_support_multidevice (GdkWindow *window);
 GDK_AVAILABLE_IN_3_8
 GdkFrameClock* gdk_window_get_frame_clock      (GdkWindow     *window);
 
+GDK_AVAILABLE_IN_3_10
+void           gdk_window_set_shadow_region     (GdkWindow      *window,
+                                                 cairo_region_t *region);
+
 G_END_DECLS
 
 #endif /* __GDK_WINDOW_H__ */
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index 97ac21c..bf4afa0 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -292,6 +292,9 @@ struct _GdkWindowImplClass
                                            GdkAtom         property);
 
   gint         (* get_scale_factor)       (GdkWindow      *window);
+
+  void         (* set_shadow_region)      (GdkWindow      *window,
+                                           cairo_region_t *region);
 };
 
 /* Interface Functions */
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 3fe545c..a71ba33 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -5444,6 +5444,38 @@ gdk_x11_window_get_scale_factor (GdkWindow *window)
 }
 
 static void
+gdk_x11_window_set_shadow_region (GdkWindow      *window,
+                                  cairo_region_t *region)
+{
+  Atom     xatom;
+  int num_rectangles, i;
+  gulong *data;
+  cairo_rectangle_int_t rectangle;
+
+  num_rectangles = cairo_region_num_rectangles (region);
+g_print ("region has %d rects\n", num_rectangles);
+  data = g_new (gulong, 4 * num_rectangles);
+  for (i = 0; i < num_rectangles; i++)
+    {
+      cairo_region_get_rectangle (region, i, &rectangle);
+      data[4*i] = rectangle.x;
+      data[4*i+1] = rectangle.y;
+      data[4*i+2] = rectangle.width;
+      data[4*i+3] = rectangle.height;
+      g_print ("%d %d %d %d\n", rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+    }
+
+  xatom = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+                                                 "_MUTTER_SHADOW_SHAPE");
+  XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+                   GDK_WINDOW_XID (window),
+                   xatom, XA_CARDINAL,
+                   32, PropModeReplace,
+                   (guchar *)data, 4 * num_rectangles);
+  g_free (data);
+}
+
+static void
 gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -5531,4 +5563,5 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
   impl_class->change_property = _gdk_x11_window_change_property;
   impl_class->delete_property = _gdk_x11_window_delete_property;
   impl_class->get_scale_factor = gdk_x11_window_get_scale_factor;
+  impl_class->set_shadow_region = gdk_x11_window_set_shadow_region;
 }


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