]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
stacking fixes for layers
[chaz/openbox] / openbox / client.c
index 719f46a155a7f08387ba5ba8c2e189c8dc08a4f2..6bc2b630f00046ccf5b7f9d10e7bb0c13d971a0e 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;
@@ -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)
This page took 0.023576 seconds and 4 git commands to generate.