X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fscreen.c;h=9f14ea8cb68f735d3952005920986be890fb2b8f;hb=5cf61ee02354c1c9f80c11f3796afc4b948055d6;hp=5c0f255f422e784c69ac686420b5b0b22d75838e;hpb=d1de946a62c73634ae86384f9f33b2dd2fce4941;p=chaz%2Fopenbox diff --git a/openbox/screen.c b/openbox/screen.c index 5c0f255f..9f14ea8c 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -1,9 +1,9 @@ #include "openbox.h" #include "prop.h" +#include "config.h" #include "screen.h" #include "client.h" #include "frame.h" -#include "engine.h" #include "focus.h" #include "dispatch.h" #include "../render/render.h" @@ -148,13 +148,23 @@ gboolean screen_annex() void screen_startup() { + GSList *it; + screen_desktop_names = g_ptr_array_new(); /* get the initial size */ screen_resize(); + /* set the names */ + for (it = config_desktops_names; it; it = it->next) + g_ptr_array_add(screen_desktop_names, it->data); /* dont strdup */ + PROP_SETSA(ob_root, net_desktop_names, utf8, screen_desktop_names); + g_ptr_array_set_size(screen_desktop_names, 0); /* rm the ptrs so they dont + get frees when we + update the desktop + names */ screen_num_desktops = 0; - screen_set_num_desktops(4); + screen_set_num_desktops(config_desktops_num); screen_desktop = 0; screen_set_desktop(0); @@ -208,7 +218,7 @@ void screen_set_num_desktops(guint num) { guint i, old; gulong *viewport; - GSList *it; + GList *it; g_assert(num > 0); @@ -244,7 +254,7 @@ void screen_set_num_desktops(guint num) for (it = client_list; it != NULL; it = it->next) { Client *c = it->data; if (c->desktop >= num) - client_set_desktop(num - 1); + client_set_desktop(c, num - 1, FALSE); } dispatch_ob(Event_Ob_NumDesktops, num, old); @@ -258,33 +268,40 @@ void screen_set_desktop(guint num) { GList *it; guint old; + XEvent e; 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; + g_message("Moving to desktop %d", num+1); + /* 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) { Client *c = it->data; if (!c->frame->visible && client_should_show(c)) - engine_frame_show(c->frame); + 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); + frame_hide(c->frame); } + /* focus the last focused window on the desktop, and ignore enter events + from the switch so it doesnt mess with the focus */ + XSync(ob_display, FALSE); + while (XCheckTypedEvent(ob_display, EnterNotify, &e)); + focus_fallback(Fallback_Desktop); + dispatch_ob(Event_Ob_Desktop, num, old); } @@ -378,14 +395,14 @@ void screen_show_desktop(gboolean show) for (it = g_list_last(stacking_list); it != NULL; it = it->prev) { Client *client = it->data; if (client->frame->visible && !client_should_show(client)) - engine_frame_hide(client->frame); + frame_hide(client->frame); } } else { /* top to bottom */ for (it = stacking_list; it != NULL; it = it->next) { Client *client = it->data; if (!client->frame->visible && client_should_show(client)) - engine_frame_show(client->frame); + frame_show(client->frame); } } @@ -417,7 +434,7 @@ void screen_install_colormap(Client *client, gboolean install) void screen_update_struts() { - GSList *it; + GList *it; guint i; g_free(strut); @@ -489,7 +506,7 @@ static void screen_update_area() */ if (!RECT_EQUAL(old_area, area[i])) { /* the area has changed, adjust all the maximized windows */ - GSList *it; + GList *it; for (it = client_list; it; it = it->next) { Client *c = it->data; if (i < screen_num_desktops) {