SubstructureNotifyMask | SubstructureRedirectMask | \
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
-guint screen_num_desktops = 1;
+guint screen_num_desktops = 0;
guint screen_desktop = 0;
Size screen_physical_size;
gboolean screen_showing_desktop;
static Rect *area = NULL;
static Strut *strut = NULL;
+static Window support_window = None;
static void screen_update_area();
gboolean screen_annex()
{
XErrorHandler old;
- Window support;
pid_t pid;
int i, num_support;
Atom *supported;
PROP_SET32(ob_root, openbox_pid, cardinal, pid);
/* create the netwm support window */
- support = XCreateSimpleWindow(ob_display, ob_root, 0, 0, 1, 1, 0, 0, 0);
+ support_window = XCreateSimpleWindow(ob_display, ob_root, 0,0,1,1,0,0,0);
/* set supporting window */
- PROP_SET32(ob_root, net_supporting_wm_check, window, support);
+ PROP_SET32(ob_root, net_supporting_wm_check, window, support_window);
/* set properties on the supporting window */
- PROP_SETS(support, net_wm_name, utf8, "Openbox");
- PROP_SET32(support, net_supporting_wm_check, window, support);
+ PROP_SETS(support_window, net_wm_name, utf8, "Openbox");
+ PROP_SET32(support_window, net_supporting_wm_check, window,support_window);
/* set the _NET_SUPPORTED_ATOMS hint */
num_support = 48;
void screen_shutdown()
{
guint i;
+
+ XSelectInput(ob_display, ob_root, NoEventMask);
+
+ PROP_ERASE(ob_root, openbox_pid); /* we're not running here no more! */
+ PROP_ERASE(ob_root, net_supported); /* not without us */
+ PROP_ERASE(ob_root, net_showing_desktop); /* don't keep this mode */
+
+ XDestroyWindow(ob_display, support_window);
+
for (i = 0; i < screen_desktop_names->len; ++i)
g_free(g_ptr_array_index(screen_desktop_names, i));
g_ptr_array_free(screen_desktop_names, TRUE);
void screen_resize()
{
- /* Set the _NET_DESKTOP_GEOMETRY hint */
/* XXX RandR support here? */
int geometry[2];
+ /* Set the _NET_DESKTOP_GEOMETRY hint */
geometry[0] = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen));
geometry[1] = HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen));
PROP_SET32A(ob_root, net_desktop_geometry, cardinal, geometry, 2);
void screen_set_num_desktops(guint num)
{
- unsigned long *viewport;
+ guint i, old;
+ gulong *viewport;
g_assert(num > 0);
}
*/
+ 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);
/* may be some unnamed desktops that we need to fill in with names */
screen_update_desktop_names();
- dispatch_ob(Event_Ob_NumDesktops);
+ /* 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)
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;
- /* 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 before hiding the rest to lessen the enter/leave events */
/* show windows from top to bottom */
for (it = stacking_list; it != NULL; it = it->next) {
engine_frame_show(c->frame);
}
- dispatch_ob(Event_Ob_Desktop);
+ /* 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);
+ }
+
+ dispatch_ob(Event_Ob_Desktop, num, old);
}
void screen_update_layout()
}
}
- 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);
+ dispatch_ob(Event_Ob_ShowDesktop, show, 0);
}
void screen_install_colormap(Client *client, gboolean install)