]> Dogcows Code - chaz/openbox/blobdiff - openbox/screen.c
move config option loading for the kernel into config.c/h
[chaz/openbox] / openbox / screen.c
index e9d0ce1a67d1e06f211083e059561dd95e1ea6f7..49d3d22d46316c5b7a7d0f266010c84cf1cbd03b 100644 (file)
@@ -1,5 +1,6 @@
 #include "openbox.h"
 #include "prop.h"
+#include "config.h"
 #include "screen.h"
 #include "client.h"
 #include "frame.h"
@@ -148,12 +149,24 @@ gboolean screen_annex()
 
 void screen_startup()
 {
+    GSList *it;
+
     screen_desktop_names = g_ptr_array_new();
      
     /* get the initial size */
     screen_resize();
 
-    screen_set_num_desktops(4);
+    /* set the names */
+    for (it = config_desktops_names; it; it = it->next)
+        g_ptr_array_add(screen_desktop_names, it->data); /* dont strdup */
+    PROP_SETSA(ob_root, net_desktop_names, utf8, screen_desktop_names);
+    g_ptr_array_set_size(screen_desktop_names, 0); /* rm the ptrs so they dont
+                                                      get frees when we
+                                                      update the desktop
+                                                      names */
+    screen_num_desktops = 0;
+    screen_set_num_desktops(config_desktops_num);
+    screen_desktop = 0;
     screen_set_desktop(0);
 
     /* don't start in showing-desktop mode */
@@ -206,27 +219,9 @@ void screen_set_num_desktops(guint num)
 {
     guint i, old;
     gulong *viewport;
-     
+    GList *it;
+
     g_assert(num > 0);
-  
-    /* move windows on desktops that will no longer exist! */
-    /* XXX
-       std::list<Client*>::iterator it, end = clients.end();
-       for (it = clients.begin(); it != end; ++it) {
-       unsigned int d = (*it)->desktop();
-       if (d >= num && d != 0xffffffff) {
-       XEvent ce;
-       ce.xclient.type = ClientMessage;
-       ce.xclient.message_type = otk::Property::atoms.net_wm_desktop;
-       ce.xclient.display = **otk::display;
-       ce.xclient.window = (*it)->window();
-       ce.xclient.format = 32;
-       ce.xclient.data.l[0] = num - 1;
-       XSendEvent(**otk::display, _info->rootWindow(), false,
-       SubstructureNotifyMask | SubstructureRedirectMask, &ce);
-       }
-       }
-    */
 
     old = screen_num_desktops;
     screen_num_desktops = num;
@@ -256,6 +251,13 @@ void screen_set_num_desktops(guint num)
     for (i = old; i < num; ++i)
         focus_order[i] = NULL;
 
+    /* move windows on desktops that will no longer exist! */
+    for (it = client_list; it != NULL; it = it->next) {
+        Client *c = it->data;
+        if (c->desktop >= num)
+            client_set_desktop(c, num - 1, FALSE);
+    }
+
     dispatch_ob(Event_Ob_NumDesktops, num, old);
 
     /* change our desktop if we're on one that no longer exists! */
@@ -267,17 +269,18 @@ void screen_set_desktop(guint num)
 {
     GList *it;
     guint old;
+    XEvent e;
      
     g_assert(num < screen_num_desktops);
 
-    g_message("Moving to desktop %u", num);
-  
     old = screen_desktop;
     screen_desktop = num;
     PROP_SET32(ob_root, net_current_desktop, cardinal, num);
 
     if (old == num) return;
 
+    g_message("Moving to desktop %d", num+1);
+
     /* show windows before hiding the rest to lessen the enter/leave events */
 
     /* show windows from top to bottom */
@@ -294,6 +297,12 @@ void screen_set_desktop(guint num)
             engine_frame_hide(c->frame);
     }
 
+    /* focus the last focused window on the desktop, and ignore enter events
+       from the switch so it doesnt mess with the focus */
+    XSync(ob_display, FALSE);
+    while (XCheckTypedEvent(ob_display, EnterNotify, &e));
+    focus_fallback(Fallback_Desktop);
+
     dispatch_ob(Event_Ob_Desktop, num, old);
 }
 
@@ -426,13 +435,13 @@ void screen_install_colormap(Client *client, gboolean install)
 
 void screen_update_struts()
 {
-    GSList *it;
+    GList *it;
     guint i;
      
     g_free(strut);
     strut = g_new0(Strut, screen_num_desktops + 1);
 
-    for (it = client_list; it; it = it->next) {
+    for (it = client_list; it != NULL; it = it->next) {
        Client *c = it->data;
        if (c->iconic) continue; /* these dont count in the strut */
     
@@ -498,7 +507,7 @@ static void screen_update_area()
 */
        if (!RECT_EQUAL(old_area, area[i])) {
            /* the area has changed, adjust all the maximized windows */
-           GSList *it;
+           GList *it;
            for (it = client_list; it; it = it->next) {
                Client *c = it->data;
                if (i < screen_num_desktops) {
This page took 0.0313 seconds and 4 git commands to generate.