Enlightenment CVS committal

Author  : xcomputerman
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_x


Modified Files:
        Ecore_X.h ecore_x.c ecore_x_window.c 


Log Message:
Implement more functions prerequisite to Xdnd
- ecore_x_window_visible_get() <-- yeah, hard to believe it wasn't there
- ecore_x_server_grab/ungrab <-- that too
- ecore_x_window_at_xy_get()

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Ecore_X.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -3 -r1.39 -r1.40
--- Ecore_X.h   21 Feb 2004 21:44:48 -0000      1.39
+++ Ecore_X.h   29 Feb 2004 04:29:24 -0000      1.40
@@ -737,6 +737,8 @@
 int              ecore_x_window_depth_get(Ecore_X_Window win);
 void             ecore_x_window_cursor_show(Ecore_X_Window win, int show);
 void             ecore_x_window_defaults_set(Ecore_X_Window win);
+int              ecore_x_window_visible_get(Ecore_X_Window win);
+Ecore_X_Window   ecore_x_window_at_xy_get(int x, int y);
 
 Ecore_X_Atom     ecore_x_window_prop_any_type(void);
 void             ecore_x_window_prop_property_set(Ecore_X_Window win, Ecore_X_Atom 
type, Ecore_X_Atom format, int size, void *data, int number);
@@ -866,6 +868,10 @@
      ecore_x_keyboard_grab(Ecore_X_Window win);
    void
      ecore_x_keyboard_ungrab(void);
+   void
+     ecore_x_grab(void);
+   void
+     ecore_x_ungrab(void);
        
        
 #ifdef __cplusplus
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- ecore_x.c   21 Feb 2004 21:44:48 -0000      1.31
+++ ecore_x.c   29 Feb 2004 04:29:25 -0000      1.32
@@ -16,6 +16,7 @@
 static void (**_ecore_x_event_handlers) (XEvent * event) = NULL;
 
 static int _ecore_x_init_count = 0;
+static int _ecore_x_grab_count = 0;
 
 Display *_ecore_x_disp = NULL;
 double   _ecore_x_double_click_time = 0.25;
@@ -1161,12 +1162,34 @@
                        CurrentTime);
 }
 
-void
-ecore_x_keyboard_ungrab(void)
+void ecore_x_keyboard_ungrab(void)
 {
    XUngrabKeyboard(_ecore_x_disp, CurrentTime);   
 }
 
+void
+ecore_x_grab(void)
+{
+   _ecore_x_grab_count++;
+   
+   if (_ecore_x_grab_count == 1)
+      XGrabServer(_ecore_x_disp);
+}
+
+void
+ecore_x_ungrab(void)
+{
+   _ecore_x_grab_count--;
+   if (_ecore_x_grab_count < 0)
+      _ecore_x_grab_count = 0;
+
+   if (_ecore_x_grab_count == 0)
+   {
+      XUngrabServer(_ecore_x_disp);
+      XSync(_ecore_x_disp, False);
+   }
+}
+
 /*****************************************************************************/
 /*****************************************************************************/
 /*****************************************************************************/
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x_window.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- ecore_x_window.c    21 Feb 2004 21:44:48 -0000      1.14
+++ ecore_x_window.c    29 Feb 2004 04:29:25 -0000      1.15
@@ -444,3 +444,73 @@
        XDefineCursor(_ecore_x_disp, win, 0);   
      }
 }
+
+/**
+ * To be documented.
+ *
+ * FIXME: To be fixed.
+ */
+int
+ecore_x_window_visible_get(Ecore_X_Window win)
+{
+   XWindowAttributes attr;
+
+   return (XGetWindowAttributes(_ecore_x_disp, win, &attr) &&
+           (attr.map_state == IsViewable));
+}
+
+static Window
+_ecore_x_window_at_xy_get(Window base, int bx, int by, int x, int y)
+{
+   Window           *list = NULL;
+   Window            parent_win = 0, child = 0, root_win = 0;
+   int               i, wx, wy, ww, wh;
+   unsigned int      num;
+
+   if (!ecore_x_window_visible_get(base))
+      return 0;
+
+   ecore_x_window_geometry_get(base, &wx, &wy, &ww, &wh);
+   wx += bx;
+   wy += by;
+
+   if (!((x >= wx) && (y >= wy) && (x < (wx + ww)) && (y < (wy + wh))))
+      return 0;
+   
+   if (!XQueryTree(_ecore_x_disp, base, &root_win, &parent_win, &list, &num))
+      return base;
+
+   if (list)
+   {
+      for (i = num - 1;; --i)
+      {
+         if ((child = _ecore_x_window_at_xy_get(list[i], wx, wy, x, y)))
+         {
+            XFree(list);
+            return child;
+         }
+         if (!i)
+            break;
+      }
+      XFree(list);
+   }
+
+   return base;
+}
+
+Ecore_X_Window
+ecore_x_window_at_xy_get(int x, int y)
+{
+   Ecore_X_Window    win, root;
+   
+   /* FIXME: Proper function to determine current root/virtual root
+    * window missing here */
+   root = DefaultRootWindow(_ecore_x_disp);
+   
+   ecore_x_grab();
+   win = _ecore_x_window_at_xy_get(root, 0, 0, x, y);
+   ecore_x_ungrab();
+   
+   return win ? win : root;
+}
+




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to