summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2011-04-14 10:38:44 -0400
committerKristian Høgsberg <krh@bitplanet.net>2011-04-18 10:24:45 -0400
commit320a5634cf7060b5db22a0519b0ddc532894eb3b (patch)
tree096acb46904cb21d84a8b892ba331927fdb97241
parenta0010d8f8260387e9edd27a9f3d466ac784c12de (diff)
Introduce display.bind to request events from a global
-rw-r--r--protocol/wayland.xml6
-rw-r--r--wayland/scanner.c4
-rw-r--r--wayland/wayland-client.c35
-rw-r--r--wayland/wayland-client.h5
-rw-r--r--wayland/wayland-egl.h22
-rw-r--r--wayland/wayland-server.c17
6 files changed, 65 insertions, 24 deletions
diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 486cc0c..90dc763 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -4,6 +4,12 @@
<!-- The core global object. This is a special singleton object.
It is used for internal wayland protocol features. -->
<interface name="display" version="1">
+ <request name="bind">
+ <arg name="id" type="uint"/>
+ <arg name="interface" type="string"/>
+ <arg name="version" type="uint"/>
+ </request>
+
<!-- sync is an just an echo, which will reply with a sync event.
Since requests are handled in-order, this can be used as a
barrier to ensure all previous requests have ben handled.
diff --git a/wayland/scanner.c b/wayland/scanner.c
index 4d9d8ad..d05f621 100644
--- a/wayland/scanner.c
+++ b/wayland/scanner.c
@@ -322,14 +322,16 @@ emit_stubs(struct wl_list *message_list, struct interface *interface)
/* We provide a hand written constructor for the display object */
if (strcmp(interface->name, "display") != 0)
printf("static inline struct wl_%s *\n"
- "wl_%s_create(struct wl_display *display, uint32_t id)\n"
+ "wl_%s_create(struct wl_display *display, uint32_t id, uint32_t version)\n"
"{\n"
+ "\twl_display_bind(display, id, \"%s\", version);\n\n"
"\treturn (struct wl_%s *)\n"
"\t\twl_proxy_create_for_id(display, &wl_%s_interface, id);\n"
"}\n\n",
interface->name,
interface->name,
interface->name,
+ interface->name,
interface->name);
printf("static inline void\n"
diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c
index 451a83f..ff33f9f 100644
--- a/wayland/wayland-client.c
+++ b/wayland/wayland-client.c
@@ -65,6 +65,13 @@ struct wl_frame_handler {
struct wl_list link;
};
+struct wl_global {
+ uint32_t id;
+ char *interface;
+ uint32_t version;
+ struct wl_list link;
+};
+
struct wl_display {
struct wl_proxy proxy;
struct wl_connection *connection;
@@ -73,6 +80,7 @@ struct wl_display {
uint32_t mask;
struct wl_hash_table *objects;
struct wl_list global_listener_list;
+ struct wl_list global_list;
struct wl_visual *argb_visual;
struct wl_visual *premultiplied_argb_visual;
@@ -233,6 +241,22 @@ wl_display_get_rgb_visual(struct wl_display *display)
return display->rgb_visual;
}
+/* Can't do this, there may be more than one instance of an
+ * interface... */
+WL_EXPORT uint32_t
+wl_display_get_global(struct wl_display *display,
+ const char *interface, uint32_t version)
+{
+ struct wl_global *global;
+
+ wl_list_for_each(global, &display->global_list, link)
+ if (strcmp(interface, global->interface) == 0 &&
+ version <= global->version)
+ return global->id;
+
+ return 0;
+}
+
static void
display_handle_invalid_object(void *data,
struct wl_display *display, uint32_t id)
@@ -264,6 +288,7 @@ display_handle_global(void *data,
uint32_t id, const char *interface, uint32_t version)
{
struct wl_global_listener *listener;
+ struct wl_global *global;
if (strcmp(interface, "display") == 0)
wl_hash_table_insert(display->objects,
@@ -271,6 +296,12 @@ display_handle_global(void *data,
else if (strcmp(interface, "visual") == 0)
add_visual(display, id);
+ global = malloc(sizeof *global);
+ global->id = id;
+ global->interface = strdup(interface);
+ global->version = version;
+ wl_list_insert(display->global_list.prev, &global->link);
+
wl_list_for_each(listener, &display->global_listener_list, link)
(*listener->handler)(display,
id, interface, version, listener->data);
@@ -402,6 +433,7 @@ wl_display_connect(const char *name)
return NULL;
}
wl_list_init(&display->global_listener_list);
+ wl_list_init(&display->global_list);
display->proxy.object.interface = &wl_display_interface;
display->proxy.object.id = 1;
@@ -423,6 +455,9 @@ wl_display_connect(const char *name)
free(display);
return NULL;
}
+
+ wl_display_bind(display, 1, "display", 1);
+
return display;
}
diff --git a/wayland/wayland-client.h b/wayland/wayland-client.h
index a5992a2..f1ac797 100644
--- a/wayland/wayland-client.h
+++ b/wayland/wayland-client.h
@@ -75,10 +75,13 @@ typedef void (*wl_display_global_func_t)(struct wl_display *display,
void
wl_display_remove_global_listener(struct wl_display *display,
struct wl_global_listener *listener);
-
struct wl_global_listener *
wl_display_add_global_listener(struct wl_display *display,
wl_display_global_func_t handler, void *data);
+WL_EXPORT uint32_t
+wl_display_get_global(struct wl_display *display,
+ const char *interface, uint32_t version);
+
struct wl_visual *
wl_display_get_argb_visual(struct wl_display *display);
struct wl_visual *
diff --git a/wayland/wayland-egl.h b/wayland/wayland-egl.h
index d3de87c..85fe73d 100644
--- a/wayland/wayland-egl.h
+++ b/wayland/wayland-egl.h
@@ -32,19 +32,11 @@ extern "C" {
#define WL_EGL_PLATFORM 1
-struct wl_egl_display;
struct wl_egl_window;
struct wl_egl_pixmap;
-struct wl_egl_display *
-wl_egl_display_create(struct wl_display *egl_display);
-
-void
-wl_egl_display_destroy(struct wl_egl_display *egl_display);
-
struct wl_egl_window *
-wl_egl_window_create(struct wl_egl_display *egl_display,
- struct wl_surface *surface,
+wl_egl_window_create(struct wl_surface *surface,
int width, int height,
struct wl_visual *visual);
@@ -58,22 +50,16 @@ wl_egl_window_resize(struct wl_egl_window *egl_window,
void
wl_egl_window_get_attached_size(struct wl_egl_window *egl_window,
- int *width, int *height);
+ int *width, int *height);
struct wl_egl_pixmap *
-wl_egl_pixmap_create(struct wl_egl_display *egl_display,
- int width, int height,
+wl_egl_pixmap_create(int width, int height,
struct wl_visual *visual, uint32_t flags);
void
wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap);
struct wl_buffer *
-wl_egl_pixmap_create_buffer(struct wl_egl_display *egl_display,
- struct wl_egl_pixmap *egl_pixmap);
-
-void
-wl_egl_pixmap_flush(struct wl_egl_display *egl_display,
- struct wl_egl_pixmap *egl_pixmap);
+wl_egl_pixmap_create_buffer(struct wl_egl_pixmap *egl_pixmap);
#ifdef __cplusplus
}
diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
index 66ad861..a8fb15f 100644
--- a/wayland/wayland-server.c
+++ b/wayland/wayland-server.c
@@ -250,10 +250,6 @@ wl_client_create(struct wl_display *display, int fd)
global->object->interface->name,
global->object->interface->version);
- wl_list_for_each(global, &display->global_list, link)
- if (global->func)
- global->func(client, global->object);
-
return client;
}
@@ -476,6 +472,18 @@ wl_input_device_update_grab(struct wl_input_device *device,
}
static void
+display_bind(struct wl_client *client,
+ struct wl_display *display, uint32_t id,
+ const char *interface, uint32_t version)
+{
+ struct wl_global *global;
+
+ wl_list_for_each(global, &display->global_list, link)
+ if (global->object->id == id && global->func)
+ global->func(client, global->object);
+}
+
+static void
display_sync(struct wl_client *client,
struct wl_display *display, uint32_t key)
{
@@ -518,6 +526,7 @@ display_frame(struct wl_client *client,
}
struct wl_display_interface display_interface = {
+ display_bind,
display_sync,
display_frame
};