From a0d14c7d4468b6348d906a68bb5dfe3acce0ad64 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 14 Oct 2011 18:54:32 -0400 Subject: [PATCH] make undecorated windows place according to their undecorated state (bug #5179) splits client_setup_decor_and_functions() into 3 functions. 1. add client_setup_default_decor_and_functions() - called from client_get_all() to get the maximum decor/functions that will be available for use by the client. 2. add client_setup_decor_undecorated() - sets up the client's undecorarted decor if the flag is set by the per-app settings or session state. - we do this before setting up the frame so the frame reflects the window as it should be when getting placed. 3. client_setup_decor_and_functions() - calls the above 2 to perform the same functions as before. - added to client_apply_startup_state() so that we can ensure it was run fully at least once in the mapping process, since it is not called in client_get_all() anymore. --- openbox/client.c | 52 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/openbox/client.c b/openbox/client.c index c9cd0763..2e432dbe 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -112,6 +112,8 @@ static gboolean client_can_steal_focus(ObClient *self, gboolean allow_other_desktop, gboolean request_from_user, Time steal_time, Time launch_time); +static void client_setup_default_decor_and_functions(ObClient *self); +static void client_setup_decor_undecorated(ObClient *self); void client_startup(gboolean reconfig) { @@ -238,6 +240,18 @@ void client_manage(Window window, ObPrompt *prompt) that needs to be freed with g_free(). */ settings = client_get_settings_state(self); + /* the session should get the last say though */ + client_restore_session_state(self); + + /* the per-app settings/session may have changed the decorations for + the window, so we setup decorations for that here. this is a special + case because we want to place the window according to these decoration + changes. + we do this before setting up the frame so that it will reflect the + decorations of the window as it will be placed on screen. + */ + client_setup_decor_undecorated(self); + /* specify that if we exit, the window should not be destroyed and should be reparented back to root automatically, unless we are managing an internal ObPrompt window */ @@ -253,9 +267,6 @@ void client_manage(Window window, ObPrompt *prompt) time now */ grab_server(FALSE); - /* the session should get the last say though */ - client_restore_session_state(self); - /* this needs to occur once we have a frame, since it sets a property on the frame */ client_update_opacity(self); @@ -1177,11 +1188,8 @@ static void client_get_all(ObClient *self, gboolean real) client_get_type_and_transientness(self); client_update_normal_hints(self); - /* set up the decor/functions before getting the state. the states may - affect which functions are available, but we want to know the maximum - decor/functions are available to this window, so we can then apply them - in client_apply_startup_state() */ - client_setup_decor_and_functions(self, FALSE); + /* set up the maximum possible decor/functions */ + client_setup_default_decor_and_functions(self); client_get_state(self); @@ -1735,7 +1743,7 @@ void client_update_normal_hints(ObClient *self) ob_debug("Normal hints: not set"); } -void client_setup_decor_and_functions(ObClient *self, gboolean reconfig) +static void client_setup_default_decor_and_functions(ObClient *self) { /* start with everything (cept fullscreen) */ self->decorations = @@ -1868,6 +1876,23 @@ void client_setup_decor_and_functions(ObClient *self, gboolean reconfig) self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE; self->decorations &= ~OB_FRAME_DECOR_MAXIMIZE; } +} + +/*! Set up decor for a client based on its undecorated state. */ +static void client_setup_decor_undecorated(ObClient *self) +{ + /* If the user requested no decorations, then remove all the decorations, + except the border. But don't add a border if there wasn't one. */ + if (self->undecorated) + self->decorations &= (config_theme_keepborder ? + OB_FRAME_DECOR_BORDER : 0); +} + +void client_setup_decor_and_functions(ObClient *self, gboolean reconfig) +{ + client_setup_default_decor_and_functions(self); + + client_setup_decor_undecorated(self); if (self->max_horz && self->max_vert) { /* once upon a time you couldn't resize maximized windows, that is not @@ -1877,12 +1902,6 @@ void client_setup_decor_and_functions(ObClient *self, gboolean reconfig) self->decorations &= ~(OB_FRAME_DECOR_HANDLE | OB_FRAME_DECOR_GRIPS); } - /* finally, the user can have requested no decorations, which overrides - everything (but doesnt give it a border if it doesnt have one) */ - if (self->undecorated) - self->decorations &= (config_theme_keepborder ? - OB_FRAME_DECOR_BORDER : 0); - /* if we don't have a titlebar, then we cannot shade! */ if (!(self->decorations & OB_FRAME_DECOR_TITLEBAR)) self->functions &= ~OB_CLIENT_FUNC_SHADE; @@ -2814,6 +2833,9 @@ static void client_apply_startup_state(ObClient *self, if (fullscreen) client_fullscreen(self, TRUE); + /* make sure client_setup_decor_and_functions() is called at least once */ + client_setup_decor_and_functions(self, FALSE); + /* if the window hasn't been configured yet, then do so now, in fact the x,y,w,h may _not_ be the same as the area rect, which can end up meaning that the client isn't properly moved/resized by the fullscreen -- 2.45.2