|
|
@ -44,31 +44,26 @@ struct wl_global { |
|
|
|
uint32_t id; |
|
|
|
uint32_t id; |
|
|
|
char *interface; |
|
|
|
char *interface; |
|
|
|
uint32_t version; |
|
|
|
uint32_t version; |
|
|
|
|
|
|
|
struct wl_proxy *proxy; |
|
|
|
struct wl_list link; |
|
|
|
struct wl_list link; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct wl_proxy { |
|
|
|
struct wl_global_listener { |
|
|
|
struct wl_object base; |
|
|
|
wl_display_global_func_t handler; |
|
|
|
struct wl_display *display; |
|
|
|
void *data; |
|
|
|
|
|
|
|
struct wl_list link; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct wl_display { |
|
|
|
struct wl_listener { |
|
|
|
struct wl_proxy proxy; |
|
|
|
void (**implementation)(void); |
|
|
|
struct wl_connection *connection; |
|
|
|
void *data; |
|
|
|
int fd; |
|
|
|
struct wl_list link; |
|
|
|
uint32_t id, id_count, next_range; |
|
|
|
}; |
|
|
|
uint32_t mask; |
|
|
|
|
|
|
|
struct wl_hash *objects; |
|
|
|
|
|
|
|
struct wl_list global_list; |
|
|
|
|
|
|
|
struct wl_list visual_list; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_display_update_func_t update; |
|
|
|
|
|
|
|
void *update_data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_display_event_func_t event_handler; |
|
|
|
|
|
|
|
void *event_handler_data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_output *output; |
|
|
|
struct wl_proxy { |
|
|
|
|
|
|
|
struct wl_object base; |
|
|
|
|
|
|
|
struct wl_display *display; |
|
|
|
|
|
|
|
struct wl_list listener_list; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct wl_compositor { |
|
|
|
struct wl_compositor { |
|
|
@ -81,14 +76,42 @@ struct wl_surface { |
|
|
|
|
|
|
|
|
|
|
|
struct wl_visual { |
|
|
|
struct wl_visual { |
|
|
|
struct wl_proxy proxy; |
|
|
|
struct wl_proxy proxy; |
|
|
|
struct wl_list link; |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct wl_output { |
|
|
|
struct wl_output { |
|
|
|
struct wl_proxy proxy; |
|
|
|
struct wl_proxy proxy; |
|
|
|
|
|
|
|
struct wl_listener listener; |
|
|
|
int32_t width, height; |
|
|
|
int32_t width, height; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_input_device { |
|
|
|
|
|
|
|
struct wl_proxy proxy; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_display { |
|
|
|
|
|
|
|
struct wl_proxy proxy; |
|
|
|
|
|
|
|
struct wl_connection *connection; |
|
|
|
|
|
|
|
int fd; |
|
|
|
|
|
|
|
uint32_t id, id_count, next_range; |
|
|
|
|
|
|
|
uint32_t mask; |
|
|
|
|
|
|
|
struct wl_hash *objects; |
|
|
|
|
|
|
|
struct wl_list global_list; |
|
|
|
|
|
|
|
struct wl_listener listener; |
|
|
|
|
|
|
|
struct wl_list global_listener_list; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_visual *argb_visual; |
|
|
|
|
|
|
|
struct wl_visual *premultiplied_argb_visual; |
|
|
|
|
|
|
|
struct wl_visual *rgb_visual; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_display_update_func_t update; |
|
|
|
|
|
|
|
void *update_data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_display_global_func_t global_handler; |
|
|
|
|
|
|
|
void *global_handler_data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_compositor *compositor; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
static int |
|
|
|
connection_update(struct wl_connection *connection, |
|
|
|
connection_update(struct wl_connection *connection, |
|
|
|
uint32_t mask, void *data) |
|
|
|
uint32_t mask, void *data) |
|
|
@ -103,46 +126,117 @@ connection_update(struct wl_connection *connection, |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
WL_EXPORT int |
|
|
|
output_handle_geometry(struct wl_display *display, |
|
|
|
wl_object_implements(struct wl_object *object, |
|
|
|
struct wl_output *output, int32_t width, int32_t height) |
|
|
|
const char *interface, int version) |
|
|
|
{ |
|
|
|
{ |
|
|
|
output->width = width; |
|
|
|
return strcmp(object->interface->name, interface) == 0 && |
|
|
|
output->height = height; |
|
|
|
object->interface->version >= version; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
struct wl_output_listener { |
|
|
|
WL_EXPORT struct wl_global_listener * |
|
|
|
void (*geometry)(struct wl_display *display, |
|
|
|
wl_display_add_global_listener(struct wl_display *display, |
|
|
|
struct wl_output *output, |
|
|
|
wl_display_global_func_t handler, void *data) |
|
|
|
int32_t width, int32_t height); |
|
|
|
{ |
|
|
|
}; |
|
|
|
struct wl_global_listener *listener; |
|
|
|
|
|
|
|
struct wl_global *global; |
|
|
|
|
|
|
|
|
|
|
|
static const struct wl_output_listener output_listener = { |
|
|
|
listener = malloc(sizeof *listener); |
|
|
|
output_handle_geometry |
|
|
|
if (listener == NULL) |
|
|
|
}; |
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
listener->handler = handler; |
|
|
|
add_output(struct wl_display *display, struct wl_global *global) |
|
|
|
listener->data = data; |
|
|
|
{ |
|
|
|
wl_list_insert(display->global_listener_list.prev, &listener->link); |
|
|
|
struct wl_output *output; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output = malloc(sizeof *output); |
|
|
|
/* FIXME: Need a destructor for void *data? */ |
|
|
|
if (output == NULL) |
|
|
|
|
|
|
|
return; |
|
|
|
global = container_of(display->global_list.next, |
|
|
|
|
|
|
|
struct wl_global, link); |
|
|
|
|
|
|
|
while (&global->link != &display->global_list) { |
|
|
|
|
|
|
|
if (global->proxy != NULL) |
|
|
|
|
|
|
|
(*handler)(display, &global->proxy->base, data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global = container_of(global->link.next, |
|
|
|
|
|
|
|
struct wl_global, link); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
output->proxy.base.interface = &wl_output_interface; |
|
|
|
return listener; |
|
|
|
output->proxy.base.implementation = (void(**)(void)) &output_listener; |
|
|
|
|
|
|
|
output->proxy.base.id = global->id; |
|
|
|
|
|
|
|
output->proxy.display = display; |
|
|
|
|
|
|
|
display->output = output; |
|
|
|
|
|
|
|
wl_hash_insert(display->objects, &output->proxy.base); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WL_EXPORT void |
|
|
|
WL_EXPORT void |
|
|
|
wl_display_get_geometry(struct wl_display *display, int32_t *width, int32_t *height) |
|
|
|
wl_display_remove_global_listener(struct wl_display *display, |
|
|
|
|
|
|
|
struct wl_global_listener *listener) |
|
|
|
{ |
|
|
|
{ |
|
|
|
*width = display->output->width; |
|
|
|
wl_list_remove(&listener->link); |
|
|
|
*height = display->output->height; |
|
|
|
free(listener); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct wl_proxy * |
|
|
|
|
|
|
|
wl_proxy_create_for_global(struct wl_display *display, |
|
|
|
|
|
|
|
struct wl_global *global, |
|
|
|
|
|
|
|
const struct wl_interface *interface) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct wl_proxy *proxy; |
|
|
|
|
|
|
|
struct wl_global_listener *listener; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proxy = malloc(sizeof *proxy); |
|
|
|
|
|
|
|
if (proxy == NULL) |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proxy->base.interface = interface; |
|
|
|
|
|
|
|
proxy->base.id = global->id; |
|
|
|
|
|
|
|
proxy->display = display; |
|
|
|
|
|
|
|
global->proxy = proxy; |
|
|
|
|
|
|
|
wl_list_init(&proxy->listener_list); |
|
|
|
|
|
|
|
wl_hash_insert(display->objects, &proxy->base); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listener = container_of(display->global_listener_list.next, |
|
|
|
|
|
|
|
struct wl_global_listener, link); |
|
|
|
|
|
|
|
while (&listener->link != &display->global_listener_list) { |
|
|
|
|
|
|
|
(*listener->handler)(display, &proxy->base, listener->data); |
|
|
|
|
|
|
|
listener = container_of(listener->link.next, |
|
|
|
|
|
|
|
struct wl_global_listener, link); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return proxy; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
|
|
|
wl_proxy_add_listener(struct wl_proxy *proxy, void (**implementation)(void), void *data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct wl_listener *listener; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listener = malloc(sizeof *listener); |
|
|
|
|
|
|
|
if (listener == NULL) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listener->implementation = (void (**)(void)) implementation; |
|
|
|
|
|
|
|
listener->data = data; |
|
|
|
|
|
|
|
wl_list_insert(proxy->listener_list.prev, &listener->link); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
va_list ap; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
va_start(ap, opcode); |
|
|
|
|
|
|
|
wl_connection_vmarshal(proxy->display->connection, |
|
|
|
|
|
|
|
&proxy->base, opcode, ap, |
|
|
|
|
|
|
|
&proxy->base.interface->methods[opcode]); |
|
|
|
|
|
|
|
va_end(ap); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WL_EXPORT int |
|
|
|
|
|
|
|
wl_output_add_listener(struct wl_output *output, |
|
|
|
|
|
|
|
const struct wl_output_listener *listener, |
|
|
|
|
|
|
|
void *data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return wl_proxy_add_listener(&output->proxy, |
|
|
|
|
|
|
|
(void (**)(void)) listener, data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
@ -150,66 +244,69 @@ add_visual(struct wl_display *display, struct wl_global *global) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct wl_visual *visual; |
|
|
|
struct wl_visual *visual; |
|
|
|
|
|
|
|
|
|
|
|
visual = malloc(sizeof *visual); |
|
|
|
visual = (struct wl_visual *) |
|
|
|
if (visual == NULL) |
|
|
|
wl_proxy_create_for_global(display, global, |
|
|
|
return; |
|
|
|
&wl_visual_interface); |
|
|
|
|
|
|
|
if (display->argb_visual == NULL) |
|
|
|
visual->proxy.base.interface = &wl_visual_interface; |
|
|
|
display->argb_visual = visual; |
|
|
|
visual->proxy.base.id = global->id; |
|
|
|
else if (display->premultiplied_argb_visual == NULL) |
|
|
|
visual->proxy.base.implementation = NULL; |
|
|
|
display->premultiplied_argb_visual = visual; |
|
|
|
visual->proxy.display = display; |
|
|
|
else |
|
|
|
wl_list_insert(display->visual_list.prev, &visual->link); |
|
|
|
display->rgb_visual = visual; |
|
|
|
wl_hash_insert(display->objects, &visual->proxy.base); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WL_EXPORT struct wl_visual * |
|
|
|
WL_EXPORT struct wl_visual * |
|
|
|
wl_display_get_argb_visual(struct wl_display *display) |
|
|
|
wl_display_get_argb_visual(struct wl_display *display) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return container_of(display->visual_list.next, |
|
|
|
return display->argb_visual; |
|
|
|
struct wl_visual, link); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WL_EXPORT struct wl_visual * |
|
|
|
WL_EXPORT struct wl_visual * |
|
|
|
wl_display_get_premultiplied_argb_visual(struct wl_display *display) |
|
|
|
wl_display_get_premultiplied_argb_visual(struct wl_display *display) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return container_of(display->visual_list.next->next, |
|
|
|
return display->premultiplied_argb_visual; |
|
|
|
struct wl_visual, link); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WL_EXPORT struct wl_visual * |
|
|
|
WL_EXPORT struct wl_visual * |
|
|
|
wl_display_get_rgb_visual(struct wl_display *display) |
|
|
|
wl_display_get_rgb_visual(struct wl_display *display) |
|
|
|
{ |
|
|
|
{ |
|
|
|
/* FIXME: Where's cddar when you need it... */ |
|
|
|
return display->rgb_visual; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return container_of(display->visual_list.next->next->next, |
|
|
|
WL_EXPORT int |
|
|
|
struct wl_visual, link); |
|
|
|
wl_input_device_add_listener(struct wl_input_device *input_device, |
|
|
|
|
|
|
|
const struct wl_input_device_listener *listener, |
|
|
|
|
|
|
|
void *data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return wl_proxy_add_listener(&input_device->proxy, |
|
|
|
|
|
|
|
(void (**)(void)) listener, data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
display_handle_invalid_object(struct wl_display *display, |
|
|
|
display_handle_invalid_object(void *data, |
|
|
|
struct wl_object *object, uint32_t id) |
|
|
|
struct wl_display *display, uint32_t id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fprintf(stderr, "sent request to invalid object\n"); |
|
|
|
fprintf(stderr, "sent request to invalid object\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
display_handle_invalid_method(struct wl_display *display, |
|
|
|
display_handle_invalid_method(void *data,
|
|
|
|
struct wl_object *object, |
|
|
|
struct wl_display *display, |
|
|
|
uint32_t id, uint32_t opcode) |
|
|
|
uint32_t id, uint32_t opcode) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fprintf(stderr, "sent invalid request opcode\n"); |
|
|
|
fprintf(stderr, "sent invalid request opcode\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
display_handle_no_memory(struct wl_display *display, |
|
|
|
display_handle_no_memory(void *data, |
|
|
|
struct wl_object *object) |
|
|
|
struct wl_display *display) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fprintf(stderr, "server out of memory\n"); |
|
|
|
fprintf(stderr, "server out of memory\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
display_handle_global(struct wl_display *display, |
|
|
|
display_handle_global(void *data, |
|
|
|
struct wl_object *object, |
|
|
|
struct wl_display *display, |
|
|
|
uint32_t id, const char *interface, uint32_t version) |
|
|
|
uint32_t id, const char *interface, uint32_t version) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct wl_global *global; |
|
|
|
struct wl_global *global; |
|
|
@ -222,32 +319,41 @@ display_handle_global(struct wl_display *display, |
|
|
|
global->interface = strdup(interface); |
|
|
|
global->interface = strdup(interface); |
|
|
|
global->version = version; |
|
|
|
global->version = version; |
|
|
|
wl_list_insert(display->global_list.prev, &global->link); |
|
|
|
wl_list_insert(display->global_list.prev, &global->link); |
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(global->interface, "display") == 0) |
|
|
|
if (strcmp(global->interface, "display") == 0) |
|
|
|
wl_hash_insert(display->objects, &display->proxy.base); |
|
|
|
wl_hash_insert(display->objects, &display->proxy.base); |
|
|
|
if (strcmp(global->interface, "visual") == 0) |
|
|
|
else if (strcmp(global->interface, "compositor") == 0) |
|
|
|
|
|
|
|
display->compositor = (struct wl_compositor *)
|
|
|
|
|
|
|
|
wl_proxy_create_for_global(display, global, |
|
|
|
|
|
|
|
&wl_compositor_interface); |
|
|
|
|
|
|
|
else if (strcmp(global->interface, "visual") == 0) |
|
|
|
add_visual(display, global); |
|
|
|
add_visual(display, global); |
|
|
|
else if (strcmp(global->interface, "output") == 0) |
|
|
|
else if (strcmp(global->interface, "output") == 0) |
|
|
|
add_output(display, global); |
|
|
|
wl_proxy_create_for_global(display, global, |
|
|
|
|
|
|
|
&wl_output_interface); |
|
|
|
|
|
|
|
else if (strcmp(global->interface, "input_device") == 0) |
|
|
|
|
|
|
|
wl_proxy_create_for_global(display, global, |
|
|
|
|
|
|
|
&wl_input_device_interface); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
display_handle_range(struct wl_display *display, |
|
|
|
display_handle_range(void *data, |
|
|
|
struct wl_object *object, uint32_t range) |
|
|
|
struct wl_display *display, uint32_t range) |
|
|
|
{ |
|
|
|
{ |
|
|
|
display->next_range = range; |
|
|
|
display->next_range = range; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
struct wl_display_listener { |
|
|
|
struct wl_display_listener { |
|
|
|
void (*invalid_object)(struct wl_display *display, |
|
|
|
void (*invalid_object)(void *data, |
|
|
|
struct wl_object *object, uint32_t id); |
|
|
|
struct wl_display *display, uint32_t id); |
|
|
|
void (*invalid_method)(struct wl_display *display, |
|
|
|
void (*invalid_method)(void *data, struct wl_display *display, |
|
|
|
struct wl_object *object, |
|
|
|
|
|
|
|
uint32_t id, uint32_t opcode); |
|
|
|
uint32_t id, uint32_t opcode); |
|
|
|
void (*no_memory)(struct wl_display *display, struct wl_object *object); |
|
|
|
void (*no_memory)(void *data, |
|
|
|
void (*global)(struct wl_display *display, struct wl_object *object, |
|
|
|
struct wl_display *display); |
|
|
|
|
|
|
|
void (*global)(void *data, struct wl_display *display, |
|
|
|
uint32_t id, const char *interface, uint32_t version); |
|
|
|
uint32_t id, const char *interface, uint32_t version); |
|
|
|
void (*range)(struct wl_display *display, |
|
|
|
void (*range)(void *data, |
|
|
|
struct wl_object *object, uint32_t range); |
|
|
|
struct wl_display *display, uint32_t range); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static const struct wl_display_listener display_listener = { |
|
|
|
static const struct wl_display_listener display_listener = { |
|
|
@ -289,12 +395,15 @@ wl_display_create(const char *name, size_t name_size) |
|
|
|
|
|
|
|
|
|
|
|
display->objects = wl_hash_create(); |
|
|
|
display->objects = wl_hash_create(); |
|
|
|
wl_list_init(&display->global_list); |
|
|
|
wl_list_init(&display->global_list); |
|
|
|
wl_list_init(&display->visual_list); |
|
|
|
wl_list_init(&display->global_listener_list); |
|
|
|
|
|
|
|
|
|
|
|
display->proxy.base.interface = &wl_display_interface; |
|
|
|
display->proxy.base.interface = &wl_display_interface; |
|
|
|
display->proxy.base.implementation = (void(**)(void)) &display_listener; |
|
|
|
|
|
|
|
display->proxy.base.id = 1; |
|
|
|
display->proxy.base.id = 1; |
|
|
|
display->proxy.display = display; |
|
|
|
display->proxy.display = display; |
|
|
|
|
|
|
|
wl_list_init(&display->proxy.listener_list); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
display->listener.implementation = (void(**)(void)) &display_listener; |
|
|
|
|
|
|
|
wl_list_insert(display->proxy.listener_list.prev, &display->listener.link); |
|
|
|
|
|
|
|
|
|
|
|
display->connection = wl_connection_create(display->fd, |
|
|
|
display->connection = wl_connection_create(display->fd, |
|
|
|
connection_update, |
|
|
|
connection_update, |
|
|
@ -351,26 +460,37 @@ handle_event(struct wl_display *display, |
|
|
|
uint32_t id, uint32_t opcode, uint32_t size) |
|
|
|
uint32_t id, uint32_t opcode, uint32_t size) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint32_t p[32]; |
|
|
|
uint32_t p[32]; |
|
|
|
struct wl_object *object; |
|
|
|
struct wl_listener *listener; |
|
|
|
|
|
|
|
struct wl_proxy *proxy; |
|
|
|
|
|
|
|
|
|
|
|
wl_connection_copy(display->connection, p, size); |
|
|
|
wl_connection_copy(display->connection, p, size); |
|
|
|
if (id == 1) |
|
|
|
if (id == 1) |
|
|
|
object = &display->proxy.base; |
|
|
|
proxy = &display->proxy; |
|
|
|
else |
|
|
|
else |
|
|
|
object = wl_hash_lookup(display->objects, id); |
|
|
|
proxy = (struct wl_proxy *) wl_hash_lookup(display->objects, id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (proxy != NULL) { |
|
|
|
|
|
|
|
if (wl_list_empty(&proxy->listener_list)) { |
|
|
|
|
|
|
|
printf("proxy found for object %d, opcode %d, but no listeners\n", |
|
|
|
|
|
|
|
id, opcode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listener = container_of(proxy->listener_list.next, |
|
|
|
|
|
|
|
struct wl_listener, link); |
|
|
|
|
|
|
|
while (&listener->link != &proxy->listener_list) { |
|
|
|
|
|
|
|
|
|
|
|
if (object != NULL) |
|
|
|
|
|
|
|
wl_connection_demarshal(display->connection, |
|
|
|
wl_connection_demarshal(display->connection, |
|
|
|
size, |
|
|
|
size, |
|
|
|
display->objects, |
|
|
|
display->objects, |
|
|
|
object->implementation[opcode], |
|
|
|
listener->implementation[opcode], |
|
|
|
display, |
|
|
|
listener->data, |
|
|
|
object,
|
|
|
|
&proxy->base,
|
|
|
|
&object->interface->events[opcode]); |
|
|
|
&proxy->base.interface->events[opcode]); |
|
|
|
else if (display->event_handler != NULL) |
|
|
|
|
|
|
|
display->event_handler(display, id, |
|
|
|
listener = container_of(listener->link.next, |
|
|
|
opcode, size, p + 2, |
|
|
|
struct wl_listener, link); |
|
|
|
display->event_handler_data); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wl_connection_consume(display->connection, size); |
|
|
|
wl_connection_consume(display->connection, size); |
|
|
|
} |
|
|
|
} |
|
|
@ -403,16 +523,6 @@ wl_display_iterate(struct wl_display *display, uint32_t mask) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WL_EXPORT void |
|
|
|
|
|
|
|
wl_display_set_event_handler(struct wl_display *display, |
|
|
|
|
|
|
|
wl_display_event_func_t handler, |
|
|
|
|
|
|
|
void *data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/* FIXME: This needs something more generic... */ |
|
|
|
|
|
|
|
display->event_handler = handler; |
|
|
|
|
|
|
|
display->event_handler_data = data; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WL_EXPORT uint32_t |
|
|
|
WL_EXPORT uint32_t |
|
|
|
wl_display_allocate_id(struct wl_display *display) |
|
|
|
wl_display_allocate_id(struct wl_display *display) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -435,32 +545,16 @@ wl_display_write(struct wl_display *display, const void *data, size_t count) |
|
|
|
WL_EXPORT struct wl_compositor * |
|
|
|
WL_EXPORT struct wl_compositor * |
|
|
|
wl_display_get_compositor(struct wl_display *display) |
|
|
|
wl_display_get_compositor(struct wl_display *display) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct wl_compositor *compositor; |
|
|
|
return display->compositor; |
|
|
|
uint32_t id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id = wl_display_get_object_id(display, "compositor", 1); |
|
|
|
|
|
|
|
if (id == 0) |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
compositor = malloc(sizeof *compositor); |
|
|
|
|
|
|
|
compositor->proxy.base.interface = &wl_compositor_interface; |
|
|
|
|
|
|
|
compositor->proxy.base.id = id; |
|
|
|
|
|
|
|
compositor->proxy.display = display; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return compositor; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
WL_EXPORT int |
|
|
|
wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...) |
|
|
|
wl_compositor_add_listener(struct wl_compositor *compositor, |
|
|
|
|
|
|
|
const struct wl_compositor_listener *listener, |
|
|
|
|
|
|
|
void *data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
va_list ap; |
|
|
|
return wl_proxy_add_listener(&compositor->proxy, |
|
|
|
|
|
|
|
(void (**)(void)) listener, data); |
|
|
|
va_start(ap, opcode); |
|
|
|
|
|
|
|
wl_connection_vmarshal(proxy->display->connection, |
|
|
|
|
|
|
|
&proxy->base, opcode, ap, |
|
|
|
|
|
|
|
&proxy->base.interface->methods[opcode]); |
|
|
|
|
|
|
|
va_end(ap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WL_EXPORT struct wl_surface * |
|
|
|
WL_EXPORT struct wl_surface * |
|
|
|