From: devilhorns Date: Tue, 2 Aug 2011 01:32:10 +0000 (+0000) Subject: Ecore_Xcb: Allow ecore_xcb to support unstable/development version(s) of xcb. X-Git-Tag: build/2012-07-04.173327~974 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=25f417e82c8375b3b8cff7b6fe51e5d7978745eb;p=profile%2Fivi%2Fecore.git Ecore_Xcb: Allow ecore_xcb to support unstable/development version(s) of xcb. (based on patch from Boris Faure) NB: This is untested/unsupported code. Ymmv, but using/compiling ecore_x with versions of xcb > 0.3.6 is not supported yet (until such time that standard distros support 0.3.8 out of the box). git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@61971 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/configure.ac b/configure.ac index fa7ab9d..124a9ab 100644 --- a/configure.ac +++ b/configure.ac @@ -783,11 +783,18 @@ if test "x$want_ecore_x_xcb" = "xyes" ; then fi fi -## x11-xcb - PKG_CHECK_MODULES(XCB, x11-xcb xcb xcb-shm xcb-icccm xcb-image xcb-keysyms, + PKG_CHECK_MODULES(XCB, x11-xcb xcb xcb-shm xcb-event xcb-icccm >= 0.3.8 xcb-util >= 0.3.8 xcb-image xcb-keysyms, [ have_ecore_x_xcb="yes" - requirements_ecore_x="x11-xcb xcb xcb-shm xcb-icccm xcb-image xcb-keysyms ${requirements_ecore_x}" ], - [ have_ecore_x_xcb="no" ]) + requirements_ecore_x="x11-xcb xcb xcb-shm xcb-event xcb-icccm xcb-util xcb-image xcb-keysyms ${requirements_ecore_x}" + ], + [ + PKG_CHECK_MODULES(XCB, x11-xcb xcb xcb-event xcb-shm xcb-icccm xcb-image xcb-keysyms, + [ have_ecore_x_xcb="yes" + AC_DEFINE(OLD_XCB_VERSION, 1, [xcb version]) + requirements_ecore_x="x11-xcb xcb xcb-event xcb-shm xcb-icccm xcb-image xcb-keysyms ${requirements_ecore_x}" ], + [ have_ecore_x_xcb="no" ]) + ], + [have_ecore_x_xcb="no" ]) if test "x$have_ecore_x_xcb" = "xyes" ; then diff --git a/src/lib/ecore_x/xcb/ecore_xcb_error.c b/src/lib/ecore_x/xcb/ecore_xcb_error.c index c58c13c..f5a457e 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_error.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_error.c @@ -67,10 +67,18 @@ _ecore_xcb_error_handle(xcb_generic_error_t *err) WRN("Got Error:"); WRN("\tEvent: %s", xcb_event_get_request_label(err->major_code)); WRN("\tError: %s", xcb_event_get_error_label(err->error_code)); + +#ifdef OLD_XCB_VERSION if (err->error_code == XCB_EVENT_ERROR_BAD_VALUE) WRN("\tBad Value: %d", ((xcb_value_error_t *)err)->bad_value); else if (err->error_code == XCB_EVENT_ERROR_BAD_WINDOW) WRN("\tBad Window: %d", ((xcb_window_error_t *)err)->bad_value); +#else + if (err->error_code == XCB_VALUE) + WRN("\tBad Value: %d", ((xcb_value_error_t *)err)->bad_value); + else if (err->error_code == XCB_WINDOW) + WRN("\tBad Window: %d", ((xcb_window_error_t *)err)->bad_value); +#endif _error_request_code = err->sequence; _error_code = err->error_code; diff --git a/src/lib/ecore_x/xcb/ecore_xcb_events.c b/src/lib/ecore_x/xcb/ecore_xcb_events.c index eb2c959..4186a2c 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_events.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_events.c @@ -240,6 +240,7 @@ _ecore_xcb_events_handle(xcb_generic_event_t *ev) * so trap those cases and ignore. We also ignore BadValue from * xcb_grab/ungrab_button (happens when we are using any_mod) * and a few others */ +#ifdef OLD_XCB_VERSION if (err->error_code == XCB_EVENT_ERROR_BAD_WINDOW) return; else if (err->error_code == XCB_EVENT_ERROR_BAD_MATCH) { @@ -254,7 +255,22 @@ _ecore_xcb_events_handle(xcb_generic_event_t *ev) (err->major_code == XCB_UNGRAB_BUTTON)) return; } - +#else + if (err->error_code == XCB_WINDOW) return; + else if (err->error_code == XCB_MATCH) + { + if ((err->major_code == XCB_SET_INPUT_FOCUS) || + (err->major_code == XCB_CONFIGURE_WINDOW)) + return; + } + else if (err->error_code == XCB_VALUE) + { + if ((err->major_code == XCB_KILL_CLIENT) || + (err->major_code == XCB_GRAB_BUTTON) || + (err->major_code == XCB_UNGRAB_BUTTON)) + return; + } +#endif /* WRN("Got Event Error:"); */ /* WRN("\tMajor Code: %d", err->major_code); */ /* WRN("\tMinor Code: %d", err->minor_code); */ @@ -1627,8 +1643,13 @@ _ecore_xcb_event_handle_client_message(xcb_generic_event_t *event) e->source = ev->data.data32[3]; ecore_event_add(ECORE_X_EVENT_WINDOW_STATE_REQUEST, e, NULL, NULL); } +#ifdef OLD_XCB_VERSION else if ((ev->type == ECORE_X_ATOM_WM_CHANGE_STATE) && (ev->format == 32) && (ev->data.data32[0] == XCB_WM_STATE_ICONIC)) +#else + else if ((ev->type == ECORE_X_ATOM_WM_CHANGE_STATE) && (ev->format == 32) && + (ev->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC)) +#endif { Ecore_X_Event_Window_State_Request *e; diff --git a/src/lib/ecore_x/xcb/ecore_xcb_icccm.c b/src/lib/ecore_x/xcb/ecore_xcb_icccm.c index 6c86686..e0fad37 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_icccm.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_icccm.c @@ -161,26 +161,42 @@ EAPI char * ecore_x_icccm_title_get(Ecore_X_Window win) { xcb_get_property_cookie_t cookie; +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_t prop; +#else + xcb_icccm_get_text_property_reply_t prop; +#endif uint8_t ret = 0; char *title = NULL; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!win) return NULL; - +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_name_unchecked(_ecore_xcb_conn, win); ret = xcb_get_wm_name_reply(_ecore_xcb_conn, cookie, &prop, NULL); +#else + cookie = xcb_icccm_get_wm_name_unchecked(_ecore_xcb_conn, win); + ret = xcb_icccm_get_wm_name_reply(_ecore_xcb_conn, cookie, &prop, NULL); +#endif if (ret == 0) return NULL; if (prop.name_len < 1) { +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); +#else + xcb_icccm_get_text_property_reply_wipe(&prop); +#endif return NULL; } if (!(title = malloc((prop.name_len + 1) * sizeof(char *)))) { +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); +#else + xcb_icccm_get_text_property_reply_wipe(&prop); +#endif return NULL; } memcpy(title, prop.name, sizeof(char *) * prop.name_len); @@ -210,7 +226,11 @@ ecore_x_icccm_title_get(Ecore_X_Window win) } } +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); +#else + xcb_icccm_get_text_property_reply_wipe(&prop); +#endif return title; } @@ -238,14 +258,23 @@ ecore_x_icccm_title_set(Ecore_X_Window win, const char *title) if (ret) { +#ifdef OLD_XCB_VERSION xcb_set_wm_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, strlen(prop.value), prop.value); - +#else + xcb_icccm_set_wm_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, 8, + strlen(prop.value), prop.value); +#endif if (prop.value) free(prop.value); } else - xcb_set_wm_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, - strlen(title), title); +#ifdef OLD_XCB_VERSION + xcb_set_wm_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, + strlen(title), title); +#else + xcb_icccm_set_wm_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, 8, + strlen(title), title); +#endif free(list[0]); } @@ -261,7 +290,11 @@ EAPI void ecore_x_icccm_name_class_get(Ecore_X_Window win, char **name, char **class) { xcb_get_property_cookie_t cookie; +#ifdef OLD_XCB_VERSION xcb_get_wm_class_reply_t prop; +#else + xcb_icccm_get_wm_class_reply_t prop; +#endif uint8_t ret = 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -269,14 +302,23 @@ ecore_x_icccm_name_class_get(Ecore_X_Window win, char **name, char **class) if (name) *name = NULL; if (class) *class = NULL; +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_class_unchecked(_ecore_xcb_conn, win); ret = xcb_get_wm_class_reply(_ecore_xcb_conn, cookie, &prop, NULL); +#else + cookie = xcb_icccm_get_wm_class_unchecked(_ecore_xcb_conn, win); + ret = xcb_icccm_get_wm_class_reply(_ecore_xcb_conn, cookie, &prop, NULL); +#endif if (ret == 0) return; if (name) *name = strdup(prop.instance_name); if (class) *class = strdup(prop.class_name); +#ifdef OLD_XCB_VERSION xcb_get_wm_class_reply_wipe(&prop); +#else + xcb_icccm_get_wm_class_reply_wipe(&prop); +#endif } /** @@ -361,8 +403,13 @@ ecore_x_icccm_transient_for_get(Ecore_X_Window win) LOGFN(__FILE__, __LINE__, __FUNCTION__); +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_transient_for_unchecked(_ecore_xcb_conn, win); xcb_get_wm_transient_for_reply(_ecore_xcb_conn, cookie, &forwin, NULL); +#else + cookie = xcb_icccm_get_wm_transient_for_unchecked(_ecore_xcb_conn, win); + xcb_icccm_get_wm_transient_for_reply(_ecore_xcb_conn, cookie, &forwin, NULL); +#endif return forwin; } @@ -452,6 +499,7 @@ ecore_x_icccm_state_get(Ecore_X_Window win) } prop = (uint8_t *)xcb_get_property_value(reply); +#ifdef OLD_XCB_VERSION switch (prop[0]) { case XCB_WM_STATE_WITHDRAWN: @@ -466,6 +514,22 @@ ecore_x_icccm_state_get(Ecore_X_Window win) default: break; } +#else + switch (prop[0]) + { + case XCB_ICCCM_WM_STATE_WITHDRAWN: + hint = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN; + break; + case XCB_ICCCM_WM_STATE_NORMAL: + hint = ECORE_X_WINDOW_STATE_HINT_NORMAL; + break; + case XCB_ICCCM_WM_STATE_ICONIC: + hint = ECORE_X_WINDOW_STATE_HINT_ICONIC; + break; + default: + break; + } +#endif free(reply); return hint; @@ -474,10 +538,15 @@ ecore_x_icccm_state_get(Ecore_X_Window win) EAPI void ecore_x_icccm_state_set(Ecore_X_Window win, Ecore_X_Window_State_Hint state) { +#ifdef OLD_XCB_VERSION xcb_wm_hints_t hints; +#else + xcb_icccm_wm_hints_t hints; +#endif LOGFN(__FILE__, __LINE__, __FUNCTION__); +#ifdef OLD_XCB_VERSION xcb_wm_hints_set_none(&hints); hints.flags = XCB_WM_HINT_STATE; @@ -490,6 +559,21 @@ ecore_x_icccm_state_set(Ecore_X_Window win, Ecore_X_Window_State_Hint state) xcb_wm_hints_set_iconic(&hints); xcb_set_wm_hints(_ecore_xcb_conn, win, &hints); +#else + xcb_icccm_wm_hints_set_none(&hints); + + hints.flags = XCB_ICCCM_WM_HINT_STATE; + + if (state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN) + xcb_icccm_wm_hints_set_withdrawn(&hints); + else if (state == ECORE_X_WINDOW_STATE_HINT_NORMAL) + xcb_icccm_wm_hints_set_normal(&hints); + else if (state == ECORE_X_WINDOW_STATE_HINT_ICONIC) + xcb_icccm_wm_hints_set_iconic(&hints); + + xcb_icccm_set_wm_hints(_ecore_xcb_conn, win, &hints); +#endif + } EAPI void @@ -504,10 +588,15 @@ ecore_x_icccm_delete_window_send(Ecore_X_Window win, Ecore_X_Time t) EAPI void ecore_x_icccm_hints_set(Ecore_X_Window win, Eina_Bool accepts_focus, Ecore_X_Window_State_Hint initial_state, Ecore_X_Pixmap icon_pixmap, Ecore_X_Pixmap icon_mask, Ecore_X_Window icon_window, Ecore_X_Window window_group, Eina_Bool is_urgent) { +#ifdef OLD_XCB_VERSION xcb_wm_hints_t hints; +#else + xcb_icccm_wm_hints_t hints; +#endif LOGFN(__FILE__, __LINE__, __FUNCTION__); +#ifdef OLD_XCB_VERSION xcb_wm_hints_set_none(&hints); xcb_wm_hints_set_input(&hints, accepts_focus); @@ -525,13 +614,41 @@ ecore_x_icccm_hints_set(Ecore_X_Window win, Eina_Bool accepts_focus, Ecore_X_Win if (is_urgent) xcb_wm_hints_set_urgency(&hints); xcb_set_wm_hints(_ecore_xcb_conn, win, &hints); +#else + xcb_icccm_wm_hints_set_none(&hints); + xcb_icccm_wm_hints_set_input(&hints, accepts_focus); + + if (initial_state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN) + xcb_icccm_wm_hints_set_withdrawn(&hints); + else if (initial_state == ECORE_X_WINDOW_STATE_HINT_NORMAL) + xcb_icccm_wm_hints_set_normal(&hints); + else if (initial_state == ECORE_X_WINDOW_STATE_HINT_ICONIC) + xcb_icccm_wm_hints_set_iconic(&hints); + + if (icon_pixmap != 0) + xcb_icccm_wm_hints_set_icon_pixmap(&hints, icon_pixmap); + if (icon_mask != 0) + xcb_icccm_wm_hints_set_icon_mask(&hints, icon_mask); + if (icon_window != 0) + xcb_icccm_wm_hints_set_icon_window(&hints, icon_window); + if (window_group != 0) + xcb_icccm_wm_hints_set_window_group(&hints, window_group); + if (is_urgent) + xcb_icccm_wm_hints_set_urgency(&hints); + + xcb_icccm_set_wm_hints(_ecore_xcb_conn, win, &hints); +#endif } EAPI Eina_Bool ecore_x_icccm_hints_get(Ecore_X_Window win, Eina_Bool *accepts_focus, Ecore_X_Window_State_Hint *initial_state, Ecore_X_Pixmap *icon_pixmap, Ecore_X_Pixmap *icon_mask, Ecore_X_Window *icon_window, Ecore_X_Window *window_group, Eina_Bool *is_urgent) { xcb_get_property_cookie_t cookie; +#ifdef OLD_XCB_VERSION xcb_wm_hints_t hints; +#else + xcb_icccm_wm_hints_t hints; +#endif uint8_t ret = 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -544,12 +661,22 @@ ecore_x_icccm_hints_get(Ecore_X_Window win, Eina_Bool *accepts_focus, Ecore_X_Wi if (window_group) *window_group = 0; if (is_urgent) *is_urgent = EINA_FALSE; +#ifdef OLD_XCB_VERSION xcb_wm_hints_set_none(&hints); cookie = xcb_get_wm_hints_unchecked(_ecore_xcb_conn, win); ret = xcb_get_wm_hints_reply(_ecore_xcb_conn, cookie, &hints, NULL); +#else + xcb_icccm_wm_hints_set_none(&hints); + cookie = xcb_icccm_get_wm_hints_unchecked(_ecore_xcb_conn, win); + ret = xcb_icccm_get_wm_hints_reply(_ecore_xcb_conn, cookie, &hints, NULL); +#endif if (!ret) return EINA_FALSE; +#ifdef OLD_XCB_VERSION if ((hints.flags & XCB_WM_HINT_INPUT) && (accepts_focus)) +#else + if ((hints.flags & XCB_ICCCM_WM_HINT_INPUT) && (accepts_focus)) +#endif { if (hints.input) *accepts_focus = EINA_TRUE; @@ -557,6 +684,7 @@ ecore_x_icccm_hints_get(Ecore_X_Window win, Eina_Bool *accepts_focus, Ecore_X_Wi *accepts_focus = EINA_FALSE; } +#ifdef OLD_XCB_VERSION if ((hints.flags & XCB_WM_HINT_STATE) && (initial_state)) { if (hints.initial_state == XCB_WM_STATE_WITHDRAWN) @@ -581,6 +709,32 @@ ecore_x_icccm_hints_get(Ecore_X_Window win, Eina_Bool *accepts_focus, Ecore_X_Wi if ((hints.flags & XCB_WM_HINT_X_URGENCY) && (is_urgent)) *is_urgent = EINA_TRUE; +#else + if ((hints.flags & XCB_ICCCM_WM_HINT_STATE) && (initial_state)) + { + if (hints.initial_state == XCB_ICCCM_WM_STATE_WITHDRAWN) + *initial_state = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN; + else if (hints.initial_state == XCB_ICCCM_WM_STATE_NORMAL) + *initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL; + else if (hints.initial_state == XCB_ICCCM_WM_STATE_ICONIC) + *initial_state = ECORE_X_WINDOW_STATE_HINT_ICONIC; + } + + if ((hints.flags & XCB_ICCCM_WM_HINT_ICON_PIXMAP) && (icon_pixmap)) + *icon_pixmap = hints.icon_pixmap; + + if ((hints.flags & XCB_ICCCM_WM_HINT_ICON_MASK) && (icon_mask)) + *icon_mask = hints.icon_mask; + + if ((hints.flags & XCB_ICCCM_WM_HINT_ICON_WINDOW) && (icon_window)) + *icon_window = hints.icon_window; + + if ((hints.flags & XCB_ICCCM_WM_HINT_WINDOW_GROUP) && (window_group)) + *window_group = hints.window_group; + + if ((hints.flags & XCB_ICCCM_WM_HINT_X_URGENCY) && (is_urgent)) + *is_urgent = EINA_TRUE; +#endif return EINA_TRUE; } @@ -596,7 +750,11 @@ EAPI char * ecore_x_icccm_icon_name_get(Ecore_X_Window win) { xcb_get_property_cookie_t cookie; +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_t prop; +#else + xcb_icccm_get_text_property_reply_t prop; +#endif uint8_t ret = 0; char *tmp = NULL; @@ -604,19 +762,32 @@ ecore_x_icccm_icon_name_get(Ecore_X_Window win) if (!win) return NULL; +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_icon_name_unchecked(_ecore_xcb_conn, win); ret = xcb_get_wm_icon_name_reply(_ecore_xcb_conn, cookie, &prop, NULL); +#else + cookie = xcb_icccm_get_wm_icon_name_unchecked(_ecore_xcb_conn, win); + ret = xcb_icccm_get_wm_icon_name_reply(_ecore_xcb_conn, cookie, &prop, NULL); +#endif if (ret == 0) return NULL; if (prop.name_len < 1) { +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); +#else + xcb_icccm_get_text_property_reply_wipe(&prop); +#endif return NULL; } if (!(tmp = malloc((prop.name_len + 1) * sizeof(char *)))) { +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); +#else + xcb_icccm_get_text_property_reply_wipe(&prop); +#endif return NULL; } memcpy(tmp, prop.name, sizeof(char *) * prop.name_len); @@ -646,7 +817,11 @@ ecore_x_icccm_icon_name_get(Ecore_X_Window win) } } +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); +#else + xcb_icccm_get_text_property_reply_wipe(&prop); +#endif return tmp; } @@ -681,14 +856,23 @@ ecore_x_icccm_icon_name_set(Ecore_X_Window win, const char *name) if (ret) { +#ifdef OLD_XCB_VERSION xcb_set_wm_icon_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, strlen(prop.value), prop.value); - +#else + xcb_icccm_set_wm_icon_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, + 8, strlen(prop.value), prop.value); +#endif if (prop.value) free(prop.value); } else +#ifdef OLD_XCB_VERSION xcb_set_wm_icon_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, strlen(name), name); +#else + xcb_icccm_set_wm_icon_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, + 8, strlen(name), name); +#endif free(list[0]); } @@ -709,7 +893,11 @@ ecore_x_icccm_iconic_request_send(Ecore_X_Window win, Ecore_X_Window root) ev.format = 32; ev.window = win; ev.type = ECORE_X_ATOM_WM_CHANGE_STATE; +#ifdef OLD_XCB_VERSION ev.data.data32[0] = XCB_WM_STATE_ICONIC; +#else + ev.data.data32[0] = XCB_ICCCM_WM_STATE_ICONIC; +#endif xcb_send_event(_ecore_xcb_conn, 0, root, (XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | @@ -728,15 +916,24 @@ ecore_x_icccm_protocol_set(Ecore_X_Window win, Ecore_X_WM_Protocol protocol, Ein { Ecore_X_Atom proto; xcb_get_property_cookie_t cookie; +#ifdef OLD_XCB_VERSION xcb_get_wm_protocols_reply_t protos; +#else + xcb_icccm_get_wm_protocols_reply_t protos; +#endif int i = 0, count = 0, set = 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (protocol >= ECORE_X_WM_PROTOCOL_NUM) return; proto = _ecore_xcb_atoms_wm_protocol[protocol]; +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_protocols_unchecked(_ecore_xcb_conn, win, proto); if (!xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protos, NULL)) +#else + cookie = xcb_icccm_get_wm_protocols_unchecked(_ecore_xcb_conn, win, proto); + if (!xcb_icccm_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protos, NULL)) +#endif count = 0; else count = protos.atoms_len; @@ -762,9 +959,15 @@ ecore_x_icccm_protocol_set(Ecore_X_Window win, Ecore_X_WM_Protocol protocol, Ein for (i = 0; i < count; i++) atoms[i] = protos.atoms[i]; atoms[count] = proto; +#ifdef OLD_XCB_VERSION xcb_set_wm_protocols(_ecore_xcb_conn, ECORE_X_ATOM_WM_PROTOCOLS, win, count, atoms); +#else + xcb_icccm_set_wm_protocols(_ecore_xcb_conn, + ECORE_X_ATOM_WM_PROTOCOLS, + win, count, atoms); +#endif free(atoms); } } @@ -782,9 +985,16 @@ ecore_x_icccm_protocol_set(Ecore_X_Window win, Ecore_X_WM_Protocol protocol, Ein for (j = (i + 1); j < count; j++) protos.atoms[j - 1] = protos.atoms[j]; if (count > 1) +#ifdef OLD_XCB_VERSION xcb_set_wm_protocols(_ecore_xcb_conn, ECORE_X_ATOM_WM_PROTOCOLS, win, count - 1, protos.atoms); +#else + xcb_icccm_set_wm_protocols(_ecore_xcb_conn, + ECORE_X_ATOM_WM_PROTOCOLS, + win, count - 1, + protos.atoms); +#endif else ecore_x_window_prop_property_del(win, ECORE_X_ATOM_WM_PROTOCOLS); @@ -794,7 +1004,11 @@ ecore_x_icccm_protocol_set(Ecore_X_Window win, Ecore_X_WM_Protocol protocol, Ein } } +#ifdef OLD_XCB_VERSION xcb_get_wm_protocols_reply_wipe(&protos); +#else + xcb_icccm_get_wm_protocols_reply_wipe(&protos); +#endif } /** @@ -809,7 +1023,11 @@ ecore_x_icccm_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol protocol) Ecore_X_Atom proto; Eina_Bool ret = EINA_FALSE; xcb_get_property_cookie_t cookie; +#ifdef OLD_XCB_VERSION xcb_get_wm_protocols_reply_t reply; +#else + xcb_icccm_get_wm_protocols_reply_t reply; +#endif uint8_t val = 0; unsigned int i = 0; @@ -818,8 +1036,13 @@ ecore_x_icccm_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol protocol) if (protocol >= ECORE_X_WM_PROTOCOL_NUM) return EINA_FALSE; proto = _ecore_xcb_atoms_wm_protocol[protocol]; +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_protocols_unchecked(_ecore_xcb_conn, win, proto); val = xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &reply, NULL); +#else + cookie = xcb_icccm_get_wm_protocols_unchecked(_ecore_xcb_conn, win, proto); + val = xcb_icccm_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &reply, NULL); +#endif if (!val) return EINA_FALSE; for (i = 0; i < reply.atoms_len; i++) @@ -829,7 +1052,12 @@ ecore_x_icccm_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol protocol) break; } +#ifdef OLD_XCB_VERSION xcb_get_wm_protocols_reply_wipe(&reply); +#else + xcb_icccm_get_wm_protocols_reply_wipe(&reply); +#endif + return ret; } @@ -845,8 +1073,13 @@ ecore_x_icccm_protocol_atoms_set(Ecore_X_Window win, Ecore_X_Atom *protos, int n LOGFN(__FILE__, __LINE__, __FUNCTION__); if (num > 0) +#ifdef OLD_XCB_VERSION xcb_set_wm_protocols(_ecore_xcb_conn, ECORE_X_ATOM_WM_PROTOCOLS, win, num, protos); +#else + xcb_icccm_set_wm_protocols(_ecore_xcb_conn, ECORE_X_ATOM_WM_PROTOCOLS, + win, num, protos); +#endif else ecore_x_window_prop_property_del(win, ECORE_X_ATOM_WM_PROTOCOLS); @@ -879,28 +1112,51 @@ ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win, Eina_Bool *request_pos, Eco if (min_aspect) *min_aspect = mina; if (max_aspect) *max_aspect = maxa; +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_normal_hints_unchecked(_ecore_xcb_conn, win); ret = xcb_get_wm_normal_hints_reply(_ecore_xcb_conn, cookie, &hints, NULL); +#else + cookie = xcb_icccm_get_wm_normal_hints_unchecked(_ecore_xcb_conn, win); + ret = xcb_icccm_get_wm_normal_hints_reply(_ecore_xcb_conn, cookie, + &hints, NULL); +#endif if (!ret) return EINA_FALSE; +#ifdef OLD_XCB_VERSION if ((hints.flags & XCB_SIZE_HINT_US_POSITION) || (hints.flags & XCB_SIZE_HINT_P_POSITION)) +#else + if ((hints.flags & XCB_ICCCM_SIZE_HINT_US_POSITION) || + (hints.flags & XCB_ICCCM_SIZE_HINT_P_POSITION)) +#endif { if (request_pos) *request_pos = EINA_TRUE; } +#ifdef OLD_XCB_VERSION if (hints.flags & XCB_SIZE_HINT_P_WIN_GRAVITY) +#else + if (hints.flags & XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY) +#endif { if (gravity) *gravity = hints.win_gravity; } +#ifdef OLD_XCB_VERSION if (hints.flags & XCB_SIZE_HINT_P_MIN_SIZE) +#else + if (hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE) +#endif { minw = hints.min_width; minh = hints.min_height; } +#ifdef OLD_XCB_VERSION if (hints.flags & XCB_SIZE_HINT_P_MAX_SIZE) +#else + if (hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE) +#endif { maxw = hints.max_width; maxh = hints.max_height; @@ -908,7 +1164,11 @@ ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win, Eina_Bool *request_pos, Eco if (maxh < minh) maxh = minh; } +#ifdef OLD_XCB_VERSION if (hints.flags & XCB_SIZE_HINT_BASE_SIZE) +#else + if (hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE) +#endif { basew = hints.base_width; baseh = hints.base_height; @@ -916,7 +1176,11 @@ ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win, Eina_Bool *request_pos, Eco if (baseh > minh) minh = baseh; } +#ifdef OLD_XCB_VERSION if (hints.flags & XCB_SIZE_HINT_P_RESIZE_INC) +#else + if (hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC) +#endif { stepx = hints.width_inc; stepy = hints.height_inc; @@ -924,7 +1188,11 @@ ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win, Eina_Bool *request_pos, Eco if (stepy < 1) stepy = 1; } +#ifdef OLD_XCB_VERSION if (hints.flags & XCB_SIZE_HINT_P_ASPECT) +#else + if (hints.flags & XCB_ICCCM_SIZE_HINT_P_ASPECT) +#endif { if (hints.min_aspect_den > 0) mina = ((double)hints.min_aspect_num) / ((double)hints.min_aspect_den); @@ -956,11 +1224,19 @@ ecore_x_icccm_size_pos_hints_set(Ecore_X_Window win, Eina_Bool request_pos, Ecor LOGFN(__FILE__, __LINE__, __FUNCTION__); +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_normal_hints_unchecked(_ecore_xcb_conn, win); ret = xcb_get_wm_normal_hints_reply(_ecore_xcb_conn, cookie, &hints, NULL); +#else + cookie = xcb_icccm_get_wm_normal_hints_unchecked(_ecore_xcb_conn, win); + ret = xcb_icccm_get_wm_normal_hints_reply(_ecore_xcb_conn, cookie, + &hints, NULL); +#endif if (!ret) memset(&hints, 0, sizeof(xcb_size_hints_t)); hints.flags = 0; + +#ifdef OLD_XCB_VERSION if (request_pos) hints.flags |= XCB_SIZE_HINT_US_POSITION; @@ -980,6 +1256,27 @@ ecore_x_icccm_size_pos_hints_set(Ecore_X_Window win, Eina_Bool request_pos, Ecor (int32_t)(max_aspect * 10000), 10000); xcb_set_wm_normal_hints(_ecore_xcb_conn, win, &hints); +#else + if (request_pos) + hints.flags |= XCB_ICCCM_SIZE_HINT_US_POSITION; + + if (gravity != ECORE_X_GRAVITY_NW) + xcb_icccm_size_hints_set_win_gravity(&hints, gravity); + if ((min_w > 0) || (min_h > 0)) + xcb_icccm_size_hints_set_min_size(&hints, min_w, min_h); + if ((max_w > 0) || (max_h > 0)) + xcb_icccm_size_hints_set_max_size(&hints, max_w, max_h); + if ((base_w > 0) || (base_h > 0)) + xcb_icccm_size_hints_set_base_size(&hints, base_w, base_h); + if ((step_x > 1) || (step_y > 1)) + xcb_icccm_size_hints_set_resize_inc(&hints, step_x, step_y); + if ((min_aspect > 0.0) || (max_aspect > 0.0)) + xcb_icccm_size_hints_set_aspect(&hints, + (int32_t)(min_aspect * 10000), 10000, + (int32_t)(max_aspect * 10000), 10000); + + xcb_icccm_set_wm_normal_hints(_ecore_xcb_conn, win, &hints); +#endif } EAPI void @@ -1019,26 +1316,44 @@ EAPI char * ecore_x_icccm_client_machine_get(Ecore_X_Window win) { xcb_get_property_cookie_t cookie; +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_t prop; +#else + xcb_icccm_get_text_property_reply_t prop; +#endif uint8_t ret = 0; char *tmp = NULL; LOGFN(__FILE__, __LINE__, __FUNCTION__); +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_client_machine_unchecked(_ecore_xcb_conn, win); ret = xcb_get_wm_client_machine_reply(_ecore_xcb_conn, cookie, &prop, NULL); +#else + cookie = xcb_icccm_get_wm_client_machine_unchecked(_ecore_xcb_conn, win); + ret = xcb_icccm_get_wm_client_machine_reply(_ecore_xcb_conn, cookie, + &prop, NULL); +#endif if (ret == 0) return NULL; tmp = malloc((prop.name_len + 1) * sizeof(char *)); if (!tmp) { +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); +#else + xcb_icccm_get_text_property_reply_wipe(&prop); +#endif return NULL; } memcpy(tmp, prop.name, sizeof(char *) * prop.name_len); tmp[prop.name_len] = '\0'; +#ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); +#else + xcb_icccm_get_text_property_reply_wipe(&prop); +#endif return tmp; } diff --git a/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c b/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c index 9961d45..3fd613c 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c @@ -507,7 +507,11 @@ ecore_x_window_prop_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol proto { Eina_Bool ret = EINA_FALSE; Ecore_X_Atom proto; +#ifdef OLD_XCB_VERSION xcb_get_wm_protocols_reply_t protos; +#else + xcb_icccm_get_wm_protocols_reply_t protos; +#endif xcb_get_property_cookie_t cookie; uint8_t reply; uint32_t count = 0, i = 0; @@ -517,9 +521,16 @@ ecore_x_window_prop_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol proto if (protocol >= ECORE_X_WM_PROTOCOL_NUM) return EINA_FALSE; proto = _ecore_xcb_atoms_wm_protocol[protocol]; +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_protocols_unchecked(_ecore_xcb_conn, win, ECORE_X_ATOM_WM_PROTOCOLS); reply = xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protos, NULL); +#else + cookie = xcb_icccm_get_wm_protocols_unchecked(_ecore_xcb_conn, win, + ECORE_X_ATOM_WM_PROTOCOLS); + reply = xcb_icccm_get_wm_protocols_reply(_ecore_xcb_conn, cookie, + &protos, NULL); +#endif if (!reply) return EINA_FALSE; count = protos.atoms_len; @@ -532,14 +543,22 @@ ecore_x_window_prop_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol proto } } +#ifdef OLD_XCB_VERSION xcb_get_wm_protocols_reply_wipe(&protos); +#else + xcb_icccm_get_wm_protocols_reply_wipe(&protos); +#endif return ret; } EAPI Ecore_X_WM_Protocol * ecore_x_window_prop_protocol_list_get(Ecore_X_Window win, int *num_ret) { +#ifdef OLD_XCB_VERSION xcb_get_wm_protocols_reply_t protos; +#else + xcb_icccm_get_wm_protocols_reply_t protos; +#endif xcb_get_property_cookie_t cookie; uint8_t reply; uint32_t count = 0, i = 0; @@ -551,22 +570,37 @@ ecore_x_window_prop_protocol_list_get(Ecore_X_Window win, int *num_ret) *num_ret = 0; +#ifdef OLD_XCB_VERSION cookie = xcb_get_wm_protocols_unchecked(_ecore_xcb_conn, win, ECORE_X_ATOM_WM_PROTOCOLS); reply = xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protos, NULL); +#else + cookie = xcb_icccm_get_wm_protocols_unchecked(_ecore_xcb_conn, win, + ECORE_X_ATOM_WM_PROTOCOLS); + reply = xcb_icccm_get_wm_protocols_reply(_ecore_xcb_conn, cookie, + &protos, NULL); +#endif if (!reply) return NULL; count = protos.atoms_len; if (count <= 0) { +#ifdef OLD_XCB_VERSION xcb_get_wm_protocols_reply_wipe(&protos); +#else + xcb_icccm_get_wm_protocols_reply_wipe(&protos); +#endif return NULL; } prot_ret = calloc(1, count * sizeof(Ecore_X_WM_Protocol)); if (!prot_ret) { +#ifdef OLD_XCB_VERSION xcb_get_wm_protocols_reply_wipe(&protos); +#else + xcb_icccm_get_wm_protocols_reply_wipe(&protos); +#endif return NULL; } @@ -584,7 +618,11 @@ ecore_x_window_prop_protocol_list_get(Ecore_X_Window win, int *num_ret) if (num_ret) *num_ret = count; +#ifdef OLD_XCB_VERSION xcb_get_wm_protocols_reply_wipe(&protos); +#else + xcb_icccm_get_wm_protocols_reply_wipe(&protos); +#endif return prot_ret; }