-
Notifications
You must be signed in to change notification settings - Fork 0
/
wizwm.c
36 lines (28 loc) · 980 Bytes
/
wizwm.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 "screen.h"
int main(int argc, char **argv)
{
xcb_connection_t *connection = connect_to_x_server(argv[1]); /* argv[1] will be NULL if argc==1 */
/* Iterate over each screen and attempt to manage it */
/* This is quite verbose but I can't find a more elegant way to do it */
const xcb_setup_t *setup = xcb_get_setup(connection);
xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup);
for(int i = 0; i < xcb_setup_roots_length(setup); ++i) {
xcb_screen_t *screen = iter.data;
/* There can be only one! */
if(detect_window_manager(connection, screen, i)) {
fprintf(stderr, "Another window manager is currently running on screen %d\n", i);
return 1;
}
printf("Screen %d are belong to us\n", i);
init(connection, screen);
xcb_screen_next(&iter);
}
xcb_flush(connection);
/* Wait for events */
xcb_generic_event_t *event;
while((event = xcb_wait_for_event(connection))) {
free(event);
}
xcb_disconnect(connection);
return 0;
}