#include "../kernel/dispatch.h"
#include "../kernel/screen.h"
#include "../kernel/client.h"
+#include "../kernel/focus.h"
#include "../kernel/stacking.h"
static GSList **focus_order = NULL;
client_focus(e->data.c.client);
break;
+ case Event_Client_Destroy:
+ i = e->data.c.client->desktop;
+ focus_order[i] = g_slist_remove(focus_order[i], e->data.c.client);
+ break;
+
case Event_Ob_NumDesktops:
new = e->data.o.num[0];
old = e->data.o.num[1];
break;
case Event_Ob_Desktop:
- for (it = focus_order[e->data.o.num[0]]; it != NULL; it = it->next)
+ /* focus the next available target */
+ new = e->data.o.num[0];
+ for (it = focus_order[new]; it != NULL; it = it->next)
if (client_focus(it->data))
break;
break;
+ case Event_Client_Unfocus:
+ if (focus_client == NULL) { /* nothing is left with focus! */
+ /* focus the next available target */
+ for (it = focus_order[screen_desktop]; it != NULL; it = it->next)
+ if (client_focus(it->data))
+ break;
+ }
+ break;
+
case Event_Client_Focus:
/* move to the top of the list */
focus_order[e->data.c.num[1]] =
{
guint i;
- dispatch_register(Event_Client_Mapped | Event_Ob_Desktop |
- Event_Ob_NumDesktops | Event_Client_Focus |
- Event_Client_Desktop, (EventHandler)events, NULL);
+ dispatch_register(Event_Client_Mapped | Event_Client_Destroy |
+ Event_Ob_Desktop | Event_Ob_NumDesktops |
+ Event_Client_Focus | Event_Client_Unfocus |
+ Event_Client_Desktop,
+ (EventHandler)events, NULL);
focus_order = g_new(GSList*, screen_num_desktops);
for (i = 0; i < screen_num_desktops; ++i)