all repos — openbox @ 270a5b25df8db500f94a7c29430ebc224ddf18b2

openbox fork - make it a bit more like ryudo

set IconicState on windows that are not visible always. this means windows on other desktops too.

as well, this turned out to be a nice cleanup of the wmstate code.

regards to the random dude in #openbox complaining about the ICCCM to make me think to look this up and see if openbox was compliant.
Dana Jansens danakj@orodu.net
commit

270a5b25df8db500f94a7c29430ebc224ddf18b2

parent

7f58bd9eaaa8285a743be4b7b210568cfe588e3e

3 files changed, 49 insertions(+), 46 deletions(-)

jump to
M openbox/client.copenbox/client.c

@@ -71,9 +71,9 @@ static void client_get_layer(ObClient *self);

static void client_get_shaped(ObClient *self); static void client_get_mwm_hints(ObClient *self); static void client_get_gravity(ObClient *self); -static void client_showhide(ObClient *self); static void client_change_allowed_actions(ObClient *self); static void client_change_state(ObClient *self); +static void client_change_wm_state(ObClient *self); static void client_apply_startup_state(ObClient *self, gint x, gint y); static void client_restore_session_state(ObClient *self); static void client_restore_session_stacking(ObClient *self);

@@ -290,8 +290,6 @@ /* update the focus lists, do this before the call to change_state or

it can end up in the list twice! */ focus_order_add_new(self); - client_change_state(self); - /* remove the client's border (and adjust re gravity) */ client_toggle_border(self, FALSE);

@@ -303,6 +301,10 @@ /* create the decoration frame for the client window */

self->frame = frame_new(self); frame_grab_client(self->frame, self); + + /* do this after we have a frame.. it uses the frame to help determine the + WM_STATE to apply. */ + client_change_state(self); grab_server(FALSE);

@@ -1927,15 +1929,34 @@ /*ob_debug("window 0x%x user time %u\n", self->window, time);*/

} } +static void client_change_wm_state(ObClient *self) +{ + gulong state[2]; + glong old; + + old = self->wmstate; + + if (self->shaded || self->iconic || !self->frame->visible) + self->wmstate = IconicState; + else + self->wmstate = NormalState; + + if (old != self->wmstate) { + PROP_MSG(self->window, kde_wm_change_state, + self->wmstate, 1, 0, 0); + + state[0] = self->wmstate; + state[1] = None; + PROP_SETA32(self->window, wm_state, wm_state, state, 2); + } +} + static void client_change_state(ObClient *self) { - gulong state[2]; gulong netstate[11]; guint num; - state[0] = self->wmstate; - state[1] = None; - PROP_SETA32(self->window, wm_state, wm_state, state, 2); + client_change_wm_state(self); num = 0; if (self->modal)

@@ -2093,13 +2114,21 @@

return FALSE; } -static void client_showhide(ObClient *self) +void client_showhide(ObClient *self) { - if (client_should_show(self)) - frame_show(self->frame); - else + if (client_should_show(self)) { + if (!self->frame->visible) + frame_show(self->frame); + } + else if (self->frame->visible) frame_hide(self->frame); + + /* According to the ICCCM (sec 4.1.3.1) when a window is not visible, it + needs to be in IconicState. This includes when it is on another + desktop! + */ + client_change_wm_state(self); } gboolean client_normal(ObClient *self) {

@@ -2471,14 +2500,6 @@ self->iconic = iconic;

if (iconic) { if (self->functions & OB_CLIENT_FUNC_ICONIFY) { - glong old; - - old = self->wmstate; - self->wmstate = IconicState; - if (old != self->wmstate) - PROP_MSG(self->window, kde_wm_change_state, - self->wmstate, 1, 0, 0); - /* update the focus lists.. iconic windows go to the bottom of the list, put the new iconic window at the 'top of the bottom'. */

@@ -2491,16 +2512,8 @@

changed = TRUE; } } else { - glong old; - if (curdesk) client_set_desktop(self, screen_desktop, FALSE); - - old = self->wmstate; - self->wmstate = self->shaded ? IconicState : NormalState; - if (old != self->wmstate) - PROP_MSG(self->window, kde_wm_change_state, - self->wmstate, 1, 0, 0); /* this puts it after the current focused window */ focus_order_remove(self);

@@ -2616,17 +2629,6 @@ {

if ((!(self->functions & OB_CLIENT_FUNC_SHADE) && shade) || /* can't shade */ self->shaded == shade) return; /* already done */ - - /* when we're iconic, don't change the wmstate */ - if (!self->iconic) { - glong old; - - old = self->wmstate; - self->wmstate = shade ? IconicState : NormalState; - if (old != self->wmstate) - PROP_MSG(self->window, kde_wm_change_state, - self->wmstate, 1, 0, 0); - } self->shaded = shade; client_change_state(self);
M openbox/client.hopenbox/client.h

@@ -436,6 +436,11 @@ @param donthide If TRUE, the window will not be shown/hidden after its

desktop has been changed. Generally this should be FALSE. */ void client_set_desktop(ObClient *self, guint target, gboolean donthide); +/*! Show the client if it should be shown, and hide it if it should be + hidden. This is for example, when switching desktops. +*/ +void client_showhide(ObClient *self); + /*! Validate client, by making sure no Destroy or Unmap events exist in the event queue for the window. @return true if the client is valid; false if the client has already
M openbox/screen.copenbox/screen.c

@@ -449,8 +449,7 @@ /* show windows from top to bottom */

for (it = stacking_list; it; it = g_list_next(it)) { if (WINDOW_IS_CLIENT(it->data)) { ObClient *c = it->data; - if (client_should_show(c)) - frame_show(c->frame); + client_showhide(c); } }

@@ -458,8 +457,7 @@ /* hide windows from bottom to top */

for (it = g_list_last(stacking_list); it; it = g_list_previous(it)) { if (WINDOW_IS_CLIENT(it->data)) { ObClient *c = it->data; - if (c->frame->visible && !client_should_show(c)) - frame_hide(c->frame); + client_showhide(c); } }

@@ -875,8 +873,7 @@ /* bottom to top */

for (it = g_list_last(stacking_list); it; it = g_list_previous(it)) { if (WINDOW_IS_CLIENT(it->data)) { ObClient *client = it->data; - if (client->frame->visible && !client_should_show(client)) - frame_hide(client->frame); + client_showhide(client); } } } else {

@@ -884,8 +881,7 @@ /* top to bottom */

for (it = stacking_list; it; it = g_list_next(it)) { if (WINDOW_IS_CLIENT(it->data)) { ObClient *client = it->data; - if (!client->frame->visible && client_should_show(client)) - frame_show(client->frame); + client_showhide(client); } } }