-
Notifications
You must be signed in to change notification settings - Fork 33
/
mapw.c
71 lines (57 loc) · 1.08 KB
/
mapw.c
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* See LICENSE file for copyright and license details. */
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include "arg.h"
#include "util.h"
enum {
MAP = 1 << 0,
UNMAP = 1 << 1,
TOGGLE = 1 << 2
};
static xcb_connection_t *conn;
static void usage(char *);
static void
usage(char *name)
{
fprintf(stderr, "usage: %s [-h] [-mut <wid> [wid..]]\n", name);
exit(1);
}
int
main(int argc, char **argv)
{
int mapflag = 0;
xcb_window_t w = 0;
char *argv0;
ARGBEGIN {
case 'm': mapflag = MAP; break;
case 'u': mapflag = UNMAP; break;
case 't': mapflag = TOGGLE; break;
default : usage(argv0);
} ARGEND;
if (argc < 1 || mapflag == 0)
usage(argv0);
init_xcb(&conn);
while (*argv) {
w = strtoul(*argv++, NULL, 16);
switch (mapflag) {
case MAP:
xcb_map_window(conn, w);
break;
case UNMAP:
xcb_unmap_window(conn, w);
break;
case TOGGLE:
if (mapped(conn, w))
xcb_unmap_window(conn, w);
else
xcb_map_window(conn, w);
break;
}
}
xcb_aux_sync(conn);
kill_xcb(&conn);
return 0;
}