[gtk+/client-side-windows: 30/284] Move gdk_window_get_deskrelative_origin to the GdkWindowImpl and make the common code handle abs_x/y



commit ec5d176278c430b5616eb3496f0037df91804a52
Author: Alexander Larsson <alexl redhat com>
Date:   Sat Dec 6 22:43:01 2008 +0100

    Move gdk_window_get_deskrelative_origin to the GdkWindowImpl and make the common code handle abs_x/y
---
 gdk/gdk.symbols         |    2 +-
 gdk/gdkwindow.c         |   43 ++++++++++++++++++++++
 gdk/gdkwindowimpl.h     |    3 ++
 gdk/x11/gdkwindow-x11.c |   93 +++++++++++++++++------------------------------
 4 files changed, 81 insertions(+), 60 deletions(-)

diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 30c5376..b0d82eb 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -661,6 +661,7 @@ gdk_window_set_back_pixmap
 gdk_window_set_cursor
 gdk_window_get_geometry
 gdk_window_get_origin
+gdk_window_get_deskrelative_origin
 gdk_window_shape_combine_mask
 gdk_window_shape_combine_region
 gdk_window_set_child_shapes
@@ -734,7 +735,6 @@ gdk_window_lookup
 gdk_window_lookup_for_display
 #ifndef GDK_DISABLE_DEPRECATED
 gdk_window_set_hints
-gdk_window_get_deskrelative_origin
 #endif
 gdk_window_get_type_hint
 gdk_window_set_type_hint
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index ea5642f..5321ae0 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -5945,6 +5945,49 @@ gdk_window_get_origin (GdkWindow *window,
   return TRUE;
 }
 
+
+/**
+ * gdk_window_get_deskrelative_origin:
+ * @window: a toplevel #GdkWindow
+ * @x: return location for X coordinate
+ * @y: return location for Y coordinate
+ * 
+ * This gets the origin of a #GdkWindow relative to
+ * an Enlightenment-window-manager desktop. As long as you don't
+ * assume that the user's desktop/workspace covers the entire
+ * root window (i.e. you don't assume that the desktop begins
+ * at root window coordinate 0,0) this function is not necessary.
+ * It's deprecated for that reason.
+ * 
+ * Return value: not meaningful
+ **/
+gboolean
+gdk_window_get_deskrelative_origin (GdkWindow *window,
+				    gint      *x,
+				    gint      *y)
+{
+  GdkWindowObject *private;
+  gboolean return_val = FALSE;
+  gint tx = 0;
+  gint ty = 0;
+
+  g_return_if_fail (GDK_IS_WINDOW (window));
+
+  private = (GdkWindowObject *) window;
+  
+  if (!GDK_WINDOW_DESTROYED (window))
+    {
+      GDK_WINDOW_IMPL_GET_IFACE (private->impl)->get_deskrelative_origin (window, &tx, &ty);
+      
+      if (x)
+	*x = tx + private->abs_x;
+      if (y)
+	*y = ty + private->abs_y;
+    }
+  
+  return return_val;
+}
+
 /**
  * gdk_window_shape_combine_mask:
  * @window: a #GdkWindow
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index f9218b9..7ffd388 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -88,6 +88,9 @@ struct _GdkWindowImplIface
   gint         (* get_origin)           (GdkWindow       *window,
                                          gint            *x,
                                          gint            *y);
+  gint         (* get_deskrelative_origin) (GdkWindow       *window,
+                                         gint            *x,
+                                         gint            *y);
 
   void         (* shape_combine_mask)   (GdkWindow       *window,
                                          GdkBitmap       *mask,
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index dad4abc..a133655 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -2793,80 +2793,54 @@ gdk_window_x11_get_origin (GdkWindow *window,
   return return_val;
 }
 
-/**
- * gdk_window_get_deskrelative_origin:
- * @window: a toplevel #GdkWindow
- * @x: return location for X coordinate
- * @y: return location for Y coordinate
- * 
- * This gets the origin of a #GdkWindow relative to
- * an Enlightenment-window-manager desktop. As long as you don't
- * assume that the user's desktop/workspace covers the entire
- * root window (i.e. you don't assume that the desktop begins
- * at root window coordinate 0,0) this function is not necessary.
- * It's deprecated for that reason.
- * 
- * Return value: not meaningful
- **/
-gboolean
-gdk_window_get_deskrelative_origin (GdkWindow *window,
-				    gint      *x,
-				    gint      *y)
+static gboolean
+gdk_window_x11_get_deskrelative_origin (GdkWindow *window,
+					gint      *x,
+					gint      *y)
 {
   gboolean return_val = FALSE;
   gint num_children, format_return;
   Window win, *child, parent, root;
-  gint tx = 0;
-  gint ty = 0;
   Atom type_return;
   Atom atom;
   gulong number_return, bytes_after_return;
   guchar *data_return;
   
-  if (!GDK_WINDOW_DESTROYED (window) &&
-      WINDOW_IS_TOPLEVEL (window))
+  atom = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
+						"ENLIGHTENMENT_DESKTOP");
+  win = GDK_WINDOW_XID (window);
+  
+  while (XQueryTree (GDK_WINDOW_XDISPLAY (window), win, &root, &parent,
+		     &child, (unsigned int *)&num_children))
     {
-      atom = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window),
-						    "ENLIGHTENMENT_DESKTOP");
-      win = GDK_WINDOW_XID (window);
+      if ((child) && (num_children > 0))
+	XFree (child);
+      
+      if (!parent)
+	break;
+      else
+	win = parent;
+      
+      if (win == root)
+	break;
+      
+      data_return = NULL;
+      XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), win, atom, 0, 0,
+			  False, XA_CARDINAL, &type_return, &format_return,
+			  &number_return, &bytes_after_return, &data_return);
       
-      while (XQueryTree (GDK_WINDOW_XDISPLAY (window), win, &root, &parent,
-			 &child, (unsigned int *)&num_children))
+      if (type_return == XA_CARDINAL)
 	{
-	  if ((child) && (num_children > 0))
-	    XFree (child);
-	  
-	  if (!parent)
-	    break;
-	  else
-	    win = parent;
-	  
-	  if (win == root)
-	    break;
-	  
-	  data_return = NULL;
-	  XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), win, atom, 0, 0,
-			      False, XA_CARDINAL, &type_return, &format_return,
-			      &number_return, &bytes_after_return, &data_return);
-
-	  if (type_return == XA_CARDINAL)
-	    {
-	      XFree (data_return);
-              break;
-	    }
+	  XFree (data_return);
+	  break;
 	}
-      
-      return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
-					  GDK_WINDOW_XID (window),
-					  win,
-					  0, 0, &tx, &ty,
-					  &root);
-      if (x)
-	*x = tx;
-      if (y)
-	*y = ty;
     }
   
+  return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
+				      GDK_WINDOW_XID (window),
+				      win,
+				      0, 0, x, y,
+				      &root);
   
   return return_val;
 }
@@ -5959,6 +5933,7 @@ gdk_window_impl_iface_init (GdkWindowImplIface *iface)
   iface->set_cursor = gdk_window_x11_set_cursor;
   iface->get_geometry = gdk_window_x11_get_geometry;
   iface->get_origin = gdk_window_x11_get_origin;
+  iface->get_deskrelative_origin = gdk_window_x11_get_deskrelative_origin;
   iface->shape_combine_mask = gdk_window_x11_shape_combine_mask;
   iface->shape_combine_region = gdk_window_x11_shape_combine_region;
   iface->set_child_shapes = gdk_window_x11_set_child_shapes;



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