master ohmu/wmutils / src / core / ignw.c
ohmu  ·  2026-07-25
 1/* See LICENSE file for copyright and license details. */
 2
 3#include <stdio.h>
 4#include <stdlib.h>
 5#include <err.h>
 6#include <xcb/xcb.h>
 7#include <xcb/xcb_aux.h>
 8
 9#include "arg.h"
10#include "util.h"
11
12static xcb_connection_t *conn;
13
14static void usage(char *);
15static void set_override(xcb_window_t, int);
16
17static void
18usage(char *name)
19{
20	fprintf(stderr, "usage: %s [-sr] <wid> [wid..]\n", name);
21	exit(1);
22}
23
24static void
25set_override(xcb_window_t w, int or)
26{
27	uint32_t mask = XCB_CW_OVERRIDE_REDIRECT;
28	uint32_t val[] = { or };
29
30	xcb_change_window_attributes(conn, w, mask, val);
31}
32
33int
34main(int argc, char **argv)
35{
36	int setflag = 0;
37	char *argv0;
38
39	ARGBEGIN {
40		case 's': setflag = 1; break;
41		case 'r': setflag = 0; break;
42		default: usage(argv0);
43	} ARGEND;
44
45	init_xcb(&conn);
46
47	while (*argv)
48		set_override(strtoul(*argv++, NULL, 16), setflag);
49
50	xcb_aux_sync(conn);
51
52	kill_xcb(&conn);
53
54	return 0;
55}