]> Dogcows Code - chaz/openbox/blobdiff - openbox/screen.c
move the focus_order lists into the kernel
[chaz/openbox] / openbox / screen.c
index d077c495e74b1f7c79b67f96ec028de4cc4ea228..01acbfe22ff6f40570d21888eced5f8a527d120d 100644 (file)
@@ -2,7 +2,11 @@
 #include "prop.h"
 #include "screen.h"
 #include "client.h"
+#include "frame.h"
+#include "engine.h"
 #include "focus.h"
+#include "dispatch.h"
+#include "../render/render.h"
 
 #include <X11/Xlib.h>
 #ifdef HAVE_UNISTD_H
@@ -191,7 +195,8 @@ void screen_resize()
 
 void screen_set_num_desktops(guint num)
 {
-    unsigned long *viewport;
+    guint i, old;
+    gulong *viewport;
      
     g_assert(num > 0);
   
@@ -214,11 +219,12 @@ void screen_set_num_desktops(guint num)
        }
     */
 
+    old = screen_num_desktops;
     screen_num_desktops = num;
     PROP_SET32(ob_root, net_number_of_desktops, cardinal, num);
 
     /* set the viewport hint */
-    viewport = g_new0(unsigned long, num * 2);
+    viewport = g_new0(gulong, num * 2);
     PROP_SET32A(ob_root, net_desktop_viewport, cardinal, viewport, num * 2);
     g_free(viewport);
 
@@ -231,6 +237,18 @@ void screen_set_num_desktops(guint num)
     /* may be some unnamed desktops that we need to fill in with names */
     screen_update_desktop_names();
 
+    /* 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;
+
+    dispatch_ob(Event_Ob_NumDesktops, num, old);
+
     /* change our desktop if we're on one that no longer exists! */
     if (screen_desktop >= screen_num_desktops)
        screen_set_desktop(num - 1);
@@ -239,24 +257,33 @@ void screen_set_num_desktops(guint num)
 void screen_set_desktop(guint num)
 {
     GList *it;
-
-    guint old = screen_desktop;
+    guint old;
      
     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;
 
-    for (it = stacking_list; it != NULL; it = it->next)
-       client_showhide(it->data, FALSE);
+    /* 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);
+    }
+
+    /* 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);
+    }
 
-    /* force the callbacks to fire */
-    if (focus_client == NULL)
-       focus_set_client(NULL);
+    dispatch_ob(Event_Ob_Desktop, num, old);
 }
 
 void screen_update_layout()
@@ -356,15 +383,15 @@ void screen_show_desktop(gboolean show)
            Client *client = it->data;
            if (client->type == Type_Desktop)
                client_focus(client);
-           else
-               client_showhide(client, FALSE);
+           else if (client->frame->visible && !client_should_show(client))
+                engine_frame_hide(client->frame);
        }
     } else {
         /* top to bottom */
        for (it = stacking_list; it != NULL; it = it->next) {
            Client *client = it->data;
-           if (client->type != Type_Desktop)
-               client_showhide(client, FALSE);
+           if (!client->frame->visible && client_should_show(client))
+                engine_frame_show(client->frame);
        }
     }
 
@@ -377,20 +404,19 @@ void screen_show_desktop(gboolean show)
        }
     }
 
-    show = show ? 1 : 0; /* make it boolean */
+    show = !!show; /* make it boolean */
     PROP_SET32(ob_root, net_showing_desktop, cardinal, show);
+
+    dispatch_ob(Event_Ob_ShowDesktop, show, 0);
 }
 
 void screen_install_colormap(Client *client, gboolean install)
 {
     if (client == NULL) {
-       /* XXX DONT USE THE DEFAULT SHIT HERE */
        if (install)
-           XInstallColormap(ob_display,
-                            DefaultColormap(ob_display, ob_screen));
+           XInstallColormap(ob_display, render_colormap);
        else
-           XUninstallColormap(ob_display,
-                              DefaultColormap(ob_display, ob_screen));
+           XUninstallColormap(ob_display, render_colormap);
     } else {
        XWindowAttributes wa;
        if (XGetWindowAttributes(ob_display, client->window, &wa)) {
This page took 0.024189 seconds and 4 git commands to generate.