diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-10-10 20:14:35 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-12-07 19:44:09 +0000 |
| commit | 148bb1ff136ee225aaa93ff9b40700feb81503c5 (patch) | |
| tree | b335b5f2762a22646afe80911744111866bd4309 /wayland.c | |
| parent | changelog: DECSET 27127 - modifies Esc to send \E[27127~ instead of \E (diff) | |
ime: wip: add text-input object to seat
Diffstat (limited to 'wayland.c')
| -rw-r--r-- | wayland.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -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" @@ -112,6 +114,23 @@ seat_add_primary_selection(struct seat *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) { if (seat == NULL) @@ -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) |
