ime: wip: add text-input object to seat

This commit is contained in:
Daniel Eklöf 2020-10-10 22:14:35 +02:00
parent d58d0601f6
commit 148bb1ff13
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 147 additions and 0 deletions

View file

@ -18,6 +18,7 @@
#include <tllist.h>
#include <xdg-output-unstable-v1.h>
#include <xdg-decoration-unstable-v1.h>
#include <text-input-unstable-v3.h>
#define LOG_MODULE "wayland"
#define LOG_ENABLE_DBG 0
@ -25,6 +26,7 @@
#include "config.h"
#include "terminal.h"
#include "ime.h"
#include "input.h"
#include "render.h"
#include "selection.h"
@ -111,6 +113,23 @@ seat_add_primary_selection(struct seat *seat)
primary_selection_device, &primary_selection_device_listener, seat);
}
static void
seat_add_text_input(struct seat *seat)
{
if (seat->wayl->text_input_manager == NULL)
return;
struct zwp_text_input_v3 *text_input
= zwp_text_input_manager_v3_get_text_input(
seat->wayl->text_input_manager, seat->wl_seat);
if (text_input == NULL)
return;
seat->wl_text_input = text_input;
zwp_text_input_v3_add_listener(text_input, &text_input_listener, seat);
}
static void
seat_destroy(struct seat *seat)
{
@ -165,6 +184,8 @@ seat_destroy(struct seat *seat)
wl_keyboard_release(seat->wl_keyboard);
if (seat->wl_pointer != NULL)
wl_pointer_release(seat->wl_pointer);
if (seat->wl_text_input != NULL)
zwp_text_input_v3_destroy(seat->wl_text_input);
if (seat->wl_seat != NULL)
wl_seat_release(seat->wl_seat);
@ -815,6 +836,7 @@ handle_global(void *data, struct wl_registry *registry,
seat_add_data_device(seat);
seat_add_primary_selection(seat);
seat_add_text_input(seat);
wl_seat_add_listener(wl_seat, &seat_listener, seat);
}
@ -895,6 +917,18 @@ handle_global(void *data, struct wl_registry *registry,
wayl->presentation, &presentation_listener, wayl);
}
}
else if (strcmp(interface, zwp_text_input_manager_v3_interface.name) == 0) {
const uint32_t required = 1;
if (!verify_iface_version(interface, version, required))
return;
wayl->text_input_manager = wl_registry_bind(
wayl->registry, name, &zwp_text_input_manager_v3_interface, required);
tll_foreach(wayl->seats, it)
seat_add_text_input(&it->item);
}
}
static void
@ -1154,6 +1188,8 @@ wayl_destroy(struct wayland *wayl)
seat_destroy(&it->item);
tll_free(wayl->seats);
if (wayl->text_input_manager != NULL)
zwp_text_input_manager_v3_destroy(wayl->text_input_manager);
if (wayl->xdg_output_manager != NULL)
zxdg_output_manager_v1_destroy(wayl->xdg_output_manager);
if (wayl->shell != NULL)