Skip to content

Commit

Permalink
wayland: Don't enable the text-input protocol when using Fcitx
Browse files Browse the repository at this point in the history
Otherwise, key repeat will be broken. Enabling it under Wayland isn't recommended anyway.
  • Loading branch information
Kontrabant committed Jan 5, 2025
1 parent dcc645e commit 2b375d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
19 changes: 18 additions & 1 deletion src/video/wayland/SDL_waylandevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -2669,7 +2669,7 @@ void Wayland_create_primary_selection_device(SDL_VideoData *d)
}
}

void Wayland_create_text_input(SDL_VideoData *d)
static void Wayland_create_text_input(SDL_VideoData *d)
{
SDL_WaylandTextInput *text_input = NULL;

Expand All @@ -2696,6 +2696,23 @@ void Wayland_create_text_input(SDL_VideoData *d)
}
}

void Wayland_create_text_input_manager(SDL_VideoData *d, uint32_t id)
{
#ifdef HAVE_FCITX
const char *im_module = SDL_getenv("SDL_IM_MODULE");
if (im_module && SDL_strcmp(im_module, "fcitx") == 0) {
/* Override the Wayland text-input protocol when Fcitx is enabled, like how GTK_IM_MODULE does.
*
* The Fcitx wiki discourages enabling it under Wayland via SDL_IM_MODULE, so its presence must
* be intentional, and this workaround is needed for fixing key repeat detection.
*/
return;
}
#endif

d->text_input_manager = wl_registry_bind(d->registry, id, &zwp_text_input_manager_v3_interface, 1);
Wayland_create_text_input(d);
}

// Pen/Tablet support...

Expand Down
3 changes: 2 additions & 1 deletion src/video/wayland/SDL_waylandevents_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ extern int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS);

extern void Wayland_create_data_device(SDL_VideoData *d);
extern void Wayland_create_primary_selection_device(SDL_VideoData *d);
extern void Wayland_create_text_input(SDL_VideoData *d);

extern void Wayland_create_text_input_manager(SDL_VideoData *d, uint32_t id);

extern void Wayland_input_initialize_seat(SDL_VideoData *d);
extern void Wayland_display_destroy_input(SDL_VideoData *d);
Expand Down
3 changes: 1 addition & 2 deletions src/video/wayland/SDL_waylandvideo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,8 +1234,7 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint
} else if (SDL_strcmp(interface, "xdg_activation_v1") == 0) {
d->activation_manager = wl_registry_bind(d->registry, id, &xdg_activation_v1_interface, 1);
} else if (SDL_strcmp(interface, "zwp_text_input_manager_v3") == 0) {
d->text_input_manager = wl_registry_bind(d->registry, id, &zwp_text_input_manager_v3_interface, 1);
Wayland_create_text_input(d);
Wayland_create_text_input_manager(d, id);
} else if (SDL_strcmp(interface, "wl_data_device_manager") == 0) {
d->data_device_manager = wl_registry_bind(d->registry, id, &wl_data_device_manager_interface, SDL_min(3, version));
Wayland_create_data_device(d);
Expand Down

0 comments on commit 2b375d9

Please sign in to comment.