split things off into screen.c/h
[dana/dcompmgr.git] / dcompmgr.c
1 #include "screen.h"
2 #include "gettext.h"
3
4 #include <glib.h>
5 #include <stdio.h>
6 #include <string.h>
7 #include <xcb/xcb.h>
8
9 static d_screen_t        *screens = NULL;
10
11 static gint
12 all_screens(xcb_connection_t *conn)
13 {
14     static const xcb_setup_t *setup;
15     xcb_screen_iterator_t it;
16     int count, i;
17     d_screen_t sc;
18
19     setup = xcb_get_setup(conn);
20
21     count = i = 0;
22     for (it = xcb_setup_roots_iterator(setup); it.rem; xcb_screen_next(&it)) {
23         sc.super = *it.data;
24         sc.num = i++;
25         if (screen_register(conn, &sc)) {
26             ++count;
27             screens = g_renew(d_screen_t, screens, count);
28             screens[count-1] = sc;
29             printf(_("managing screen %d\n"), sc.num);
30         }
31     }
32     return count;
33 }
34
35 int
36 main(int argc, char **argv)
37 {
38     xcb_connection_t  *conn;
39
40     conn = xcb_connect(NULL, NULL);
41     if (!conn) {
42         printf(_("Unable to connect to display\n"));
43         return 1;
44     }
45
46     all_screens(conn);
47     
48
49     xcb_disconnect(conn);
50     return 0;
51 }