client: check for visibility before arranging

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-08-21 15:36:54 +02:00
parent c3d4ce3e42
commit 5449374e3d
7 changed files with 52 additions and 37 deletions

View File

@ -255,7 +255,7 @@ client_focus(client_t *c)
/* Some layouts use focused client differently, so call them back. /* Some layouts use focused client differently, so call them back.
* And anyway, we have maybe unhidden */ * And anyway, we have maybe unhidden */
globalconf.screens[c->screen].need_arrange = true; client_need_arrange(c);
/* execute hook */ /* execute hook */
luaA_client_userdata_new(globalconf.L, globalconf.screen_focus->client_focus); luaA_client_userdata_new(globalconf.L, globalconf.screen_focus->client_focus);
@ -623,8 +623,7 @@ client_setfloating(client_t *c, bool floating)
} }
else else
client_setlayer(c, c->oldlayer); client_setlayer(c, c->oldlayer);
if(client_isvisible(c, c->screen)) client_need_arrange(c);
globalconf.screens[c->screen].need_arrange = true;
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
client_saveprops(c); client_saveprops(c);
} }
@ -928,10 +927,13 @@ client_setborder(client_t *c, int width)
xcb_configure_window(globalconf.connection, c->win, xcb_configure_window(globalconf.connection, c->win,
XCB_CONFIG_WINDOW_BORDER_WIDTH, &w); XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
if(c->isfloating || layout_get_current(c->screen) == layout_floating) if(client_isvisible(c, c->screen))
titlebar_update_geometry_floating(c); {
else if(c->isfloating || layout_get_current(c->screen) == layout_floating)
globalconf.screens[c->screen].need_arrange = true; titlebar_update_geometry_floating(c);
else
globalconf.screens[c->screen].need_arrange = true;
}
} }
/** Kill a client. /** Kill a client.
@ -960,8 +962,8 @@ luaA_client_swap(lua_State *L)
client_t **c = luaA_checkudata(L, 1, "client"); client_t **c = luaA_checkudata(L, 1, "client");
client_t **swap = luaA_checkudata(L, 2, "client"); client_t **swap = luaA_checkudata(L, 2, "client");
client_list_swap(&globalconf.clients, *swap, *c); client_list_swap(&globalconf.clients, *swap, *c);
globalconf.screens[(*c)->screen].need_arrange = true; client_need_arrange(*c);
globalconf.screens[(*swap)->screen].need_arrange = true; client_need_arrange(*swap);
widget_invalidate_cache((*c)->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache((*c)->screen, WIDGET_CACHE_CLIENTS);
widget_invalidate_cache((*swap)->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache((*swap)->screen, WIDGET_CACHE_CLIENTS);
return 0; return 0;
@ -1155,9 +1157,9 @@ luaA_client_newindex(lua_State *L)
b = luaA_checkboolean(L, 3); b = luaA_checkboolean(L, 3);
if(b != (*c)->ishidden) if(b != (*c)->ishidden)
{ {
client_need_arrange(*c);
(*c)->ishidden = b; (*c)->ishidden = b;
if(client_maybevisible(*c, (*c)->screen)) client_need_arrange(*c);
globalconf.screens[(*c)->screen].need_arrange = true;
} }
break; break;
case A_TK_ICON_PATH: case A_TK_ICON_PATH:
@ -1181,8 +1183,7 @@ luaA_client_newindex(lua_State *L)
break; break;
case A_TK_HONORSIZEHINTS: case A_TK_HONORSIZEHINTS:
(*c)->honorsizehints = luaA_checkboolean(L, 3); (*c)->honorsizehints = luaA_checkboolean(L, 3);
if(client_isvisible(*c, (*c)->screen)) client_need_arrange(*c);
globalconf.screens[(*c)->screen].need_arrange = true;
break; break;
case A_TK_BORDER_WIDTH: case A_TK_BORDER_WIDTH:
client_setborder(*c, luaL_checknumber(L, 3)); client_setborder(*c, luaL_checknumber(L, 3));
@ -1211,7 +1212,7 @@ luaA_client_newindex(lua_State *L)
simplewindow_delete(&(*c)->titlebar->sw); simplewindow_delete(&(*c)->titlebar->sw);
titlebar_unref(&(*c)->titlebar); titlebar_unref(&(*c)->titlebar);
(*c)->titlebar = NULL; (*c)->titlebar = NULL;
globalconf.screens[(*c)->screen].need_arrange = true; client_need_arrange(*c);
} }
if(t) if(t)

View File

@ -26,6 +26,13 @@
#include "structs.h" #include "structs.h"
#define client_need_arrange(c) \
do { \
if(!globalconf.screens[(c)->screen].need_arrange \
&& client_isvisible(c, (c)->screen)) \
globalconf.screens[(c)->screen].need_arrange = true; \
} while(0)
bool client_maybevisible(client_t *, int); bool client_maybevisible(client_t *, int);
bool client_isvisible(client_t *, int); bool client_isvisible(client_t *, int);
client_t * client_getbywin(xcb_window_t); client_t * client_getbywin(xcb_window_t);

22
event.c
View File

@ -221,7 +221,7 @@ event_handle_configurerequest(void *data __attribute__ ((unused)),
} }
else else
{ {
globalconf.screens[c->screen].need_arrange = true; client_need_arrange(c);
/* If we do not resize the client, at least tell it that it /* If we do not resize the client, at least tell it that it
* has its new configuration. That fixes at least * has its new configuration. That fixes at least
* gnome-terminal */ * gnome-terminal */
@ -531,7 +531,6 @@ event_handle_propertynotify(void *data __attribute__ ((unused)),
xcb_connection_t *connection, xcb_property_notify_event_t *ev) xcb_connection_t *connection, xcb_property_notify_event_t *ev)
{ {
client_t *c; client_t *c;
xcb_window_t trans;
xembed_window_t *emwin; xembed_window_t *emwin;
xcb_size_hints_t size_hints; xcb_size_hints_t size_hints;
@ -543,13 +542,16 @@ event_handle_propertynotify(void *data __attribute__ ((unused)),
{ {
if(ev->atom == WM_TRANSIENT_FOR) if(ev->atom == WM_TRANSIENT_FOR)
{ {
xcb_get_wm_transient_for_reply(connection, if(!c->isfloating)
xcb_get_wm_transient_for_unchecked(connection, {
c->win), xcb_window_t trans;
&trans, NULL); xcb_get_wm_transient_for_reply(connection,
if(!c->isfloating xcb_get_wm_transient_for_unchecked(connection,
&& (c->isfloating = (client_getbywin(trans) != NULL))) c->win),
globalconf.screens[c->screen].need_arrange = true; &trans, NULL);
if(client_getbywin(trans))
client_setfloating(c, true);
}
} }
else if (ev->atom == WM_NORMAL_HINTS) else if (ev->atom == WM_NORMAL_HINTS)
client_updatesizehints(c, &size_hints); client_updatesizehints(c, &size_hints);
@ -652,8 +654,8 @@ event_handle_clientmessage(void *data __attribute__ ((unused)),
&& ev->format == 32 && ev->format == 32
&& ev->data.data32[0] == XCB_WM_STATE_ICONIC) && ev->data.data32[0] == XCB_WM_STATE_ICONIC)
{ {
client_need_arrange(c);
c->ishidden = true; c->ishidden = true;
globalconf.screens[c->screen].need_arrange = true;
} }
} }
else if(ev->type == _XEMBED) else if(ev->type == _XEMBED)

7
ewmh.c
View File

@ -343,10 +343,15 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
else if(state == _NET_WM_STATE_HIDDEN) else if(state == _NET_WM_STATE_HIDDEN)
{ {
if(set == _NET_WM_STATE_REMOVE) if(set == _NET_WM_STATE_REMOVE)
{
client_need_arrange(c);
c->ishidden = false; c->ishidden = false;
}
else if(set == _NET_WM_STATE_ADD) else if(set == _NET_WM_STATE_ADD)
{
client_need_arrange(c);
c->ishidden = true; c->ishidden = true;
globalconf.screens[c->screen].need_arrange = true; }
} }
else if(state == _NET_WM_STATE_DEMANDS_ATTENTION) else if(state == _NET_WM_STATE_DEMANDS_ATTENTION)
{ {

View File

@ -132,6 +132,7 @@ screen_client_moveto(client_t *c, int new_screen, bool doresize)
tag_array_t *old_tags = &globalconf.screens[old_screen].tags, tag_array_t *old_tags = &globalconf.screens[old_screen].tags,
*new_tags = &globalconf.screens[new_screen].tags; *new_tags = &globalconf.screens[new_screen].tags;
area_t from, to; area_t from, to;
bool wasvisible = client_isvisible(c, c->screen);
c->screen = new_screen; c->screen = new_screen;
@ -210,8 +211,9 @@ screen_client_moveto(client_t *c, int new_screen, bool doresize)
else else
{ {
c->f_geometry = new_f_geometry; c->f_geometry = new_f_geometry;
globalconf.screens[old_screen].need_arrange = true; if(wasvisible)
globalconf.screens[c->screen].need_arrange = true; globalconf.screens[old_screen].need_arrange = true;
client_need_arrange(c);
} }
} }
} }

6
tag.c
View File

@ -135,7 +135,7 @@ tag_client(client_t *c, tag_t *t)
client_array_append(&t->clients, c); client_array_append(&t->clients, c);
client_saveprops(c); client_saveprops(c);
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
globalconf.screens[c->screen].need_arrange = true; client_need_arrange(c);
} }
/** Untag a client with specified tag. /** Untag a client with specified tag.
@ -148,11 +148,11 @@ untag_client(client_t *c, tag_t *t)
for(int i = 0; i < t->clients.len; i++) for(int i = 0; i < t->clients.len; i++)
if(t->clients.tab[i] == c) if(t->clients.tab[i] == c)
{ {
client_need_arrange(c);
client_array_take(&t->clients, i); client_array_take(&t->clients, i);
tag_unref(&t); tag_unref(&t);
client_saveprops(c); client_saveprops(c);
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
globalconf.screens[c->screen].need_arrange = true;
return; return;
} }
} }
@ -471,7 +471,7 @@ luaA_tag_newindex(lua_State *L)
return 0; return 0;
} }
if((*tag)->screen != SCREEN_UNDEF) if((*tag)->screen != SCREEN_UNDEF && (*tag)->selected)
globalconf.screens[(*tag)->screen].need_arrange = true; globalconf.screens[(*tag)->screen].need_arrange = true;
return 0; return 0;

View File

@ -290,8 +290,7 @@ titlebar_init(client_t *c)
xcb_change_window_attributes(globalconf.connection, c->titlebar->sw->window, xcb_change_window_attributes(globalconf.connection, c->titlebar->sw->window,
XCB_CW_BORDER_PIXEL, &c->titlebar->border.color.pixel); XCB_CW_BORDER_PIXEL, &c->titlebar->border.color.pixel);
if(client_isvisible(c, c->screen)) client_need_arrange(c);
globalconf.screens[c->screen].need_arrange = true;
c->titlebar->need_update = true; c->titlebar->need_update = true;
} }
@ -388,7 +387,7 @@ luaA_titlebar_newindex(lua_State *L)
simplewindow_delete(&(*newc)->titlebar->sw); simplewindow_delete(&(*newc)->titlebar->sw);
titlebar_unref(&(*newc)->titlebar); titlebar_unref(&(*newc)->titlebar);
(*newc)->titlebar = NULL; (*newc)->titlebar = NULL;
globalconf.screens[(*newc)->screen].need_arrange = true; client_need_arrange(*newc);
} }
/* Attach titlebar to client */ /* Attach titlebar to client */
(*newc)->titlebar = *titlebar; (*newc)->titlebar = *titlebar;
@ -404,7 +403,7 @@ luaA_titlebar_newindex(lua_State *L)
/* unref and NULL the ref */ /* unref and NULL the ref */
titlebar_unref(&c->titlebar); titlebar_unref(&c->titlebar);
c->titlebar = NULL; c->titlebar = NULL;
globalconf.screens[c->screen].need_arrange = true; client_need_arrange(c);
} }
} }
break; break;
@ -463,9 +462,8 @@ luaA_titlebar_newindex(lua_State *L)
return 0; return 0;
} }
if((c || (c = client_getbytitlebar(*titlebar))) if((c || (c = client_getbytitlebar(*titlebar))))
&& client_isvisible(c, c->screen)) client_need_arrange(c);
globalconf.screens[c->screen].need_arrange = true;
return 0; return 0;
} }