twm_get_focus - libwm - X windows manipulation library
(HTM) git clone git://z3bra.org/libwm
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit d9726345df54827e0e23029f47aefff3daec100b
(DIR) parent e72afad71ff21c17964634f381b1290acb6ff522
(HTM) Author: dcat <dcat@iotek.org>
Date: Sun, 22 Nov 2015 02:53:00 +0100
wm_get_focus
Diffstat:
M libwm.c | 18 ++++++++++++++++++
M wm.h | 6 ++++++
2 files changed, 24 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/libwm.c b/libwm.c
t@@ -109,6 +109,24 @@ wm_get_windows(xcb_window_t w, xcb_window_t **l)
return childnum;
}
+xcb_window_t
+wm_get_focus(void)
+{
+ xcb_window_t w = 0;
+ xcb_get_input_focus_cookie_t c;
+ xcb_get_input_focus_reply_t *r;
+
+ c = xcb_get_input_focus(conn);
+ r = xcb_get_input_focus_reply(conn, c, NULL);
+ if (r == NULL)
+ return -1;
+
+ w = r->focus;
+ free(r);
+ return w;
+}
+
+
int
wm_get_attribute(xcb_window_t w, int attr)
{
(DIR) diff --git a/wm.h b/wm.h
t@@ -104,6 +104,12 @@ int wm_get_screen();
int wm_get_windows(xcb_window_t wid, xcb_window_t **list);
/*
+ * Get focused window identifier
+ * returns -1 on error
+ */
+xcb_window_t wm_get_focus(void);
+
+/*
* Retrive the value of an attribute for a specific windows.
* The possible values for the attributes are:
* ATTR_W - width