mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-16 06:59:47 -05:00
Introduce display.bind to request events from a global
This commit is contained in:
parent
a0010d8f82
commit
320a5634cf
6 changed files with 65 additions and 24 deletions
|
|
@ -4,6 +4,12 @@
|
||||||
<!-- The core global object. This is a special singleton object.
|
<!-- The core global object. This is a special singleton object.
|
||||||
It is used for internal wayland protocol features. -->
|
It is used for internal wayland protocol features. -->
|
||||||
<interface name="display" version="1">
|
<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.
|
<!-- 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
|
Since requests are handled in-order, this can be used as a
|
||||||
barrier to ensure all previous requests have ben handled.
|
barrier to ensure all previous requests have ben handled.
|
||||||
|
|
|
||||||
|
|
@ -322,14 +322,16 @@ emit_stubs(struct wl_list *message_list, struct interface *interface)
|
||||||
/* We provide a hand written constructor for the display object */
|
/* We provide a hand written constructor for the display object */
|
||||||
if (strcmp(interface->name, "display") != 0)
|
if (strcmp(interface->name, "display") != 0)
|
||||||
printf("static inline struct wl_%s *\n"
|
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"
|
"{\n"
|
||||||
|
"\twl_display_bind(display, id, \"%s\", version);\n\n"
|
||||||
"\treturn (struct wl_%s *)\n"
|
"\treturn (struct wl_%s *)\n"
|
||||||
"\t\twl_proxy_create_for_id(display, &wl_%s_interface, id);\n"
|
"\t\twl_proxy_create_for_id(display, &wl_%s_interface, id);\n"
|
||||||
"}\n\n",
|
"}\n\n",
|
||||||
interface->name,
|
interface->name,
|
||||||
interface->name,
|
interface->name,
|
||||||
interface->name,
|
interface->name,
|
||||||
|
interface->name,
|
||||||
interface->name);
|
interface->name);
|
||||||
|
|
||||||
printf("static inline void\n"
|
printf("static inline void\n"
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,13 @@ struct wl_frame_handler {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wl_global {
|
||||||
|
uint32_t id;
|
||||||
|
char *interface;
|
||||||
|
uint32_t version;
|
||||||
|
struct wl_list link;
|
||||||
|
};
|
||||||
|
|
||||||
struct wl_display {
|
struct wl_display {
|
||||||
struct wl_proxy proxy;
|
struct wl_proxy proxy;
|
||||||
struct wl_connection *connection;
|
struct wl_connection *connection;
|
||||||
|
|
@ -73,6 +80,7 @@ struct wl_display {
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
struct wl_hash_table *objects;
|
struct wl_hash_table *objects;
|
||||||
struct wl_list global_listener_list;
|
struct wl_list global_listener_list;
|
||||||
|
struct wl_list global_list;
|
||||||
|
|
||||||
struct wl_visual *argb_visual;
|
struct wl_visual *argb_visual;
|
||||||
struct wl_visual *premultiplied_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;
|
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
|
static void
|
||||||
display_handle_invalid_object(void *data,
|
display_handle_invalid_object(void *data,
|
||||||
struct wl_display *display, uint32_t id)
|
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)
|
uint32_t id, const char *interface, uint32_t version)
|
||||||
{
|
{
|
||||||
struct wl_global_listener *listener;
|
struct wl_global_listener *listener;
|
||||||
|
struct wl_global *global;
|
||||||
|
|
||||||
if (strcmp(interface, "display") == 0)
|
if (strcmp(interface, "display") == 0)
|
||||||
wl_hash_table_insert(display->objects,
|
wl_hash_table_insert(display->objects,
|
||||||
|
|
@ -271,6 +296,12 @@ display_handle_global(void *data,
|
||||||
else if (strcmp(interface, "visual") == 0)
|
else if (strcmp(interface, "visual") == 0)
|
||||||
add_visual(display, id);
|
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)
|
wl_list_for_each(listener, &display->global_listener_list, link)
|
||||||
(*listener->handler)(display,
|
(*listener->handler)(display,
|
||||||
id, interface, version, listener->data);
|
id, interface, version, listener->data);
|
||||||
|
|
@ -402,6 +433,7 @@ wl_display_connect(const char *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wl_list_init(&display->global_listener_list);
|
wl_list_init(&display->global_listener_list);
|
||||||
|
wl_list_init(&display->global_list);
|
||||||
|
|
||||||
display->proxy.object.interface = &wl_display_interface;
|
display->proxy.object.interface = &wl_display_interface;
|
||||||
display->proxy.object.id = 1;
|
display->proxy.object.id = 1;
|
||||||
|
|
@ -423,6 +455,9 @@ wl_display_connect(const char *name)
|
||||||
free(display);
|
free(display);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wl_display_bind(display, 1, "display", 1);
|
||||||
|
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,10 +75,13 @@ typedef void (*wl_display_global_func_t)(struct wl_display *display,
|
||||||
void
|
void
|
||||||
wl_display_remove_global_listener(struct wl_display *display,
|
wl_display_remove_global_listener(struct wl_display *display,
|
||||||
struct wl_global_listener *listener);
|
struct wl_global_listener *listener);
|
||||||
|
|
||||||
struct wl_global_listener *
|
struct wl_global_listener *
|
||||||
wl_display_add_global_listener(struct wl_display *display,
|
wl_display_add_global_listener(struct wl_display *display,
|
||||||
wl_display_global_func_t handler, void *data);
|
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 *
|
struct wl_visual *
|
||||||
wl_display_get_argb_visual(struct wl_display *display);
|
wl_display_get_argb_visual(struct wl_display *display);
|
||||||
struct wl_visual *
|
struct wl_visual *
|
||||||
|
|
|
||||||
|
|
@ -32,19 +32,11 @@ extern "C" {
|
||||||
|
|
||||||
#define WL_EGL_PLATFORM 1
|
#define WL_EGL_PLATFORM 1
|
||||||
|
|
||||||
struct wl_egl_display;
|
|
||||||
struct wl_egl_window;
|
struct wl_egl_window;
|
||||||
struct wl_egl_pixmap;
|
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 *
|
struct wl_egl_window *
|
||||||
wl_egl_window_create(struct wl_egl_display *egl_display,
|
wl_egl_window_create(struct wl_surface *surface,
|
||||||
struct wl_surface *surface,
|
|
||||||
int width, int height,
|
int width, int height,
|
||||||
struct wl_visual *visual);
|
struct wl_visual *visual);
|
||||||
|
|
||||||
|
|
@ -58,22 +50,16 @@ wl_egl_window_resize(struct wl_egl_window *egl_window,
|
||||||
|
|
||||||
void
|
void
|
||||||
wl_egl_window_get_attached_size(struct wl_egl_window *egl_window,
|
wl_egl_window_get_attached_size(struct wl_egl_window *egl_window,
|
||||||
int *width, int *height);
|
int *width, int *height);
|
||||||
|
|
||||||
struct wl_egl_pixmap *
|
struct wl_egl_pixmap *
|
||||||
wl_egl_pixmap_create(struct wl_egl_display *egl_display,
|
wl_egl_pixmap_create(int width, int height,
|
||||||
int width, int height,
|
|
||||||
struct wl_visual *visual, uint32_t flags);
|
struct wl_visual *visual, uint32_t flags);
|
||||||
void
|
void
|
||||||
wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap);
|
wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap);
|
||||||
|
|
||||||
struct wl_buffer *
|
struct wl_buffer *
|
||||||
wl_egl_pixmap_create_buffer(struct wl_egl_display *egl_display,
|
wl_egl_pixmap_create_buffer(struct wl_egl_pixmap *egl_pixmap);
|
||||||
struct wl_egl_pixmap *egl_pixmap);
|
|
||||||
|
|
||||||
void
|
|
||||||
wl_egl_pixmap_flush(struct wl_egl_display *egl_display,
|
|
||||||
struct wl_egl_pixmap *egl_pixmap);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -250,10 +250,6 @@ wl_client_create(struct wl_display *display, int fd)
|
||||||
global->object->interface->name,
|
global->object->interface->name,
|
||||||
global->object->interface->version);
|
global->object->interface->version);
|
||||||
|
|
||||||
wl_list_for_each(global, &display->global_list, link)
|
|
||||||
if (global->func)
|
|
||||||
global->func(client, global->object);
|
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -475,6 +471,18 @@ wl_input_device_update_grab(struct wl_input_device *device,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
display_sync(struct wl_client *client,
|
display_sync(struct wl_client *client,
|
||||||
struct wl_display *display, uint32_t key)
|
struct wl_display *display, uint32_t key)
|
||||||
|
|
@ -518,6 +526,7 @@ display_frame(struct wl_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wl_display_interface display_interface = {
|
struct wl_display_interface display_interface = {
|
||||||
|
display_bind,
|
||||||
display_sync,
|
display_sync,
|
||||||
display_frame
|
display_frame
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue