From bf451445c3b9525d60225d0c41953bddd674ed8d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 5 Sep 2008 02:05:30 +0200 Subject: [PATCH] client: stop default tagging of sticky windows Signed-off-by: Julien Danjou --- client.c | 30 +++++++++++++++++++++++++----- mouse.c | 2 +- screen.c | 20 ++++++++++++-------- screen.h | 2 +- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/client.c b/client.c index bc24c791..447eb743 100644 --- a/client.c +++ b/client.c @@ -388,7 +388,6 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, { xcb_get_property_cookie_t ewmh_icon_cookie; client_t *c; - bool retloadprops; const uint32_t select_input_val[] = { XCB_EVENT_MASK_STRUCTURE_NOTIFY @@ -429,12 +428,33 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, client_updatewmhints(c); /* Try to load props if any */ - if(!(retloadprops = client_loadprops(c, &globalconf.screens[screen]))) - screen_client_moveto(c, screen, true); + client_loadprops(c, &globalconf.screens[screen]); + + /* move client to screen, but do not tag it for now */ + screen_client_moveto(c, screen, false, true); /* Then check clients hints */ ewmh_check_client_hints(c); + /* Check if client has been tagged by loading props, or maybe with its + * hints. + * If not, we tag it with current selected ones. + * This could be done on Lua side, but it's a sane behaviour. */ + if(!c->issticky) + { + int i; + tag_array_t *tags = &globalconf.screens[screen].tags; + for(i = 0; i < tags->len; i++) + if(is_client_tagged(c, tags->tab[i])) + break; + + /* if no tag, set current selected */ + if(i == tags->len) + for(i = 0; i < tags->len; i++) + if(tags->tab[i]->selected) + tag_client(c, tags->tab[i]); + } + /* Push client in client list */ client_list_push(&globalconf.clients, c); client_ref(&c); @@ -581,7 +601,7 @@ client_resize(client_t *c, area_t geometry, bool hints) window_configure(c->win, geometry, c->border); if(c->screen != new_screen) - screen_client_moveto(c, new_screen, false); + screen_client_moveto(c, new_screen, true, false); resized = true; } @@ -1270,7 +1290,7 @@ luaA_client_newindex(lua_State *L) i = luaL_checknumber(L, 3) - 1; luaA_checkscreen(i); if(i != (*c)->screen) - screen_client_moveto(*c, i, true); + screen_client_moveto(*c, i, true, true); } break; case A_TK_HIDE: diff --git a/mouse.c b/mouse.c index a556a590..86428fa8 100644 --- a/mouse.c +++ b/mouse.c @@ -543,7 +543,7 @@ mouse_client_move(client_t *c, int snap, bool infobox) newscreen = screen_getbycoord(c->screen, mouse_x, mouse_y); if(newscreen != c->screen) { - screen_client_moveto(c, newscreen, true); + screen_client_moveto(c, newscreen, true, true); globalconf.screens[c->screen].need_arrange = true; globalconf.screens[newscreen].need_arrange = true; layout_refresh(); diff --git a/screen.c b/screen.c index 53b4d2a4..7dc957d7 100644 --- a/screen.c +++ b/screen.c @@ -194,11 +194,12 @@ screen_virttophys(int screen) /** Move a client to a virtual screen. * \param c The client to move. * \param new_screen The destinatiuon screen number. + * \param dotag Set to true if we also change tags. * \param doresize Set to true if we also move the client to the new x and * y of the new screen. */ void -screen_client_moveto(client_t *c, int new_screen, bool doresize) +screen_client_moveto(client_t *c, int new_screen, bool dotag, bool doresize) { int i, old_screen = c->screen; tag_array_t *old_tags = &globalconf.screens[old_screen].tags, @@ -208,14 +209,17 @@ screen_client_moveto(client_t *c, int new_screen, bool doresize) c->screen = new_screen; - /* remove old tags */ - for(i = 0; i < old_tags->len; i++) - untag_client(c, old_tags->tab[i]); + if(dotag && !c->issticky) + { + /* remove old tags */ + for(i = 0; i < old_tags->len; i++) + untag_client(c, old_tags->tab[i]); - /* add new tags */ - for(i = 0; i < new_tags->len; i++) - if(new_tags->tab[i]->selected) - tag_client(c, new_tags->tab[i]); + /* add new tags */ + for(i = 0; i < new_tags->len; i++) + if(new_tags->tab[i]->selected) + tag_client(c, new_tags->tab[i]); + } /* resize the windows if it's floating */ if(doresize && old_screen != c->screen) diff --git a/screen.h b/screen.h index 6883f1af..35558f54 100644 --- a/screen.h +++ b/screen.h @@ -30,7 +30,7 @@ int screen_getbycoord(int, int, int); area_t screen_area_get(int, statusbar_t *, padding_t *, bool); area_t display_area_get(int, statusbar_t *, padding_t *); int screen_virttophys(int); -void screen_client_moveto(client_t *, int, bool); +void screen_client_moveto(client_t *, int, bool, bool); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80