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);
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
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;
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);
+ }
+}
+
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
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;
+}
+