]> Dogcows Code - chaz/openbox/blobdiff - openbox/screen.c
move the openbox engine into librender and the kernel. the theme is loaded and stored...
[chaz/openbox] / openbox / screen.c
index 928c1ef62c6d8c3180f8f64050a03be949fec845..9f14ea8cb68f735d3952005920986be890fb2b8f 100644 (file)
@@ -1,9 +1,9 @@
 #include "openbox.h"
 #include "prop.h"
+#include "config.h"
 #include "screen.h"
 #include "client.h"
 #include "frame.h"
-#include "engine.h"
 #include "focus.h"
 #include "dispatch.h"
 #include "../render/render.h"
@@ -148,13 +148,23 @@ gboolean screen_annex()
 
 void screen_startup()
 {
+    GSList *it;
+
     screen_desktop_names = g_ptr_array_new();
      
     /* get the initial size */
     screen_resize();
 
+    /* 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(4);
+    screen_set_num_desktops(config_desktops_num);
     screen_desktop = 0;
     screen_set_desktop(0);
 
@@ -208,7 +218,7 @@ void screen_set_num_desktops(guint num)
 {
     guint i, old;
     gulong *viewport;
-    GSList *it;
+    GList *it;
 
     g_assert(num > 0);
 
@@ -244,7 +254,7 @@ void screen_set_num_desktops(guint num)
     for (it = client_list; it != NULL; it = it->next) {
         Client *c = it->data;
         if (c->desktop >= num)
-            client_set_desktop(c, num - 1);
+            client_set_desktop(c, num - 1, FALSE);
     }
 
     dispatch_ob(Event_Ob_NumDesktops, num, old);
@@ -258,33 +268,40 @@ 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 */
     for (it = stacking_list; it != NULL; it = it->next) {
         Client *c = it->data;
        if (!c->frame->visible && client_should_show(c))
-            engine_frame_show(c->frame);
+            frame_show(c->frame);
     }
 
     /* hide windows from bottom to top */
     for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
         Client *c = it->data;
        if (c->frame->visible && !client_should_show(c))
-            engine_frame_hide(c->frame);
+            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);
 }
 
@@ -378,14 +395,14 @@ void screen_show_desktop(gboolean show)
        for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
            Client *client = it->data;
            if (client->frame->visible && !client_should_show(client))
-                engine_frame_hide(client->frame);
+                frame_hide(client->frame);
        }
     } else {
         /* top to bottom */
        for (it = stacking_list; it != NULL; it = it->next) {
            Client *client = it->data;
            if (!client->frame->visible && client_should_show(client))
-                engine_frame_show(client->frame);
+                frame_show(client->frame);
        }
     }
 
@@ -417,7 +434,7 @@ void screen_install_colormap(Client *client, gboolean install)
 
 void screen_update_struts()
 {
-    GSList *it;
+    GList *it;
     guint i;
      
     g_free(strut);
@@ -489,7 +506,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.028138 seconds and 4 git commands to generate.