10 Client
*focus_client
= NULL
;
11 GList
**focus_order
= NULL
; /* these lists are created when screen_startup
12 sets the number of desktops */
14 Window focus_backup
= None
;
16 void focus_set_client(Client
*client
);
20 /* create the window which gets focus when no clients get it. Have to
21 make it override-redirect so we don't try manage it, since it is
23 XSetWindowAttributes attrib
;
25 attrib
.override_redirect
= TRUE
;
26 focus_backup
= XCreateWindow(ob_display
, ob_root
,
27 -100, -100, 1, 1, 0, 0, InputOnly
,
28 CopyFromParent
, CWOverrideRedirect
, &attrib
);
29 XMapRaised(ob_display
, focus_backup
);
31 /* start with nothing focused */
32 focus_set_client(NULL
);
39 for (i
= 0; i
< screen_num_desktops
; ++i
)
40 g_list_free(focus_order
[i
]);
43 /* reset focus to root */
44 XSetInputFocus(ob_display
, PointerRoot
, RevertToNone
, CurrentTime
);
47 void focus_set_client(Client
*client
)
53 /* uninstall the old colormap, and install the new one */
54 screen_install_colormap(focus_client
, FALSE
);
55 screen_install_colormap(client
, TRUE
);
59 /* when nothing will be focused, send focus to the backup target */
60 XSetInputFocus(ob_display
, focus_backup
, RevertToNone
, CurrentTime
);
64 focus_client
= client
;
66 /* move to the top of the list */
68 desktop
= client
->desktop
;
69 if (desktop
== DESKTOP_ALL
) desktop
= screen_desktop
;
70 focus_order
[desktop
] = g_list_remove(focus_order
[desktop
], client
);
71 focus_order
[desktop
] = g_list_prepend(focus_order
[desktop
], client
);
74 /* set the NET_ACTIVE_WINDOW hint */
75 active
= client
? client
->window
: None
;
76 PROP_SET32(ob_root
, net_active_window
, window
, active
);
78 if (focus_client
!= NULL
)
79 dispatch_client(Event_Client_Focus
, focus_client
, 0, 0);
81 dispatch_client(Event_Client_Unfocus
, old
, 0, 0);