+
+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