]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
when un-showing the desktop if a window is getting shown, iconify the others so just...
[chaz/openbox] / openbox / client.c
index 719f46a155a7f08387ba5ba8c2e189c8dc08a4f2..f41c7558140062b53dee565ebaffb9b69a1283a1 100644 (file)
@@ -73,7 +73,6 @@ static void client_get_session_ids(ObClient *self);
 static void client_get_area(ObClient *self);
 static void client_get_desktop(ObClient *self);
 static void client_get_state(ObClient *self);
-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_colormap(ObClient *self);
@@ -283,7 +282,6 @@ void client_manage(Window window)
 
     /* non-zero defaults */
     self->wmstate = WithdrawnState; /* make sure it gets updated first time */
-    self->layer = -1;
     self->desktop = screen_num_desktops; /* always an invalid value */
     self->user_time = focus_client ? focus_client->user_time : CurrentTime;
 
@@ -296,8 +294,6 @@ void client_manage(Window window)
 
     client_setup_decor_and_functions(self);
 
-    client_calc_layer(self);
-
     {
         Time t = sn_app_started(self->startup_id, self->class);
         if (t) self->user_time = t;
@@ -325,7 +321,8 @@ void client_manage(Window window)
 
     grab_server(FALSE);
 
-    stacking_add_nonintrusive(CLIENT_AS_WINDOW(self));
+    /* do this to add ourselves to the stacking list in a non-intrusive way */
+    client_calc_layer(self);
 
     /* focus the new window? */
     if (ob_state() != OB_STATE_STARTING &&
@@ -506,11 +503,10 @@ ObClient *client_fake_manage(Window window)
     settings = client_get_settings_state(self);
 
     client_setup_decor_and_functions(self);
-    /* adjust the decorations so we know the sizes */
-    frame_adjust_area(self->frame, FALSE, TRUE, TRUE);
 
-    /* create the decoration frame for the client window */
+    /* create the decoration frame for the client window and adjust its size */
     self->frame = frame_new(self);
+    frame_adjust_area(self->frame, FALSE, TRUE, TRUE);
     return self;
 }
 
@@ -1005,6 +1001,7 @@ static void client_get_all(ObClient *self, gboolean real)
        from per-app settings */
     client_get_session_ids(self);
 
+    /* now we got everything that can affect the decorations */
     if (!real)
         return;
 
@@ -1020,9 +1017,6 @@ static void client_get_all(ObClient *self, gboolean real)
                                 desktop is not specified */
     client_get_shaped(self);
 
-    client_get_layer(self); /* if layer hasn't been specified, get it from
-                               other sources if possible */
-
     {
         /* a couple type-based defaults for new windows */
 
@@ -1110,41 +1104,6 @@ static void client_get_desktop(ObClient *self)
     }
 }
 
-static void client_get_layer(ObClient *self)
-{
-    if (!(self->above || self->below)) {
-        if (self->group) {
-            /* apply stuff from the group */
-            GSList *it;
-            gint layer = -2;
-
-            for (it = self->group->members; it; it = g_slist_next(it)) {
-                ObClient *c = it->data;
-                if (c != self && !client_search_transient(self, c) &&
-                    client_normal(self) && client_normal(c))
-                {
-                    layer = MAX(layer,
-                                (c->above ? 1 : (c->below ? -1 : 0)));
-                }
-            }
-            switch (layer) {
-            case -1:
-                self->below = TRUE;
-                break;
-            case -2:
-            case 0:
-                break;
-            case 1:
-                self->above = TRUE;
-                break;
-            default:
-                g_assert_not_reached();
-                break;
-            }
-        }
-    }
-}
-
 static void client_get_state(ObClient *self)
 {
     guint32 *state;
@@ -1735,7 +1694,7 @@ static void client_change_allowed_actions(ObClient *self)
         else self->shaded = FALSE;
     }
     if (!(self->functions & OB_CLIENT_FUNC_ICONIFY) && self->iconic) {
-        if (self->frame) client_iconify(self, FALSE, TRUE);
+        if (self->frame) client_iconify(self, FALSE, TRUE, FALSE);
         else self->iconic = FALSE;
     }
     if (!(self->functions & OB_CLIENT_FUNC_FULLSCREEN) && self->fullscreen) {
@@ -2337,7 +2296,7 @@ static ObStackingLayer calc_layer(ObClient *self)
 }
 
 static void client_calc_layer_recursive(ObClient *self, ObClient *orig,
-                                        ObStackingLayer min, gboolean raised)
+                                        ObStackingLayer min)
 {
     ObStackingLayer old, own;
     GSList *it;
@@ -2346,28 +2305,14 @@ static void client_calc_layer_recursive(ObClient *self, ObClient *orig,
     own = calc_layer(self);
     self->layer = MAX(own, min);
 
+    if (self->layer != old) {
+        stacking_remove(CLIENT_AS_WINDOW(self));
+        stacking_add_nonintrusive(CLIENT_AS_WINDOW(self));
+    }
+
     for (it = self->transients; it; it = g_slist_next(it))
         client_calc_layer_recursive(it->data, orig,
-                                    self->layer,
-                                    raised ? raised : self->layer > old);
-
-    /* restack. but only if the original window is managed.
-
-       raised is used so that only the bottom-most window in the stacking
-       order is raised, the others will automatically come with it.
-
-       also only the highest windows in the stacking order (no transients)
-       are lowered, cuz the rest come for free
-    */
-    if (!raised && orig->frame) {
-        if (self->layer > old) {
-            stacking_remove(CLIENT_AS_WINDOW(self));
-            stacking_add_nonintrusive(CLIENT_AS_WINDOW(self));
-        } else if (self->layer < old && self->transients == NULL) {
-            stacking_remove(CLIENT_AS_WINDOW(self));
-            stacking_add_nonintrusive(CLIENT_AS_WINDOW(self));
-        }
-    }
+                                    self->layer);
 }
 
 void client_calc_layer(ObClient *self)
@@ -2381,7 +2326,7 @@ void client_calc_layer(ObClient *self)
     it = client_search_all_top_parents(self);
 
     for (; it; it = g_slist_next(it))
-        client_calc_layer_recursive(it->data, orig, 0, FALSE);
+        client_calc_layer_recursive(it->data, orig, 0);
 }
 
 gboolean client_should_show(ObClient *self)
@@ -2487,7 +2432,7 @@ static void client_apply_startup_state(ObClient *self, gint x, gint y)
 
     if (self->iconic) {
         self->iconic = FALSE;
-        client_iconify(self, TRUE, FALSE);
+        client_iconify(self, TRUE, FALSE, TRUE);
     }
     if (self->fullscreen) {
         self->fullscreen = FALSE;
@@ -2862,7 +2807,8 @@ void client_fullscreen(ObClient *self, gboolean fs)
 }
 
 static void client_iconify_recursive(ObClient *self,
-                                     gboolean iconic, gboolean curdesk)
+                                     gboolean iconic, gboolean curdesk,
+                                     gboolean hide_animation)
 {
     GSList *it;
     gboolean changed = FALSE;
@@ -2902,7 +2848,7 @@ static void client_iconify_recursive(ObClient *self,
 
     if (changed) {
         client_change_state(self);
-        if (ob_state() != OB_STATE_STARTING && config_animate_iconify)
+        if (config_animate_iconify && !hide_animation)
             frame_begin_iconify_animation(self->frame, iconic);
         /* do this after starting the animation so it doesn't flash */
         client_showhide(self);
@@ -2913,15 +2859,17 @@ static void client_iconify_recursive(ObClient *self,
     for (it = self->transients; it; it = g_slist_next(it))
         if (it->data != self)
             if (client_is_direct_child(self, it->data) || !iconic)
-                client_iconify_recursive(it->data, iconic, curdesk);
+                client_iconify_recursive(it->data, iconic, curdesk,
+                                         hide_animation);
 }
 
-void client_iconify(ObClient *self, gboolean iconic, gboolean curdesk)
+void client_iconify(ObClient *self, gboolean iconic, gboolean curdesk,
+                    gboolean hide_animation)
 {
     if (self->functions & OB_CLIENT_FUNC_ICONIFY || !iconic) {
         /* move up the transient chain as far as possible first */
         self = client_search_top_normal_parent(self);
-        client_iconify_recursive(self, iconic, curdesk);
+        client_iconify_recursive(self, iconic, curdesk, hide_animation);
     }
 }
 
@@ -3155,10 +3103,10 @@ void client_set_wm_state(ObClient *self, glong state)
   
     switch (state) {
     case IconicState:
-        client_iconify(self, TRUE, TRUE);
+        client_iconify(self, TRUE, TRUE, FALSE);
         break;
     case NormalState:
-        client_iconify(self, FALSE, TRUE);
+        client_iconify(self, FALSE, TRUE, FALSE);
         break;
     }
 }
@@ -3322,7 +3270,7 @@ void client_set_state(ObClient *self, Atom action, glong data1, glong data2)
         stacking_raise(CLIENT_AS_WINDOW(self));
     }
     if (iconic != self->iconic)
-        client_iconify(self, iconic, FALSE);
+        client_iconify(self, iconic, FALSE, FALSE);
 
     if (demands_attention != self->demands_attention)
         client_hilite(self, demands_attention);
@@ -3445,9 +3393,9 @@ static void client_present(ObClient *self, gboolean here, gboolean raise)
     event_halt_focus_delay();
 
     if (client_normal(self) && screen_showing_desktop)
-        screen_show_desktop(FALSE, FALSE);
+        screen_show_desktop(FALSE, self);
     if (self->iconic)
-        client_iconify(self, FALSE, here);
+        client_iconify(self, FALSE, here, FALSE);
     if (self->desktop != DESKTOP_ALL &&
         self->desktop != screen_desktop)
     {
This page took 0.026579 seconds and 4 git commands to generate.