-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathpfw.c
More file actions
45 lines (33 loc) · 761 Bytes
/
pfw.c
File metadata and controls
45 lines (33 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* See LICENSE file for copyright and license details. */
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include "util.h"
static xcb_connection_t *conn;
static xcb_window_t focus_window(void);
static xcb_window_t
focus_window(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)
errx(1, "xcb_get_input_focus");
w = r->focus;
free(r);
if (w == XCB_NONE || w == XCB_INPUT_FOCUS_POINTER_ROOT)
errx(1, "focus not set");
return w;
}
int
main(int argc, char **argv)
{
init_xcb(&conn);
printf("0x%08x\n", focus_window());
kill_xcb(&conn);
return 0;
}