summaryrefslogtreecommitdiff
path: root/openbox/focus.c
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-03-16 21:11:39 +0000
committerDana Jansens <danakj@orodu.net>2003-03-16 21:11:39 +0000
commitf8a47de5ec444c452093371e3db16857eb39a490 (patch)
tree31db2567842d98232775f9980f7a8d2586c0ac71 /openbox/focus.c
parent8ba0586bcbdc7fe9648f1063812126d71a041670 (diff)
merge the C branch into HEAD
Diffstat (limited to 'openbox/focus.c')
-rw-r--r--openbox/focus.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/openbox/focus.c b/openbox/focus.c
new file mode 100644
index 00000000..3c7b635b
--- /dev/null
+++ b/openbox/focus.c
@@ -0,0 +1,57 @@
+#include "openbox.h"
+#include "client.h"
+#include "screen.h"
+#include "prop.h"
+#include "hooks.h"
+
+#include <X11/Xlib.h>
+
+Client *focus_client = NULL;
+
+Window focus_backup = None;
+
+void focus_set_client(Client *client);
+
+void focus_startup()
+{
+ /* create the window which gets focus when no clients get it. Have to
+ make it override-redirect so we don't try manage it, since it is
+ mapped. */
+ XSetWindowAttributes attrib;
+
+ attrib.override_redirect = TRUE;
+ focus_backup = XCreateWindow(ob_display, ob_root,
+ -100, -100, 1, 1, 0, 0, InputOnly,
+ CopyFromParent, CWOverrideRedirect, &attrib);
+ XMapRaised(ob_display, focus_backup);
+
+ /* start with nothing focused */
+ focus_set_client(NULL);
+}
+
+void focus_set_client(Client *client)
+{
+ Window active;
+
+ /* sometimes this is called with the already-focused window, this is
+ important for the python scripts to work (eg, c = 0 twice). don't just
+ return if _focused_client == c */
+
+ /* uninstall the old colormap, and install the new one */
+ screen_install_colormap(focus_client, FALSE);
+ screen_install_colormap(client, TRUE);
+
+
+ if (client == NULL) {
+ /* when nothing will be focused, send focus to the backup target */
+ XSetInputFocus(ob_display, focus_backup, RevertToNone, CurrentTime);
+ }
+
+ focus_client = client;
+
+ /* set the NET_ACTIVE_WINDOW hint */
+ active = client ? client->window : None;
+ PROP_SET32(ob_root, net_active_window, window, active);
+
+ HOOKFIRECLIENT(focused, client);
+}