Ecore Pointer get root x,y position without ecore_x_window.
authorDeon 'PrinceAMD' Thomas <PrinceAMD.Elive@Gmail.com>
Thu, 18 Apr 2013 03:07:26 +0000 (12:07 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 18 Apr 2013 03:07:26 +0000 (12:07 +0900)
src/lib/ecore_x/Ecore_X.h
src/lib/ecore_x/xlib/ecore_x.c

index 16fc338..ddd21a2 100644 (file)
@@ -1927,6 +1927,7 @@ EAPI void             ecore_x_focus_reset(void);
 EAPI void             ecore_x_events_allow_all(void);
 EAPI void             ecore_x_pointer_last_xy_get(int *x, int *y);
 EAPI void             ecore_x_pointer_xy_get(Ecore_X_Window win, int *x, int *y);
+EAPI void             ecore_x_pointer_root_xy_get(int *x, int *y);
 
 /* ecore_x_region.c */
 EAPI Ecore_X_XRegion *ecore_x_xregion_new(void);
index 8f578d7..40d6c24 100644 (file)
@@ -2116,6 +2116,32 @@ ecore_x_pointer_xy_get(Ecore_X_Window win,
    if (y) *y = wy;
 }
 
+EAPI void
+ecore_x_pointer_root_xy_get(int *x, int *y)
+{
+   Ecore_X_Window *root;
+   Window rwin, cwin;
+   int rx, ry, wx, wy, ret;
+   int i, num;
+   unsigned int mask;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   root = ecore_x_window_root_list(&num);
+   for (i = 0; i < num; i++) 
+     {
+        ret = XQueryPointer(_ecore_x_disp, root[i], &rwin, &cwin,
+                            &rx, &ry, &wx, &wy, &mask);
+        if (ret) break;
+     }
+
+   if (!ret)
+     rx = ry = -1;
+
+   if (x) *x = rx;
+   if (y) *y = ry;
+   free(root);
+}
+
 /**
  * Retrieve the Visual ID from a given Visual.
  *