summaryrefslogtreecommitdiff
path: root/lib/renderers/wayland/registry.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/renderers/wayland/registry.c')
-rw-r--r--lib/renderers/wayland/registry.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/lib/renderers/wayland/registry.c b/lib/renderers/wayland/registry.c
index 726ed94..da8bc43 100644
--- a/lib/renderers/wayland/registry.c
+++ b/lib/renderers/wayland/registry.c
@@ -27,6 +27,17 @@ const enum mod_bit BM_XKB_MODS[MASK_LAST] = {
};
static void
+xdg_shell_ping(void *data, struct xdg_shell *shell, uint32_t serial)
+{
+ (void)data;
+ xdg_shell_pong(shell, serial);
+}
+
+static const struct xdg_shell_listener xdg_shell_listener = {
+ .ping = xdg_shell_ping,
+};
+
+static void
shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
{
(void)wl_shm;
@@ -250,10 +261,11 @@ static void
display_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, int width, int height, int refresh)
{
(void)wl_output, (void)refresh, (void)height, (void)width;
- struct output *output = data;
+ struct wayland *wayland = data;
if (flags & WL_OUTPUT_MODE_CURRENT) {
- output->height = height;
+ wayland->window.width = width;
+ wayland->window.max_height = height;
}
}
@@ -272,8 +284,12 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, co
if (strcmp(interface, "wl_compositor") == 0) {
wayland->compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1);
- } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
- wayland->layer_shell = wl_registry_bind(registry, id, &zwlr_layer_shell_v1_interface, 1);
+ } else if (strcmp(interface, "xdg_shell") == 0) {
+ wayland->xdg_shell = wl_registry_bind(registry, id, &xdg_shell_interface, 1);
+ xdg_shell_use_unstable_version(wayland->xdg_shell, XDG_SHELL_VERSION_CURRENT);
+ xdg_shell_add_listener(wayland->xdg_shell, &xdg_shell_listener, data);
+ } else if (strcmp(interface, "wl_shell") == 0) {
+ wayland->shell = wl_registry_bind(registry, id, &wl_shell_interface, 1);
} else if (strcmp(interface, "wl_seat") == 0) {
wayland->seat = wl_registry_bind(registry, id, &wl_seat_interface, 1);
wl_seat_add_listener(wayland->seat, &seat_listener, &wayland->input);
@@ -281,11 +297,8 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, co
wayland->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
wl_shm_add_listener(wayland->shm, &shm_listener, data);
} else if (strcmp(interface, "wl_output") == 0) {
- struct wl_output *wl_output = wl_registry_bind(registry, id, &wl_output_interface, 2);
- struct output *output = calloc(1, sizeof(struct output));
- output->output = wl_output;
- wl_list_insert(&wayland->outputs, &output->link);
- wl_output_add_listener(wl_output, &output_listener, output);
+ wayland->output = wl_registry_bind(registry, id, &wl_output_interface, 2);
+ wl_output_add_listener(wayland->output, &output_listener, wayland);
}
}
@@ -321,8 +334,11 @@ bm_wl_registry_destroy(struct wayland *wayland)
if (wayland->shm)
wl_shm_destroy(wayland->shm);
- if (wayland->layer_shell)
- zwlr_layer_shell_v1_destroy(wayland->layer_shell);
+ if (wayland->shell)
+ wl_shell_destroy(wayland->shell);
+
+ if (wayland->xdg_shell)
+ xdg_shell_destroy(wayland->xdg_shell);
if (wayland->compositor)
wl_compositor_destroy(wayland->compositor);
@@ -342,11 +358,9 @@ bm_wl_registry_register(struct wayland *wayland)
if (!(wayland->registry = wl_display_get_registry(wayland->display)))
return false;
- wl_list_init(&wayland->outputs);
- wl_list_init(&wayland->windows);
wl_registry_add_listener(wayland->registry, &registry_listener, wayland);
wl_display_roundtrip(wayland->display); // trip 1, registry globals
- if (!wayland->compositor || !wayland->seat || !wayland->shm || !wayland->layer_shell)
+ if (!wayland->compositor || !wayland->seat || !wayland->shm || !(wayland->shell || wayland->xdg_shell))
return false;
wl_display_roundtrip(wayland->display); // trip 2, global listeners