wl_display_event_func_t event_handler;
void *event_handler_data;
- uint32_t output_id;
- int32_t width, height;
+ struct wl_output *output;
};
struct wl_compositor {
struct wl_list link;
};
+struct wl_output {
+ struct wl_proxy proxy;
+ int32_t width, height;
+};
+
static int
connection_update(struct wl_connection *connection,
uint32_t mask, void *data)
WL_EXPORT void
wl_display_get_geometry(struct wl_display *display, int32_t *width, int32_t *height)
{
- *width = display->width;
- *height = display->height;
+ *width = display->output->width;
+ *height = display->output->height;
}
static void
if (visual == NULL)
return;
- visual->proxy.display = display;
+ visual->proxy.interface = &wl_visual_interface;
visual->proxy.id = global->id;
+ visual->proxy.display = display;
wl_list_insert(display->visual_list.prev, &visual->link);
}
}
static void
+add_output(struct wl_display *display, struct wl_global *global)
+{
+ struct wl_output *output;
+
+ output = malloc(sizeof *output);
+ if (output == NULL)
+ return;
+
+ output->proxy.interface = &wl_output_interface;
+ output->proxy.id = global->id;
+ output->proxy.display = display;
+ display->output = output;
+}
+
+static void
handle_display_event(struct wl_display *display,
uint32_t opcode, uint32_t *p, uint32_t size)
{
global->interface[length] = '\0';
global->version = p[2 + DIV_ROUNDUP(length, sizeof *p)];
wl_list_insert(display->global_list.prev, &global->link);
-
if (strcmp(global->interface, "visual") == 0)
add_visual(display, global);
- else if (strcmp(global->interface, "output") == 0) {
- display->output_id = p[0];
- }
+ else if (strcmp(global->interface, "output") == 0)
+ add_output(display, global);
break;
case WL_DISPLAY_RANGE:
uint32_t opcode, uint32_t *p, uint32_t size)
{
switch (opcode) {
- case WL_OUTPUT_PRESENCE:
- display->width = p[0];
- display->height = p[1];
+ case WL_OUTPUT_GEOMETRY:
+ display->output->width = p[0];
+ display->output->height = p[1];
break;
}
}
wl_connection_copy(display->connection, p, size);
if (object == 1) {
handle_display_event(display, opcode, p + 2, size);
- } if (object == display->output_id) {
+ } else if (object == display->output->proxy.id) {
handle_output_event(display, opcode, p + 2, size);
} else if (display->event_handler != NULL)
display->event_handler(display, object, opcode, size, p + 2,
}
static void
-post_output_presence(struct wl_client *client, struct wl_object *global)
+post_output_geometry(struct wl_client *client, struct wl_object *global)
{
struct egl_compositor *ec =
container_of(global, struct egl_compositor, output.base);
wl_client_post_event(client, global,
- WL_OUTPUT_PRESENCE, ec->width, ec->height);
+ WL_OUTPUT_GEOMETRY, ec->width, ec->height);
}
static const char gem_device[] = "/dev/dri/card0";
/* FIXME: This needs to be much more expressive... something like randr 1.2. */
ec->output.base.interface = &wl_output_interface;
wl_display_add_object(display, &ec->output.base);
- wl_display_add_global(display, &ec->output.base, post_output_presence);
+ wl_display_add_global(display, &ec->output.base, post_output_geometry);
add_visuals(ec);