]> Dogcows Code - chaz/openbox/blob - openbox/focus.c
kill a comment
[chaz/openbox] / openbox / focus.c
1 #include "openbox.h"
2 #include "client.h"
3 #include "screen.h"
4 #include "prop.h"
5 #include "dispatch.h"
6
7 #include <X11/Xlib.h>
8
9 Client *focus_client = NULL;
10
11 Window focus_backup = None;
12
13 void focus_set_client(Client *client);
14
15 void focus_startup()
16 {
17 /* create the window which gets focus when no clients get it. Have to
18 make it override-redirect so we don't try manage it, since it is
19 mapped. */
20 XSetWindowAttributes attrib;
21
22 attrib.override_redirect = TRUE;
23 focus_backup = XCreateWindow(ob_display, ob_root,
24 -100, -100, 1, 1, 0, 0, InputOnly,
25 CopyFromParent, CWOverrideRedirect, &attrib);
26 XMapRaised(ob_display, focus_backup);
27
28 /* start with nothing focused */
29 focus_set_client(NULL);
30 }
31
32 void focus_set_client(Client *client)
33 {
34 Window active;
35 Client *old;
36
37 /* uninstall the old colormap, and install the new one */
38 screen_install_colormap(focus_client, FALSE);
39 screen_install_colormap(client, TRUE);
40
41
42 if (client == NULL) {
43 /* when nothing will be focused, send focus to the backup target */
44 XSetInputFocus(ob_display, focus_backup, RevertToNone, CurrentTime);
45 }
46
47 old = focus_client;
48 focus_client = client;
49
50 /* set the NET_ACTIVE_WINDOW hint */
51 active = client ? client->window : None;
52 PROP_SET32(ob_root, net_active_window, window, active);
53
54 if (focus_client != NULL)
55 dispatch_client(Event_Client_Focus, focus_client, 0, 0);
56 if (old != NULL)
57 dispatch_client(Event_Client_Unfocus, old, 0, 0);
58 }
This page took 0.036756 seconds and 5 git commands to generate.