ohmu
·
2026-07-25
1/* See LICENSE file for copyright and license details. */
2
3#include <xcb/xcb.h>
4#include <xcb/xcb_aux.h>
5#include <stdlib.h>
6#include <stdio.h>
7#include <err.h>
8
9#include "util.h"
10
11static xcb_connection_t *conn;
12
13static void usage(char *name);
14static void teleport(xcb_window_t, int, int, int, int);
15
16static void
17usage(char *name)
18{
19 fprintf(stderr, "usage: %s <x> <y> <w> <h> <wid>\n", name);
20 exit(1);
21}
22
23static void
24teleport(xcb_window_t win, int x, int y, int w, int h)
25{
26 uint32_t values[4];
27 uint32_t mask = XCB_CONFIG_WINDOW_X
28 | XCB_CONFIG_WINDOW_Y
29 | XCB_CONFIG_WINDOW_WIDTH
30 | XCB_CONFIG_WINDOW_HEIGHT;
31
32 values[0] = x;
33 values[1] = y;
34 values[2] = w;
35 values[3] = h;
36
37 xcb_configure_window(conn, win, mask, values);
38}
39
40int
41main(int argc, char **argv)
42{
43 xcb_window_t win;
44
45 if (argc != 6)
46 usage(argv[0]);
47
48 init_xcb(&conn);
49
50 win = strtoul(argv[5], NULL, 16);
51 if (!win)
52 errx(1, "cannot get window");
53
54 teleport(win, atoi(argv[1]), atoi(argv[2]),
55 atoi(argv[3]), atoi(argv[4]));
56 xcb_aux_sync(conn);
57
58 kill_xcb(&conn);
59
60 return 0;
61}