]> icculus.org git repositories - dana/openbox.git/blob - openbox/screen.c
add ability to set a texture to None
[dana/openbox.git] / openbox / screen.c
1 #include "openbox.h"
2 #include "dock.h"
3 #include "xerror.h"
4 #include "prop.h"
5 #include "startup.h"
6 #include "timer.h"
7 #include "config.h"
8 #include "screen.h"
9 #include "client.h"
10 #include "frame.h"
11 #include "focus.h"
12 #include "dispatch.h"
13 #include "extensions.h"
14
15 #ifdef USE_LIBSN
16 #  define SN_API_NOT_YET_FROZEN
17 #  include <libsn/sn.h>
18 #endif
19
20 #include <X11/Xlib.h>
21 #ifdef HAVE_UNISTD_H
22 #  include <sys/types.h>
23 #  include <unistd.h>
24 #endif
25
26 /*! The event mask to grab on the root window */
27 #define ROOT_EVENTMASK (StructureNotifyMask | PropertyChangeMask | \
28                         EnterWindowMask | LeaveWindowMask | \
29                         SubstructureNotifyMask | SubstructureRedirectMask | \
30                         ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
31
32 guint    screen_num_desktops    = 0;
33 guint    screen_desktop         = 0;
34 Size     screen_physical_size;
35 gboolean screen_showing_desktop;
36 DesktopLayout screen_desktop_layout;
37 char   **screen_desktop_names = NULL;
38
39 static Rect  *area = NULL;
40 static Strut *strut = NULL;
41 static Window support_window = None;
42
43 #ifdef USE_LIBSN
44 static SnMonitorContext *sn_context;
45 static int sn_busy_cnt;
46 static Timer *sn_timer = NULL;
47
48 static void sn_event_func(SnMonitorEvent *event, void *data);
49 #endif
50
51 static void screen_update_area();
52 static void set_root_cursor();
53
54 static gboolean running;
55 static int another_running(Display *d, XErrorEvent *e)
56 {
57     (void)d;(void)e;
58     g_message("A window manager is already running on screen %d",
59               ob_screen);
60     running = TRUE;
61     return -1;
62 }
63
64 gboolean screen_annex()
65 {
66     XErrorHandler old;
67     pid_t pid;
68     int i, num_support;
69     guint32 *supported;
70
71     running = FALSE;
72     old = XSetErrorHandler(another_running);
73     XSelectInput(ob_display, ob_root, ROOT_EVENTMASK);
74     XSync(ob_display, FALSE);
75     XSetErrorHandler(old);
76     if (running)
77         return FALSE;
78
79     g_message("Managing screen %d", ob_screen);
80
81     set_root_cursor();
82
83     /* set the OPENBOX_PID hint */
84     pid = getpid();
85     PROP_SET32(ob_root, openbox_pid, cardinal, pid);
86
87     /* create the netwm support window */
88     support_window = XCreateSimpleWindow(ob_display, ob_root, 0,0,1,1,0,0,0);
89
90     /* set supporting window */
91     PROP_SET32(ob_root, net_supporting_wm_check, window, support_window);
92
93     /* set properties on the supporting window */
94     PROP_SETS(support_window, net_wm_name, "Openbox3");
95     PROP_SET32(support_window, net_supporting_wm_check, window,support_window);
96
97     /* set the _NET_SUPPORTED_ATOMS hint */
98     num_support = 61;
99     i = 0;
100     supported = g_new(guint32, num_support);
101     supported[i++] = prop_atoms.net_current_desktop;
102     supported[i++] = prop_atoms.net_number_of_desktops;
103     supported[i++] = prop_atoms.net_desktop_geometry;
104     supported[i++] = prop_atoms.net_desktop_viewport;
105     supported[i++] = prop_atoms.net_active_window;
106     supported[i++] = prop_atoms.net_workarea;
107     supported[i++] = prop_atoms.net_client_list;
108     supported[i++] = prop_atoms.net_client_list_stacking;
109     supported[i++] = prop_atoms.net_desktop_names;
110     supported[i++] = prop_atoms.net_close_window;
111     supported[i++] = prop_atoms.net_desktop_layout;
112     supported[i++] = prop_atoms.net_showing_desktop;
113     supported[i++] = prop_atoms.net_wm_name;
114     supported[i++] = prop_atoms.net_wm_visible_name;
115     supported[i++] = prop_atoms.net_wm_icon_name;
116     supported[i++] = prop_atoms.net_wm_visible_icon_name;
117     supported[i++] = prop_atoms.net_wm_desktop;
118     supported[i++] = prop_atoms.net_wm_strut;
119     supported[i++] = prop_atoms.net_wm_window_type;
120     supported[i++] = prop_atoms.net_wm_window_type_desktop;
121     supported[i++] = prop_atoms.net_wm_window_type_dock;
122     supported[i++] = prop_atoms.net_wm_window_type_toolbar;
123     supported[i++] = prop_atoms.net_wm_window_type_menu;
124     supported[i++] = prop_atoms.net_wm_window_type_utility;
125     supported[i++] = prop_atoms.net_wm_window_type_splash;
126     supported[i++] = prop_atoms.net_wm_window_type_dialog;
127     supported[i++] = prop_atoms.net_wm_window_type_normal;
128     supported[i++] = prop_atoms.net_wm_allowed_actions;
129     supported[i++] = prop_atoms.net_wm_action_move;
130     supported[i++] = prop_atoms.net_wm_action_resize;
131     supported[i++] = prop_atoms.net_wm_action_minimize;
132     supported[i++] = prop_atoms.net_wm_action_shade;
133     supported[i++] = prop_atoms.net_wm_action_maximize_horz;
134     supported[i++] = prop_atoms.net_wm_action_maximize_vert;
135     supported[i++] = prop_atoms.net_wm_action_fullscreen;
136     supported[i++] = prop_atoms.net_wm_action_change_desktop;
137     supported[i++] = prop_atoms.net_wm_action_close;
138     supported[i++] = prop_atoms.net_wm_state;
139     supported[i++] = prop_atoms.net_wm_state_modal;
140     supported[i++] = prop_atoms.net_wm_state_maximized_vert;
141     supported[i++] = prop_atoms.net_wm_state_maximized_horz;
142     supported[i++] = prop_atoms.net_wm_state_shaded;
143     supported[i++] = prop_atoms.net_wm_state_skip_taskbar;
144     supported[i++] = prop_atoms.net_wm_state_skip_pager;
145     supported[i++] = prop_atoms.net_wm_state_hidden;
146     supported[i++] = prop_atoms.net_wm_state_fullscreen;
147     supported[i++] = prop_atoms.net_wm_state_above;
148     supported[i++] = prop_atoms.net_wm_state_below;
149     supported[i++] = prop_atoms.net_moveresize_window;
150     supported[i++] = prop_atoms.net_wm_moveresize;
151     supported[i++] = prop_atoms.net_wm_moveresize_size_topleft;
152     supported[i++] = prop_atoms.net_wm_moveresize_size_top;
153     supported[i++] = prop_atoms.net_wm_moveresize_size_topright;
154     supported[i++] = prop_atoms.net_wm_moveresize_size_right;
155     supported[i++] = prop_atoms.net_wm_moveresize_size_bottomright;
156     supported[i++] = prop_atoms.net_wm_moveresize_size_bottom;
157     supported[i++] = prop_atoms.net_wm_moveresize_size_bottomleft;
158     supported[i++] = prop_atoms.net_wm_moveresize_size_left;
159     supported[i++] = prop_atoms.net_wm_moveresize_move;
160     supported[i++] = prop_atoms.net_wm_moveresize_size_keyboard;
161     supported[i++] = prop_atoms.net_wm_moveresize_move_keyboard;
162     g_assert(i == num_support);
163 /*
164   supported[] = prop_atoms.net_wm_action_stick;
165 */
166
167     PROP_SETA32(ob_root, net_supported, atom, supported, num_support);
168     g_free(supported);
169
170     return TRUE;
171 }
172
173 void screen_startup()
174 {
175     GSList *it;
176     guint i;
177
178     /* get the initial size */
179     screen_resize(WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)),
180                   HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen)));
181
182     /* set the names */
183     screen_desktop_names = g_new(char*,
184                                  g_slist_length(config_desktops_names) + 1);
185     for (i = 0, it = config_desktops_names; it; ++i, it = it->next)
186         screen_desktop_names[i] = it->data; /* dont strdup */
187     screen_desktop_names[i] = NULL;
188     PROP_SETSS(ob_root, net_desktop_names, screen_desktop_names);
189     g_free(screen_desktop_names); /* dont free the individual strings */
190     screen_desktop_names = NULL;
191
192     screen_num_desktops = 0;
193     screen_set_num_desktops(config_desktops_num);
194     if (startup_desktop >= screen_num_desktops)
195         startup_desktop = 0;
196     screen_desktop = startup_desktop;
197     screen_set_desktop(startup_desktop);
198
199     /* don't start in showing-desktop mode */
200     screen_showing_desktop = FALSE;
201     PROP_SET32(ob_root, net_showing_desktop, cardinal, screen_showing_desktop);
202
203     screen_update_layout();
204
205 #ifdef USE_LIBSN
206     sn_context = sn_monitor_context_new(ob_sn_display, ob_screen,
207                                         sn_event_func, NULL, NULL);
208     sn_busy_cnt = 0;
209 #endif
210 }
211
212 void screen_shutdown()
213 {
214     XSelectInput(ob_display, ob_root, NoEventMask);
215
216     PROP_ERASE(ob_root, openbox_pid); /* we're not running here no more! */
217     PROP_ERASE(ob_root, net_supported); /* not without us */
218     PROP_ERASE(ob_root, net_showing_desktop); /* don't keep this mode */
219
220     XDestroyWindow(ob_display, support_window);
221
222     g_strfreev(screen_desktop_names);
223     g_free(strut);
224     g_free(area);
225 }
226
227 void screen_resize(int w, int h)
228 {
229     GList *it;
230     guint32 geometry[2];
231
232     /* Set the _NET_DESKTOP_GEOMETRY hint */
233     geometry[0] = w;
234     geometry[1] = h;
235     PROP_SETA32(ob_root, net_desktop_geometry, cardinal, geometry, 2);
236     screen_physical_size.width = geometry[0];
237     screen_physical_size.height = geometry[1];
238
239     if (ob_state == State_Starting)
240         return;
241
242     dock_configure();
243     screen_update_struts();
244
245     for (it = client_list; it; it = it->next)
246         client_move_onscreen(it->data);
247 }
248
249 void screen_set_num_desktops(guint num)
250 {
251     guint i, old;
252     guint32 *viewport;
253     GList *it;
254
255     g_assert(num > 0);
256
257     old = screen_num_desktops;
258     screen_num_desktops = num;
259     PROP_SET32(ob_root, net_number_of_desktops, cardinal, num);
260
261     /* set the viewport hint */
262     viewport = g_new0(guint32, num * 2);
263     PROP_SETA32(ob_root, net_desktop_viewport, cardinal, viewport, num * 2);
264     g_free(viewport);
265
266     /* the number of rows/columns will differ */
267     screen_update_layout();
268
269     /* may be some unnamed desktops that we need to fill in with names */
270     screen_update_desktop_names();
271
272     /* update the focus lists */
273     /* free our lists for the desktops which have disappeared */
274     for (i = num; i < old; ++i)
275         g_list_free(focus_order[i]);
276     /* realloc the array */
277     focus_order = g_renew(GList*, focus_order, num);
278     /* set the new lists to be empty */
279     for (i = old; i < num; ++i)
280         focus_order[i] = NULL;
281
282     /* move windows on desktops that will no longer exist! */
283     for (it = client_list; it != NULL; it = it->next) {
284         Client *c = it->data;
285         if (c->desktop >= num && c->desktop != DESKTOP_ALL)
286             client_set_desktop(c, num - 1, FALSE);
287     }
288
289     /* change our struts/area to match (after moving windows) */
290     screen_update_struts();
291
292     dispatch_ob(Event_Ob_NumDesktops, num, old);
293
294     /* change our desktop if we're on one that no longer exists! */
295     if (screen_desktop >= screen_num_desktops)
296         screen_set_desktop(num - 1);
297 }
298
299 void screen_set_desktop(guint num)
300 {
301     GList *it;
302     guint old;
303     XEvent e;
304      
305     g_assert(num < screen_num_desktops);
306
307     old = screen_desktop;
308     screen_desktop = num;
309     PROP_SET32(ob_root, net_current_desktop, cardinal, num);
310
311     if (old == num) return;
312
313     g_message("Moving to desktop %d", num+1);
314
315     /* show windows before hiding the rest to lessen the enter/leave events */
316
317     /* show windows from top to bottom */
318     for (it = stacking_list; it != NULL; it = it->next) {
319         if (WINDOW_IS_CLIENT(it->data)) {
320             Client *c = it->data;
321             if (!c->frame->visible && client_should_show(c))
322                 frame_show(c->frame);
323         }
324     }
325
326     /* hide windows from bottom to top */
327     for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
328         if (WINDOW_IS_CLIENT(it->data)) {
329             Client *c = it->data;
330             if (c->frame->visible && !client_should_show(c))
331                 frame_hide(c->frame);
332         }
333     }
334
335     /* focus the last focused window on the desktop, and ignore enter events
336        from the switch so it doesnt mess with the focus */
337     while (XCheckTypedEvent(ob_display, EnterNotify, &e));
338     focus_fallback(Fallback_Desktop);
339
340     dispatch_ob(Event_Ob_Desktop, num, old);
341 }
342
343 void screen_update_layout()
344 {
345     guint32 *data = NULL;
346     guint num;
347
348     /* defaults */
349     screen_desktop_layout.orientation = prop_atoms.net_wm_orientation_horz;
350     screen_desktop_layout.start_corner = prop_atoms.net_wm_topleft;
351     screen_desktop_layout.rows = 1;
352     screen_desktop_layout.columns = screen_num_desktops;
353
354     if (PROP_GETA32(ob_root, net_desktop_layout, cardinal, &data, &num)) {
355         if (num == 3 || num == 4) {
356             if (data[0] == prop_atoms.net_wm_orientation_vert)
357                 screen_desktop_layout.orientation = data[0];
358             if (num == 3)
359                 screen_desktop_layout.start_corner =
360                     prop_atoms.net_wm_topright;
361             else {
362                 if (data[3] == prop_atoms.net_wm_topright)
363                     screen_desktop_layout.start_corner = data[3];
364                 else if (data[3] == prop_atoms.net_wm_bottomright)
365                     screen_desktop_layout.start_corner = data[3];
366                 else if (data[3] == prop_atoms.net_wm_bottomleft)
367                     screen_desktop_layout.start_corner = data[3];
368             }
369
370             /* fill in a zero rows/columns */
371             if (!(data[1] == 0 && data[2] == 0)) { /* both 0's is bad data.. */
372                 if (data[1] == 0) {
373                     data[1] = (screen_num_desktops +
374                                screen_num_desktops % data[2]) / data[2];
375                 } else if (data[2] == 0) {
376                     data[2] = (screen_num_desktops +
377                                screen_num_desktops % data[1]) / data[1];
378                 }
379                 screen_desktop_layout.columns = data[1];
380                 screen_desktop_layout.rows = data[2];
381             }
382
383             /* bounds checking */
384             if (screen_desktop_layout.orientation ==
385                 prop_atoms.net_wm_orientation_horz) {
386                 if (screen_desktop_layout.rows > screen_num_desktops)
387                     screen_desktop_layout.rows = screen_num_desktops;
388                 if (screen_desktop_layout.columns >
389                     ((screen_num_desktops + screen_num_desktops %
390                       screen_desktop_layout.rows) /
391                      screen_desktop_layout.rows))
392                     screen_desktop_layout.columns =
393                         (screen_num_desktops + screen_num_desktops %
394                          screen_desktop_layout.rows) /
395                         screen_desktop_layout.rows;
396             } else {
397                 if (screen_desktop_layout.columns > screen_num_desktops)
398                     screen_desktop_layout.columns = screen_num_desktops;
399                 if (screen_desktop_layout.rows >
400                     ((screen_num_desktops + screen_num_desktops %
401                       screen_desktop_layout.columns) /
402                      screen_desktop_layout.columns))
403                     screen_desktop_layout.rows =
404                         (screen_num_desktops + screen_num_desktops %
405                          screen_desktop_layout.columns) /
406                         screen_desktop_layout.columns;
407             }
408         }
409         g_free(data);
410     }
411 }
412
413 void screen_update_desktop_names()
414 {
415     guint i;
416
417     /* empty the array */
418     g_strfreev(screen_desktop_names);
419     screen_desktop_names = NULL;
420
421     if (PROP_GETSS(ob_root, net_desktop_names, utf8, &screen_desktop_names))
422         for (i = 0; screen_desktop_names[i] && i <= screen_num_desktops; ++i);
423     else
424         i = 0;
425     if (i <= screen_num_desktops) {
426         screen_desktop_names = g_renew(char*, screen_desktop_names,
427                                        screen_num_desktops + 1);
428         screen_desktop_names[screen_num_desktops] = NULL;
429         for (; i < screen_num_desktops; ++i)
430             screen_desktop_names[i] = g_strdup("Unnamed Desktop");
431     }
432 }
433
434 void screen_show_desktop(gboolean show)
435 {
436     GList *it;
437      
438     if (show == screen_showing_desktop) return; /* no change */
439
440     screen_showing_desktop = show;
441
442     if (show) {
443         /* bottom to top */
444         for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
445             if (WINDOW_IS_CLIENT(it->data)) {
446                 Client *client = it->data;
447                 if (client->frame->visible && !client_should_show(client))
448                     frame_hide(client->frame);
449             }
450         }
451     } else {
452         /* top to bottom */
453         for (it = stacking_list; it != NULL; it = it->next) {
454             if (WINDOW_IS_CLIENT(it->data)) {
455                 Client *client = it->data;
456                 if (!client->frame->visible && client_should_show(client))
457                     frame_show(client->frame);
458             }
459         }
460     }
461
462     if (show) {
463         /* focus desktop */
464         for (it = focus_order[screen_desktop]; it; it = it->next)
465             if (((Client*)it->data)->type == Type_Desktop &&
466                 client_focus(it->data))
467                 break;
468     } else {
469         focus_fallback(Fallback_NoFocus);
470     }
471
472     show = !!show; /* make it boolean */
473     PROP_SET32(ob_root, net_showing_desktop, cardinal, show);
474
475     dispatch_ob(Event_Ob_ShowDesktop, show, 0);
476 }
477
478 void screen_install_colormap(Client *client, gboolean install)
479 {
480     XWindowAttributes wa;
481
482     if (client == NULL) {
483         if (install)
484             XInstallColormap(ob_display,
485                              DefaultColormap(ob_display, ob_screen));
486         else
487             XUninstallColormap(ob_display,
488                                DefaultColormap(ob_display, ob_screen));
489     } else {
490         if (XGetWindowAttributes(ob_display, client->window, &wa) &&
491             wa.colormap != None) {
492             xerror_set_ignore(TRUE);
493             if (install)
494                 XInstallColormap(ob_display, wa.colormap);
495             else
496                 XUninstallColormap(ob_display, wa.colormap);
497             xerror_set_ignore(FALSE);
498         }
499     }
500 }
501
502 void screen_update_struts()
503 {
504     GList *it;
505     guint i;
506      
507     g_free(strut);
508     strut = g_new0(Strut, screen_num_desktops + 1);
509
510     for (it = client_list; it != NULL; it = it->next) {
511         Client *c = it->data;
512         if (c->iconic) continue; /* these dont count in the strut */
513     
514         if (c->desktop == 0xffffffff) {
515             for (i = 0; i < screen_num_desktops; ++i)
516                 STRUT_ADD(strut[i], c->strut);
517         } else {
518             g_assert(c->desktop < screen_num_desktops);
519             STRUT_ADD(strut[c->desktop], c->strut);
520         }
521         /* apply to the 'all desktops' strut */
522         STRUT_ADD(strut[screen_num_desktops], c->strut);
523     }
524
525     for (i = 0; i < screen_num_desktops; ++i)
526         STRUT_ADD(strut[i], dock_strut);
527
528     screen_update_area();
529 }
530
531 static void screen_update_area()
532 {
533     guint i;
534     guint32 *dims;
535
536     g_free(area);
537     area = g_new0(Rect, screen_num_desktops + 1);
538      
539     dims = g_new(guint32, 4 * screen_num_desktops);
540     for (i = 0; i < screen_num_desktops + 1; ++i) {
541         Rect old_area = area[i];
542 /*
543   #ifdef    XINERAMA
544   // reset to the full areas
545   if (isXineramaActive())
546   xineramaUsableArea = getXineramaAreas();
547   #endif // XINERAMA
548 */
549
550         RECT_SET(area[i], strut[i].left, strut[i].top,
551                  screen_physical_size.width - (strut[i].left +
552                                                strut[i].right),
553                  screen_physical_size.height - (strut[i].top +
554                                                 strut[i].bottom));
555     
556 /*
557   #ifdef    XINERAMA
558   if (isXineramaActive()) {
559   // keep each of the ximerama-defined areas inside the strut
560   RectList::iterator xit, xend = xineramaUsableArea.end();
561   for (xit = xineramaUsableArea.begin(); xit != xend; ++xit) {
562   if (xit->x() < usableArea.x()) {
563   xit->setX(usableArea.x());
564   xit->setWidth(xit->width() - usableArea.x());
565   }
566   if (xit->y() < usableArea.y()) {
567   xit->setY(usableArea.y());
568   xit->setHeight(xit->height() - usableArea.y());
569   }
570   if (xit->x() + xit->width() > usableArea.width())
571   xit->setWidth(usableArea.width() - xit->x());
572   if (xit->y() + xit->height() > usableArea.height())
573   xit->setHeight(usableArea.height() - xit->y());
574   }
575   }
576   #endif // XINERAMA
577 */
578         if (!RECT_EQUAL(old_area, area[i])) {
579             /* the area has changed, adjust all the maximized windows */
580             GList *it;
581             for (it = client_list; it; it = it->next) {
582                 Client *c = it->data;
583                 if (i < screen_num_desktops) {
584                     if (c->desktop == i)
585                         client_remaximize(c);
586                 } else {
587                     /* the 'all desktops' size */
588                     if (c->desktop == DESKTOP_ALL)
589                         client_remaximize(c);
590                 }
591             }
592         }
593
594         /* don't set these for the 'all desktops' area */
595         if (i < screen_num_desktops) {
596             dims[(i * 4) + 0] = area[i].x;
597             dims[(i * 4) + 1] = area[i].y;
598             dims[(i * 4) + 2] = area[i].width;
599             dims[(i * 4) + 3] = area[i].height;
600         }
601     }
602     PROP_SETA32(ob_root, net_workarea, cardinal,
603                 dims, 4 * screen_num_desktops);
604     g_free(dims);
605 }
606
607 Rect *screen_area(guint desktop)
608 {
609     if (desktop >= screen_num_desktops) {
610         if (desktop == DESKTOP_ALL)
611             return &area[screen_num_desktops];
612         return NULL;
613     }
614     return &area[desktop];
615 }
616
617 Strut *screen_strut(guint desktop)
618 {
619     if (desktop >= screen_num_desktops) {
620         if (desktop == DESKTOP_ALL)
621             return &strut[screen_num_desktops];
622         return NULL;
623     }
624     return &strut[desktop];
625 }
626
627 static void set_root_cursor()
628 {
629 #ifdef USE_LIBSN
630         if (sn_busy_cnt)
631             XDefineCursor(ob_display, ob_root, ob_cursors.busy);
632         else
633 #endif
634             XDefineCursor(ob_display, ob_root, ob_cursors.ptr);
635 }
636
637 #ifdef USE_LIBSN
638 static void sn_timeout(void *data)
639 {
640     timer_stop(sn_timer);
641     sn_timer = NULL;
642     sn_busy_cnt = 0;
643
644     set_root_cursor();
645 }
646
647 static void sn_event_func(SnMonitorEvent *ev, void *data)
648 {
649     SnStartupSequence *seq;
650     const char *seq_id, *bin_name;
651     int cnt = sn_busy_cnt;
652
653     if (!(seq = sn_monitor_event_get_startup_sequence(ev)))
654         return;
655
656     seq_id = sn_startup_sequence_get_id(seq);
657     bin_name = sn_startup_sequence_get_binary_name(seq);
658     
659     if (!(seq_id && bin_name))
660         return;
661
662     switch (sn_monitor_event_get_type(ev)) {
663     case SN_MONITOR_EVENT_INITIATED:
664         ++sn_busy_cnt;
665         if (sn_timer)
666             timer_stop(sn_timer);
667         /* 30 second timeout for apps to start */
668         sn_timer = timer_start(30 * 1000000, sn_timeout, NULL);
669         break;
670     case SN_MONITOR_EVENT_CHANGED:
671         break;
672     case SN_MONITOR_EVENT_COMPLETED:
673         if (sn_busy_cnt) --sn_busy_cnt;
674         if (sn_timer) {
675             timer_stop(sn_timer);
676             sn_timer = NULL;
677         }
678         break;
679     case SN_MONITOR_EVENT_CANCELED:
680         if (sn_busy_cnt) --sn_busy_cnt;
681         if (sn_timer) {
682             timer_stop(sn_timer);
683             sn_timer = NULL;
684         }
685     };
686
687     if (sn_busy_cnt != cnt)
688         set_root_cursor();
689 }
690 #endif