]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
when looking for the focus target, search for modal children in the entire transient...
[chaz/openbox] / openbox / client.c
index 28405c131297a7d6c3663e3faa10395e81fea043..c7d03a826fa61c28e8bbd9452178586b4df69cf5 100644 (file)
@@ -277,9 +277,7 @@ void client_manage(Window window)
 
     /* focus the new window? */
     if (ob_state() != OB_STATE_STARTING &&
-        (config_focus_new || (self->transient_for &&
-                              self->transient_for != OB_TRAN_GROUP &&
-                              client_focused(self->transient_for))) &&
+        (config_focus_new || client_search_focus_parent(self)) &&
         /* note the check against Type_Normal/Dialog, not client_normal(self),
            which would also include other types. in this case we want more
            strict rules for focus */
@@ -1666,7 +1664,9 @@ static ObStackingLayer calc_layer(ObClient *self)
 {
     ObStackingLayer l;
 
-    if (self->fullscreen) l = OB_STACKING_LAYER_FULLSCREEN;
+    if (self->fullscreen &&
+        (client_focused(self) || client_search_focus_tree(self)))
+        l = OB_STACKING_LAYER_FULLSCREEN;
     else if (self->type == OB_CLIENT_TYPE_DESKTOP)
         l = OB_STACKING_LAYER_DESKTOP;
     else if (self->type == OB_CLIENT_TYPE_DOCK) {
@@ -2183,7 +2183,7 @@ void client_maximize(ObClient *self, gboolean max, int dir, gboolean savearea)
             }
         }
         if ((dir == 0 || dir == 2) && self->max_vert) { /* vert */
-            if (self->pre_max_area.width > 0) {
+            if (self->pre_max_area.height > 0) {
                 y = self->pre_max_area.y;
                 h = self->pre_max_area.height;
 
@@ -2289,7 +2289,7 @@ void client_set_desktop_recursive(ObClient *self,
             client_showhide(self);
         /* raise if it was not already on the desktop */
         if (old != DESKTOP_ALL)
-            stacking_raise(CLIENT_AS_WINDOW(self));
+            client_raise(self);
         screen_update_areas();
 
         /* add to the new desktop(s) */
@@ -2492,7 +2492,7 @@ ObClient *client_focus_target(ObClient *self)
     ObClient *child;
      
     /* if we have a modal child, then focus it, not us */
-    child = client_search_modal_child(self);
+    child = client_search_modal_child(client_search_top_transient(self));
     if (child) return child;
     return self;
 }
@@ -2602,7 +2602,7 @@ void client_activate(ObClient *self, gboolean here)
     if (client_normal(self) && screen_showing_desktop)
         screen_show_desktop(FALSE);
     if (self->iconic)
-        client_iconify(self, FALSE, FALSE);
+        client_iconify(self, FALSE, here);
     if (self->desktop != DESKTOP_ALL &&
         self->desktop != screen_desktop) {
         if (here)
@@ -2615,8 +2615,25 @@ void client_activate(ObClient *self, gboolean here)
         return;
     if (self->shaded)
         client_shade(self, FALSE);
+
     client_focus(self);
-    stacking_raise(CLIENT_AS_WINDOW(self));
+
+    /* we do this 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_raise(ObClient *self)
+{
+    action_run_string("Raise", self);
+}
+
+void client_lower(ObClient *self)
+{
+    action_run_string("Raise", self);
 }
 
 gboolean client_focused(ObClient *self)
@@ -2807,6 +2824,52 @@ ObClient *client_search_top_transient(ObClient *self)
     return self;
 }
 
+ObClient *client_search_focus_parent(ObClient *self)
+{
+    if (self->transient_for) {
+        if (self->transient_for != OB_TRAN_GROUP) {
+            if (client_focused(self->transient_for))
+                return self->transient_for;
+        } else {
+            GSList *it;
+
+            for (it = self->group->members; it; it = it->next) {
+                ObClient *c = it->data;
+
+                /* checking transient_for prevents infinate loops! */
+                if (c != self && !c->transient_for)
+                    if (client_focused(c))
+                        return c;
+            }
+        }
+    }
+
+    return NULL;
+}
+
+ObClient *client_search_parent(ObClient *self, ObClient *search)
+{
+    if (self->transient_for) {
+        if (self->transient_for != OB_TRAN_GROUP) {
+            if (self->transient_for == search)
+                return search;
+        } else {
+            GSList *it;
+
+            for (it = self->group->members; it; it = it->next) {
+                ObClient *c = it->data;
+
+                /* checking transient_for prevents infinate loops! */
+                if (c != self && !c->transient_for)
+                    if (c == search)
+                        return search;
+            }
+        }
+    }
+
+    return NULL;
+}
+
 ObClient *client_search_transient(ObClient *self, ObClient *search)
 {
     GSList *sit;
This page took 0.027851 seconds and 4 git commands to generate.