2017-04-25 19:06:58 +00:00
|
|
|
#include <stdint.h>
|
2017-04-25 23:19:21 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2017-04-25 19:06:58 +00:00
|
|
|
#include <wayland-client.h>
|
2017-06-19 17:05:10 +00:00
|
|
|
#include <wlr/types.h>
|
|
|
|
#include "types.h"
|
2017-04-25 19:06:58 +00:00
|
|
|
#include "backend/wayland.h"
|
|
|
|
#include "common/log.h"
|
|
|
|
|
|
|
|
static void registry_global(void *data, struct wl_registry *registry,
|
|
|
|
uint32_t name, const char *interface, uint32_t version) {
|
2017-06-19 17:05:10 +00:00
|
|
|
struct wlr_backend_state *state = data;
|
2017-04-25 19:06:58 +00:00
|
|
|
wlr_log(L_DEBUG, "Remote wayland global: %s v%d", interface, version);
|
2017-04-25 23:19:21 +00:00
|
|
|
|
|
|
|
if (strcmp(interface, wl_compositor_interface.name) == 0) {
|
2017-06-19 17:05:10 +00:00
|
|
|
state->compositor = wl_registry_bind(registry, name,
|
2017-04-25 23:19:21 +00:00
|
|
|
&wl_compositor_interface, version);
|
|
|
|
} else if (strcmp(interface, wl_shell_interface.name) == 0) {
|
2017-06-19 17:05:10 +00:00
|
|
|
state->shell = wl_registry_bind(registry, name,
|
2017-04-25 23:19:21 +00:00
|
|
|
&wl_shell_interface, version);
|
|
|
|
} else if (strcmp(interface, wl_shm_interface.name) == 0) {
|
2017-06-19 17:05:10 +00:00
|
|
|
state->shm = wl_registry_bind(registry, name,
|
2017-04-25 23:19:21 +00:00
|
|
|
&wl_shm_interface, version);
|
|
|
|
} else if (strcmp(interface, wl_seat_interface.name) == 0) {
|
2017-06-19 17:05:10 +00:00
|
|
|
state->seat = wl_registry_bind(registry, name,
|
2017-04-25 23:19:21 +00:00
|
|
|
&wl_seat_interface, version);
|
2017-06-19 17:05:10 +00:00
|
|
|
wl_seat_add_listener(state->seat, &seat_listener, state);
|
2017-04-25 23:19:21 +00:00
|
|
|
}
|
2017-04-25 19:06:58 +00:00
|
|
|
}
|
|
|
|
|
2017-04-25 23:19:21 +00:00
|
|
|
static void registry_global_remove(void *data, struct wl_registry *registry,
|
|
|
|
uint32_t name) {
|
2017-04-25 19:06:58 +00:00
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_registry_listener registry_listener = {
|
|
|
|
.global = registry_global,
|
|
|
|
.global_remove = registry_global_remove
|
|
|
|
};
|
|
|
|
|
2017-06-19 20:36:40 +00:00
|
|
|
void wlr_wl_registry_poll(struct wlr_backend_state *state) {
|
2017-06-19 17:05:10 +00:00
|
|
|
wl_registry_add_listener(state->registry, ®istry_listener, state);
|
|
|
|
wl_display_dispatch(state->remote_display);
|
|
|
|
wl_display_roundtrip(state->remote_display);
|
2017-04-25 19:06:58 +00:00
|
|
|
}
|