It is used for internal wayland protocol features. -->
<interface name="wl_display" version="1">
<request name="bind">
- <arg name="id" type="uint"/>
+ <arg name="name" type="uint"/>
<arg name="interface" type="string"/>
<arg name="version" type="uint"/>
+ <arg name="id" type="new_id" interface="wl_object"/>
</request>
<!-- sync is an just an echo, which will reply with a key event.
if (strcmp(interface->name, "wl_display") == 0)
return;
- printf("static inline struct %s *\n"
- "%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 %s *)\n"
- "\t\twl_proxy_create_for_id(display, &%s_interface, id);\n"
- "}\n\n",
- interface->name,
- interface->name,
- interface->name,
- interface->name,
- interface->name);
-
printf("static inline void\n"
"%s_set_user_data(struct %s *%s, void *user_data)\n"
"{\n"
}
WL_EXPORT struct wl_proxy *
-wl_proxy_create_for_id(struct wl_display *display,
- const struct wl_interface *interface, uint32_t id)
+wl_proxy_create(struct wl_proxy *factory, const struct wl_interface *interface)
{
struct wl_proxy *proxy;
+ struct wl_display *display = factory->display;
proxy = malloc(sizeof *proxy);
if (proxy == NULL)
proxy->object.interface = interface;
proxy->object.implementation = NULL;
- proxy->object.id = id;
+ proxy->object.id = wl_display_allocate_id(display);
proxy->display = display;
wl_hash_table_insert(display->objects, proxy->object.id, proxy);
return proxy;
}
-WL_EXPORT struct wl_proxy *
-wl_proxy_create(struct wl_proxy *factory,
- const struct wl_interface *interface)
-{
- return wl_proxy_create_for_id(factory->display, interface,
- wl_display_allocate_id(factory->display));
-}
-
WL_EXPORT void
wl_proxy_destroy(struct wl_proxy *proxy)
{
return NULL;
}
- wl_display_bind(display, 1, "wl_display", 1);
-
return display;
}
return display->id++;
}
-WL_EXPORT void
+WL_EXPORT void *
wl_display_bind(struct wl_display *display,
- uint32_t id, const char *interface, uint32_t version)
+ uint32_t name, const struct wl_interface *interface)
{
- wl_proxy_marshal(&display->proxy,
- WL_DISPLAY_BIND, id, interface, version);
+ struct wl_proxy *proxy;
+
+ proxy = wl_proxy_create(&display->proxy, interface);
+ if (proxy == NULL)
+ return NULL;
+
+ wl_proxy_marshal(&display->proxy, WL_DISPLAY_BIND,
+ name, interface->name, interface->version, proxy);
+
+ return proxy;
}
WL_EXPORT struct wl_callback *
void wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data);
void *wl_proxy_get_user_data(struct wl_proxy *proxy);
-void wl_display_bind(struct wl_display *display,
- uint32_t id, const char *interface, uint32_t version);
+void *wl_display_bind(struct wl_display *display,
+ uint32_t name, const struct wl_interface *interface);
+
struct wl_callback *wl_display_sync(struct wl_display *display);
#include "wayland-client-protocol.h"
static void
display_bind(struct wl_client *client,
- struct wl_resource *resource, uint32_t id,
- const char *interface, uint32_t version)
+ struct wl_resource *resource, uint32_t name,
+ const char *interface, uint32_t version, uint32_t id)
{
struct wl_global *global;
struct wl_display *display = resource->data;
wl_list_for_each(global, &display->global_list, link)
- if (global->object->id == id)
+ if (global->object->id == name)
break;
if (&global->link == &display->global_list)
wl_client_post_error(client, &client->display->resource.object,
WL_DISPLAY_ERROR_INVALID_OBJECT,
- "invalid object %d", id);
+ "invalid global %d", name);
else if (global->bind)
- global->bind(client, global->object, version);
+ global->bind(client, global->object, version, id);
- wl_hash_table_insert(client->objects,
- global->object->id, global->object);
-
+ wl_hash_table_insert(client->objects, id, global->object);
}
static void
static void
compositor_bind(struct wl_client *client,
- struct wl_object *global, uint32_t version)
+ struct wl_object *global, uint32_t version, uint32_t id)
{
struct wl_compositor *compositor =
container_of(global, struct wl_compositor, resource.object);
compositor->resource.client = client;
+ compositor->resource.object.id = id;
+
wl_resource_post_event(&compositor->resource,
WL_COMPOSITOR_TOKEN_VISUAL,
&compositor->argb_visual.object,
typedef void (*wl_global_bind_func_t)(struct wl_client *client,
struct wl_object *global,
- uint32_t version);
+ uint32_t version, uint32_t id);
int wl_display_add_global(struct wl_display *display,
struct wl_object *object,