-
Notifications
You must be signed in to change notification settings - Fork 5
/
kiosk-wm.c
36 lines (30 loc) · 1.11 KB
/
kiosk-wm.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
#include <X11/Xlib.h>
int main() {
Display *display = XOpenDisplay(0x0);
if (!display) return 1;
Window root = DefaultRootWindow(display);
// This allows us to receive CreateNotify and ConfigureNotify events.
XSelectInput(display, root, SubstructureNotifyMask);
for(;;) {
XEvent ev;
XNextEvent(display, &ev);
if (ev.type == CreateNotify) {
// MoveResize all created windows.
XMoveResizeWindow(display, ev.xcreatewindow.window, 0, 0, 1920, 1080);
} else if (ev.type == ConfigureNotify) {
// We may also need to catch windows that move or resize themselves.
// A lot of applications resize their windows immediately after creating them.
XConfigureEvent ce = ev.xconfigure;
// Only MoveResize if it's not correct already.
if (
ce.x != 0
|| ce.y != 0
|| ce.width != 1920
|| ce.height != 1080
) {
XMoveResizeWindow(display, ce.window, 0, 0, 1920, 1080);
}
}
}
return 0;
}