[gtk+] gdk: add gdk_window_set_shadow_width()



commit 04897e5b09baa33d73dccd76336d12516f2920e4
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Dec 12 22:38:12 2013 -0500

    gdk: add gdk_window_set_shadow_width()
    
    And deprecate the X11-specific version of it.
    
    We call this new API _set_shadow_width() and not _set_frame_extents()
    because we already have a gdk_window_get_frame_extents() with a
    different meaning and different type of value.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720374

 docs/reference/gdk/gdk3-sections.txt |    1 +
 gdk/gdkwindow.c                      |   39 ++++++++++++++++++++++++++++++
 gdk/gdkwindow.h                      |    7 +++++
 gdk/gdkwindowimpl.h                  |    5 ++++
 gdk/x11/gdkwindow-x11.c              |   44 +++++++++++++++++++--------------
 gdk/x11/gdkx11window.h               |    2 +-
 gtk/gtkwindow.c                      |   20 +++++++--------
 7 files changed, 87 insertions(+), 31 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index 8652973..c0962ff 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -450,6 +450,7 @@ gdk_window_set_modal_hint
 gdk_window_get_modal_hint
 gdk_window_set_type_hint
 gdk_window_get_type_hint
+gdk_window_set_shadow_width
 gdk_window_set_skip_taskbar_hint
 gdk_window_set_skip_pager_hint
 gdk_window_set_urgency_hint
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index a890e11..17a1125 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -10872,3 +10872,42 @@ gdk_window_set_opaque_region (GdkWindow      *window,
   if (impl_class->set_opaque_region)
     return impl_class->set_opaque_region (window, region);
 }
+
+/**
+ * gdk_window_set_shadow_width:
+ * @window: a #GdkWindow
+ * @left: The left extent
+ * @right: The right extent
+ * @top: The top extent
+ * @bottom: The bottom extent
+ *
+ * Newer GTK+ windows using client-side decorations use extra geometry
+ * around their frames for effects like shadows and invisible borders.
+ * Window managers that want to maximize windows or snap to edges need
+ * to know where the extents of the actual frame lie, so that users
+ * don't feel like windows are snapping against random invisible edges.
+ *
+ * Note that this property is automatically updated by GTK+, so this
+ * function should only be used by applications which do not use GTK+
+ * to create toplevel windows.
+ *
+ * Since: 3.12
+ */
+void
+gdk_window_set_shadow_width (GdkWindow *window,
+                             gint       left,
+                             gint       right,
+                             gint       top,
+                             gint       bottom)
+{
+  GdkWindowImplClass *impl_class;
+
+  g_return_if_fail (GDK_IS_WINDOW (window));
+  g_return_if_fail (!GDK_WINDOW_DESTROYED (window));
+  g_return_if_fail (left >= 0 && right >= 0 && top >= 0 && bottom >= 0);
+
+  impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
+
+  if (impl_class->set_shadow_width)
+    impl_class->set_shadow_width (window, left, right, top, bottom);
+}
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index 014f2f7..0d89782 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -1096,6 +1096,13 @@ void       gdk_window_set_event_compression    (GdkWindow      *window,
 GDK_AVAILABLE_IN_3_12
 gboolean   gdk_window_get_event_compression    (GdkWindow      *window);
 
+GDK_AVAILABLE_IN_3_12
+void       gdk_window_set_shadow_width         (GdkWindow      *window,
+                                                gint            left,
+                                                gint            right,
+                                                gint            top,
+                                                gint            bottom);
+
 G_END_DECLS
 
 #endif /* __GDK_WINDOW_H__ */
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index b0b43b9..ab04985 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -295,6 +295,11 @@ struct _GdkWindowImplClass
 
   void         (* set_opaque_region)      (GdkWindow      *window,
                                            cairo_region_t *region);
+  void         (* set_shadow_width)       (GdkWindow      *window,
+                                           gint            left,
+                                           gint            right,
+                                           gint            top,
+                                           gint            bottom);
 };
 
 /* Interface Functions */
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 5b51db3..63ecf14 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -3660,6 +3660,25 @@ gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window,
     }
 }
 
+static void
+gdk_x11_window_set_shadow_width (GdkWindow *window,
+                                 int        left,
+                                 int        right,
+                                 int        top,
+                                 int        bottom)
+{
+  Atom frame_extents;
+  gulong data[4] = { left, right, top, bottom };
+
+  frame_extents = gdk_x11_get_xatom_by_name_for_display (gdk_window_get_display (window),
+                                                         "_GTK_FRAME_EXTENTS");
+  XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+                   GDK_WINDOW_XID (window),
+                   frame_extents, XA_CARDINAL,
+                   32, PropModeReplace,
+                   (guchar *) &data, 4);
+}
+
 /**
  * gdk_x11_window_set_frame_extents:
  * @window: (type GdkX11Window): a #GdkWindow
@@ -3668,17 +3687,12 @@ gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window,
  * @top: The top extent
  * @bottom: The bottom extent
  *
- * Newer GTK+ windows using client-side decorations use extra geometry
- * around their frames for effects like shadows and invisible borders.
- * Window managers that want to maximize windows or snap to edges need
- * to know where the extents of the actual frame lie, so that users
- * don't feel like windows are snapping against random invisible edges.
- *
- * Note that this property is automatically updated by GTK+, so this
- * function should only be used by applications which do not use GTK+
- * to create toplevel windows.
+ * This is the same as gdk_window_set_shadow_width() but it only works
+ * on GdkX11Window.
  *
  * Since: 3.10
+ *
+ * Deprecated: 3.12: Use gdk_window_set_shadow_width() instead.
  */
 void
 gdk_x11_window_set_frame_extents (GdkWindow *window,
@@ -3687,16 +3701,7 @@ gdk_x11_window_set_frame_extents (GdkWindow *window,
                                   int        top,
                                   int        bottom)
 {
-  Atom frame_extents;
-  gulong data[4] = { left, right, top, bottom };
-
-  frame_extents = gdk_x11_get_xatom_by_name_for_display (gdk_window_get_display (window),
-                                                         "_GTK_FRAME_EXTENTS");
-  XChangeProperty (GDK_WINDOW_XDISPLAY (window),
-                   GDK_WINDOW_XID (window),
-                   frame_extents, XA_CARDINAL,
-                   32, PropModeReplace,
-                   (guchar *) &data, 4);
+  gdk_x11_window_set_shadow_width (window, left, right, top, bottom);
 }
 
 /**
@@ -5712,4 +5717,5 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
   impl_class->delete_property = _gdk_x11_window_delete_property;
   impl_class->get_scale_factor = gdk_x11_window_get_scale_factor;
   impl_class->set_opaque_region = gdk_x11_window_set_opaque_region;
+  impl_class->set_shadow_width = gdk_x11_window_set_shadow_width;
 }
diff --git a/gdk/x11/gdkx11window.h b/gdk/x11/gdkx11window.h
index 8e8290c..1943c34 100644
--- a/gdk/x11/gdkx11window.h
+++ b/gdk/x11/gdkx11window.h
@@ -65,7 +65,7 @@ void     gdk_x11_window_set_utf8_property    (GdkWindow *window,
 GDK_AVAILABLE_IN_3_2
 void     gdk_x11_window_set_theme_variant (GdkWindow   *window,
                                            char        *variant);
-GDK_AVAILABLE_IN_3_10
+GDK_DEPRECATED_IN_3_12_FOR(gdk_window_set_shadow_width)
 void     gdk_x11_window_set_frame_extents (GdkWindow *window,
                                            int        left,
                                            int        right,
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index e0dca5b..88b884c 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6422,21 +6422,19 @@ update_border_windows (GtkWindow *window)
 }
 
 static void
-update_frame_extents (GtkWindow *window,
-                      GtkBorder *border)
+update_shadow_width (GtkWindow *window,
+                     GtkBorder *border)
 {
-#ifdef GDK_WINDOWING_X11
   GdkWindow *gdk_window;
 
   gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
 
-  if (GDK_IS_X11_WINDOW (gdk_window))
-    gdk_x11_window_set_frame_extents (gdk_window,
-                                      border->left,
-                                      border->right,
-                                      border->top,
-                                      border->bottom);
-#endif
+  if (gdk_window)
+    gdk_window_set_shadow_width (gdk_window,
+                                 border->left,
+                                 border->right,
+                                 border->top,
+                                 border->bottom);
 }
 
 static void
@@ -6571,7 +6569,7 @@ _gtk_window_set_allocation (GtkWindow           *window,
   priv->title_height = 0;
 
   if (priv->client_decorated)
-    update_frame_extents (window, &window_border);
+    update_shadow_width (window, &window_border);
 
   update_opaque_region (window, &window_border, &child_allocation);
 


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