]> 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 83c59030b4da3156735e1c33548811d5e2739fe4..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;
 
@@ -294,7 +292,7 @@ void client_manage(Window window)
     /* the session should get the last say */
     client_restore_session_state(self);
 
-    client_calc_layer(self);
+    client_setup_decor_and_functions(self);
 
     {
         Time t = sn_app_started(self->startup_id, self->class);
@@ -323,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 &&
@@ -451,7 +450,7 @@ void client_manage(Window window)
            raised to the top. Legacy begets legacy I guess?
         */
         if (!client_restore_session_stacking(self))
-            client_raise(self);
+            stacking_raise(CLIENT_AS_WINDOW(self));
     }
 
     /* this has to happen before we try focus the window, but we want it to
@@ -503,8 +502,11 @@ ObClient *client_fake_manage(Window window)
        uses too */
     settings = client_get_settings_state(self);
 
-    /* create the decoration frame for the client window */
+    client_setup_decor_and_functions(self);
+
+    /* 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;
 }
 
@@ -993,51 +995,48 @@ static void client_get_all(ObClient *self, gboolean real)
     /* this can change the mwmhints for special cases */
     client_get_type_and_transientness(self);
     client_get_state(self);
-    client_update_protocols(self);
     client_update_normal_hints(self);
 
-    /* got the type, the mwmhints, the protocols, and the normal hints
-       (min/max sizes), so we're ready to set up the decorations/functions */
-    client_setup_decor_and_functions(self);
+    /* get the session related properties, these can change decorations
+       from per-app settings */
+    client_get_session_ids(self);
 
-    if (real) {
-        client_update_wmhints(self);
-        /* this may have already been called from client_update_wmhints */
-        if (self->transient_for == NULL)
-            client_update_transient_for(self);
+    /* now we got everything that can affect the decorations */
+    if (!real)
+        return;
 
-        client_get_startup_id(self);
-        client_get_desktop(self);/* uses transient data/group/startup id if a
-                                    desktop is not specified */
-        client_get_shaped(self);
+    client_update_protocols(self);
 
-        client_get_layer(self); /* if layer hasn't been specified, get it from
-                                   other sources if possible */
+    client_update_wmhints(self);
+    /* this may have already been called from client_update_wmhints */
+    if (self->transient_for == NULL)
+        client_update_transient_for(self);
 
-        {
-            /* a couple type-based defaults for new windows */
+    client_get_startup_id(self);
+    client_get_desktop(self);/* uses transient data/group/startup id if a
+                                desktop is not specified */
+    client_get_shaped(self);
 
-            /* this makes sure that these windows appear on all desktops */
-            if (self->type == OB_CLIENT_TYPE_DESKTOP)
-                self->desktop = DESKTOP_ALL;
-        }
+    {
+        /* a couple type-based defaults for new windows */
+
+        /* this makes sure that these windows appear on all desktops */
+        if (self->type == OB_CLIENT_TYPE_DESKTOP)
+            self->desktop = DESKTOP_ALL;
+    }
   
 #ifdef SYNC
-        client_update_sync_request_counter(self);
+    client_update_sync_request_counter(self);
 #endif
 
-        /* get the session related properties */
-        client_get_session_ids(self);
-
-        client_get_colormap(self);
-        client_update_title(self);
-        client_update_strut(self);
-        client_update_icons(self);
-        client_update_user_time_window(self);
-        if (!self->user_time_window) /* check if this would have been called */
-            client_update_user_time(self);
-        client_update_icon_geometry(self);
-    }
+    client_get_colormap(self);
+    client_update_title(self);
+    client_update_strut(self);
+    client_update_icons(self);
+    client_update_user_time_window(self);
+    if (!self->user_time_window) /* check if this would have been called */
+        client_update_user_time(self);
+    client_update_icon_geometry(self);
 }
 
 static void client_get_startup_id(ObClient *self)
@@ -1105,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;
@@ -1664,7 +1628,7 @@ void client_setup_decor_and_functions(ObClient *self)
 
     /* kill the handle on fully maxed windows */
     if (self->max_vert && self->max_horz)
-        self->decorations &= ~OB_FRAME_DECOR_HANDLE;
+        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) */
@@ -1730,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) {
@@ -2199,6 +2163,8 @@ static void client_get_session_ids(ObClient *self)
         localhost[127] = '\0';
         if (strcmp(localhost, s) != 0)
             self->client_machine = s;
+        else
+            g_free(s);
     }
 }
 
@@ -2330,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;
@@ -2339,16 +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);
-
-    if (!raised && self->layer != old)
-        if (orig->frame) { /* only restack if the original window is managed */
-            stacking_remove(CLIENT_AS_WINDOW(self));
-            stacking_add(CLIENT_AS_WINDOW(self));
-        }
+                                    self->layer);
 }
 
 void client_calc_layer(ObClient *self)
@@ -2362,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)
@@ -2468,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;
@@ -2843,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;
@@ -2883,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);
@@ -2894,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);
     }
 }
 
@@ -3075,7 +3042,7 @@ void client_set_desktop_recursive(ObClient *self,
             client_showhide(self);
         /* raise if it was not already on the desktop */
         if (old != DESKTOP_ALL)
-            client_raise(self);
+            stacking_raise(CLIENT_AS_WINDOW(self));
         if (STRUT_EXISTS(self->strut))
             screen_update_areas();
     }
@@ -3136,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;
     }
 }
@@ -3300,10 +3267,10 @@ void client_set_state(ObClient *self, Atom action, glong data1, glong data2)
         self->modal = modal;
         /* when a window changes modality, then its stacking order with its
            transients needs to change */
-        client_raise(self);
+        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);
@@ -3426,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)
     {
@@ -3442,17 +3409,10 @@ static void client_present(ObClient *self, gboolean here, gboolean raise)
         return;
     if (self->shaded)
         client_shade(self, FALSE);
+    if (raise)
+        stacking_raise(CLIENT_AS_WINDOW(self));
 
     client_focus(self);
-
-    if (raise) {
-        /* we do this as an action here. this is rather important. this is
-           because we want the results from the focus change to take place 
-           BEFORE we go about raising the window. when a fullscreen window 
-           loses focus, we need this or else the raise wont be able to raise 
-           above the to-lose-focus fullscreen window. */
-        client_raise(self);
-    }
 }
 
 void client_activate(ObClient *self, gboolean here, gboolean user)
@@ -3508,16 +3468,6 @@ void client_bring_helper_windows(ObClient *self)
     client_bring_helper_windows_recursive(self, self->desktop);
 }
 
-void client_raise(ObClient *self)
-{
-    action_run_string("Raise", self, CurrentTime);
-}
-
-void client_lower(ObClient *self)
-{
-    action_run_string("Lower", self, CurrentTime);
-}
-
 gboolean client_focused(ObClient *self)
 {
     return self == focus_client;
This page took 0.032851 seconds and 4 git commands to generate.