]> Dogcows Code - chaz/openbox/blobdiff - openbox/screen.c
a) remove focus_hilite, it is not needed and complicated things
[chaz/openbox] / openbox / screen.c
index f37c02e97704c12766dd6e31ba2c25643fa373df..a54b2b564074f771ba2bacae86b61045413ac5fe 100644 (file)
@@ -45,7 +45,7 @@
 /*! The event mask to grab on the root window */
 #define ROOT_EVENTMASK (StructureNotifyMask | PropertyChangeMask | \
                         EnterWindowMask | LeaveWindowMask | \
-                        SubstructureRedirectMask | \
+                        SubstructureRedirectMask | FocusChangeMask | \
                         ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
 
 guint    screen_num_desktops;
@@ -166,7 +166,7 @@ gboolean screen_annex()
                                        CopyFromParent, InputOutput,
                                        CopyFromParent,
                                        CWOverrideRedirect, &attrib);
-    XMapRaised(ob_display, screen_support_win);
+    XMapWindow(ob_display, screen_support_win);
 
     if (!replace_wm()) {
         XDestroyWindow(ob_display, screen_support_win);
@@ -300,8 +300,16 @@ void screen_startup(gboolean reconfig)
         screen_num_desktops = 0;
     screen_set_num_desktops(config_desktops_num);
     if (!reconfig) {
-        screen_set_desktop(MIN(config_screen_firstdesk, screen_num_desktops)
-                           - 1);
+        guint32 d;
+        /* start on the current desktop when a wm was already running */
+        if (PROP_GET32(RootWindow(ob_display, ob_screen),
+                       net_current_desktop, cardinal, &d) &&
+            d < screen_num_desktops)
+        {
+            screen_set_desktop(d);
+        } else
+            screen_set_desktop(MIN(config_screen_firstdesk,
+                                   screen_num_desktops) - 1);
 
         /* don't start in showing-desktop mode */
         screen_showing_desktop = FALSE;
@@ -372,7 +380,7 @@ void screen_resize()
 
 void screen_set_num_desktops(guint num)
 {
-    guint i, old;
+    guint old;
     gulong *viewport;
     GList *it;
 
@@ -410,20 +418,11 @@ void screen_set_num_desktops(guint num)
     /* change our desktop if we're on one that no longer exists! */
     if (screen_desktop >= screen_num_desktops)
         screen_set_desktop(num - 1);
-
-   /* update the focus lists */
-    /* free our lists for the desktops which have disappeared */
-    for (i = num; i < old; ++i)
-        g_list_free(focus_order[i]);
-    /* realloc the array */
-    focus_order = g_renew(GList*, focus_order, num);
-    /* set the new lists to be empty */
-    for (i = old; i < num; ++i)
-        focus_order[i] = NULL;
 }
 
 void screen_set_desktop(guint num)
 {
+    ObClient *c;
     GList *it;
     guint old;
      
@@ -445,12 +444,11 @@ void screen_set_desktop(guint num)
 
     /* show windows before hiding the rest to lessen the enter/leave events */
 
-    /* show windows from top to bottom */
+    /* show/hide windows from top to bottom */
     for (it = stacking_list; it; it = g_list_next(it)) {
         if (WINDOW_IS_CLIENT(it->data)) {
             ObClient *c = it->data;
-            if (client_should_show(c))
-                frame_show(c->frame);
+            client_show(c);
         }
     }
 
@@ -458,25 +456,16 @@ void screen_set_desktop(guint num)
     for (it = g_list_last(stacking_list); it; it = g_list_previous(it)) {
         if (WINDOW_IS_CLIENT(it->data)) {
             ObClient *c = it->data;
-            if (c->frame->visible && !client_should_show(c))
-                frame_hide(c->frame);
+            client_hide(c);
         }
     }
 
-    event_ignore_queued_enters();
+    /* reduce flicker by hiliting now rather than waiting for the server
+       FocusIn event */
+    if ((c = focus_fallback_target(TRUE, focus_client)))
+        frame_adjust_focus(c->frame, TRUE);
 
-    focus_hilite = focus_fallback_target(OB_FOCUS_FALLBACK_NOFOCUS);
-    if (focus_hilite) {
-        frame_adjust_focus(focus_hilite->frame, TRUE);
-
-        /*!
-          When this focus_client check is not used, you can end up with races,
-          as demonstrated with gnome-panel, sometmies the window you click on
-          another desktop ends up losing focus cuz of the focus change here.
-        */
-        /*if (!focus_client)*/
-        client_focus(focus_hilite);
-    }
+    event_ignore_queued_enters();
 }
 
 static void get_row_col(guint d, guint *r, guint *c)
@@ -875,8 +864,7 @@ void screen_show_desktop(gboolean show)
         for (it = g_list_last(stacking_list); it; it = g_list_previous(it)) {
             if (WINDOW_IS_CLIENT(it->data)) {
                 ObClient *client = it->data;
-                if (client->frame->visible && !client_should_show(client))
-                    frame_hide(client->frame);
+                client_showhide(client);
             }
         }
     } else {
@@ -884,20 +872,27 @@ void screen_show_desktop(gboolean show)
         for (it = stacking_list; it; it = g_list_next(it)) {
             if (WINDOW_IS_CLIENT(it->data)) {
                 ObClient *client = it->data;
-                if (!client->frame->visible && client_should_show(client))
-                    frame_show(client->frame);
+                client_showhide(client);
             }
         }
     }
 
     if (show) {
         /* focus desktop */
-        for (it = focus_order[screen_desktop]; it; it = g_list_next(it))
-            if (((ObClient*)it->data)->type == OB_CLIENT_TYPE_DESKTOP &&
-                client_validate(it->data) && client_focus(it->data))
+        for (it = focus_order; it; it = g_list_next(it)) {
+            ObClient *c = it->data;
+            if (c->type == OB_CLIENT_TYPE_DESKTOP &&
+                (c->desktop == screen_desktop || c->desktop == DESKTOP_ALL) &&
+                client_focus(it->data))
                 break;
+        }
     } else {
-        focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
+        ObClient *c;
+
+        /* use NULL for the "old" argument because the desktop was focused
+           and we don't want to fallback to the desktop by default */
+        if ((c = focus_fallback_target(TRUE, NULL)))
+            client_focus(c);
     }
 
     show = !!show; /* make it boolean */
This page took 0.024136 seconds and 4 git commands to generate.