ohmu
·
2026-07-17
1// window teleport
2// can be used as a resizer/mover in scripts
3
4#include <xcb/xcb.h>
5#include <xcb/xcb_aux.h>
6#include <stdlib.h>
7#include <stdio.h>
8#include <inttypes.h>
9
10xcb_connection_t *connection;
11
12void
13teleport_window(xcb_window_t window, int x, int y, int w, int h)
14{
15 uint32_t properties[4] = { x, y, w, h };
16 uint32_t mask = XCB_CONFIG_WINDOW_X
17 | XCB_CONFIG_WINDOW_Y
18 | XCB_CONFIG_WINDOW_WIDTH
19 | XCB_CONFIG_WINDOW_HEIGHT;
20 xcb_configure_window(connection, window, mask, properties);
21}
22
23int
24main(int argc, char *argv[])
25{
26 xcb_window_t window;
27
28 if (argc != 6) {
29 fprintf(stderr, "usage: %s x y w h wid\n", argv[0]);
30 exit(1);
31 }
32 connection = xcb_connect(NULL,NULL);
33
34 window = strtoul(argv[5], NULL, 16);
35 if (!window) {
36 fprintf(stderr, "can't find window\n");
37 exit(1);
38 }
39
40 teleport_window(window, atoi(argv[1]), atoi(argv[2]),
41 atoi(argv[3]), atoi(argv[4]));
42 xcb_aux_sync(connection);
43 xcb_disconnect(connection);
44 return 0;
45}