X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fscreen.c;h=928c1ef62c6d8c3180f8f64050a03be949fec845;hb=3443454f33f88e10f187b78594ecfb5c09e1448d;hp=b2975e7283c93e04c4209bb9c66f9302707f06bd;hpb=4fbc127a5737935a0808cfa13418e4ff23129266;p=chaz%2Fopenbox diff --git a/openbox/screen.c b/openbox/screen.c index b2975e72..928c1ef6 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -153,7 +153,9 @@ void screen_startup() /* get the initial size */ screen_resize(); + screen_num_desktops = 0; screen_set_num_desktops(4); + screen_desktop = 0; screen_set_desktop(0); /* don't start in showing-desktop mode */ @@ -184,10 +186,10 @@ void screen_shutdown() 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); @@ -206,27 +208,9 @@ void screen_set_num_desktops(guint num) { guint i, old; gulong *viewport; - + GSList *it; + g_assert(num > 0); - - /* move windows on desktops that will no longer exist! */ - /* XXX - std::list::iterator it, end = clients.end(); - for (it = clients.begin(); it != end; ++it) { - unsigned int d = (*it)->desktop(); - if (d >= num && d != 0xffffffff) { - XEvent ce; - ce.xclient.type = ClientMessage; - ce.xclient.message_type = otk::Property::atoms.net_wm_desktop; - ce.xclient.display = **otk::display; - ce.xclient.window = (*it)->window(); - ce.xclient.format = 32; - ce.xclient.data.l[0] = num - 1; - XSendEvent(**otk::display, _info->rootWindow(), false, - SubstructureNotifyMask | SubstructureRedirectMask, &ce); - } - } - */ old = screen_num_desktops; screen_num_desktops = num; @@ -256,6 +240,13 @@ void screen_set_num_desktops(guint num) for (i = old; i < num; ++i) focus_order[i] = NULL; + /* move windows on desktops that will no longer exist! */ + for (it = client_list; it != NULL; it = it->next) { + Client *c = it->data; + if (c->desktop >= num) + client_set_desktop(c, num - 1); + } + dispatch_ob(Event_Ob_NumDesktops, num, old); /* change our desktop if we're on one that no longer exists! */ @@ -278,12 +269,7 @@ void screen_set_desktop(guint 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) { @@ -292,6 +278,13 @@ void screen_set_desktop(guint num) engine_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)) + engine_frame_hide(c->frame); + } + dispatch_ob(Event_Ob_Desktop, num, old); } @@ -375,24 +368,16 @@ void screen_update_desktop_names() void screen_show_desktop(gboolean show) { GList *it; - static Window saved_focus = 0; if (show == screen_showing_desktop) return; /* no change */ - /* save the window focus, and restore it when leaving the show-desktop - mode */ - if (show && focus_client) - saved_focus = focus_client->window; - screen_showing_desktop = show; if (show) { /* bottom to top */ for (it = g_list_last(stacking_list); it != NULL; it = it->prev) { Client *client = it->data; - if (client->type == Type_Desktop) - client_focus(client); - else if (client->frame->visible && !client_should_show(client)) + if (client->frame->visible && !client_should_show(client)) engine_frame_hide(client->frame); } } else { @@ -404,15 +389,6 @@ void screen_show_desktop(gboolean show) } } - if (!show) { - Client *f = focus_client; - if (!f || f->type == Type_Desktop) { - Client *c = g_hash_table_lookup(client_map, - (gpointer)saved_focus); - if (c) client_focus(c); - } - } - show = !!show; /* make it boolean */ PROP_SET32(ob_root, net_showing_desktop, cardinal, show); @@ -421,14 +397,16 @@ void screen_show_desktop(gboolean show) void screen_install_colormap(Client *client, gboolean install) { + XWindowAttributes wa; + if (client == NULL) { if (install) XInstallColormap(ob_display, render_colormap); else XUninstallColormap(ob_display, render_colormap); } else { - XWindowAttributes wa; - if (XGetWindowAttributes(ob_display, client->window, &wa)) { + if (XGetWindowAttributes(ob_display, client->window, &wa) && + wa.colormap != None) { if (install) XInstallColormap(ob_display, wa.colormap); else @@ -442,11 +420,10 @@ void screen_update_struts() GSList *it; guint i; - if (strut != NULL) - g_free(strut); + g_free(strut); strut = g_new0(Strut, screen_num_desktops + 1); - for (it = client_list; it; it = it->next) { + for (it = client_list; it != NULL; it = it->next) { Client *c = it->data; if (c->iconic) continue; /* these dont count in the strut */ @@ -467,9 +444,8 @@ static void screen_update_area() { guint i; gulong *dims; - - if (area != NULL) - g_free(area); + + g_free(area); area = g_new0(Rect, screen_num_desktops + 1); dims = g_new(unsigned long, 4 * screen_num_desktops);