summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-05-11 12:32:13 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-05-11 13:14:45 +0200
commit3c5e3d213ef264d3debb01e39378e7db8db32b6a (patch)
tree7253ae4260d7975d9847d96af4f4572bfffb512e
parent2d27f3b6e9001d4fae4a4de7a19db76b5174f9d7 (diff)
Identify visuals using a type-event
Also allow server-side lookup of a visual's type using its "type" element. Helpful for EGL_WL_bind_wayland_display implementations that cant access wl_compositor.*_visual directly.
-rw-r--r--TODO2
-rw-r--r--protocol/wayland.xml13
-rw-r--r--wayland/wayland-client.c37
-rw-r--r--wayland/wayland-server.c21
-rw-r--r--wayland/wayland-server.h1
5 files changed, 59 insertions, 15 deletions
diff --git a/TODO b/TODO
index fceacd4..dabfb93 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
Core wayland protocol
- - Fix visuals
-
- Generic error reporting mechanism: display.error(object, code, msg)
event that all interfaces can use to report fatal (ie client
killing) errors. The object is the object that the "error is
diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 11976fa..f46a9c5 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -455,10 +455,19 @@
</event>
</interface>
-
<!-- A visual is the pixel format. The different visuals are
currently only identified by the order they are advertised by
the 'global' events. We need something better. -->
- <interface name="wl_visual" version="1"/>
+ <interface name="wl_visual" version="1">
+ <event name="type">
+ <arg name="type" type="uint"/>
+ </event>
+
+ <enum name="type">
+ <entry name="rgb" value="0"/>
+ <entry name="argb" value="1"/>
+ <entry name="premultiplied_argb" value="2"/>
+ </enum>
+ </interface>
</protocol>
diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c
index 59c68f7..1adeeba 100644
--- a/wayland/wayland-client.c
+++ b/wayland/wayland-client.c
@@ -209,18 +209,39 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
}
static void
-add_visual(struct wl_display *display, uint32_t id)
+wl_visual_type(void *data, struct wl_visual *visual, unsigned int type)
{
- struct wl_visual *visual;
+ struct wl_display *display = data;
- visual = (struct wl_visual *)
- wl_proxy_create_for_id(display, &wl_visual_interface, id);
- if (display->argb_visual == NULL)
+ printf("visual type: %d\n", type);
+
+ switch (type) {
+ case WL_VISUAL_TYPE_RGB:
+ display->rgb_visual = visual;
+ break;
+ case WL_VISUAL_TYPE_ARGB:
display->argb_visual = visual;
- else if (display->premultiplied_argb_visual == NULL)
+ break;
+ case WL_VISUAL_TYPE_PREMULTIPLIED_ARGB:
display->premultiplied_argb_visual = visual;
- else
- display->rgb_visual = visual;
+ break;
+ default:
+ /* FIXME: unknown type, drop it? */
+ break;
+ }
+}
+
+static struct wl_visual_listener visual_listener = {
+ wl_visual_type
+};
+
+static void
+add_visual(struct wl_display *display, uint32_t id)
+{
+ struct wl_visual *visual;
+
+ visual = wl_visual_create(display, id, 1);
+ wl_visual_add_listener(visual, &visual_listener, display);
}
WL_EXPORT struct wl_visual *
diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
index 8d5caf4..0ccceff 100644
--- a/wayland/wayland-server.c
+++ b/wayland/wayland-server.c
@@ -795,6 +795,15 @@ wl_display_add_socket(struct wl_display *display, const char *name)
return 0;
}
+static void
+post_visual_type(struct wl_client *client, struct wl_object *object,
+ uint32_t version)
+{
+ struct wl_visual *visual = (struct wl_visual *) object;
+
+ wl_client_post_event(client, object, WL_VISUAL_TYPE, visual->type);
+}
+
WL_EXPORT int
wl_compositor_init(struct wl_compositor *compositor,
const struct wl_compositor_interface *interface,
@@ -806,12 +815,16 @@ wl_compositor_init(struct wl_compositor *compositor,
if (wl_display_add_global(display, &compositor->object, NULL))
return -1;
+ compositor->argb_visual.type = WL_VISUAL_TYPE_ARGB;
compositor->argb_visual.object.interface = &wl_visual_interface;
compositor->argb_visual.object.implementation = NULL;
wl_display_add_object(display, &compositor->argb_visual.object);
- if (wl_display_add_global(display, &compositor->argb_visual.object, NULL))
+ if (wl_display_add_global(display, &compositor->argb_visual.object,
+ post_visual_type))
return -1;
+ compositor->premultiplied_argb_visual.type =
+ WL_VISUAL_TYPE_PREMULTIPLIED_ARGB;
compositor->premultiplied_argb_visual.object.interface =
&wl_visual_interface;
compositor->premultiplied_argb_visual.object.implementation = NULL;
@@ -819,15 +832,17 @@ wl_compositor_init(struct wl_compositor *compositor,
&compositor->premultiplied_argb_visual.object);
if (wl_display_add_global(display,
&compositor->premultiplied_argb_visual.object,
- NULL))
+ post_visual_type))
return -1;
+ compositor->rgb_visual.type = WL_VISUAL_TYPE_RGB;
compositor->rgb_visual.object.interface = &wl_visual_interface;
compositor->rgb_visual.object.implementation = NULL;
wl_display_add_object(display,
&compositor->rgb_visual.object);
if (wl_display_add_global(display,
- &compositor->rgb_visual.object, NULL))
+ &compositor->rgb_visual.object,
+ post_visual_type))
return -1;
return 0;
diff --git a/wayland/wayland-server.h b/wayland/wayland-server.h
index 7e752de..aa5d629 100644
--- a/wayland/wayland-server.h
+++ b/wayland/wayland-server.h
@@ -100,6 +100,7 @@ void wl_client_post_global(struct wl_client *client, struct wl_object *object);
struct wl_visual {
struct wl_object object;
+ enum wl_visual_type type;
};
struct wl_shm_callbacks {