-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
-#include "Ecore.h"
#include "ecore_xcb_private.h"
-#include "Ecore_X_Atoms.h"
-
-
-static int ignore_num = 0;
-static Ecore_X_Window *ignore_list = NULL;
-
-static Ecore_X_Window _ecore_x_window_at_xy_get(Ecore_X_Window base,
- int16_t base_x,
- int16_t base_y,
- int16_t x,
- int16_t y,
- Ecore_X_Window *skip,
- int skip_num);
-
#ifdef ECORE_XCB_RENDER
-static Ecore_X_Window _ecore_x_window_argb_internal_new(Ecore_X_Window parent,
- int16_t x,
- int16_t y,
- uint16_t w,
- uint16_t h,
- uint8_t override_redirect,
- uint8_t save_under);
-#endif /* ECORE_XCB_RENDER */
+# include <xcb/render.h>
+#endif
+#ifdef ECORE_XCB_SHAPE
+# include <xcb/shape.h>
+#endif
+#ifdef ECORE_XCB_XPRINT
+#include <xcb/xprint.h>
+#endif
+
+/* local function prototypes */
+static Ecore_X_Window _ecore_xcb_window_argb_internal_new(Ecore_X_Window parent,
+ int x,
+ int y,
+ int w,
+ int h,
+ uint8_t override_redirect,
+ uint8_t save_under);
+static Ecore_X_Window _ecore_xcb_window_at_xy_get(Ecore_X_Window base,
+ int bx,
+ int by,
+ int x,
+ int y,
+ Ecore_X_Window *skip,
+ int skip_num);
+static int _ecore_xcb_window_modifiers_get(unsigned int state);
+static xcb_visualtype_t *_ecore_xcb_window_find_visual_by_id(xcb_visualid_t id);
+#ifdef ECORE_XCB_XPRINT
+static xcb_screen_t *_ecore_xcb_window_screen_of_display(int screen);
+#endif
+
+/* local variables */
+static int ignore_num = 0;
+static Ecore_X_Window *ignore_list = NULL;
+/* external variables */
+int _ecore_xcb_button_grabs_num = 0;
+int _ecore_xcb_key_grabs_num = 0;
+Ecore_X_Window *_ecore_xcb_button_grabs = NULL;
+Ecore_X_Window *_ecore_xcb_key_grabs = NULL;
+Eina_Bool (*_ecore_xcb_window_grab_replay_func)(void *data,
+ int type,
+ void *event);
+void *_ecore_xcb_window_grab_replay_data;
/**
* @defgroup Ecore_X_Window_Create_Group X Window Creation Functions
ecore_x_window_new(Ecore_X_Window parent,
int x,
int y,
- int width,
- int height)
-{
- uint32_t value_list[9];
- Ecore_X_Window window;
- xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
- uint32_t value_mask;
-
- if (parent == 0) parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
-
- value_mask =
- XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
- XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
- XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
-
- value_list[0] = XCB_NONE;
- value_list[1] = 0;
- value_list[2] = XCB_GRAVITY_NORTH_WEST;
- value_list[3] = XCB_GRAVITY_NORTH_WEST;
- value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
- value_list[5] = 0;
- value_list[6] = 0;
- value_list[7] =
- XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
- XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
- XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
- XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
- XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
- XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
- XCB_EVENT_MASK_COLOR_MAP_CHANGE;
- value_list[8] = XCB_EVENT_MASK_NO_EVENT;
-
- window = xcb_generate_id(_ecore_xcb_conn);
- xcb_create_window(_ecore_xcb_conn,
- XCB_WINDOW_CLASS_COPY_FROM_PARENT,
- window, parent, x, y, width, height, 0,
- XCB_WINDOW_CLASS_INPUT_OUTPUT,
- vis,
- value_mask,
- value_list);
-
- if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root) ecore_x_window_defaults_set(window);
- return window;
+ int w,
+ int h)
+{
+ Ecore_X_Window win;
+ uint32_t mask, mask_list[9];
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ if (parent == 0)
+ parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+
+ /* NB: Order here is very important due to xcb_cw_t enum */
+ mask = (XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
+ XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE |
+ XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK |
+ XCB_CW_DONT_PROPAGATE);
+
+ mask_list[0] = XCB_BACK_PIXMAP_NONE;
+ mask_list[1] = 0;
+ mask_list[2] = XCB_GRAVITY_NORTH_WEST;
+ mask_list[3] = XCB_GRAVITY_NORTH_WEST;
+ mask_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
+ mask_list[5] = 0;
+ mask_list[6] = 0;
+ mask_list[7] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
+ XCB_EVENT_MASK_BUTTON_PRESS |
+ XCB_EVENT_MASK_BUTTON_RELEASE |
+ XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
+ XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
+ XCB_EVENT_MASK_VISIBILITY_CHANGE |
+ XCB_EVENT_MASK_STRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_FOCUS_CHANGE |
+ XCB_EVENT_MASK_PROPERTY_CHANGE |
+ XCB_EVENT_MASK_COLOR_MAP_CHANGE);
+ mask_list[8] = XCB_EVENT_MASK_NO_EVENT;
+
+ win = xcb_generate_id(_ecore_xcb_conn);
+ xcb_create_window(_ecore_xcb_conn, XCB_COPY_FROM_PARENT,
+ win, parent, x, y, w, h, 0,
+ XCB_WINDOW_CLASS_INPUT_OUTPUT,
+ XCB_COPY_FROM_PARENT, mask, mask_list);
+
+ if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
+ ecore_x_window_defaults_set(win);
+
+ return win;
}
/**
ecore_x_window_override_new(Ecore_X_Window parent,
int x,
int y,
- int width,
- int height)
-{
- uint32_t value_list[9];
- Ecore_X_Window window;
- xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
- uint32_t value_mask;
-
- if (parent == 0) parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
-
- value_mask =
- XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
- XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
- XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
-
- value_list[0] = XCB_NONE;
- value_list[1] = 0;
- value_list[2] = XCB_GRAVITY_NORTH_WEST;
- value_list[3] = XCB_GRAVITY_NORTH_WEST;
- value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
- value_list[5] = 1;
- value_list[6] = 0;
- value_list[7] =
- XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
- XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
- XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
- XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
- XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
- XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
- XCB_EVENT_MASK_COLOR_MAP_CHANGE;
- value_list[8] = XCB_EVENT_MASK_NO_EVENT;
-
- window = xcb_generate_id(_ecore_xcb_conn);
- xcb_create_window(_ecore_xcb_conn,
- XCB_WINDOW_CLASS_COPY_FROM_PARENT,
- window, parent, x, y, width, height, 0,
- XCB_WINDOW_CLASS_INPUT_OUTPUT,
- vis,
- value_mask,
- value_list);
- return window;
+ int w,
+ int h)
+{
+ Ecore_X_Window win;
+ uint32_t mask, mask_list[9];
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ if (parent == 0)
+ parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+
+ /* NB: Order here is very important due to xcb_cw_t enum */
+ mask = (XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
+ XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE |
+ XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK |
+ XCB_CW_DONT_PROPAGATE);
+
+ mask_list[0] = XCB_BACK_PIXMAP_NONE;
+ mask_list[1] = 0;
+ mask_list[2] = XCB_GRAVITY_NORTH_WEST;
+ mask_list[3] = XCB_GRAVITY_NORTH_WEST;
+ mask_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
+ mask_list[5] = 1;
+ mask_list[6] = 0;
+ mask_list[7] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
+ XCB_EVENT_MASK_BUTTON_PRESS |
+ XCB_EVENT_MASK_BUTTON_RELEASE |
+ XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
+ XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
+ XCB_EVENT_MASK_VISIBILITY_CHANGE |
+ XCB_EVENT_MASK_STRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_FOCUS_CHANGE |
+ XCB_EVENT_MASK_PROPERTY_CHANGE |
+ XCB_EVENT_MASK_COLOR_MAP_CHANGE);
+ mask_list[8] = XCB_EVENT_MASK_NO_EVENT;
+
+ win = xcb_generate_id(_ecore_xcb_conn);
+ xcb_create_window(_ecore_xcb_conn, XCB_COPY_FROM_PARENT,
+ win, parent, x, y, w, h, 0,
+ XCB_WINDOW_CLASS_INPUT_OUTPUT,
+ XCB_COPY_FROM_PARENT, mask, mask_list);
+
+ return win;
}
/**
ecore_x_window_input_new(Ecore_X_Window parent,
int x,
int y,
- int width,
- int height)
-{
- uint32_t value_list[3];
- Ecore_X_Window window;
- xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
- uint32_t value_mask;
-
- if (parent == 0) parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
-
- value_mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
-
- value_list[0] = 1;
- value_list[1] =
- XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
- XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
- XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
- XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
- XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
- XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
- XCB_EVENT_MASK_COLOR_MAP_CHANGE;
- value_list[2] = XCB_EVENT_MASK_NO_EVENT;
-
- window = xcb_generate_id(_ecore_xcb_conn);
- xcb_create_window(_ecore_xcb_conn,
- XCB_WINDOW_CLASS_COPY_FROM_PARENT,
- window, parent, x, y, width, height, 0,
- XCB_WINDOW_CLASS_INPUT_OUTPUT,
- vis,
- value_mask,
- value_list);
+ int w,
+ int h)
+{
+ Ecore_X_Window win;
+ uint32_t mask, mask_list[3];
- if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
- {
- }
+ LOGFN(__FILE__, __LINE__, __FUNCTION__)
+ CHECK_XCB_CONN;
- return window;
+ if (parent == 0)
+ parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+
+ /* NB: Order here is very important due to xcb_cw_t enum */
+ mask = (XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK |
+ XCB_CW_DONT_PROPAGATE);
+
+ mask_list[0] = 1;
+ mask_list[1] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
+ XCB_EVENT_MASK_BUTTON_PRESS |
+ XCB_EVENT_MASK_BUTTON_RELEASE |
+ XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
+ XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
+ XCB_EVENT_MASK_VISIBILITY_CHANGE |
+ XCB_EVENT_MASK_STRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_FOCUS_CHANGE |
+ XCB_EVENT_MASK_PROPERTY_CHANGE |
+ XCB_EVENT_MASK_COLOR_MAP_CHANGE);
+ mask_list[2] = XCB_EVENT_MASK_NO_EVENT;
+
+ win = xcb_generate_id(_ecore_xcb_conn);
+ xcb_create_window(_ecore_xcb_conn, XCB_COPY_FROM_PARENT,
+ win, parent, x, y, w, h, 0,
+ XCB_WINDOW_CLASS_INPUT_ONLY,
+ XCB_COPY_FROM_PARENT, mask, mask_list);
+
+ return win;
}
/**
* window of the default display is used.
* @param x X position.
* @param y Y position.
- * @param width Width.
- * @param height Height.
- * @return The new window handle.
+ * @param w Width.
+ * @param h Height.
+ * @return The new window handle.
* @ingroup Ecore_X_Window_Create_Group
*/
EAPI Ecore_X_Window
ecore_x_window_manager_argb_new(Ecore_X_Window parent,
int x,
int y,
- int width,
- int height)
+ int w,
+ int h)
{
- Ecore_X_Window window = 0;
+ Ecore_X_Window win = 0;
-#ifdef ECORE_XCB_RENDER
- window = _ecore_x_window_argb_internal_new(parent,
- x, y, width, height,
- 1, 0);
-#endif /* ECORE_XCB_RENDER */
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
- return window;
+ win = _ecore_xcb_window_argb_internal_new(parent, x, y, w, h, 1, 0);
+
+ return win;
}
/**
* window of the default display is used.
* @param x X position.
* @param y Y position.
- * @param width Width.
- * @param height Height.
- * @return The new window handle.
+ * @param w Width.
+ * @param h Height.
+ * @return The new window handle.
* @ingroup Ecore_X_Window_Create_Group
*/
EAPI Ecore_X_Window
ecore_x_window_argb_new(Ecore_X_Window parent,
int x,
int y,
- int width,
- int height)
+ int w,
+ int h)
{
- Ecore_X_Window window = 0;
+ Ecore_X_Window win = 0;
-#ifdef ECORE_XCB_RENDER
- window = _ecore_x_window_argb_internal_new(parent,
- x, y, width, height,
- 0, 0);
-#endif /* ECORE_XCB_RENDER */
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
- return window;
+ win = _ecore_xcb_window_argb_internal_new(parent, x, y, w, h, 0, 0);
+
+ return win;
}
/**
* window of the default display is used.
* @param x X position.
* @param y Y position.
- * @param width Width.
- * @param height Height.
- * @return The new window handle.
+ * @param w Width.
+ * @param h Height.
+ * @return The new window handle.
* @ingroup Ecore_X_Window_Create_Group
*/
EAPI Ecore_X_Window
ecore_x_window_override_argb_new(Ecore_X_Window parent,
int x,
int y,
- int width,
- int height)
+ int w,
+ int h)
{
- Ecore_X_Window window = 0;
+ Ecore_X_Window win = 0;
-#ifdef ECORE_XCB_RENDER
- window = _ecore_x_window_argb_internal_new(parent,
- x, y, width, height,
- 1, 0);
-#endif /* ECORE_XCB_RENDER */
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
- return window;
+ win = _ecore_xcb_window_argb_internal_new(parent, x, y, w, h, 1, 0);
+
+ return win;
}
/**
/**
* Deletes the given window.
- * @param window The given window.
+ * @param win The given window.
* @ingroup Ecore_X_Window_Destroy_Group
*/
EAPI void
-ecore_x_window_del(Ecore_X_Window window)
+ecore_x_window_free(Ecore_X_Window win)
{
- /* sorry sir, deleting the root window doesn't sound like
- * a smart idea.
- */
- if (window)
- xcb_destroy_window(_ecore_xcb_conn, window);
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ if (win)
+ {
+ /* xcb_destroy_notify_event_t ev; */
+ /* Ecore_X_Window root; */
+
+ /* if (xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem == 1) */
+ /* root = ((xcb_screen_t *)_ecore_xcb_screen)->root; */
+ /* else */
+ /* { */
+ /* xcb_get_geometry_cookie_t cookie; */
+ /* xcb_get_geometry_reply_t *reply; */
+
+ /* cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win); */
+ /* reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL); */
+ /* if (!reply) return; */
+ /* root = reply->root; */
+ /* free(reply); */
+ /* } */
+
+ /* memset(&ev, 0, sizeof(xcb_destroy_notify_event_t)); */
+
+ /* ev.response_type = XCB_DESTROY_NOTIFY; */
+ /* ev.window = win; */
+ /* ev.event = root; */
+
+ /* xcb_send_event(_ecore_xcb_conn, 0, root, */
+ /* XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | */
+ /* XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, */
+ /* (const char *)&ev); */
+
+ xcb_destroy_window(_ecore_xcb_conn, win);
+// ecore_x_flush();
+ }
}
/**
* Sends a delete request to the given window.
- * @param window The given window.
+ * @param win The given window.
* @ingroup Ecore_X_Window_Destroy_Group
*/
EAPI void
-ecore_x_window_delete_request_send(Ecore_X_Window window)
+ecore_x_window_delete_request_send(Ecore_X_Window win)
{
- xcb_client_message_event_t ev;
-
- /* sorry sir, deleting the root window doesn't sound like
- * a smart idea.
- */
- if (window == 0)
- return;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
- ev.response_type = XCB_CLIENT_MESSAGE;
- ev.format = 32;
- ev.sequence = 0;
- ev.window = window;
- ev.type = ECORE_X_ATOM_WM_PROTOCOLS;
- ev.data.data32[0] = ECORE_X_ATOM_WM_DELETE_WINDOW;
- ev.data.data32[1] = XCB_CURRENT_TIME;
-
- xcb_send_event(_ecore_xcb_conn, 0, window,
- XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
+ if (!win) return;
+ ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS,
+ XCB_EVENT_MASK_NO_EVENT,
+ ECORE_X_ATOM_WM_DELETE_WINDOW,
+ XCB_CURRENT_TIME, 0, 0, 0);
}
-/**
- * @defgroup Ecore_X_Window_Configure_Group X Window Configure Functions
- *
- * Functions to configure X windows.
- */
-
-
-/**
- * Configures the given window with the given mask.
- * @param window The given window.
- * @param mask The given mask.
- * @param x The X coordinate of the window.
- * @param y The Y coordinate of the window.
- * @param width The width of the window.
- * @param height The height of the window.
- * @param border_width The border width of the window.
- * @param sibling The sibling window of the window.
- * @param stack_mode The stack mode of the window.
- * @ingroup Ecore_X_Window_Configure_Group
- */
EAPI void
-ecore_x_window_configure(Ecore_X_Window window,
+ecore_x_window_configure(Ecore_X_Window win,
Ecore_X_Window_Configure_Mask mask,
int x,
int y,
- int width,
- int height,
+ int w,
+ int h,
int border_width,
Ecore_X_Window sibling,
int stack_mode)
{
- uint32_t *value_list;
- uint32_t value_mask;
- int length = 0;
-
- if (!window)
- return;
-
- value_mask = mask;
- for ( ; value_mask; value_mask >>= 1)
- if (value_mask & 1)
- length++;
- value_list = (uint32_t *)malloc(sizeof(uint32_t) * length);
- if (!value_list)
- return;
-
- value_mask = mask;
- for ( ; value_mask; value_mask >>= 1, value_list++)
- if (value_mask & 1)
- {
- switch (value_mask) {
- case XCB_CONFIG_WINDOW_X:
- *value_list = x;
- break;
- case XCB_CONFIG_WINDOW_Y:
- *value_list = y;
- break;
- case XCB_CONFIG_WINDOW_WIDTH:
- *value_list = width;
- break;
- case XCB_CONFIG_WINDOW_HEIGHT:
- *value_list = height;
- break;
- case XCB_CONFIG_WINDOW_BORDER_WIDTH:
- *value_list = border_width;
- break;
- case XCB_CONFIG_WINDOW_SIBLING:
- *value_list = sibling;
- break;
- case XCB_CONFIG_WINDOW_STACK_MODE:
- *value_list = stack_mode;
- break;
- }
- }
+ uint16_t vmask = 0;
+ uint32_t vlist[7];
+ unsigned int i = 0;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ if (!win) return;
+
+ if (mask & XCB_CONFIG_WINDOW_X)
+ {
+ vmask |= XCB_CONFIG_WINDOW_X;
+ vlist[i++] = x;
+ }
+ if (mask & XCB_CONFIG_WINDOW_Y)
+ {
+ vmask |= XCB_CONFIG_WINDOW_Y;
+ vlist[i++] = y;
+ }
+ if (mask & XCB_CONFIG_WINDOW_WIDTH)
+ {
+ vmask |= XCB_CONFIG_WINDOW_WIDTH;
+ vlist[i++] = w;
+ }
+ if (mask & XCB_CONFIG_WINDOW_HEIGHT)
+ {
+ vmask |= XCB_CONFIG_WINDOW_HEIGHT;
+ vlist[i++] = h;
+ }
+ if (mask & XCB_CONFIG_WINDOW_BORDER_WIDTH)
+ {
+ vmask |= XCB_CONFIG_WINDOW_BORDER_WIDTH;
+ vlist[i++] = border_width;
+ }
+ if (mask & XCB_CONFIG_WINDOW_SIBLING)
+ {
+ vmask |= XCB_CONFIG_WINDOW_SIBLING;
+ vlist[i++] = sibling;
+ }
+ if (mask & XCB_CONFIG_WINDOW_STACK_MODE)
+ {
+ vmask |= XCB_CONFIG_WINDOW_STACK_MODE;
+ vlist[i++] = stack_mode;
+ }
- xcb_configure_window(_ecore_xcb_conn, window, mask, value_list);
- free(value_list);
+ xcb_configure_window(_ecore_xcb_conn, win, vmask,
+ (const uint32_t *)&vlist);
+// ecore_x_flush();
}
/**
+ * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
+ *
+ * Functions that change or retrieve the geometry of X windows.
+ */
+
+/**
* Moves a window to the position @p x, @p y.
*
* The position is relative to the upper left hand corner of the
* parent window.
*
- * @param window The window to move.
- * @param x X position.
- * @param y Y position.
- * @ingroup Ecore_X_Window_Configure_Group
+ * @param win The window to move.
+ * @param x X position.
+ * @param y Y position.
+ * @ingroup Ecore_X_Window_Geometry_Group
*/
EAPI void
-ecore_x_window_move(Ecore_X_Window window,
+ecore_x_window_move(Ecore_X_Window win,
int x,
int y)
{
- uint32_t value_list[2];
- uint32_t value_mask;
+ uint32_t list[2], mask;
- if (!window)
- return;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- value_mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
+ if (!win) return;
- value_list[0] = x;
- value_list[1] = y;
+ mask = (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y);
+ list[0] = x;
+ list[1] = y;
- xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
+ xcb_configure_window(_ecore_xcb_conn, win, mask,
+ (const uint32_t *)&list);
+// ecore_x_flush();
}
/**
* Resizes a window.
- * @param window The window to resize.
- * @param width New width of the window.
- * @param height New height of the window.
- * @ingroup Ecore_X_Window_Configure_Group
+ * @param win The window to resize.
+ * @param w New width of the window.
+ * @param h New height of the window.
+ * @ingroup Ecore_X_Window_Geometry_Group
*/
EAPI void
-ecore_x_window_resize(Ecore_X_Window window,
- int width,
- int height)
+ecore_x_window_resize(Ecore_X_Window win,
+ int w,
+ int h)
{
- uint32_t value_list[2];
- uint32_t value_mask;
+ uint32_t list[2], mask;
- if (!window)
- return;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- if (width < 1) width = 1;
- if (height < 1) height = 1;
+ if (!win) return;
+ if (w < 1) w = 1;
+ if (h < 1) h = 1;
- value_mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
+ mask = (XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT);
+ list[0] = w;
+ list[1] = h;
- value_list[0] = width;
- value_list[1] = height;
-
- xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
+ xcb_configure_window(_ecore_xcb_conn, win, mask,
+ (const uint32_t *)&list);
+// ecore_x_flush();
}
/**
* Moves and resizes a window.
- * @param window The window to move and resize.
- * @param x New X position of the window.
- * @param y New Y position of the window.
- * @param width New width of the window.
- * @param height New height of the window.
- * @ingroup Ecore_X_Window_Configure_Group
+ * @param win The window to move and resize.
+ * @param x New X position of the window.
+ * @param y New Y position of the window.
+ * @param w New width of the window.
+ * @param h New height of the window.
+ * @ingroup Ecore_X_Window_Geometry_Group
*/
EAPI void
-ecore_x_window_move_resize(Ecore_X_Window window,
+ecore_x_window_move_resize(Ecore_X_Window win,
int x,
int y,
- int width,
- int height)
+ int w,
+ int h)
{
- uint32_t value_list[4];
- uint32_t value_mask;
+ uint32_t list[4], mask;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- if (!window)
- return;
+ if (!win) return;
+ if (w < 1) w = 1;
+ if (h < 1) h = 1;
- if (width < 1) width = 1;
- if (height < 1) height = 1;
+ mask = (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
+ XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT);
+ list[0] = x;
+ list[1] = y;
+ list[2] = w;
+ list[3] = h;
- value_mask =
- XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
- XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
+ xcb_configure_window(_ecore_xcb_conn, win, mask,
+ (const uint32_t *)&list);
+// ecore_x_flush();
+}
- value_list[0] = x;
- value_list[1] = y;
- value_list[2] = width;
- value_list[3] = height;
+/**
+ * Retrieves the width of the border of the given window.
+ * @param win The given window.
+ * @return Width of the border of @p win.
+ * @ingroup Ecore_X_Window_Geometry_Group
+ */
+EAPI int
+ecore_x_window_border_width_get(Ecore_X_Window win)
+{
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
- xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
+ if (!win) return 0;
+ return ecore_x_drawable_border_width_get(win);
}
/**
* Sets the width of the border of the given window.
- * @param window The given window.
- * @param border_width The new border width.
- * @ingroup Ecore_X_Window_Configure_Group
+ * @param win The given window.
+ * @param width The new border width.
+ * @ingroup Ecore_X_Window_Geometry_Group
*/
EAPI void
-ecore_x_window_border_width_set(Ecore_X_Window window,
+ecore_x_window_border_width_set(Ecore_X_Window win,
int border_width)
{
- uint32_t value_list;
+ uint32_t list;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- /* doesn't make sense to call this on a root window */
- if (!window)
- return;
+ if (!win) return;
- value_list = border_width;
+ list = border_width;
- xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_BORDER_WIDTH, &value_list);
+ xcb_configure_window(_ecore_xcb_conn, win,
+ XCB_CONFIG_WINDOW_BORDER_WIDTH, &list);
+// ecore_x_flush();
}
/**
+ * @defgroup Ecore_X_Window_Z_Order_Group X Window Z Order Functions
+ *
+ * Functions that change the Z order of X windows.
+ */
+
+/**
* Raises the given window.
- * @param window The window to raise.
- * @ingroup Ecore_X_Window_Configure_Group
+ * @param win The window to raise.
+ * @ingroup Ecore_X_Window_Z_Order_Group
*/
EAPI void
-ecore_x_window_raise(Ecore_X_Window window)
+ecore_x_window_raise(Ecore_X_Window win)
{
- uint32_t value_list;
+ uint32_t list[] = { XCB_STACK_MODE_ABOVE };
- if (!window)
- return;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- value_list = XCB_STACK_MODE_ABOVE;
-
- xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_STACK_MODE, &value_list);
+ xcb_configure_window(_ecore_xcb_conn, win,
+ XCB_CONFIG_WINDOW_STACK_MODE, list);
+// ecore_x_flush();
}
/**
* Lowers the given window.
- * @param window The window to lower.
- * @ingroup Ecore_X_Window_Configure_Group
+ * @param win The window to lower.
+ * @ingroup Ecore_X_Window_Z_Order_Group
*/
EAPI void
-ecore_x_window_lower(Ecore_X_Window window)
+ecore_x_window_lower(Ecore_X_Window win)
{
- uint32_t value_list;
+ uint32_t list[] = { XCB_STACK_MODE_BELOW };
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- if (!window)
- return;
+ xcb_configure_window(_ecore_xcb_conn, win,
+ XCB_CONFIG_WINDOW_STACK_MODE, list);
+// ecore_x_flush();
+}
- value_list = XCB_STACK_MODE_BELOW;
+/**
+ * Retrieves the depth of the given window.
+ * @param win The given window.
+ * @return Depth of the window.
+ */
+EAPI int
+ecore_x_window_depth_get(Ecore_X_Window win)
+{
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
- xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_STACK_MODE, &value_list);
+ return ecore_x_drawable_depth_get(win);
}
/**
- * @defgroup Evas_X_Window_Change_Properties_Group X Window Change Property Functions
+ * @defgroup Ecore_X_Window_Properties_Group X Window Property Functions
*
- * Functions that change window properties.
+ * Functions that set window properties.
*/
/**
* The default properties set for the window are @c WM_CLIENT_MACHINE and
* @c _NET_WM_PID.
*
- * @param window The given window.
- * @ingroup Ecore_X_Window_Change_Property_Group
+ * @param win The given window.
+ * @ingroup Ecore_X_Window_Properties_Group
*/
EAPI void
-ecore_x_window_defaults_set(Ecore_X_Window window)
-{
- char buf[MAXHOSTNAMELEN];
- pid_t pid;
- int argc;
- char **argv;
-
- /*
- * Set WM_CLIENT_MACHINE.
- */
- gethostname(buf, MAXHOSTNAMELEN);
- buf[MAXHOSTNAMELEN - 1] = '\0';
- /* The ecore function uses UTF8 which Xlib may not like (especially
- * with older clients) */
- /* ecore_xcb_window_prop_string_set(win, ECORE_X_ATOM_WM_CLIENT_MACHINE,
- (char *)buf); */
- xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
- ECORE_X_ATOM_WM_CLIENT_MACHINE,
- ECORE_X_ATOM_STRING,
- 8, strlen(buf), buf);
-
- /*
- * Set _NET_WM_PID
- */
- pid = getpid();
- ecore_x_netwm_pid_set(window, pid);
+ecore_x_window_defaults_set(Ecore_X_Window win)
+{
+ char buff[MAXHOSTNAMELEN], **argv;
+ int argc;
+ pid_t pid;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- ecore_x_netwm_window_type_set(window, ECORE_X_WINDOW_TYPE_NORMAL);
+ gethostname(buff, MAXHOSTNAMELEN);
+ buff[MAXHOSTNAMELEN - 1] = '\0';
+ xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win,
+ ECORE_X_ATOM_WM_CLIENT_MACHINE, ECORE_X_ATOM_STRING,
+ 8, strlen(buff), buff);
+
+ pid = getpid();
+ ecore_x_netwm_pid_set(win, pid);
+ ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL);
ecore_app_args_get(&argc, &argv);
- ecore_x_icccm_command_set(window, argc, argv);
+ ecore_x_icccm_command_set(win, argc, argv);
}
/**
* @defgroup Ecore_X_Window_Visibility_Group X Window Visibility Functions
*
- * Functions to change the visibility of X windows.
+ * Functions to access and change the visibility of X windows.
*/
/**
*
* Synonymous to "mapping" a window in X Window System terminology.
*
- * @param window The window to show.
- * @ingroup Ecore_X_Window_Visibility_Group
+ * @param win The window to show.
+ * @ingroup Ecore_X_Window_Visibility
*/
EAPI void
-ecore_x_window_show(Ecore_X_Window window)
+ecore_x_window_show(Ecore_X_Window win)
{
- xcb_map_window(_ecore_xcb_conn, window);
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ if (win)
+ xcb_map_window(_ecore_xcb_conn, win);
}
/**
*
* Synonymous to "unmapping" a window in X Window System terminology.
*
- * @param window The window to hide.
- * @ingroup Ecore_X_Window_Visibility_Group
+ * @param win The window to hide.
+ * @ingroup Ecore_X_Window_Visibility
*/
EAPI void
-ecore_x_window_hide(Ecore_X_Window window)
+ecore_x_window_hide(Ecore_X_Window win)
{
- xcb_unmap_notify_event_t ev;
- Ecore_X_Window root;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- /* ICCCM: SEND unmap event... */
- root = window;
- /* FIXME: is it correct ? */
- if (xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem == 1)
- root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
- else
+ if (win)
{
- xcb_get_geometry_cookie_t cookie;
- xcb_get_geometry_reply_t *rep;
- Ecore_X_Drawable draw;
-
- /* FIXME: can we avoid round trips, here ? */
- draw = window;
- cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, draw);
- rep = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
- if (!rep)
- return;
- root = rep->root;
- free(rep);
- }
- ev.response_type = XCB_UNMAP_NOTIFY;
- ev.pad0 = 0;
- ev.sequence = 0;
- ev.event = root;
- ev.window = window;
- ev.from_configure = 0;
+ xcb_unmap_notify_event_t ev;
+ Ecore_X_Window root;
+
+ if (xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem == 1)
+ root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+ else
+ {
+ xcb_get_geometry_cookie_t cookie;
+ xcb_get_geometry_reply_t *reply;
+
+ cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win);
+ reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
+ if (!reply) return;
+ root = reply->root;
+ free(reply);
+ }
+
+ memset(&ev, 0, sizeof(xcb_unmap_notify_event_t));
+
+ ev.response_type = XCB_UNMAP_NOTIFY;
+ ev.window = win;
+ ev.event = root;
+ ev.from_configure = 0;
- xcb_send_event(_ecore_xcb_conn, 0, root,
- XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
- (const char *)&ev);
- xcb_unmap_window(_ecore_xcb_conn, window);
+ xcb_send_event(_ecore_xcb_conn, 0, root,
+ (XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT),
+ (const char *)&ev);
+
+ xcb_unmap_window(_ecore_xcb_conn, win);
+// ecore_x_flush();
+ }
}
/**
- * @defgroup Ecore_X_Window_Input_Focus_Group X Window Input Focus Functions
+ * @defgroup Ecore_X_Window_Focus_Functions X Window Focus Functions
*
- * Functions that manage the focus of an X Window.
+ * Functions that give the focus to an X Window.
*/
/**
- * Sets the focus to the window @p window.
- * @param window The window to focus.
- * @ingroup Ecore_X_Window_Input_Focus_Group
+ * Sets the focus to the window @p win.
+ * @param win The window to focus.
+ * @ingroup Ecore_X_Window_Focus_Functions
*/
EAPI void
-ecore_x_window_focus(Ecore_X_Window window)
+ecore_x_window_focus(Ecore_X_Window win)
{
- Ecore_X_Time time = XCB_CURRENT_TIME;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- if (window == 0) window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+ if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
- /* xcb_set_input_focus(_ecore_xcb_conn, XCB_INPUT_FOCUS_NONE, win, time); */
xcb_set_input_focus(_ecore_xcb_conn,
- XCB_INPUT_FOCUS_POINTER_ROOT, window, time);
+ XCB_INPUT_FOCUS_PARENT, win, XCB_CURRENT_TIME);
+// ecore_x_flush();
}
/**
* Sets the focus to the given window at a specific time.
- * @param window The window to focus.
- * @param time When to set the focus to the window.
- * @ingroup Ecore_X_Window_Input_Focus_Group
+ * @param win The window to focus.
+ * @param t When to set the focus to the window.
+ * @ingroup Ecore_X_Window_Focus_Functions
*/
EAPI void
-ecore_x_window_focus_at_time(Ecore_X_Window window,
- Ecore_X_Time time)
+ecore_x_window_focus_at_time(Ecore_X_Window win,
+ Ecore_X_Time time __UNUSED__)
{
- if (window == 0) window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- /* xcb_set_input_focus(_ecore_xcb_conn, XCB_INPUT_FOCUS_NONE, win, time); */
- xcb_set_input_focus(_ecore_xcb_conn,
- XCB_INPUT_FOCUS_POINTER_ROOT, window, time);
+ if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+ xcb_set_input_focus(_ecore_xcb_conn,
+ XCB_INPUT_FOCUS_PARENT, win, XCB_CURRENT_TIME);
+// ecore_x_flush();
}
/**
- * @defgroup Ecore_X_Window_Reparent_Group X Window Reparent Functions
+ * @defgroup Ecore_X_Window_Parent_Group X Window Parent Functions
*
* Functions that retrieve or changes the parent window of a window.
*/
/**
* Moves a window to within another window at a given position.
- * @param window The window to reparent.
+ * @param win The window to reparent.
* @param new_parent The new parent window.
* @param x X position within new parent window.
* @param y Y position within new parent window.
- * @ingroup Ecore_X_Window_Reparent_Group
+ * @ingroup Ecore_X_Window_Parent_Group
*/
EAPI void
-ecore_x_window_reparent(Ecore_X_Window window,
- Ecore_X_Window new_parent,
+ecore_x_window_reparent(Ecore_X_Window win,
+ Ecore_X_Window parent,
int x,
int y)
{
- if (new_parent == 0) new_parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
-
- xcb_reparent_window(_ecore_xcb_conn, window, new_parent, x, y);
-}
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+ if (parent == 0)
+ parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
-/**
- * @defgroup Ecore_X_Window_Change_Attributes_Group X Window Change Attributes Functions
- *
- * Functions that change the attributes of a window.
- */
+ xcb_reparent_window(_ecore_xcb_conn, win, parent, x, y);
+// ecore_x_flush();
+}
-/**
- * Sets the background pixmap of the given window.
- * @param window The given window.
- * @param pixmap The pixmap to set to.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
- */
EAPI void
-ecore_x_window_pixmap_set(Ecore_X_Window window,
+ecore_x_window_pixmap_set(Ecore_X_Window win,
Ecore_X_Pixmap pixmap)
{
- uint32_t value_list;
+ uint32_t list;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- value_list = pixmap;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_BACK_PIXMAP, &value_list);
+ list = pixmap;
+
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_BACK_PIXMAP, &list);
+// ecore_x_flush();
}
/**
* Sets the background color of the given window.
- * @param window The given window.
- * @param red The red component of the color to set to.
- * @param green The green component of the color to set to.
- * @param blue The blue component of the color to set to.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
+ * @param win The given window
+ * @param r red value (0...65536, 16 bits)
+ * @param g green value (0...65536, 16 bits)
+ * @param b blue value (0...65536, 16 bits)
*/
EAPI void
-ecore_x_window_background_color_set(Ecore_X_Window window,
+ecore_x_window_background_color_set(Ecore_X_Window win,
unsigned short red,
unsigned short green,
unsigned short blue)
{
xcb_alloc_color_cookie_t cookie;
- xcb_alloc_color_reply_t *rep;
- uint32_t value_list;
-
- /* FIXME: should I provide a reply, and not the color components, here ? */
- /* (because of roundtrips) */
- cookie = xcb_alloc_color_unchecked(_ecore_xcb_conn,
- ((xcb_screen_t *)_ecore_xcb_screen)->default_colormap,
- red, green, blue);
- rep = xcb_alloc_color_reply(_ecore_xcb_conn, cookie, NULL);
- if (!rep)
- return;
-
- value_list = rep->pixel;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_BACK_PIXEL, &value_list);
- free(rep);
+ xcb_alloc_color_reply_t *reply;
+ uint32_t list;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ cookie =
+ xcb_alloc_color_unchecked(_ecore_xcb_conn,
+ ((xcb_screen_t *)_ecore_xcb_screen)->default_colormap,
+ red, green, blue);
+ reply = xcb_alloc_color_reply(_ecore_xcb_conn, cookie, NULL);
+ if (!reply) return;
+ list = reply->pixel;
+ free(reply);
+
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_BACK_PIXEL, &list);
+// ecore_x_flush();
}
-/**
- * Sets the bit gravity of the given window.
- * @param window The given window.
- * @param gravity The gravity.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
- */
EAPI void
-ecore_x_window_pixel_gravity_set(Ecore_X_Window window,
+ecore_x_window_pixel_gravity_set(Ecore_X_Window win,
Ecore_X_Gravity gravity)
{
- uint32_t value_list;
+ uint32_t list;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- value_list = gravity;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_BIT_GRAVITY, &value_list);
+ list = gravity;
+
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_BIT_GRAVITY, &list);
+// ecore_x_flush();
}
-/**
- * Sets the gravity of the given window.
- * @param window The given window.
- * @param gravity The gravity.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
- */
EAPI void
-ecore_x_window_gravity_set(Ecore_X_Window window,
+ecore_x_window_gravity_set(Ecore_X_Window win,
Ecore_X_Gravity gravity)
{
- uint32_t value_list;
+ uint32_t list;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- value_list = gravity;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_WIN_GRAVITY, &value_list);
+ list = gravity;
+
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_WIN_GRAVITY, &list);
+// ecore_x_flush();
}
-/**
- * Sets the override attribute of the given window.
- * @param window The given window.
- * @param override_redirect The override_redirect boolean.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
- */
EAPI void
-ecore_x_window_override_set(Ecore_X_Window window,
- int override_redirect)
+ecore_x_window_override_set(Ecore_X_Window win,
+ Eina_Bool override)
{
- uint32_t value_list;
+ uint32_t list;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- value_list = override_redirect;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_OVERRIDE_REDIRECT, &value_list);
+ list = override;
+
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_OVERRIDE_REDIRECT, &list);
+// ecore_x_flush();
}
/**
- * Shows the cursor of the given window.
- * @param window The given window.
- * @param show If set to @c 0, hide the cursor. Show it otherwise.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
+ * @brief Show the cursor on a window of type Ecore_X_Window.
+ * @param win The window for which the cursor will be showed.
+ * @param show Enables the show of the cursor on the window if equals EINA_TRUE, disables if equals EINA_FALSE.
*/
EAPI void
-ecore_x_window_cursor_show(Ecore_X_Window window,
- int show)
+ecore_x_window_cursor_show(Ecore_X_Window win,
+ Eina_Bool show)
{
- if (window == 0) window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+ uint32_t list = 0;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
if (!show)
{
- Ecore_X_Cursor cursor;
- Ecore_X_Drawable draw;
- Ecore_X_Pixmap pixmap;
- Ecore_X_Pixmap mask;
- Ecore_X_GC gc;
- xcb_point_t point;
- uint32_t value_list;
-
- draw = window;
- pixmap = xcb_generate_id(_ecore_xcb_conn);
- xcb_create_pixmap(_ecore_xcb_conn,
- 1, pixmap, draw,
- 1, 1);
- mask = xcb_generate_id(_ecore_xcb_conn);
- xcb_create_pixmap(_ecore_xcb_conn,
- 1, mask, draw,
- 1, 1);
-
+ Ecore_X_Cursor cursor;
+ Ecore_X_Pixmap p, m;
+ Ecore_X_GC gc;
+ xcb_point_t point;
+
+ p = xcb_generate_id(_ecore_xcb_conn);
+ xcb_create_pixmap(_ecore_xcb_conn, 1, p, win, 1, 1);
+ m = xcb_generate_id(_ecore_xcb_conn);
+ xcb_create_pixmap(_ecore_xcb_conn, 1, m, win, 1, 1);
gc = xcb_generate_id(_ecore_xcb_conn);
- xcb_create_gc (_ecore_xcb_conn, gc, draw, 0, NULL);
- value_list = 0;
- xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_FOREGROUND, &value_list);
-
- draw = mask;
+ xcb_create_gc(_ecore_xcb_conn, gc, win, 0, NULL);
+ xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_FOREGROUND, &list);
point.x = 0;
point.y = 0;
- xcb_poly_point(_ecore_xcb_conn, XCB_COORD_MODE_ORIGIN, draw,
- gc, 1, &point);
-
+ xcb_poly_point(_ecore_xcb_conn, XCB_COORD_MODE_ORIGIN,
+ win, gc, 1, &point);
xcb_free_gc(_ecore_xcb_conn, gc);
cursor = xcb_generate_id(_ecore_xcb_conn);
xcb_create_cursor(_ecore_xcb_conn, cursor,
- pixmap, mask,
- 0, 0, 0,
- 0, 0, 0,
- 0, 0);
- value_list = cursor;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_CURSOR, &value_list);
+ p, m, 0, 0, 0, 0, 0, 0, 0, 0);
+ list = cursor;
+
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_CURSOR, &list);
xcb_free_cursor(_ecore_xcb_conn, cursor);
- xcb_free_pixmap(_ecore_xcb_conn, mask);
- xcb_free_pixmap(_ecore_xcb_conn, pixmap);
+ xcb_free_pixmap(_ecore_xcb_conn, m);
+ xcb_free_pixmap(_ecore_xcb_conn, p);
}
else
{
- uint32_t value_list;
-
- value_list = 0;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_CURSOR, &value_list);
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_CURSOR, &list);
}
+// ecore_x_flush();
}
-/**
- * Sets the cursor of the given window.
- * @param window The given window.
- * @param cursor The given cursor.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
- */
EAPI void
-ecore_x_window_cursor_set(Ecore_X_Window window,
+ecore_x_window_cursor_set(Ecore_X_Window win,
Ecore_X_Cursor cursor)
{
- uint32_t value_list;
+ uint32_t list;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ list = cursor;
- value_list = cursor;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_CURSOR, &value_list);
+ xcb_change_window_attributes(_ecore_xcb_conn, win, XCB_CW_CURSOR, &list);
+// ecore_x_flush();
}
-/**
- * Todo
- * @param window The given window.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
- */
EAPI void
-ecore_x_window_container_manage(Ecore_X_Window window)
+ecore_x_window_container_manage(Ecore_X_Window win)
{
- uint32_t value_list;
+ uint32_t list;
- value_list =
- XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
- XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_EVENT_MASK, &value_list);
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+ list = (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
+ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);
+
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_EVENT_MASK, &list);
+// ecore_x_flush();
}
-/**
- * Todo
- * @param window The given window.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
- */
EAPI void
-ecore_x_window_client_manage(Ecore_X_Window window)
-{
- uint32_t value_list;
-
- value_list =
- XCB_EVENT_MASK_VISIBILITY_CHANGE |
-/* XCB_EVENT_MASK_RESIZE_REDIRECT | */
- XCB_EVENT_MASK_STRUCTURE_NOTIFY |
- XCB_EVENT_MASK_FOCUS_CHANGE |
- XCB_EVENT_MASK_PROPERTY_CHANGE |
- XCB_EVENT_MASK_COLOR_MAP_CHANGE;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_EVENT_MASK, &value_list);
+ecore_x_window_client_manage(Ecore_X_Window win)
+{
+ uint32_t list;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ list = (XCB_EVENT_MASK_VISIBILITY_CHANGE |
+ XCB_EVENT_MASK_FOCUS_CHANGE |
+ XCB_EVENT_MASK_PROPERTY_CHANGE |
+ XCB_EVENT_MASK_COLOR_MAP_CHANGE |
+ XCB_EVENT_MASK_STRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);
+
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_EVENT_MASK, &list);
+
#ifdef ECORE_XCB_SHAPE
- xcb_shape_select_input(_ecore_xcb_conn, window, 1);
-#endif /* ECORE_XCB_SHAPE */
+ xcb_shape_select_input(_ecore_xcb_conn, win, EINA_TRUE);
+#endif
+// ecore_x_flush();
}
-/**
- * Todo
- * @param window The given window.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
- */
EAPI void
-ecore_x_window_sniff(Ecore_X_Window window)
+ecore_x_window_sniff(Ecore_X_Window win)
{
- uint32_t value_list;
+ uint32_t list;
- value_list =
- XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
- XCB_EVENT_MASK_PROPERTY_CHANGE;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_EVENT_MASK, &value_list);
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ list = (XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_PROPERTY_CHANGE);
+
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_EVENT_MASK, &list);
+// ecore_x_flush();
}
-/**
- * Todo
- * @param window The given window.
- * @ingroup Ecore_X_Window_Change_Attributes_Group
- */
EAPI void
-ecore_x_window_client_sniff(Ecore_X_Window window)
-{
- uint32_t value_list;
-
- value_list =
- XCB_EVENT_MASK_VISIBILITY_CHANGE |
- XCB_EVENT_MASK_STRUCTURE_NOTIFY |
- XCB_EVENT_MASK_FOCUS_CHANGE |
- XCB_EVENT_MASK_PROPERTY_CHANGE |
- XCB_EVENT_MASK_COLOR_MAP_CHANGE;
- xcb_change_window_attributes(_ecore_xcb_conn, window,
- XCB_CW_EVENT_MASK, &value_list);
+ecore_x_window_client_sniff(Ecore_X_Window win)
+{
+ uint32_t list;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ list = (XCB_EVENT_MASK_VISIBILITY_CHANGE |
+ XCB_EVENT_MASK_STRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_FOCUS_CHANGE |
+ XCB_EVENT_MASK_PROPERTY_CHANGE |
+ XCB_EVENT_MASK_COLOR_MAP_CHANGE);
+
+ xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_EVENT_MASK, &list);
#ifdef ECORE_XCB_SHAPE
- xcb_shape_select_input(_ecore_xcb_conn, window, 1);
-#endif /* ECORE_XCB_SHAPE */
+ xcb_shape_select_input(_ecore_xcb_conn, win, EINA_TRUE);
+#endif
+// ecore_x_flush();
}
-/**
- * Clears an area of the given window.
- * @param window The given window.
- * @param x The X coordinate of the area.
- * @param y The Y coordinate of the area.
- * @param width The width of the area.
- * @param height The height of the area.
- * @ingroup Ecore_X_Window_Clear_Area_Group
- */
EAPI void
-ecore_x_window_area_clear(Ecore_X_Window window,
+ecore_x_window_area_clear(Ecore_X_Window win,
int x,
int y,
- int width,
- int height)
+ int w,
+ int h)
{
- xcb_clear_area(_ecore_xcb_conn, 0, window, x, y, width, height);
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ xcb_clear_area(_ecore_xcb_conn, 0, win, x, y, w, h);
+// ecore_x_flush();
}
-/**
- * Exposes an area of the given window.
- * @param window The given window.
- * @param x The X coordinate of the area.
- * @param y The Y coordinate of the area.
- * @param width The width of the area.
- * @param height The height of the area.
- * @ingroup Ecore_X_Window_Clear_Area_Group
- */
EAPI void
-ecore_x_window_area_expose(Ecore_X_Window window,
+ecore_x_window_area_expose(Ecore_X_Window win,
int x,
int y,
- int width,
- int height)
+ int w,
+ int h)
{
- xcb_clear_area(_ecore_xcb_conn, 1, window, x, y, width, height);
-}
-
-
-/**
- * @defgroup Ecore_X_Window_Save_Set_Group X Window Change Save Set Functions
- *
- * Functions that either inserts or deletes the specified window from
- * the client's save-set.
- */
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
-/**
- * Inserts the window in the client's save-set.
- * @param window The window to insert in the client's save-set.
- * @ingroup Ecore_X_Window_Save_Set_Group
- */
-EAPI void
-ecore_x_window_save_set_add(Ecore_X_Window window)
-{
- xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_INSERT, window);
+ xcb_clear_area(_ecore_xcb_conn, 1, win, x, y, w, h);
+// ecore_x_flush();
}
-/**
- * Deletes the window from the client's save-set.
- * @param window The window to delete from the client's save-set.
- * @ingroup Ecore_X_Window_Save_Set_Group
- */
EAPI void
-ecore_x_window_save_set_del(Ecore_X_Window window)
+ecore_x_window_save_set_add(Ecore_X_Window win)
{
- xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_DELETE, window);
-}
-
-/******************************
- *
- * Request that have a reply
- *
- ******************************/
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+ xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_INSERT, win);
+}
-/**
- * Sends the GetInputFocus request.
- * @ingroup Ecore_X_Window_Input_Focus_Group
- */
EAPI void
-ecore_x_get_input_focus_prefetch(void)
+ecore_x_window_save_set_del(Ecore_X_Window win)
{
- xcb_get_input_focus_cookie_t cookie;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- cookie = xcb_get_input_focus_unchecked(_ecore_xcb_conn);
- _ecore_xcb_cookie_cache(cookie.sequence);
+ xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_DELETE, win);
}
/**
- * Gets the reply of the GetInputFocus request sent by ecore_x_get_input_focus_prefetch().
- * @ingroup Ecore_X_Window_Input_Focus_Group
+ * gets the window that has focus.
+ * @return The window that has focus.
+ * @ingroup Ecore_X_Window_Focus_Functions
*/
-EAPI void
-ecore_x_get_input_focus_fetch(void)
+EAPI Ecore_X_Window
+ecore_x_window_focus_get(void)
{
xcb_get_input_focus_cookie_t cookie;
xcb_get_input_focus_reply_t *reply;
+ Ecore_X_Window focus = 0;
- cookie.sequence = _ecore_xcb_cookie_get();
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ cookie = xcb_get_input_focus_unchecked(_ecore_xcb_conn);
reply = xcb_get_input_focus_reply(_ecore_xcb_conn, cookie, NULL);
- _ecore_xcb_reply_cache(reply);
+ if (!reply) return 0;
+ focus = reply->focus;
+ free(reply);
+ return focus;
}
-/**
- * Gets the window that has focus.
- * @return The window that has focus.
- *
- * Returns the window that has the focus. If an error aoocured, @c 0
- * is returned, otherwise the function returns the window that has focus.
- *
- * To use this function, you must call before, and in order,
- * ecore_x_get_input_focus_prefetch(), which sends the GetInputFocus request,
- * then ecore_x_get_input_focus_fetch(), which gets the reply.
- * @ingroup Ecore_X_Window_Input_Focus_Group
- */
-EAPI Ecore_X_Window
-ecore_x_window_focus_get(void)
+EAPI int
+ecore_x_window_argb_get(Ecore_X_Window win)
{
- xcb_get_input_focus_reply_t *reply;
- Ecore_X_Window window = 0;
-
- reply = _ecore_xcb_reply_get();
- if (!reply) return window;
-
- return reply->focus;
-}
+ uint8_t ret = 0;
+#ifdef ECORE_XCB_RENDER
+ Ecore_X_Visual visual;
+#endif
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
-/**
- * @defgroup Ecore_X_Window_Get_Attributes_Group X Window Get Attributes Functions
- *
- * Functions that get the attributes of a window.
- */
+// if (!win) return ret;
+#ifdef ECORE_XCB_RENDER
+ /* grab the window's visual */
+ visual = _ecore_xcb_window_visual_get(win);
-/**
- * Sends the GetWindowAttributes request.
- * @ingroup Ecore_X_Window_Get_Attributes_Group
- */
-EAPI void
-ecore_x_get_window_attributes_prefetch(Ecore_X_Window window)
-{
- xcb_get_window_attributes_cookie_t cookie;
+ /* check if this visual supports alpha */
+ ret = _ecore_xcb_render_visual_supports_alpha(visual);
+#endif
- cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, window);
- _ecore_xcb_cookie_cache(cookie.sequence);
+ return ret;
}
-/**
- * Gets the reply of the GetWindowAttributes request sent by ecore_x_get_window_attributes_prefetch().
- * @ingroup Ecore_X_Window_Get_Attributes_Group
- */
-EAPI void
-ecore_x_get_window_attributes_fetch(void)
+EAPI Eina_Bool
+ecore_x_window_manage(Ecore_X_Window win)
{
xcb_get_window_attributes_cookie_t cookie;
xcb_get_window_attributes_reply_t *reply;
+ xcb_void_cookie_t change_cookie;
+ xcb_generic_error_t *err;
+ uint32_t list;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- cookie.sequence = _ecore_xcb_cookie_get();
+ cookie = xcb_get_window_attributes(_ecore_xcb_conn, win);
reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
- _ecore_xcb_reply_cache(reply);
+ if (!reply) return EINA_FALSE;
+
+ ecore_x_sync(); // needed
+
+ list = (XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
+ XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_RESIZE_REDIRECT |
+ XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
+ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_STRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
+ reply->your_event_mask);
+ free(reply);
+
+ change_cookie = xcb_change_window_attributes(_ecore_xcb_conn, win,
+ XCB_CW_EVENT_MASK, &list);
+
+ ecore_x_sync(); // needed
+
+ err = xcb_request_check(_ecore_xcb_conn, change_cookie);
+ if (err)
+ {
+ _ecore_xcb_error_handle(err);
+ free(err);
+ return EINA_FALSE;
+ }
+
+ return EINA_TRUE;
}
-/**
- * Retrieves the attributes of a window.
- * @param windows Unused.
- * @param att_ret Pointer to an Ecore_X_Window_Attributes
- * structure in which the attributes of a window
- * are to be stored.
- *
- * Retrieves the attributes of a window. If
- * @p att_ret is @c NULL, the function does nothing. If an error
- * occurred, @p att_ret is set to 0. Otherwise, the @p att_ret structure
- * is filled with the attributes os the requested window.
- *
- * To use this function, you must call before, and in order,
- * ecore_x_get_window_attributes_prefetch(), which sends the GetWindowAttributes request,
- * then ecore_x_get_window_attributes_fetch(), which gets the reply.
- * @ingroup Ecore_X_Window_Get_Attributes_Group
- */
-EAPI int
-ecore_x_window_attributes_get(Ecore_X_Window window __UNUSED__,
+EAPI Eina_Bool
+ecore_x_window_attributes_get(Ecore_X_Window win,
Ecore_X_Window_Attributes *att_ret)
{
+ xcb_get_window_attributes_cookie_t cookie;
xcb_get_window_attributes_reply_t *reply;
+ xcb_get_geometry_cookie_t gcookie;
+ xcb_get_geometry_reply_t *greply;
- if (!att_ret) return 0;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- reply = _ecore_xcb_reply_get();
- if (!reply) return 0;
+ cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, win);
+ reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
+ if (!reply) return EINA_FALSE;
memset(att_ret, 0, sizeof(Ecore_X_Window_Attributes));
- if (reply->map_state != XCB_MAP_STATE_UNMAPPED) att_ret->visible = 1;
- if (reply->map_state == XCB_MAP_STATE_VIEWABLE) att_ret->viewable = 1;
- if (reply->override_redirect) att_ret->override = 1;
- if (reply->_class == XCB_WINDOW_CLASS_INPUT_ONLY) att_ret->input_only = 1;
- if (reply->save_under) att_ret->save_under = 1;
+ if (reply->map_state != XCB_MAP_STATE_UNMAPPED)
+ att_ret->visible = EINA_TRUE;
- att_ret->event_mask.mine = reply->your_event_mask;
- att_ret->event_mask.all = reply->all_event_masks;
- att_ret->event_mask.no_propagate = reply->do_not_propagate_mask;
- att_ret->window_gravity = reply->win_gravity;
- att_ret->pixel_gravity = reply->bit_gravity;
- att_ret->colormap = reply->colormap;
- att_ret->visual = reply->visual;
+ if (reply->map_state == XCB_MAP_STATE_VIEWABLE)
+ att_ret->viewable = EINA_TRUE;
- return 1;
-}
+ if (reply->override_redirect)
+ att_ret->override = EINA_TRUE;
-/**
- * Finds out whether the given window is currently visible.
- * @param window Unused.
- * @return 1 if the window is visible, otherwise 0.
- *
- * Finds out whether the given window is currently visible.
- * If an error occurred, or if the window is not visible, 0 is
- * returned. Otherwise 1 is returned.
- *
- * To use this function, you must call before, and in order,
- * ecore_x_get_window_attributes_prefetch(), which sends the GetWindowAttributes request,
- * then ecore_x_get_window_attributes_fetch(), which gets the reply.
- * @ingroup Ecore_X_Window_Get_Attributes_Group
- */
-EAPI int
-ecore_x_window_visible_get(Ecore_X_Window window __UNUSED__)
-{
- xcb_get_window_attributes_reply_t *reply;
+ if (reply->_class == XCB_WINDOW_CLASS_INPUT_ONLY)
+ att_ret->input_only = EINA_TRUE;
- reply = _ecore_xcb_reply_get();
- if (!reply) return 0;
+ if (reply->save_under)
+ att_ret->save_under = EINA_TRUE;
- return (reply->map_state == XCB_MAP_STATE_VIEWABLE) ? 1 : 0;
+ att_ret->event_mask.mine = reply->your_event_mask;
+ att_ret->event_mask.all = reply->all_event_masks;
+ att_ret->event_mask.no_propagate = reply->do_not_propagate_mask;
+ att_ret->window_gravity = reply->win_gravity;
+ att_ret->pixel_gravity = reply->bit_gravity;
+ att_ret->colormap = reply->colormap;
+ att_ret->visual = _ecore_xcb_window_find_visual_by_id(reply->visual);
+
+ free(reply);
+
+ gcookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win);
+ greply = xcb_get_geometry_reply(_ecore_xcb_conn, gcookie, NULL);
+ if (!greply) return EINA_TRUE;
+
+ /* xcb_translate_coordinates_reply_t *trans; */
+ /* xcb_query_tree_cookie_t tcookie; */
+ /* xcb_query_tree_reply_t *treply; */
+
+ /* tcookie = xcb_query_tree(_ecore_xcb_conn, win); */
+ /* treply = xcb_query_tree_reply(_ecore_xcb_conn, tcookie, NULL); */
+
+ /* trans = */
+ /* xcb_translate_coordinates_reply(_ecore_xcb_conn, */
+ /* xcb_translate_coordinates(_ecore_xcb_conn, */
+ /* win, treply->parent, greply->x, greply->y), NULL); */
+ /* free(treply); */
+
+ att_ret->root = greply->root;
+ att_ret->depth = greply->depth;
+// att_ret->x = trans->dst_x;
+// att_ret->y = trans->dst_y;
+ att_ret->x = greply->x;
+ att_ret->y = greply->y;
+ att_ret->w = greply->width;
+ att_ret->h = greply->height;
+ att_ret->border = greply->border_width;
+
+// free(trans);
+
+ free(greply);
+ return EINA_TRUE;
}
-
/**
- * Sends the QueryPointer request.
- * @ingroup Ecore_X_Window_Parent_Group
+ * Retrieves the size of the given window.
+ * @param win The given window.
+ * @param w Pointer to an integer into which the width is to be stored.
+ * @param h Pointer to an integer into which the height is to be stored.
+ * @ingroup Ecore_X_Window_Geometry_Group
*/
EAPI void
-ecore_x_pointer_xy_get_prefetch(Ecore_X_Window window)
+ecore_x_window_size_get(Ecore_X_Window win,
+ int *width,
+ int *height)
{
- xcb_query_pointer_cookie_t cookie;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- cookie = xcb_query_pointer_unchecked(_ecore_xcb_conn, window);
- _ecore_xcb_cookie_cache(cookie.sequence);
+ if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+ ecore_x_drawable_geometry_get(win, NULL, NULL, width, height);
}
/**
- * Gets the reply of the QueryPointer request sent by ecore_x_query_pointer_prefetch().
- * @ingroup Ecore_X_Window_Parent_Group
+ * Set if a window should be ignored.
+ * @param win The given window.
+ * @param ignore if to ignore
*/
EAPI void
-ecore_x_pointer_xy_get_fetch(void)
+ecore_x_window_ignore_set(Ecore_X_Window win,
+ int ignore)
{
- xcb_query_pointer_cookie_t cookie;
- xcb_query_pointer_reply_t *reply;
-
- cookie.sequence = _ecore_xcb_cookie_get();
- reply = xcb_query_pointer_reply(_ecore_xcb_conn, cookie, NULL);
- _ecore_xcb_reply_cache(reply);
-}
+ int i = 0, j = 0, count = 0;
-/**
- * Retrieves the coordinates of the pointer.
- * @param window Unused.
- * @param x The X coordinate of the pointer.
- * @param y The Y coordinate of the pointer.
- *
- * Retrieves the coordinates of the pointer.
- * If the window used in
- * ecore_x_query_pointer_prefetch() is not on the same screen than
- * the root window or if an error occured, @p x and @p y are set
- * to 0. Otherwise, they are respectively set to the X and Y
- * coordinates of the pointer.
- *
- * To use this function, you must call before, and in order,
- * ecore_x_query_pointer_prefetch(), which sends the QueryPointer request,
- * then ecore_x_query_pointer_fetch(), which gets the reply.
- * @ingroup Ecore_X_Window_Parent_Group
- */
-EAPI void
-ecore_x_pointer_xy_get(Ecore_X_Window window __UNUSED__,
- int *x,
- int *y)
-{
- xcb_query_pointer_reply_t *reply;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- reply = _ecore_xcb_reply_get();
- if (!reply)
+ if (ignore)
{
- if (x) *x = 0;
- if (y) *y = 0;
+ if (ignore_list)
+ {
+ for (i = 0; i < ignore_num; i++)
+ if (win == ignore_list[i]) return;
- return;
+ ignore_list =
+ realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
+ if (!ignore_list) return;
+
+ ignore_list[ignore_num++] = win;
+ }
+ else
+ {
+ ignore_num = 0;
+ ignore_list = malloc(sizeof(Ecore_X_Window));
+ if (!ignore_list) return;
+ ignore_list[ignore_num++] = win;
+ }
}
+ else
+ {
+ if (!ignore_list) return;
+ for (count = ignore_num, i = 0, j = 0; i < count; i++)
+ {
+ if (win != ignore_list[i])
+ ignore_list[j++] = ignore_list[i];
+ else
+ ignore_num--;
+ }
+ if (ignore_num <= 0)
+ {
+ free(ignore_list);
+ ignore_list = NULL;
+ return;
+ }
- if (x) *x = reply->win_x;
- if (y) *y = reply->win_y;
+ ignore_list =
+ realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
+ }
}
-
/**
- * Sends the QueryTree request.
- * @ingroup Ecore_X_Window_Parent_Group
+ * Get the ignore list
+ * @param num number of windows in the list
+ * @return list of windows to ignore
*/
-EAPI void
-ecore_x_query_tree_prefetch(Ecore_X_Window window)
+EAPI Ecore_X_Window *
+ecore_x_window_ignore_list(int *num)
{
- xcb_query_tree_cookie_t cookie;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
- cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, window);
- _ecore_xcb_cookie_cache(cookie.sequence);
+ if (num) *num = ignore_num;
+ return ignore_list;
}
/**
- * Gets the reply of the QueryTree request sent by ecore_x_query_tree_prefetch().
- * @ingroup Ecore_X_Window_Parent_Group
+ * Get a list of all the root windows on the server.
+ *
+ * @note The returned array will need to be freed after use.
+ * @param num_ret Pointer to integer to put number of windows returned in.
+ * @return An array of all the root windows. @c NULL is returned if memory
+ * could not be allocated for the list, or if @p num_ret is @c NULL.
*/
-EAPI void
-ecore_x_query_tree_fetch(void)
+EAPI Ecore_X_Window *
+ecore_x_window_root_list(int *num_ret)
{
- xcb_query_tree_cookie_t cookie;
- xcb_query_tree_reply_t *reply;
+ xcb_screen_iterator_t iter;
+ uint8_t i, num;
+ Ecore_X_Window *roots = NULL;
+#ifdef ECORE_XCB_XPRINT
+ const xcb_query_extension_reply_t *ext_reply;
+#endif
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ if (!num_ret) return NULL;
+ if (num_ret) *num_ret = 0;
+
+ /* if (xcb_connection_has_error(_ecore_xcb_conn)) */
+ /* { */
+ /* DBG("XCB Connection Has Error !!!"); */
+ /* return NULL; */
+ /* } */
+
+ num = ecore_x_screen_count_get();
+
+#ifdef ECORE_XCB_XPRINT
+ ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_x_print_id);
+ if ((ext_reply) && (ext_reply->present))
+ {
+ xcb_x_print_print_query_screens_cookie_t cookie;
+ xcb_x_print_print_query_screens_reply_t *reply;
- cookie.sequence = _ecore_xcb_cookie_get();
- reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
- _ecore_xcb_reply_cache(reply);
-}
+ cookie = xcb_x_print_print_query_screens_unchecked(_ecore_xcb_conn);
+ reply =
+ xcb_x_print_print_query_screens_reply(_ecore_xcb_conn, cookie, NULL);
+ if (reply)
+ {
+ xcb_window_t *screens;
+ int psnum = 0, overlap = 0, j = 0, k = 0;
-/**
- * Retrieves the parent window of the given window.
- * @param window Unused.
- * @return The parent window of @p window.
- *
- * Retrieves the parent window of the given window. If
- * an error occured, @c 0 is returned.
- *
- * To use this function, you must call before, and in order,
- * ecore_x_query_tree_prefetch(), which sends the QueryTree request,
- * then ecore_x_query_tree_fetch(), which gets the reply.
- * @ingroup Ecore_X_Window_Parent_Group
- */
-EAPI Ecore_X_Window
-ecore_x_window_parent_get(Ecore_X_Window window __UNUSED__)
-{
- xcb_query_tree_reply_t *reply;
+ psnum = xcb_x_print_print_query_screens_roots_length(reply);
+ screens = xcb_x_print_print_query_screens_roots(reply);
+ for (i = 0; i < num; i++)
+ {
+ for (j = 0; j < psnum; j++)
+ {
+ xcb_screen_t *s;
- reply = _ecore_xcb_reply_get();
- if (!reply) return 0;
+ if ((s = _ecore_xcb_window_screen_of_display(i)))
+ {
+ if (s->root == screens[j])
+ overlap++;
+ }
+ }
+ }
+ if (!(roots = malloc((num - overlap)
+ * sizeof(Ecore_X_Window)))) return NULL;
+ for (i = 0; i < num; i++)
+ {
+ Eina_Bool is_print = EINA_FALSE;
- return reply->parent;
-}
+ for (j = 0; j < psnum; j++)
+ {
+ xcb_screen_t *s;
+
+ if ((s = _ecore_xcb_window_screen_of_display(i)))
+ {
+ if (s->root == screens[j])
+ {
+ is_print = EINA_TRUE;
+ break;
+ }
+ }
+ }
+ if (!is_print)
+ {
+ xcb_screen_t *s;
+ if ((s = _ecore_xcb_window_screen_of_display(i)))
+ {
+ roots[k] = s->root;
+ k++;
+ }
+ }
+ }
+ if (num_ret) *num_ret = k;
+ free(reply);
+ }
+ else
+ {
+ /* Fallback to default method */
+ iter =
+ xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
+ if (!(roots = malloc(num * sizeof(Ecore_X_Window)))) return NULL;
+ if (num_ret) *num_ret = num;
+ for (i = 0; iter.rem; xcb_screen_next(&iter), i++)
+ roots[i] = iter.data->root;
+ }
+ }
+ else
+ {
+ /* Fallback to default method */
+ iter =
+ xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
+ if (!(roots = malloc(num * sizeof(Ecore_X_Window)))) return NULL;
+ if (num_ret) *num_ret = num;
+ for (i = 0; iter.rem; xcb_screen_next(&iter), i++)
+ roots[i] = iter.data->root;
+ }
+#else
+ iter =
+ xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
+ if (!(roots = malloc(num * sizeof(Ecore_X_Window)))) return NULL;
+ if (num_ret) *num_ret = num;
+ for (i = 0; iter.rem; xcb_screen_next(&iter), i++)
+ roots[i] = iter.data->root;
+#endif
+
+ return roots;
+}
-/**
- * Retrieves the children windows of the given window.
- * @param window Unused.
- * @param num children windows count.
- * @return The children windows.
- *
- * Retrieves the children windows of the given window. If
- * an error occured, @c 0 is returned.
- *
- * To use this function, you must call before, and in order,
- * ecore_x_query_tree_prefetch(), which sends the QueryTree request,
- * then ecore_x_query_tree_fetch(), which gets the reply.
- * @ingroup Ecore_X_Window_Parent_Group
- */
EAPI Ecore_X_Window *
-ecore_x_window_children_get(Ecore_X_Window window __UNUSED__,
+ecore_x_window_children_get(Ecore_X_Window win,
int *num)
{
+ xcb_query_tree_cookie_t cookie;
xcb_query_tree_reply_t *reply;
- Ecore_X_Window *windows = NULL;
+ Ecore_X_Window *windows = NULL;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
if (num) *num = 0;
- reply = _ecore_xcb_reply_get();
+ cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, win);
+ reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return NULL;
- windows = malloc(reply->children_len);
- if (!windows)
- return NULL;
-
if (num) *num = reply->children_len;
- memcpy(windows,
- xcb_query_tree_children(reply),
- sizeof(Ecore_X_Window) * reply->children_len);
-
- return windows;
-}
-
-/* FIXME: I've tried to remove the round trips. 3 cookies are */
-/* created at the beginning of the function. Because of */
-/* the recursivity of the algo, I can't find better trick */
-static Ecore_X_Window
-_ecore_x_window_at_xy_get(Ecore_X_Window base,
- int16_t base_x,
- int16_t base_y,
- int16_t x,
- int16_t y,
- Ecore_X_Window *skip,
- int skip_num)
-{
- xcb_window_iterator_t iter_children;
- xcb_get_window_attributes_cookie_t cookie_get_window_attributes;
- xcb_get_geometry_cookie_t cookie_get_geometry;
- xcb_query_tree_cookie_t cookie_query_tree;
- xcb_get_window_attributes_reply_t *reply_get_window_attributes;
- xcb_get_geometry_reply_t *reply_get_geometry;
- xcb_query_tree_reply_t *reply_query_tree;
- Ecore_X_Window window = 0;
- Ecore_X_Window child = 0;
- int16_t win_x;
- int16_t win_y;
- uint16_t win_width;
- uint16_t win_height;
-
- cookie_get_window_attributes = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, base);
- cookie_get_geometry = xcb_get_geometry_unchecked(_ecore_xcb_conn, base);
- cookie_query_tree = xcb_query_tree_unchecked(_ecore_xcb_conn, base);
-
- reply_get_window_attributes = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie_get_window_attributes, NULL);
- if (!reply_get_window_attributes)
- {
- reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
- if (reply_get_geometry) free(reply_get_geometry);
- reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
- if (reply_query_tree) free(reply_query_tree);
- return window;
- }
-
- if (reply_get_window_attributes->map_state != XCB_MAP_STATE_VIEWABLE)
- {
- free(reply_get_window_attributes);
- reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
- if (reply_get_geometry) free(reply_get_geometry);
- reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
- if (reply_query_tree) free(reply_query_tree);
- return window;
- }
-
- free(reply_get_window_attributes);
-
- reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
- if (!reply_get_geometry)
- {
- reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
- if (reply_query_tree) free(reply_query_tree);
- return window;
- }
-
- win_x = reply_get_geometry->x;
- win_y = reply_get_geometry->y;
- win_width = reply_get_geometry->width;
- win_height = reply_get_geometry->height;
-
- free(reply_get_geometry);
-
- win_x += base_x;
- win_y += base_y;
-
- if (!((x >= win_x) &&
- (y >= win_y) &&
- (x < (int16_t)(win_x + win_width)) &&
- (y < (int16_t)(win_y + win_height))))
+ if (reply->children_len > 0)
{
- reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
- if (reply_query_tree) free(reply_query_tree);
- return window;
- }
+ windows = malloc(sizeof(Ecore_X_Window) * reply->children_len);
+ if (windows)
+ {
+ unsigned int i = 0;
+ xcb_window_t *w;
- reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
- if (!reply_query_tree)
- {
- if (skip)
- {
- int i;
-
- for (i = 0; i < skip_num; i++)
- if (base == skip[i])
- return window;
- }
- return base;
+ w = xcb_query_tree_children(reply);
+ for (i = 0; i < reply->children_len; i++)
+ windows[i] = w[i];
+ }
}
- iter_children = xcb_query_tree_children_iterator(reply_query_tree);
- for (; iter_children.rem; xcb_window_next(&iter_children))
- {
- if (skip)
- {
- int j;
+ free(reply);
+ return windows;
+}
- for (j = 0; j < skip_num; j++)
- if (*iter_children.data == skip[j])
- continue;
- }
- child = _ecore_x_window_at_xy_get(*iter_children.data, win_x, win_y, x, y, skip, skip_num);
- if (child)
- {
- free(reply_query_tree);
+/**
+ * Retrieves the root window a given window is on.
+ * @param win The window to get the root window of
+ * @return The root window of @p win
+ * @ingroup Ecore_X_Window_Geometry_Group
+ */
+EAPI Ecore_X_Window
+ecore_x_window_root_get(Ecore_X_Window win)
+{
+ xcb_get_geometry_cookie_t gcookie;
+ xcb_get_geometry_reply_t *greply;
+ Ecore_X_Window window = 0;
- return child;
- }
- }
+ /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
+ CHECK_XCB_CONN;
- if (skip)
- {
- int i;
-
- for (i = 0; i < skip_num; i++)
- if (base == skip[i])
- {
- /* We return 0. child has an xid equal to 0 */
- free(reply_query_tree);
- return child;
- }
- }
+ gcookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win);
+ greply = xcb_get_geometry_reply(_ecore_xcb_conn, gcookie, NULL);
+ if (!greply) return 0;
+ window = greply->root;
+ free(greply);
- free(reply_query_tree);
+ return window;
+}
- return base;
+EAPI Ecore_X_Window
+ecore_x_window_root_first_get(void)
+{
+ return ((xcb_screen_t *)_ecore_xcb_screen)->root;
}
/**
- * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
+ * Retrieves the geometry of the given window.
*
- * Functions that change or retrieve the geometry of X windows.
+ * Note that the x & y coordingates are relative to your parent. In
+ * particular for reparenting window managers - relative to you window border.
+ * If you want screen coordinates either walk the window tree to the root,
+ * else for ecore_evas applications see ecore_evas_geometry_get(). Elementary
+ * applications can use elm_win_screen_position_get().
+ *
+ * @param win The given window.
+ * @param x Pointer to an integer in which the X position is to be stored.
+ * @param y Pointer to an integer in which the Y position is to be stored.
+ * @param w Pointer to an integer in which the width is to be stored.
+ * @param h Pointer to an integer in which the height is to be stored.
+ * @ingroup Ecore_X_Window_Geometry_Group
*/
+EAPI void
+ecore_x_window_geometry_get(Ecore_X_Window win,
+ int *x,
+ int *y,
+ int *w,
+ int *h)
+{
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+ ecore_x_drawable_geometry_get(win, x, y, w, h);
+}
/**
* Retrieves the top, visible window at the given location.
* @param x The given X position.
* @param y The given Y position.
- * @return The window at that position.
+ * @return The window at that position.
* @ingroup Ecore_X_Window_Geometry_Group
*/
EAPI Ecore_X_Window
ecore_x_window_at_xy_get(int x,
- int y)
+ int y)
{
- Ecore_X_Window window;
- Ecore_X_Window root;
+ Ecore_X_Window root, win = 0;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- /* FIXME: Proper function to determine current root/virtual root
- * window missing here */
root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
ecore_x_grab();
- window = _ecore_x_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
+ win = _ecore_xcb_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
ecore_x_ungrab();
- return window ? window : root;
+ return win ? win : root;
}
/**
* but skips the windows in the list.
* @param x The given X position.
* @param y The given Y position.
- * @return The window at that position.
+ * @param skip The list of windows to be skipped.
+ * @param skip_num The number of windows to be skipped.
+ * @return The window at that position.
* @ingroup Ecore_X_Window_Geometry_Group
*/
EAPI Ecore_X_Window
ecore_x_window_at_xy_with_skip_get(int x,
- int y,
- Ecore_X_Window *skip,
- int skip_num)
+ int y,
+ Ecore_X_Window *skip,
+ int skip_num)
{
- Ecore_X_Window window;
- Ecore_X_Window root;
+ Ecore_X_Window root, win = 0;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- /* FIXME: Proper function to determine current root/virtual root
- * window missing here */
root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
ecore_x_grab();
- window = _ecore_x_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
+ win = _ecore_xcb_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
ecore_x_ungrab();
- return window ? window : root;
+ return win ? win : root;
}
-/**
- * Retrieves the top, visible window at the given location,
- * but begins at the @p begin window instead of the root one.
- * @param begin The window from which we begin.
- * @param x The given X position.
- * @param y The given Y position.
- * @return The window at that position.
- * @ingroup Ecore_X_Window_Geometry_Group
- */
EAPI Ecore_X_Window
ecore_x_window_at_xy_begin_get(Ecore_X_Window begin,
int x,
int y)
{
- Ecore_X_Window window;
+ Ecore_X_Window win = 0;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
ecore_x_grab();
- window = _ecore_x_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
+ win = _ecore_xcb_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
ecore_x_ungrab();
- return window ? window : begin;
+ return win ? win : begin;
}
+/**
+ * Retrieves the parent window of the given window.
+ * @param win The given window.
+ * @return The parent window of @p win.
+ * @ingroup Ecore_X_Window_Parent_Group
+ */
+EAPI Ecore_X_Window
+ecore_x_window_parent_get(Ecore_X_Window win)
+{
+ xcb_query_tree_cookie_t cookie;
+ xcb_query_tree_reply_t *reply;
+ Ecore_X_Window window = 0;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
-/* FIXME: Should I provide the replies (or the cookies), instead of
- creating them in the function ? */
-#ifdef ECORE_XCB_RENDER
-static Ecore_X_Window
-_ecore_x_window_argb_internal_new(Ecore_X_Window parent,
- int16_t x,
- int16_t y,
- uint16_t w,
- uint16_t h,
- uint8_t override_redirect,
- uint8_t save_under)
-{
- uint32_t value_list[10];
- xcb_depth_iterator_t iter_depth;
- xcb_visualtype_iterator_t iter_visualtype;
- xcb_render_query_pict_formats_cookie_t cookie_pict_format;
- xcb_render_query_pict_formats_reply_t *rep_pict_format;
- Ecore_X_Screen *screen = NULL;
- Ecore_X_Window win = { 0 };
- xcb_visualid_t vis = { 0 };
- Ecore_X_Colormap colormap;
- uint32_t value_mask;
-
- cookie_pict_format = xcb_render_query_pict_formats_unchecked(_ecore_xcb_conn);
+// if (!win) return 0;
+ cookie = xcb_query_tree(_ecore_xcb_conn, win);
+ reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
+ if (!reply) return 0;
+ window = reply->parent;
+ free(reply);
- if (parent == 0)
- {
- parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
- screen = ((xcb_screen_t *)_ecore_xcb_screen);
- }
- else
- {
- xcb_screen_iterator_t iter_screen;
- xcb_get_geometry_reply_t *rep;
- Ecore_X_Drawable draw;
- Ecore_X_Window root;
+ return window;
+}
- draw = parent;
- rep = xcb_get_geometry_reply(_ecore_xcb_conn,
- xcb_get_geometry_unchecked(_ecore_xcb_conn,
- draw),
- NULL);
- if (!rep)
- return win;
+/**
+ * Finds out whether the given window is currently visible.
+ * @param win The given window.
+ * @return 1 if the window is visible, otherwise 0.
+ * @ingroup Ecore_X_Window_Visibility_Group
+ */
+EAPI int
+ecore_x_window_visible_get(Ecore_X_Window win)
+{
+ xcb_get_window_attributes_cookie_t cookie;
+ xcb_get_window_attributes_reply_t *reply;
+ int ret = EINA_FALSE;
- root = rep->root;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- free(rep);
+ cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, win);
+ reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
+ if (!reply) return EINA_FALSE;
- for (; iter_screen.rem; xcb_screen_next(&iter_screen))
- {
- if (iter_screen.data->root == root)
- {
- screen = iter_screen.data;
- }
- }
- }
- if (!screen)
- return win;
-
- /* we get the X visual types */
- iter_depth = xcb_screen_allowed_depths_iterator(screen);
- for (; iter_depth.rem; xcb_depth_next(&iter_depth)) {
- if (iter_depth.data->depth == 32) {
- iter_visualtype = xcb_depth_visuals_iterator(iter_depth.data);
- break;
- }
- }
-
- /* we get the X render visual id */
- rep_pict_format = xcb_render_query_pict_formats_reply(_ecore_xcb_conn,
- cookie_pict_format,
- NULL);
- if (!rep_pict_format)
- return win;
-
- for (; iter_visualtype.rem; xcb_visualtype_next(&iter_visualtype)) {
- if (iter_visualtype.data->_class == XCB_VISUAL_CLASS_TRUE_COLOR) {
- xcb_render_pictforminfo_iterator_t iter_forminfo;
- xcb_render_pictscreen_iterator_t iter_pictscreen;
- xcb_render_pictformat_t pict_format = { 0 };
-
- iter_forminfo = xcb_render_query_pict_formats_formats_iterator(rep_pict_format);
- for (; iter_forminfo.rem; xcb_render_pictforminfo_next(&iter_forminfo)) {
- if (iter_forminfo.data->type == XCB_RENDER_PICT_TYPE_DIRECT &&
- iter_forminfo.data->direct.alpha_mask && iter_forminfo.data->depth == 32) {
- pict_format = iter_forminfo.data->id;
- break;
- }
- }
- if (pict_format == 0) {
- free(rep_pict_format);
- return win;
- }
- iter_pictscreen = xcb_render_query_pict_formats_screens_iterator(rep_pict_format);
- for (; iter_pictscreen.rem; xcb_render_pictscreen_next(&iter_pictscreen)) {
- xcb_render_pictdepth_iterator_t iter_depth;
-
- iter_depth = xcb_render_pictscreen_depths_iterator(iter_pictscreen.data);
- for (; iter_depth.rem; xcb_render_pictdepth_next(&iter_depth)) {
- xcb_render_pictvisual_iterator_t iter_visual;
-
- iter_visual = xcb_render_pictdepth_visuals_iterator(iter_depth.data);
- for (; iter_visual.rem; xcb_render_pictvisual_next(&iter_visual)) {
- if ((iter_visual.data->visual == iter_visualtype.data->visual_id) &&
- (pict_format == iter_visual.data->format)) {
- vis = iter_visual.data->visual;
- break;
- }
- }
- }
- }
- }
- }
+ if (reply->map_state == XCB_MAP_STATE_VIEWABLE)
+ ret = EINA_TRUE;
+
+ free(reply);
+ return ret;
+}
+
+EAPI void
+ecore_x_window_button_grab(Ecore_X_Window win,
+ int button,
+ Ecore_X_Event_Mask mask,
+ int mod,
+ int any_mod)
+{
+ int i = 0;
+ uint16_t m, locks[8], ev;
+ uint8_t b;
+ Ecore_X_Window *t;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ b = button;
+ if (b == 0)
+ b = XCB_BUTTON_INDEX_ANY;
+
+ m = _ecore_xcb_window_modifiers_get(mod);
+ if (any_mod) m = XCB_MOD_MASK_ANY;
+
+ locks[0] = 0;
+ locks[1] = ECORE_X_LOCK_CAPS;
+ locks[2] = ECORE_X_LOCK_NUM;
+ locks[3] = ECORE_X_LOCK_SCROLL;
+ locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
+ locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
+ locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+ locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+
+ ev = mask;
+ for (i = 0; i < 8; i++)
+ xcb_grab_button(_ecore_xcb_conn, 0, win, ev,
+ XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC,
+ XCB_NONE, XCB_NONE, b, m | locks[i]);
+
+ _ecore_xcb_button_grabs_num++;
+ t = realloc(_ecore_xcb_button_grabs,
+ _ecore_xcb_button_grabs_num * sizeof(Ecore_X_Window));
+ if (!t) return;
+
+ _ecore_xcb_button_grabs = t;
+ _ecore_xcb_button_grabs[_ecore_xcb_button_grabs_num - 1] = win;
+}
+
+EAPI void
+ecore_x_window_button_ungrab(Ecore_X_Window win,
+ int button,
+ int mod,
+ int any_mod)
+{
+ int i = 0;
+ uint16_t m = 0, locks[8];
+ uint8_t b;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ b = button;
+ if (b == 0) b = XCB_BUTTON_INDEX_ANY;
+
+ m = _ecore_xcb_window_modifiers_get(mod);
+ if (any_mod) m = XCB_MOD_MASK_ANY;
+
+ locks[0] = 0;
+ locks[1] = ECORE_X_LOCK_CAPS;
+ locks[2] = ECORE_X_LOCK_NUM;
+ locks[3] = ECORE_X_LOCK_SCROLL;
+ locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
+ locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
+ locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+ locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+
+ for (i = 0; i < 8; i++)
+ xcb_ungrab_button(_ecore_xcb_conn, b, win, m | locks[i]);
+
+ _ecore_xcb_sync_magic_send(1, win);
+}
+
+EAPI void
+ecore_x_window_key_grab(Ecore_X_Window win,
+ const char *key,
+ int mod,
+ int any_mod)
+{
+ xcb_keycode_t keycode = XCB_NO_SYMBOL;
+ uint16_t m = 0, locks[8];
+ int i = 0;
+ Ecore_X_Window *t;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ keycode = _ecore_xcb_keymap_string_to_keycode(key);
+ if (keycode == XCB_NO_SYMBOL) return;
+
+ m = _ecore_xcb_window_modifiers_get(mod);
+ if (any_mod) m = XCB_MOD_MASK_ANY;
+
+ locks[0] = 0;
+ locks[1] = ECORE_X_LOCK_CAPS;
+ locks[2] = ECORE_X_LOCK_NUM;
+ locks[3] = ECORE_X_LOCK_SCROLL;
+ locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
+ locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
+ locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+ locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+
+ for (i = 0; i < 8; i++)
+ xcb_grab_key(_ecore_xcb_conn, 0, win, m | locks[i],
+ keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
+ _ecore_xcb_key_grabs_num++;
+ t = realloc(_ecore_xcb_key_grabs,
+ _ecore_xcb_key_grabs_num * sizeof(Ecore_X_Window));
+ if (!t) return;
+ _ecore_xcb_key_grabs = t;
+ _ecore_xcb_key_grabs[_ecore_xcb_key_grabs_num - 1] = win;
+}
- free(rep_pict_format);
+EAPI void
+ecore_x_window_key_ungrab(Ecore_X_Window win,
+ const char *key,
+ int mod,
+ int any_mod)
+{
+ xcb_keycode_t keycode = XCB_NO_SYMBOL;
+ uint16_t m = 0, locks[8];
+ int i = 0;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ keycode = _ecore_xcb_keymap_string_to_keycode(key);
+ if (keycode == XCB_NO_SYMBOL) return;
+
+ m = _ecore_xcb_window_modifiers_get(mod);
+ if (any_mod) m = XCB_MOD_MASK_ANY;
+
+ locks[0] = 0;
+ locks[1] = ECORE_X_LOCK_CAPS;
+ locks[2] = ECORE_X_LOCK_NUM;
+ locks[3] = ECORE_X_LOCK_SCROLL;
+ locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
+ locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
+ locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+ locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
+
+ for (i = 0; i < 8; i++)
+ xcb_ungrab_key(_ecore_xcb_conn, keycode, win, m | locks[i]);
+
+ _ecore_xcb_sync_magic_send(2, win);
+}
+
+/* local functions */
+Ecore_X_Window
+_ecore_xcb_window_root_of_screen_get(int screen)
+{
+ xcb_screen_iterator_t iter;
+
+ CHECK_XCB_CONN;
+ iter = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
+ for (; iter.rem; --screen, xcb_screen_next(&iter))
+ if (screen == 0)
+ {
+ xcb_screen_t *s;
+
+ if ((s = iter.data))
+ return s->root;
+ }
+ return 0;
+}
+
+static Ecore_X_Window
+_ecore_xcb_window_argb_internal_new(Ecore_X_Window parent,
+ int x,
+ int y,
+ int w,
+ int h,
+ uint8_t override_redirect,
+ uint8_t save_under)
+{
+ Ecore_X_Window win = 0;
+#ifdef ECORE_XCB_RENDER
+ uint32_t value_list[10];
+ uint32_t value_mask;
+ uint32_t vis;
+ Ecore_X_Colormap colormap;
+#endif
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+#ifdef ECORE_XCB_RENDER
+ if (parent == 0)
+ parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
- if (vis == 0)
- return win;
+ vis =
+ _ecore_xcb_render_find_visual_id(XCB_RENDER_PICT_TYPE_DIRECT, EINA_TRUE);
colormap = xcb_generate_id(_ecore_xcb_conn);
- xcb_create_colormap(_ecore_xcb_conn, XCB_COLORMAP_ALLOC_NONE, colormap, parent, vis);
-
- value_mask =
- XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
- XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
- XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE |
- XCB_CW_COLORMAP;
-
- value_list[0] = XCB_NONE;
- value_list[1] = 0;
- value_list[2] = XCB_GRAVITY_NORTH_WEST;
- value_list[3] = XCB_GRAVITY_NORTH_WEST;
- value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
- value_list[5] = override_redirect;
- value_list[6] = save_under;
- value_list[7] =
- XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
- XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
- XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
- XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
- XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
- XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
- XCB_EVENT_MASK_COLOR_MAP_CHANGE;
- value_list[8] = XCB_EVENT_MASK_NO_EVENT;
- value_list[9] = colormap;
+ xcb_create_colormap(_ecore_xcb_conn, XCB_COLORMAP_ALLOC_NONE,
+ colormap, parent, vis);
+
+ value_mask = (XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
+ XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE |
+ XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER |
+ XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE | XCB_CW_COLORMAP);
+
+ value_list[0] = XCB_BACK_PIXMAP_NONE;
+ value_list[1] = 0;
+ value_list[2] = XCB_GRAVITY_NORTH_WEST;
+ value_list[3] = XCB_GRAVITY_NORTH_WEST;
+ value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
+ value_list[5] = override_redirect;
+ value_list[6] = save_under;
+ value_list[7] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
+ XCB_EVENT_MASK_BUTTON_PRESS |
+ XCB_EVENT_MASK_BUTTON_RELEASE |
+ XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
+ XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
+ XCB_EVENT_MASK_VISIBILITY_CHANGE |
+ XCB_EVENT_MASK_STRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_FOCUS_CHANGE |
+ XCB_EVENT_MASK_PROPERTY_CHANGE |
+ XCB_EVENT_MASK_COLOR_MAP_CHANGE);
+ value_list[8] = XCB_EVENT_MASK_NO_EVENT;
+ value_list[9] = colormap;
win = xcb_generate_id(_ecore_xcb_conn);
- xcb_create_window(_ecore_xcb_conn,
- 32, /* depth */
- win, parent,
- x, y, w, h, 0,
- XCB_WINDOW_CLASS_INPUT_OUTPUT,
- vis,
- value_mask,
+ xcb_create_window(_ecore_xcb_conn, 32, win, parent, x, y, w, h, 0,
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, vis, value_mask,
value_list);
xcb_free_colormap(_ecore_xcb_conn, colormap);
if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
ecore_x_window_defaults_set(win);
+#endif
return win;
}
-#endif /* ECORE_XCB_RENDER */
+static Ecore_X_Window
+_ecore_xcb_window_at_xy_get(Ecore_X_Window base,
+ int bx,
+ int by,
+ int x,
+ int y,
+ Ecore_X_Window *skip,
+ int skip_num)
+{
+ xcb_query_tree_cookie_t cookie;
+ xcb_query_tree_reply_t *reply;
+ Ecore_X_Window *windows = NULL;
+ int wx, wy, ww, wh, num, i = 0;
+ Eina_Bool skipit = EINA_FALSE;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
-/* FIXME: round trip */
-EAPI int
-ecore_x_window_argb_get(Ecore_X_Window win)
-{
- uint8_t ret = 0;
-#ifdef ECORE_XCB_RENDER
- xcb_render_pictforminfo_iterator_t iter_forminfo;
- xcb_render_pictscreen_iterator_t iter_pictscreen;
- xcb_render_pictformat_t pict_format = { 0 };
- xcb_render_query_pict_formats_reply_t *rep_pictformat;
- xcb_get_window_attributes_reply_t *rep;
- xcb_visualid_t visual;
-
- rep = xcb_get_window_attributes_reply(_ecore_xcb_conn,
- xcb_get_window_attributes_unchecked(_ecore_xcb_conn,
- win),
- NULL);
- if (!rep)
- return ret;
-
- visual = rep->visual;
-
- free(rep);
-
- rep_pictformat = xcb_render_query_pict_formats_reply(_ecore_xcb_conn,
- xcb_render_query_pict_formats_unchecked(_ecore_xcb_conn),
- NULL);
- if (!rep_pictformat)
- return ret;
-
- iter_forminfo = xcb_render_query_pict_formats_formats_iterator(rep_pictformat);
- for (; iter_forminfo.rem; xcb_render_pictforminfo_next(&iter_forminfo))
- {
- if ((iter_forminfo.data->type == XCB_RENDER_PICT_TYPE_DIRECT) &&
- (iter_forminfo.data->direct.alpha_mask))
- {
- pict_format = iter_forminfo.data->id;
- break;
- }
- }
- if (pict_format == 0)
- {
- free(rep_pictformat);
+ if (!ecore_x_window_visible_get(base)) return 0;
- return ret;
- }
+ 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;
+
+ cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, base);
+ reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
+ if (!reply) return 0;
+
+ num = reply->children_len;
+ windows = xcb_query_tree_children(reply);
- iter_pictscreen = xcb_render_query_pict_formats_screens_iterator(rep_pictformat);
- for (; iter_pictscreen.rem; xcb_render_pictscreen_next(&iter_pictscreen))
+ for (i = (num - 1); i >= 0; --i)
{
- xcb_render_pictdepth_iterator_t iter_depth;
+ skipit = EINA_FALSE;
- iter_depth = xcb_render_pictscreen_depths_iterator(iter_pictscreen.data);
- for (; iter_depth.rem; xcb_render_pictdepth_next(&iter_depth))
+ if (skip)
{
- xcb_render_pictvisual_iterator_t iter_visual;
+ int j = 0;
- iter_visual = xcb_render_pictdepth_visuals_iterator(iter_depth.data);
- for (; iter_visual.rem; xcb_render_pictvisual_next(&iter_visual))
+ for (j = 0; j < skip_num; j++)
{
- if ((iter_visual.data->visual == visual) &&
- (pict_format == iter_visual.data->format))
+ if (windows[i] == skip[j])
{
- ret = 1;
- break;
+ skipit = EINA_TRUE;
+ goto onward;
}
}
}
- }
+onward:
+ if (!skipit)
+ {
+ Ecore_X_Window child = 0;
- free(rep_pictformat);
-#endif /* ECORE_XCB_RENDER */
+ child =
+ _ecore_xcb_window_at_xy_get(windows[i],
+ wx, wy, x, y, skip, skip_num);
+ if (child)
+ {
+ if (reply) free(reply);
+ return child;
+ }
+ }
+ }
- return ret;
+ if (reply) free(reply);
+ return base;
}
+Ecore_X_Visual
+_ecore_xcb_window_visual_get(Ecore_X_Window win)
+{
+ xcb_get_window_attributes_cookie_t cookie;
+ xcb_get_window_attributes_reply_t *reply;
+ Ecore_X_Visual visual = 0;
+
+ CHECK_XCB_CONN;
+ cookie = xcb_get_window_attributes(_ecore_xcb_conn, win);
+ reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
+ if (!reply) return 0;
+ visual = _ecore_xcb_window_find_visual_by_id(reply->visual);
+ free(reply);
+ return visual;
+}
-/**
- * Set if a window should be ignored.
- * @param window The given window.
- * @param ignore if to ignore
- */
-EAPI void
-ecore_x_window_ignore_set(Ecore_X_Window window,
- int ignore)
+void
+_ecore_xcb_window_button_grab_remove(Ecore_X_Window win)
{
- int i, j;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
- if (ignore)
- {
- if (ignore_list)
- {
- for (i = 0; i < ignore_num; i++)
- {
- if (window == ignore_list[i])
- return;
- }
- ignore_list = realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
- if (!ignore_list) return;
- ignore_list[ignore_num++] = window;
- }
- else
- {
- ignore_num = 0;
- ignore_list = malloc(sizeof(Ecore_X_Window));
- ignore_list[ignore_num++] = window;
- }
- }
- else
+ if (_ecore_xcb_button_grabs_num > 0)
{
- if (!ignore_list) return;
- for (i = 0, j = 0; i < ignore_num; i++)
- {
- if (window != ignore_list[i])
- ignore_list[i] = ignore_list[j++];
- else
- ignore_num--;
- }
- ignore_list = realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
+ int i = 0, shuffle = 0;
+
+ for (i = 0; i < _ecore_xcb_button_grabs_num; i++)
+ {
+ if (shuffle)
+ _ecore_xcb_button_grabs[i - 1] = _ecore_xcb_button_grabs[i];
+
+ if ((!shuffle) && (_ecore_xcb_button_grabs[i] == win))
+ shuffle = 1;
+ }
+
+ if (shuffle)
+ {
+ Ecore_X_Window *t;
+
+ _ecore_xcb_button_grabs_num--;
+ if (_ecore_xcb_button_grabs_num <= 0)
+ {
+ free(_ecore_xcb_button_grabs);
+ _ecore_xcb_button_grabs = NULL;
+ return;
+ }
+
+ t = realloc(_ecore_xcb_button_grabs,
+ _ecore_xcb_button_grabs_num * sizeof(Ecore_X_Window));
+ if (!t) return;
+ _ecore_xcb_button_grabs = t;
+ }
}
}
-/**
- * Get the ignore list
- * @param num number of windows in the list
- * @return list of windows to ignore
- */
-EAPI Ecore_X_Window *
-ecore_x_window_ignore_list(int *num)
+void
+_ecore_xcb_window_key_grab_remove(Ecore_X_Window win)
{
- if (num) *num = ignore_num;
- return ignore_list;
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ if (_ecore_xcb_key_grabs_num > 0)
+ {
+ int i = 0, shuffle = 0;
+
+ for (i = 0; i < _ecore_xcb_key_grabs_num; i++)
+ {
+ if (shuffle)
+ _ecore_xcb_key_grabs[i - 1] = _ecore_xcb_key_grabs[i];
+
+ if ((!shuffle) && (_ecore_xcb_key_grabs[i] == win))
+ shuffle = 1;
+ }
+
+ if (shuffle)
+ {
+ Ecore_X_Window *t;
+
+ _ecore_xcb_key_grabs_num--;
+ if (_ecore_xcb_key_grabs_num <= 0)
+ {
+ free(_ecore_xcb_key_grabs);
+ _ecore_xcb_key_grabs = NULL;
+ return;
+ }
+
+ t = realloc(_ecore_xcb_key_grabs,
+ _ecore_xcb_key_grabs_num * sizeof(Ecore_X_Window));
+ if (!t) return;
+ _ecore_xcb_key_grabs = t;
+ }
+ }
}
-/**
- * Retrieves the size of the given window.
- * @param win The given window.
- * @param w Pointer to an integer into which the width is to be stored.
- * @param h Pointer to an integer into which the height is to be stored.
- *
- * To use this function, you must call before, and in order,
- * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
- * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
- * @ingroup Ecore_X_Window_Geometry_Group
- */
-EAPI void
-ecore_x_window_size_get(Ecore_X_Window window,
- int *width,
- int *height)
+void
+_ecore_xcb_window_grab_allow_events(Ecore_X_Window event_win,
+ Ecore_X_Window child_win,
+ int type,
+ void *event,
+ Ecore_X_Time timestamp)
{
- if (window == 0)
- window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+ int i = 0;
+
+ LOGFN(__FILE__, __LINE__, __FUNCTION__);
+ CHECK_XCB_CONN;
+
+ for (i = 0; i < _ecore_xcb_button_grabs_num; i++)
+ {
+ if ((_ecore_xcb_button_grabs[i] == event_win) ||
+ (_ecore_xcb_button_grabs[i] == child_win))
+ {
+ Eina_Bool replay = EINA_FALSE;
- ecore_x_drawable_geometry_get(window, NULL, NULL, width, height);
+ if (_ecore_xcb_window_grab_replay_func)
+ {
+ replay =
+ _ecore_xcb_window_grab_replay_func(_ecore_xcb_window_grab_replay_data,
+ type, event);
+ }
+ if (replay)
+ {
+ xcb_allow_events(_ecore_xcb_conn,
+ XCB_ALLOW_REPLAY_POINTER, timestamp);
+ }
+ else
+ {
+ xcb_allow_events(_ecore_xcb_conn,
+ XCB_ALLOW_ASYNC_POINTER, timestamp);
+ }
+ break;
+ }
+ }
}
-/**
- * Retrieves the geometry of the given window.
- * @param win The given window.
- * @param x Pointer to an integer in which the X position is to be stored.
- * @param y Pointer to an integer in which the Y position is to be stored.
- * @param w Pointer to an integer in which the width is to be stored.
- * @param h Pointer to an integer in which the height is to be stored.
- *
- * To use this function, you must call before, and in order,
- * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
- * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
- * @ingroup Ecore_X_Window_Geometry_Group
- */
-EAPI void
-ecore_x_window_geometry_get(Ecore_X_Window window,
- int *x,
- int *y,
- int *width,
- int *height)
+static int
+_ecore_xcb_window_modifiers_get(unsigned int state)
{
- if (!window)
- window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
-
- ecore_x_drawable_geometry_get(window, x, y, width, height);
+ int xmodifiers = 0;
+
+ if (state & ECORE_EVENT_MODIFIER_SHIFT)
+ xmodifiers |= ECORE_X_MODIFIER_SHIFT;
+ if (state & ECORE_EVENT_MODIFIER_CTRL)
+ xmodifiers |= ECORE_X_MODIFIER_CTRL;
+ if (state & ECORE_EVENT_MODIFIER_ALT)
+ xmodifiers |= ECORE_X_MODIFIER_ALT;
+ if (state & ECORE_EVENT_MODIFIER_WIN)
+ xmodifiers |= ECORE_X_MODIFIER_WIN;
+ if (state & ECORE_EVENT_MODIFIER_ALTGR)
+ xmodifiers |= ECORE_X_MODIFIER_ALTGR;
+ if (state & ECORE_EVENT_LOCK_SCROLL)
+ xmodifiers |= ECORE_X_LOCK_SCROLL;
+ if (state & ECORE_EVENT_LOCK_NUM)
+ xmodifiers |= ECORE_X_LOCK_NUM;
+ if (state & ECORE_EVENT_LOCK_CAPS)
+ xmodifiers |= ECORE_X_LOCK_CAPS;
+ if (state & ECORE_EVENT_LOCK_SHIFT)
+ xmodifiers |= ECORE_X_LOCK_SHIFT;
+
+ return xmodifiers;
}
-/**
- * Retrieves the width of the border of the given window.
- * @param win The given window.
- * @return Width of the border of @p win.
- * @ingroup Ecore_X_Window_Geometry_Group
- */
-EAPI int
-ecore_x_window_border_width_get(Ecore_X_Window win)
+static xcb_visualtype_t *
+_ecore_xcb_window_find_visual_by_id(xcb_visualid_t id)
{
- /* doesn't make sense to call this on a root window */
- if (!win)
- return 0;
+ xcb_depth_iterator_t diter;
+ xcb_visualtype_iterator_t viter;
- return ecore_x_drawable_border_width_get(win);
+ CHECK_XCB_CONN;
+ diter = xcb_screen_allowed_depths_iterator(_ecore_xcb_screen);
+ for (; diter.rem; xcb_depth_next(&diter))
+ {
+ viter = xcb_depth_visuals_iterator(diter.data);
+ for (; viter.rem; xcb_visualtype_next(&viter))
+ {
+ if (viter.data->visual_id == id)
+ return viter.data;
+ }
+ }
+ return 0;
}
-/**
- * Retrieves the depth of the given window.
- * @param win The given window.
- * @return Depth of the window.
- */
-EAPI int
-ecore_x_window_depth_get(Ecore_X_Window win)
+#ifdef ECORE_XCB_XPRINT
+static xcb_screen_t *
+_ecore_xcb_window_screen_of_display(int screen)
{
- return ecore_x_drawable_depth_get(win);
+ xcb_screen_iterator_t iter;
+
+ CHECK_XCB_CONN;
+ iter = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
+ for (; iter.rem; --screen, xcb_screen_next(&iter))
+ if (screen == 0)
+ return iter.data;
+
+ return NULL;
}
+
+#endif