forked from wmutils/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchwb.c
More file actions
80 lines (61 loc) · 1.3 KB
/
chwb.c
File metadata and controls
80 lines (61 loc) · 1.3 KB
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
72
73
74
75
76
77
78
79
80
/* See LICENSE file for copyright and license details. */
#include <xcb/xcb.h>
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include "arg.h"
#include "util.h"
static xcb_connection_t *conn;
static void usage(char *name);
static void set_border(int, int, xcb_window_t);
static void
usage(char *name)
{
fprintf(stderr, "usage: %s <-sc ...> <wid> [wid...]\n", name);
exit(1);
}
static void
set_border(int width, int color, xcb_window_t win)
{
uint32_t values[1];
int mask;
if (width != -1) {
values[0] = width;
mask = XCB_CONFIG_WINDOW_BORDER_WIDTH;
xcb_configure_window(conn, win, mask, values);
xcb_flush(conn);
}
if (color != -1) {
values[0] = color;
mask = XCB_CW_BORDER_PIXEL;
xcb_change_window_attributes(conn, win, mask, values);
xcb_flush(conn);
}
}
int
main(int argc, char **argv)
{
char *argv0;
int color,width;
color = width = -1;
if (argc < 2)
usage(argv[0]);
ARGBEGIN {
case 's':
width = strtoul(EARGF(usage(argv0)), NULL, 10);
break;
case 'c':
color = strtoul(EARGF(usage(argv0)), NULL, 16);
break;
default:
usage(argv0);
/* NOTREACHED */
} ARGEND
init_xcb(&conn);
/* assume remaining arguments are windows */
while (*argv)
set_border(width, color, strtoul(*argv++, NULL, 16));
xcb_flush(conn);
kill_xcb(&conn);
return 0;
}