]> Dogcows Code - chaz/openbox/blobdiff - openbox/screen.c
fixed to accomodate the changes to the render/ API.
[chaz/openbox] / openbox / screen.c
index b43be922f88132264e990f6610f6280be21c3f4c..d438a8000114e67192672eddd0ff16f0ae71c373 100644 (file)
@@ -1,7 +1,9 @@
 #include "openbox.h"
-#include "slit.h"
+#include "dock.h"
+#include "xerror.h"
 #include "prop.h"
 #include "startup.h"
+#include "timer.h"
 #include "config.h"
 #include "screen.h"
 #include "client.h"
 #include "extensions.h"
 #include "../render/render.h"
 
+#ifdef USE_LIBSN
+#  define SN_API_NOT_YET_FROZEN
+#  include <libsn/sn.h>
+#endif
+
 #include <X11/Xlib.h>
 #ifdef HAVE_UNISTD_H
 #  include <sys/types.h>
@@ -34,7 +41,16 @@ static Rect  *area = NULL;
 static Strut *strut = NULL;
 static Window support_window = None;
 
+#ifdef USE_LIBSN
+static SnMonitorContext *sn_context;
+static int sn_busy_cnt;
+static Timer *sn_timer = NULL;
+
+static void sn_event_func(SnMonitorEvent *event, void *data);
+#endif
+
 static void screen_update_area();
+static void set_root_cursor();
 
 static gboolean running;
 static int another_running(Display *d, XErrorEvent *e)
@@ -63,8 +79,7 @@ gboolean screen_annex()
 
     g_message("Managing screen %d", ob_screen);
 
-    /* set the mouse cursor for the root window (the default cursor) */
-    XDefineCursor(ob_display, ob_root, ob_cursors.ptr);
+    set_root_cursor();
 
     /* set the OPENBOX_PID hint */
     pid = getpid();
@@ -77,7 +92,7 @@ gboolean screen_annex()
     PROP_SET32(ob_root, net_supporting_wm_check, window, support_window);
 
     /* set properties on the supporting window */
-    PROP_SETS(support_window, net_wm_name, "Openbox");
+    PROP_SETS(support_window, net_wm_name, "Openbox3");
     PROP_SET32(support_window, net_supporting_wm_check, window,support_window);
 
     /* set the _NET_SUPPORTED_ATOMS hint */
@@ -187,6 +202,12 @@ void screen_startup()
     PROP_SET32(ob_root, net_showing_desktop, cardinal, screen_showing_desktop);
 
     screen_update_layout();
+
+#ifdef USE_LIBSN
+    sn_context = sn_monitor_context_new(ob_sn_display, ob_screen,
+                                        sn_event_func, NULL, NULL);
+    sn_busy_cnt = 0;
+#endif
 }
 
 void screen_shutdown()
@@ -219,7 +240,7 @@ void screen_resize(int w, int h)
     if (ob_state == State_Starting)
        return;
 
-    slit_configure_all();
+    dock_configure();
     screen_update_struts();
 
     for (it = client_list; it; it = it->next)
@@ -296,22 +317,28 @@ void screen_set_desktop(guint num)
 
     /* 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))
-            frame_show(c->frame);
+        if (WINDOW_IS_CLIENT(it->data)) {
+            Client *c = it->data;
+            if (!c->frame->visible && client_should_show(c))
+                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))
-            frame_hide(c->frame);
+        if (WINDOW_IS_CLIENT(it->data)) {
+            Client *c = it->data;
+            if (c->frame->visible && !client_should_show(c))
+                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 */
     while (XCheckTypedEvent(ob_display, EnterNotify, &e));
+    g_message("switch fallback");
     focus_fallback(Fallback_Desktop);
+    g_message("/switch fallback");
 
     dispatch_ob(Event_Ob_Desktop, num, old);
 }
@@ -418,16 +445,20 @@ void screen_show_desktop(gboolean show)
     if (show) {
        /* bottom to top */
        for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
-           Client *client = it->data;
-           if (client->frame->visible && !client_should_show(client))
-                frame_hide(client->frame);
+            if (WINDOW_IS_CLIENT(it->data)) {
+                Client *client = it->data;
+                if (client->frame->visible && !client_should_show(client))
+                    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))
-                frame_show(client->frame);
+            if (WINDOW_IS_CLIENT(it->data)) {
+                Client *client = it->data;
+                if (!client->frame->visible && client_should_show(client))
+                    frame_show(client->frame);
+            }
        }
     }
 
@@ -453,16 +484,18 @@ void screen_install_colormap(Client *client, gboolean install)
 
     if (client == NULL) {
        if (install)
-           XInstallColormap(ob_display, render_colormap);
+           XInstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
        else
-           XUninstallColormap(ob_display, render_colormap);
+           XUninstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst));
     } else {
        if (XGetWindowAttributes(ob_display, client->window, &wa) &&
             wa.colormap != None) {
+            xerror_set_ignore(TRUE);
            if (install)
-               XInstallColormap(ob_display, wa.colormap);
+               XInstallColormap(RrDisplay(ob_rr_inst), wa.colormap);
            else
-               XUninstallColormap(ob_display, wa.colormap);
+               XUninstallColormap(RrDisplay(ob_rr_inst), wa.colormap);
+            xerror_set_ignore(FALSE);
        }
     }
 }
@@ -489,6 +522,10 @@ void screen_update_struts()
        /* apply to the 'all desktops' strut */
        STRUT_ADD(strut[screen_num_desktops], c->strut);
     }
+
+    for (i = 0; i < screen_num_desktops; ++i)
+        STRUT_ADD(strut[i], dock_strut);
+
     screen_update_area();
 }
 
@@ -546,11 +583,11 @@ static void screen_update_area()
                Client *c = it->data;
                if (i < screen_num_desktops) {
                    if (c->desktop == i)
-                       client_remaximize(c);
+                        client_reconfigure(c);
                } else {
                    /* the 'all desktops' size */
                    if (c->desktop == DESKTOP_ALL)
-                       client_remaximize(c);
+                        client_reconfigure(c);
                }
            }
        }
@@ -587,3 +624,68 @@ Strut *screen_strut(guint desktop)
     }
     return &strut[desktop];
 }
+
+static void set_root_cursor()
+{
+#ifdef USE_LIBSN
+        if (sn_busy_cnt)
+            XDefineCursor(ob_display, ob_root, ob_cursors.busy);
+        else
+#endif
+            XDefineCursor(ob_display, ob_root, ob_cursors.ptr);
+}
+
+#ifdef USE_LIBSN
+static void sn_timeout(void *data)
+{
+    timer_stop(sn_timer);
+    sn_timer = NULL;
+    sn_busy_cnt = 0;
+
+    set_root_cursor();
+}
+
+static void sn_event_func(SnMonitorEvent *ev, void *data)
+{
+    SnStartupSequence *seq;
+    const char *seq_id, *bin_name;
+    int cnt = sn_busy_cnt;
+
+    if (!(seq = sn_monitor_event_get_startup_sequence(ev)))
+        return;
+
+    seq_id = sn_startup_sequence_get_id(seq);
+    bin_name = sn_startup_sequence_get_binary_name(seq);
+    
+    if (!(seq_id && bin_name))
+        return;
+
+    switch (sn_monitor_event_get_type(ev)) {
+    case SN_MONITOR_EVENT_INITIATED:
+        ++sn_busy_cnt;
+        if (sn_timer)
+            timer_stop(sn_timer);
+        /* 30 second timeout for apps to start */
+        sn_timer = timer_start(30 * 1000000, sn_timeout, NULL);
+        break;
+    case SN_MONITOR_EVENT_CHANGED:
+        break;
+    case SN_MONITOR_EVENT_COMPLETED:
+        if (sn_busy_cnt) --sn_busy_cnt;
+        if (sn_timer) {
+            timer_stop(sn_timer);
+            sn_timer = NULL;
+        }
+        break;
+    case SN_MONITOR_EVENT_CANCELED:
+        if (sn_busy_cnt) --sn_busy_cnt;
+        if (sn_timer) {
+            timer_stop(sn_timer);
+            sn_timer = NULL;
+        }
+    };
+
+    if (sn_busy_cnt != cnt)
+        set_root_cursor();
+}
+#endif
This page took 0.028451 seconds and 4 git commands to generate.