window: make window_getstate() asynchronous and rename this function

according to the rest of code.
This commit is contained in:
Arnaud Fontaine 2008-08-13 18:59:34 +02:00
parent 7e15509733
commit 73c4415a0a
4 changed files with 27 additions and 12 deletions

View file

@ -60,6 +60,7 @@ scan(void)
xcb_query_tree_reply_t *tree_r;
xcb_window_t *wins = NULL;
xcb_get_window_attributes_cookie_t *attr_wins = NULL;
xcb_get_property_cookie_t *state_wins = NULL;
xcb_get_geometry_cookie_t **geom_wins = NULL;
xcb_get_window_attributes_reply_t *attr_r;
xcb_get_geometry_reply_t *geom_r;
@ -89,11 +90,16 @@ scan(void)
fatal("E: cannot get tree children");
tree_c_len = xcb_query_tree_children_length(tree_r);
attr_wins = p_new(xcb_get_window_attributes_cookie_t, tree_c_len);
state_wins = p_new(xcb_get_property_cookie_t, tree_c_len);
for(i = 0; i < tree_c_len; i++)
{
attr_wins[i] = xcb_get_window_attributes_unchecked(globalconf.connection,
wins[i]);
state_wins[i] = window_state_get_unchecked(wins[i]);
}
geom_wins = p_new(xcb_get_geometry_cookie_t *, tree_c_len);
for(i = 0; i < tree_c_len; i++)
@ -104,9 +110,10 @@ scan(void)
attr_wins[i],
NULL);
state = window_getstate(wins[i]);
state = window_state_get_reply(state_wins[i]);
has_awesome_prop = xutil_text_prop_get(globalconf.connection, wins[1], _AWESOME_PROPERTIES, NULL, NULL);
has_awesome_prop = xutil_text_prop_get(globalconf.connection, wins[1],
_AWESOME_PROPERTIES, NULL, NULL);
if(!attr_r || attr_r->override_redirect
|| (attr_r->map_state != XCB_MAP_STATE_VIEWABLE && !has_awesome_prop)
@ -123,6 +130,7 @@ scan(void)
*(geom_wins[i]) = xcb_get_geometry_unchecked(globalconf.connection, wins[i]);
}
p_delete(&state_wins);
p_delete(&attr_wins);
for(i = 0; i < tree_c_len; i++)

View file

@ -572,7 +572,7 @@ event_handle_unmapnotify(void *data __attribute__ ((unused)),
{
if(ev->event == xutil_screen_get(connection, c->phys_screen)->root
&& send_event
&& window_getstate(c->win) == XCB_WM_NORMAL_STATE)
&& window_state_get_reply(window_state_get_unchecked(c->win)) == XCB_WM_NORMAL_STATE)
client_unmanage(c);
}
else if((em = xembed_getbywin(globalconf.embedded, ev->window)))

View file

@ -42,23 +42,29 @@ window_setstate(xcb_window_t win, long state)
WM_STATE, WM_STATE, 32, 2, data);
}
/** Get a window state (WM_STATE).
/** Send request to get a window state (WM_STATE).
* \param w A client window.
* \return The cookie associated with the request.
*/
xcb_get_property_cookie_t
window_state_get_unchecked(xcb_window_t w)
{
return xcb_get_property_unchecked(globalconf.connection, false, w, WM_STATE,
WM_STATE, 0L, 2L);
}
/** Get a window state (WM_STATE).
* \param cookie The cookie.
* \return The current state of the window, or -1 on error.
*/
long
window_getstate(xcb_window_t w)
window_state_get_reply(xcb_get_property_cookie_t cookie)
{
long result = -1;
unsigned char *p = NULL;
xcb_get_property_cookie_t prop_c;
xcb_get_property_reply_t *prop_r;
prop_c = xcb_get_property_unchecked(globalconf.connection, false, w,
WM_STATE, WM_STATE,
0L, 2L);
if(!(prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL)))
if(!(prop_r = xcb_get_property_reply(globalconf.connection, cookie, NULL)))
return -1;
p = xcb_get_property_value(prop_r);

View file

@ -25,7 +25,8 @@
#include "structs.h"
void window_setstate(xcb_window_t, long);
long window_getstate(xcb_window_t);
xcb_get_property_cookie_t window_state_get_unchecked(xcb_window_t);
long window_state_get_reply(xcb_get_property_cookie_t);
void window_configure(xcb_window_t, area_t, int);
void window_grabbuttons(xcb_window_t, xcb_window_t, button_t *);
void window_root_grabbuttons(xcb_window_t);