diff --git a/awesome.c b/awesome.c index bb57c8441..153dfbbb6 100644 --- a/awesome.c +++ b/awesome.c @@ -149,7 +149,7 @@ scan(xcb_query_tree_cookie_t tree_c) continue; } - client_manage(wins[i], geom_r, true); + client_manage(wins[i], geom_r, attr_r, true); p_delete(&attr_r); p_delete(&geom_r); diff --git a/event.c b/event.c index 1881a9e2a..7eb16acdf 100644 --- a/event.c +++ b/event.c @@ -632,7 +632,7 @@ event_handle_maprequest(xcb_map_request_event_t *ev) goto bailout; } - client_manage(ev->window, geom_r, false); + client_manage(ev->window, geom_r, wa_r, false); p_delete(&geom_r); } diff --git a/objects/client.c b/objects/client.c index 9b187f7f5..33dfa9a9a 100644 --- a/objects/client.c +++ b/objects/client.c @@ -421,7 +421,7 @@ client_update_properties(client_t *c) * \param startup True if we are managing at startup time. */ void -client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, bool startup) +client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, xcb_get_window_attributes_reply_t *wattr, bool startup) { const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK }; @@ -448,8 +448,9 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, bool startup) /* consider the window banned */ c->isbanned = true; - /* Store window */ + /* Store window and visual */ c->window = w; + c->visualtype = draw_find_visual(globalconf.screen, wattr->visual); c->frame_window = xcb_generate_id(globalconf.connection); xcb_create_window(globalconf.connection, globalconf.default_depth, c->frame_window, s->root, wgeom->x, wgeom->y, wgeom->width, wgeom->height, @@ -1830,8 +1831,6 @@ luaA_client_get_maximized(lua_State *L, client_t *c) static int luaA_client_get_content(lua_State *L, client_t *c) { - xcb_get_window_attributes_cookie_t cookie; - xcb_get_window_attributes_reply_t *attr; cairo_surface_t *surface; int width = c->geometry.width; int height = c->geometry.height; @@ -1840,19 +1839,11 @@ luaA_client_get_content(lua_State *L, client_t *c) width -= c->titlebar[CLIENT_TITLEBAR_LEFT].size + c->titlebar[CLIENT_TITLEBAR_RIGHT].size; height -= c->titlebar[CLIENT_TITLEBAR_TOP].size + c->titlebar[CLIENT_TITLEBAR_BOTTOM].size; - cookie = xcb_get_window_attributes(globalconf.connection, c->window); - attr = xcb_get_window_attributes_reply(globalconf.connection, cookie, NULL); - - if (!attr) - return 0; - surface = cairo_xcb_surface_create(globalconf.connection, c->window, - draw_find_visual(globalconf.screen, attr->visual), - width, height); + c->visualtype, width, height); /* lua has to make sure to free the ref or we have a leak */ lua_pushlightuserdata(L, surface); - free(attr); return 1; } diff --git a/objects/client.h b/objects/client.h index f95618d1a..1916b1c9e 100644 --- a/objects/client.h +++ b/objects/client.h @@ -106,6 +106,9 @@ struct client_t cairo_surface_t *icon; /** Size hints */ xcb_size_hints_t size_hints; + /** The visualtype that c->window uses */ + xcb_visualtype_t *visualtype; + /** Do we honor the client's size hints? */ bool size_hints_honor; /** Machine the client is running on. */ char *machine; @@ -140,7 +143,7 @@ client_t * client_getbyframewin(xcb_window_t); void client_ban(client_t *); void client_ban_unfocus(client_t *); void client_unban(client_t *); -void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, bool); +void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, xcb_get_window_attributes_reply_t *, bool); bool client_resize(client_t *, area_t, bool); void client_unmanage(client_t *, bool); void client_kill(client_t *);