3 #include "ivi-controller-client-protocol.h"
8 #include <wayland-client.h>
12 struct wl_registry *r;
13 struct wl_array outputs;
15 struct ivi_controller *c;
18 static void c_screen(void *data, struct ivi_controller *ivi_controller,
19 uint32_t id_screen, struct ivi_controller_screen *screen) {}
21 static void c_layer(void *data, struct ivi_controller *ivi_controller,
24 static void c_surface(void *data, struct ivi_controller *ivi_controller,
25 uint32_t id_surface) {}
27 static void c_error(void *data, struct ivi_controller *ivi_controller,
28 int32_t object_id, int32_t object_type, int32_t error_code,
29 const char *error_text) {}
31 struct ivi_controller_listener c_listener = {c_screen, c_layer, c_surface,
34 static void o_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y,
35 int32_t physical_width, int32_t physical_height,
36 int32_t subpixel, const char *make, const char *model,
39 static void o_mode(void *data, struct wl_output *wl_output, uint32_t flags,
40 int32_t width, int32_t height, int32_t refresh) {}
42 static void o_done(void *data, struct wl_output *wl_output) {}
44 static void o_scale(void *data, struct wl_output *wl_output, int32_t factor) {}
46 struct wl_output_listener o_listener = {o_geometry, o_mode, o_done, o_scale};
48 static void r_global(void *data, struct wl_registry *r, uint32_t name,
49 char const *iface, uint32_t v) {
50 struct conn *c = data;
52 if (strcmp(iface, "ivi_controller") == 0) {
53 c->c = wl_registry_bind(r, name, &ivi_controller_interface, v);
54 ivi_controller_add_listener(c->c, &c_listener, c);
55 } else if (strcmp(iface, "wl_output") == 0) {
56 struct wl_output **o = wl_array_add(&c->outputs, sizeof(*o));
57 *o = wl_registry_bind(r, name, &wl_output_interface, v);
58 wl_output_add_listener(*o, &o_listener, c);
62 static void r_global_remove(void *data, struct wl_registry *r, uint32_t name) {}
64 struct wl_registry_listener r_listener = {r_global, r_global_remove};
66 int main(int argc, char **argv) {
67 lognotice("WinMan ver. %s", WINMAN_VERSION_STRING);
69 if (!getenv("XDG_RUNTIME_DIR"))
70 fatal("Environment variable XDG_RUNTIME_DIR not set");
73 wl_array_init(&c.outputs);
74 c.d = wl_display_connect(NULL);
76 fatal("Could not connect to compositor");
77 c.r = wl_display_get_registry(c.d);
78 wl_registry_add_listener(c.r, &r_listener, &c);
80 // First level objects
81 wl_display_roundtrip(c.d);
82 // Second level objects
83 wl_display_roundtrip(c.d);
86 fatal("ivi_controller global not available");
89 while (wl_display_dispatch(c.d) != -1) {
92 ivi_controller_destroy(c.c);
93 wl_registry_destroy(c.r);
94 wl_display_disconnect(c.d);