summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-12-22 16:37:07 -0500
committerKristian Høgsberg <krh@redhat.com>2008-12-22 16:37:07 -0500
commit12ea62e2112c754d62113e0656b223fbdbe351dd (patch)
treedaf32e72d40ade9418f9ea774c9ab744516c0255
parent0395f30e652bd32234942206bce15e7e6f3a9fb1 (diff)
downloadwayland-12ea62e2112c754d62113e0656b223fbdbe351dd.tar.gz
wayland-12ea62e2112c754d62113e0656b223fbdbe351dd.tar.xz
wayland-12ea62e2112c754d62113e0656b223fbdbe351dd.zip
Add a proxy for the server side output object.
-rw-r--r--wayland-client.c44
-rw-r--r--wayland-protocol.c8
-rw-r--r--wayland-protocol.h5
-rw-r--r--wayland-system-compositor.c6
4 files changed, 45 insertions, 18 deletions
diff --git a/wayland-client.c b/wayland-client.c
index 2760706..00ca30c 100644
--- a/wayland-client.c
+++ b/wayland-client.c
@@ -68,8 +68,7 @@ struct wl_display {
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 {
@@ -85,6 +84,11 @@ struct wl_visual {
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)
@@ -102,8 +106,8 @@ connection_update(struct wl_connection *connection,
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
@@ -115,8 +119,9 @@ add_visual(struct wl_display *display, struct wl_global *global)
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);
}
@@ -230,6 +235,21 @@ wl_display_get_fd(struct wl_display *display,
}
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)
{
@@ -265,12 +285,10 @@ handle_display_event(struct wl_display *display,
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:
@@ -284,9 +302,9 @@ handle_output_event(struct wl_display *display,
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;
}
}
@@ -300,7 +318,7 @@ handle_event(struct wl_display *display,
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,
diff --git a/wayland-protocol.c b/wayland-protocol.c
index 4ec40ab..2c7ba99 100644
--- a/wayland-protocol.c
+++ b/wayland-protocol.c
@@ -86,7 +86,7 @@ WL_EXPORT const struct wl_interface wl_input_device_interface = {
static const struct wl_message output_events[] = {
- { "presence", "uu" },
+ { "geometry", "uu" },
};
WL_EXPORT const struct wl_interface wl_output_interface = {
@@ -94,3 +94,9 @@ WL_EXPORT const struct wl_interface wl_output_interface = {
0, NULL,
ARRAY_LENGTH(output_events), output_events,
};
+
+WL_EXPORT const struct wl_interface wl_visual_interface = {
+ "visual", 1,
+ 0, NULL,
+ 0, NULL,
+};
diff --git a/wayland-protocol.h b/wayland-protocol.h
index 76a80c5..4e50d89 100644
--- a/wayland-protocol.h
+++ b/wayland-protocol.h
@@ -79,8 +79,11 @@ extern const struct wl_interface wl_surface_interface;
extern const struct wl_interface wl_input_device_interface;
-#define WL_OUTPUT_PRESENCE 0
+#define WL_OUTPUT_GEOMETRY 0
extern const struct wl_interface wl_output_interface;
+
+extern const struct wl_interface wl_visual_interface;
+
#endif
diff --git a/wayland-system-compositor.c b/wayland-system-compositor.c
index f3ff5b0..77c6bfe 100644
--- a/wayland-system-compositor.c
+++ b/wayland-system-compositor.c
@@ -846,13 +846,13 @@ add_visuals(struct egl_compositor *ec)
}
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";
@@ -1040,7 +1040,7 @@ egl_compositor_create(struct wl_display *display)
/* 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);