2017-04-25 21:06:58 +02:00
|
|
|
#include <stdint.h>
|
2017-04-26 01:19:21 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2017-04-25 21:06:58 +02:00
|
|
|
#include <wayland-client.h>
|
2017-06-21 18:10:07 +02:00
|
|
|
#include <wlr/util/log.h>
|
2017-04-25 21:06:58 +02:00
|
|
|
#include "backend/wayland.h"
|
2017-08-16 19:19:31 +02:00
|
|
|
#include "xdg-shell-unstable-v6-client-protocol.h"
|
|
|
|
|
|
|
|
static void xdg_shell_handle_ping(void *data, struct zxdg_shell_v6 *shell,
|
|
|
|
uint32_t serial) {
|
2017-11-01 20:14:52 +01:00
|
|
|
zxdg_shell_v6_pong(shell, serial);
|
2017-08-16 19:19:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zxdg_shell_v6_listener xdg_shell_listener = {
|
2017-11-01 20:14:52 +01:00
|
|
|
xdg_shell_handle_ping,
|
2017-08-16 19:19:31 +02:00
|
|
|
};
|
|
|
|
|
2017-04-25 21:06:58 +02:00
|
|
|
|
|
|
|
static void registry_global(void *data, struct wl_registry *registry,
|
|
|
|
uint32_t name, const char *interface, uint32_t version) {
|
2017-08-12 17:43:36 +02:00
|
|
|
struct wlr_wl_backend *backend = data;
|
2018-07-09 23:49:54 +02:00
|
|
|
wlr_log(WLR_DEBUG, "Remote wayland global: %s v%d", interface, version);
|
2017-04-26 01:19:21 +02:00
|
|
|
|
|
|
|
if (strcmp(interface, wl_compositor_interface.name) == 0) {
|
2017-08-12 17:43:36 +02:00
|
|
|
backend->compositor = wl_registry_bind(registry, name,
|
2017-04-26 01:19:21 +02:00
|
|
|
&wl_compositor_interface, version);
|
2017-08-16 19:19:31 +02:00
|
|
|
} else if (strcmp(interface, zxdg_shell_v6_interface.name) == 0) {
|
2017-08-12 17:43:36 +02:00
|
|
|
backend->shell = wl_registry_bind(registry, name,
|
2017-08-16 19:19:31 +02:00
|
|
|
&zxdg_shell_v6_interface, version);
|
|
|
|
zxdg_shell_v6_add_listener(backend->shell, &xdg_shell_listener, NULL);
|
2017-04-26 01:19:21 +02:00
|
|
|
} else if (strcmp(interface, wl_shm_interface.name) == 0) {
|
2017-08-12 17:43:36 +02:00
|
|
|
backend->shm = wl_registry_bind(registry, name,
|
2017-04-26 01:19:21 +02:00
|
|
|
&wl_shm_interface, version);
|
|
|
|
} else if (strcmp(interface, wl_seat_interface.name) == 0) {
|
2017-08-12 17:43:36 +02:00
|
|
|
backend->seat = wl_registry_bind(registry, name,
|
2017-04-26 01:19:21 +02:00
|
|
|
&wl_seat_interface, version);
|
2017-08-12 17:43:36 +02:00
|
|
|
wl_seat_add_listener(backend->seat, &seat_listener, backend);
|
2017-04-26 01:19:21 +02:00
|
|
|
}
|
2017-04-25 21:06:58 +02:00
|
|
|
}
|
|
|
|
|
2017-04-26 01:19:21 +02:00
|
|
|
static void registry_global_remove(void *data, struct wl_registry *registry,
|
|
|
|
uint32_t name) {
|
2017-04-25 21:06:58 +02:00
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_registry_listener registry_listener = {
|
|
|
|
.global = registry_global,
|
|
|
|
.global_remove = registry_global_remove
|
|
|
|
};
|
|
|
|
|
2018-04-26 00:24:58 +02:00
|
|
|
void poll_wl_registry(struct wlr_wl_backend *backend) {
|
2017-08-12 17:43:36 +02:00
|
|
|
wl_registry_add_listener(backend->registry, ®istry_listener, backend);
|
|
|
|
wl_display_dispatch(backend->remote_display);
|
|
|
|
wl_display_roundtrip(backend->remote_display);
|
2017-04-25 21:06:58 +02:00
|
|
|
}
|