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()


SVN revision: 9152
This commit is contained in:
xcomputerman 2004-02-29 04:29:25 +00:00 committed by xcomputerman
parent b97f74f636
commit 9a7832dcdc
3 changed files with 101 additions and 2 deletions

View File

@ -737,6 +737,8 @@ int ecore_x_window_border_size_get(Ecore_X_Window win);
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 @@ void ecore_x_gc_del(Ecore_X_GC gc);
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

View File

@ -16,6 +16,7 @@ static int _ecore_x_event_handlers_num = 0;
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 @@ ecore_x_keyboard_grab(Ecore_X_Window win)
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);
}
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/

View File

@ -444,3 +444,73 @@ ecore_x_window_cursor_show(Ecore_X_Window win, int show)
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;
}