]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
make the TRAN_GROUP an unsigned long
[chaz/openbox] / openbox / client.c
index a33e2847a82053b8280f1b8458691d3c3cfc175b..787f84c234fab21a095a3f111e20f8380ae4af5f 100644 (file)
@@ -10,6 +10,7 @@
 #include "stacking.h"
 #include "dispatch.h"
 #include "group.h"
+#include "config.h"
 
 #include <glib.h>
 #include <X11/Xutil.h>
@@ -138,8 +139,8 @@ void client_manage_all()
     client_startup_stack_order = NULL;
     client_startup_stack_size = 0;
 
-    if (focus_new)
-        focus_fallback(FALSE);
+    if (config_focus_new)
+        focus_fallback(Fallback_NoFocus);
 }
 
 void client_manage(Window window)
@@ -182,6 +183,7 @@ void client_manage(Window window)
        XFree(wmhint);
     }
 */
+    g_message("Managing window: %lx", window);
 
     /* choose the events we want to receive on the CLIENT window */
     attrib_set.event_mask = CLIENT_EVENTMASK;
@@ -236,8 +238,25 @@ void client_manage(Window window)
 
     dispatch_client(Event_Client_Mapped, self, 0, 0);
 
-    if (ob_state != State_Starting && focus_new)
-        client_focus(self);
+    /* focus the new window? */
+    if (ob_state != State_Starting) {
+        if (config_focus_new)
+            client_focus(self);
+        else if (self->transient_for) {
+            if (self->transient_for != TRAN_GROUP) {/* transient of a window */
+                if (focus_client == self->transient_for)
+                    client_focus(self);
+            } else { /* transient of a group */
+                GSList *it;
+
+                for (it = self->group->members; it; it = it->next)
+                    if (focus_client == it->data) {
+                        client_focus(self);
+                        break;
+                    }
+            }
+        }
+    }
 
     /* update the list hints */
     client_set_list();
@@ -245,7 +264,7 @@ void client_manage(Window window)
     /* make sure the window is visible */
     client_move_onscreen(self);
 
-/*    g_message("Managed window 0x%lx", window);*/
+    g_message("Managed window 0x%lx", window);
 }
 
 void client_unmanage_all()
@@ -260,7 +279,7 @@ void client_unmanage(Client *self)
     int j;
     GSList *it;
 
-/*    g_message("Unmanaging window: %lx", self->window);*/
+    g_message("Unmanaging window: %lx", self->window);
 
     dispatch_client(Event_Client_Destroy, self, 0, 0);
     g_assert(self != NULL);
@@ -311,6 +330,9 @@ void client_unmanage(Client *self)
         }
     }
 
+    if (focus_client == self)
+        client_unfocus(self);
+
     /* remove from its group */
     if (self->group) {
         group_remove(self->group, self);
@@ -340,6 +362,8 @@ void client_unmanage(Client *self)
            XMapWindow(ob_display, self->window);
     }
 
+    g_message("Unmanaged window 0x%lx", self->window);
+
     /* free all data allocated in the client struct */
     g_slist_free(self->transients);
     for (j = 0; j < self->nicons; ++j)
@@ -1805,13 +1829,13 @@ void client_set_desktop(Client *self, guint target, gboolean donthide)
         focus_order[old] = g_list_remove(focus_order[old], self);
     if (target == DESKTOP_ALL) {
         for (i = 0; i < screen_num_desktops; ++i) {
-            if (focus_new)
+            if (config_focus_new)
                 focus_order[i] = g_list_prepend(focus_order[i], self);
             else
                 focus_order[i] = g_list_append(focus_order[i], self);
         }
     } else {
-        if (focus_new)
+        if (config_focus_new)
             focus_order[target] = g_list_prepend(focus_order[target], self);
         else
             focus_order[target] = g_list_append(focus_order[target], self);
@@ -2075,7 +2099,7 @@ void client_unfocus(Client *self)
 {
     g_assert(focus_client == self);
     g_message("client_unfocus");
-    focus_fallback(FALSE);
+    focus_fallback(Fallback_Unfocusing);
 }
 
 gboolean client_focused(Client *self)
This page took 0.023158 seconds and 4 git commands to generate.