]> Dogcows Code - chaz/openbox/blobdiff - openbox/screen.c
remove all the startup notification code from screen.c
[chaz/openbox] / openbox / screen.c
index 6c9042a99edb1b3b51d10a6cbb5ecbea60b9c95d..38ad8978d7cf32a56fc3e1637a46c8d4c210dd8e 100644 (file)
@@ -3,24 +3,17 @@
 #include "dock.h"
 #include "xerror.h"
 #include "prop.h"
-#include "startup.h"
 #include "grab.h"
-#include "timer.h"
+#include "startupnotify.h"
 #include "config.h"
 #include "screen.h"
 #include "client.h"
 #include "frame.h"
 #include "focus.h"
 #include "popup.h"
-#include "dispatch.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>
@@ -37,6 +30,7 @@
 guint    screen_num_desktops;
 guint    screen_num_monitors;
 guint    screen_desktop;
+guint    screen_last_desktop;
 Size     screen_physical_size;
 gboolean screen_showing_desktop;
 DesktopLayout screen_desktop_layout;
@@ -48,16 +42,6 @@ static Rect  *monitor_area;
 
 static Popup *desktop_cycle_popup;
 
-#ifdef USE_LIBSN
-static SnMonitorContext *sn_context;
-static int sn_busy_cnt;
-static ObTimer *sn_timer;
-
-static void sn_event_func(SnMonitorEvent *event, void *data);
-#endif
-
-static void set_root_cursor();
-
 static gboolean replace_wm()
 {
     char *wm_sn;
@@ -67,6 +51,7 @@ static gboolean replace_wm()
 
     wm_sn = g_strdup_printf("WM_S%d", ob_screen);
     wm_sn_atom = XInternAtom(ob_display, wm_sn, FALSE);
+    g_free(wm_sn);
 
     current_wm_sn_owner = XGetSelectionOwner(ob_display, wm_sn_atom);
     if (current_wm_sn_owner) {
@@ -179,9 +164,7 @@ gboolean screen_annex()
     }
 
 
-    ob_debug("Managing screen %d\n", ob_screen);
-
-    set_root_cursor();
+    screen_set_root_cursor();
 
     /* set the OPENBOX_PID hint */
     pid = getpid();
@@ -198,7 +181,7 @@ gboolean screen_annex()
                window, screen_support_win);
 
     /* set the _NET_SUPPORTED_ATOMS hint */
-    num_support = 61;
+    num_support = 50;
     i = 0;
     supported = g_new(guint32, num_support);
     supported[i++] = prop_atoms.net_current_desktop;
@@ -251,17 +234,6 @@ gboolean screen_annex()
     supported[i++] = prop_atoms.net_wm_state_below;
     supported[i++] = prop_atoms.net_moveresize_window;
     supported[i++] = prop_atoms.net_wm_moveresize;
-    supported[i++] = prop_atoms.net_wm_moveresize_size_topleft;
-    supported[i++] = prop_atoms.net_wm_moveresize_size_top;
-    supported[i++] = prop_atoms.net_wm_moveresize_size_topright;
-    supported[i++] = prop_atoms.net_wm_moveresize_size_right;
-    supported[i++] = prop_atoms.net_wm_moveresize_size_bottomright;
-    supported[i++] = prop_atoms.net_wm_moveresize_size_bottom;
-    supported[i++] = prop_atoms.net_wm_moveresize_size_bottomleft;
-    supported[i++] = prop_atoms.net_wm_moveresize_size_left;
-    supported[i++] = prop_atoms.net_wm_moveresize_move;
-    supported[i++] = prop_atoms.net_wm_moveresize_size_keyboard;
-    supported[i++] = prop_atoms.net_wm_moveresize_move_keyboard;
     g_assert(i == num_support);
 /*
   supported[] = prop_atoms.net_wm_action_stick;
@@ -274,15 +246,16 @@ gboolean screen_annex()
     return TRUE;
 }
 
-void screen_startup()
+void screen_startup(gboolean reconfig)
 {
     GSList *it;
     guint i;
 
     desktop_cycle_popup = popup_new(FALSE);
 
-    /* get the initial size */
-    screen_resize();
+    if (!reconfig)
+        /* get the initial size */
+        screen_resize();
 
     /* set the names */
     screen_desktop_names = g_new(char*,
@@ -295,48 +268,47 @@ void screen_startup()
     g_free(screen_desktop_names); /* dont free the individual strings */
     screen_desktop_names = NULL;
 
-    screen_num_desktops = 0;
+    if (!reconfig)
+        screen_num_desktops = 0;
     screen_set_num_desktops(config_desktops_num);
-    if (startup_desktop >= screen_num_desktops)
-        startup_desktop = 0;
-    screen_desktop = startup_desktop;
-    screen_set_desktop(startup_desktop);
+    if (!reconfig) {
+        screen_set_desktop(0);
 
-    /* don't start in showing-desktop mode */
-    screen_showing_desktop = FALSE;
-    PROP_SET32(RootWindow(ob_display, ob_screen),
-               net_showing_desktop, cardinal, screen_showing_desktop);
-
-    screen_update_layout();
+        /* don't start in showing-desktop mode */
+        screen_showing_desktop = FALSE;
+        PROP_SET32(RootWindow(ob_display, ob_screen),
+                   net_showing_desktop, cardinal, screen_showing_desktop);
 
-#ifdef USE_LIBSN
-    sn_context = sn_monitor_context_new(ob_sn_display, ob_screen,
-                                        sn_event_func, NULL, NULL);
-    sn_busy_cnt = 0;
-#endif
+        screen_update_layout();
+    }
 }
 
-void screen_shutdown()
+void screen_shutdown(gboolean reconfig)
 {
     Rect **r;
 
     popup_free(desktop_cycle_popup);
 
-    XSelectInput(ob_display, RootWindow(ob_display, ob_screen), NoEventMask);
+    if (!reconfig) {
+        XSelectInput(ob_display, RootWindow(ob_display, ob_screen),
+                     NoEventMask);
 
-    /* we're not running here no more! */
-    PROP_ERASE(RootWindow(ob_display, ob_screen), openbox_pid);
-    /* not without us */
-    PROP_ERASE(RootWindow(ob_display, ob_screen), net_supported);
-    /* don't keep this mode */
-    PROP_ERASE(RootWindow(ob_display, ob_screen), net_showing_desktop);
+        /* we're not running here no more! */
+        PROP_ERASE(RootWindow(ob_display, ob_screen), openbox_pid);
+        /* not without us */
+        PROP_ERASE(RootWindow(ob_display, ob_screen), net_supported);
+        /* don't keep this mode */
+        PROP_ERASE(RootWindow(ob_display, ob_screen), net_showing_desktop);
 
-    XDestroyWindow(ob_display, screen_support_win);
+        XDestroyWindow(ob_display, screen_support_win);
+    }
 
     g_strfreev(screen_desktop_names);
+    screen_desktop_names = NULL;
     for (r = area; *r; ++r)
         g_free(*r);
     g_free(area);
+    area = NULL;
 }
 
 void screen_resize()
@@ -414,8 +386,6 @@ void screen_set_num_desktops(guint num)
     /* change our struts/area to match (after moving windows) */
     screen_update_areas();
 
-    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);
@@ -436,6 +406,8 @@ void screen_set_desktop(guint num)
 
     if (old == num) return;
 
+    screen_last_desktop = old;
+
     ob_debug("Moving to desktop %d\n", num+1);
 
     /* show windows before hiding the rest to lessen the enter/leave events */
@@ -468,8 +440,6 @@ void screen_set_desktop(guint num)
 #ifdef DEBUG_FOCUS
     ob_debug("/switch fallback\n");
 #endif
-
-    dispatch_ob(Event_Ob_Desktop, num, old);
 }
 
 static void get_row_col(guint d, guint *r, guint *c)
@@ -602,7 +572,7 @@ static void popup_cycle(guint d, gboolean show)
 }
 
 guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear,
-                           gboolean done, gboolean cancel)
+                           gboolean dialog, gboolean done, gboolean cancel)
 {
     static gboolean first = TRUE;
     static gboolean lin;
@@ -612,8 +582,7 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear,
     if (cancel) {
         d = origd;
         goto done_cycle;
-    } else if (done) {
-        screen_set_desktop(d);
+    } else if (done && dialog) {
         goto done_cycle;
     }
     if (first) {
@@ -625,7 +594,6 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear,
     get_row_col(d, &r, &c);
 
     if (lin) {
-        g_message("linear %d", d);
         switch (dir) {
         case OB_DIRECTION_EAST:
             if (d < screen_num_desktops - 1)
@@ -643,7 +611,6 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear,
             assert(0);
             return screen_desktop;
         }
-        g_message("linear %d done", d);
     } else {
         switch (dir) {
         case OB_DIRECTION_EAST:
@@ -702,15 +669,17 @@ guint screen_cycle_desktop(ObDirection dir, gboolean wrap, gboolean linear,
         d = translate_row_col(r, c);
     }
 
-    popup_cycle(d, TRUE);
-    return d;
+    if (dialog) {
+        popup_cycle(d, TRUE);
+        return d;
+    }
 
 done_cycle:
     first = TRUE;
 
     popup_cycle(0, FALSE);
 
-    return d = screen_desktop;
+    return d;
 }
 
 void screen_update_layout()
@@ -859,8 +828,6 @@ void screen_show_desktop(gboolean show)
     show = !!show; /* make it boolean */
     PROP_SET32(RootWindow(ob_display, ob_screen),
                net_showing_desktop, cardinal, show);
-
-    dispatch_ob(Event_Ob_ShowDesktop, show, 0);
 }
 
 void screen_install_colormap(ObClient *client, gboolean install)
@@ -1083,72 +1050,15 @@ Rect *screen_physical_area_monitor(guint head)
     return &monitor_area[head];
 }
 
-static void set_root_cursor()
-{
-#ifdef USE_LIBSN
-        if (sn_busy_cnt)
-            XDefineCursor(ob_display, RootWindow(ob_display, ob_screen),
-                          ob_cursor(OB_CURSOR_BUSY));
-        else
-#endif
-            XDefineCursor(ob_display, RootWindow(ob_display, ob_screen),
-                          ob_cursor(OB_CURSOR_POINTER));
-}
-
-#ifdef USE_LIBSN
-static void sn_timeout(ObTimer *t, void *data)
+void screen_set_root_cursor()
 {
-    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();
+    if (sn_app_starting())
+        XDefineCursor(ob_display, RootWindow(ob_display, ob_screen),
+                      ob_cursor(OB_CURSOR_BUSY));
+    else
+        XDefineCursor(ob_display, RootWindow(ob_display, ob_screen),
+                      ob_cursor(OB_CURSOR_POINTER));
 }
-#endif
 
 gboolean screen_pointer_pos(int *x, int *y)
 {
This page took 0.02868 seconds and 4 git commands to generate.