From 73a1011364d7522d5512c6538af1b268ce2a9237 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 24 Aug 2009 10:16:52 +0200 Subject: [PATCH] client, spawn: stop storing startup_id Signed-off-by: Julien Danjou --- client.c | 21 +++++++++++++++++---- client.h | 2 -- spawn.c | 5 +++-- spawn.h | 2 +- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/client.c b/client.c index c537a3f3..5e80704f 100644 --- a/client.c +++ b/client.c @@ -54,7 +54,6 @@ luaA_client_gc(lua_State *L) key_array_wipe(&c->keys); xcb_get_wm_protocols_reply_wipe(&c->protocols); p_delete(&c->class); - p_delete(&c->startup_id); p_delete(&c->instance); p_delete(&c->icon_name); p_delete(&c->name); @@ -588,6 +587,13 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, return; } + /* If this is a new client that just has been launched, then request its + * startup id. */ + xcb_get_property_cookie_t startup_id_q = { 0 }; + if(!startup) + startup_id_q = xcb_get_any_property(globalconf.connection, + false, w, _NET_STARTUP_ID, UINT_MAX); + xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val); client_t *c = client_new(globalconf.L); @@ -652,8 +658,6 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, property_update_wm_class(c, NULL); property_update_wm_protocols(c); - xutil_text_prop_get(globalconf.connection, c->window, _NET_STARTUP_ID, &c->startup_id, NULL); - /* update strut */ ewmh_process_client_strut(c, NULL); @@ -678,7 +682,16 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, window_state_set(c->window, XCB_WM_STATE_NORMAL); if(!startup) - spawn_start_notify(c); + { + /* Request our response */ + xcb_get_property_reply_t *reply = + xcb_get_property_reply(globalconf.connection, startup_id_q, NULL); + /* Say spawn that a client has been started, with startup id as argument */ + char *startup_id = xutil_get_text_property_from_reply(reply); + p_delete(&reply); + spawn_start_notify(c, startup_id); + p_delete(&startup_id); + } /* Call hook to notify list change */ if(globalconf.hooks.clients != LUA_REFNIL) diff --git a/client.h b/client.h index 5c862cef..d3512412 100644 --- a/client.h +++ b/client.h @@ -66,8 +66,6 @@ struct client_t char *name, *icon_name; /** WM_CLASS stuff */ char *class, *instance; - /** Startup ID */ - char *startup_id; /** Window geometry */ area_t geometry; struct diff --git a/spawn.c b/spawn.c index 72d4e83b..14bf0a73 100644 --- a/spawn.c +++ b/spawn.c @@ -195,9 +195,10 @@ spawn_monitor_event(SnMonitorEvent *event, void *data) /** Tell the spawn module that an app has been started. * \param c The client that just started. + * \param startup_id The startup id of the started application. */ void -spawn_start_notify(client_t *c) +spawn_start_notify(client_t *c, const char * startup_id) { foreach(_seq, sn_waits) { @@ -205,7 +206,7 @@ spawn_start_notify(client_t *c) bool found = false; const char *seqid = sn_startup_sequence_get_id(seq); - if(!a_strcmp(seqid, c->startup_id)) + if(!a_strcmp(seqid, startup_id)) found = true; else { diff --git a/spawn.h b/spawn.h index 7318acf0..6ebbdd8b 100644 --- a/spawn.h +++ b/spawn.h @@ -25,7 +25,7 @@ #include "structs.h" void spawn_init(void); -void spawn_start_notify(client_t *); +void spawn_start_notify(client_t *, const char *); int luaA_spawn(lua_State *); #endif