xwayland: Add a -nokeymap option

By default, Xwayland (as any Wayland client) uses the keymap set by the
Wayland compositor using the standard Wayland protocol.

There are some specific uses cases where a user would want to let the
X11 clients control the keymap. However, the Wayland compositor may
(re)send the keymap at any time, overriding whatever change was made
using the X11 mechanisms.

Add a new "-nokeymap" option to Xwayland to instruct Xwayland to simply
ignore the standard Wayland mechanism to set the keymap, hence leaving
the control entirely to the X11 clients.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Olivier Fourdan 2024-01-12 09:37:58 +01:00 committed by Olivier Fourdan
parent e89edec497
commit 0cbf6d9326
5 changed files with 21 additions and 0 deletions

View File

@ -124,6 +124,15 @@ support touch input.
Force additional non-native modes to be exposed when viewporter is not Force additional non-native modes to be exposed when viewporter is not
supported by the Wayland compositor. supported by the Wayland compositor.
.TP 8 .TP 8
.B \-nokeymap
Instructs \fIXwayland\fP to ignore the keymap set by the Wayland compositor.
By default, \fIXwayland\fP (as any Wayland client) uses the keymap set by the
Wayland compositor using the standard Wayland protocol.
This option is meant for some specific use cases where it may be desirable to
let the X11 clients control the keymap used in Xwayland, ignoring the keymap
specified by the Wayland compositor.
.B \-output \fIname\fP .B \-output \fIname\fP
Specifies on which output \fIXwayland\fP fullscreen rootful should be placed. Specifies on which output \fIXwayland\fP fullscreen rootful should be placed.
The name must match the name of an existing Wayland output (output names can The name must match the name of an existing Wayland output (output names can

View File

@ -1113,10 +1113,14 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
uint32_t format, int fd, uint32_t size) uint32_t format, int fd, uint32_t size)
{ {
struct xwl_seat *xwl_seat = data; struct xwl_seat *xwl_seat = data;
struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
DeviceIntPtr master; DeviceIntPtr master;
XkbDescPtr xkb; XkbDescPtr xkb;
XkbChangesRec changes = { 0 }; XkbChangesRec changes = { 0 };
if (xwl_screen->nokeymap)
return;
if (xwl_seat->keymap) if (xwl_seat->keymap)
munmap(xwl_seat->keymap, xwl_seat->keymap_size); munmap(xwl_seat->keymap, xwl_seat->keymap_size);

View File

@ -869,6 +869,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
ErrorF("This build does not have XDG portal support\n"); ErrorF("This build does not have XDG portal support\n");
#endif #endif
} }
else if (strcmp(argv[i], "-nokeymap") == 0) {
xwl_screen->nokeymap = 1;
}
} }
if (!xwl_screen->rootless) { if (!xwl_screen->rootless) {

View File

@ -68,6 +68,7 @@ struct xwl_screen {
int has_grab; int has_grab;
int decorate; int decorate;
int enable_ei_portal; int enable_ei_portal;
int nokeymap;
CreateScreenResourcesProcPtr CreateScreenResources; CreateScreenResourcesProcPtr CreateScreenResources;
CloseScreenProcPtr CloseScreen; CloseScreenProcPtr CloseScreen;

View File

@ -94,6 +94,7 @@ ddxUseMsg(void)
ErrorF("-fullscreen run fullscreen when rootful\n"); ErrorF("-fullscreen run fullscreen when rootful\n");
ErrorF("-geometry WxH set Xwayland window size when rootful\n"); ErrorF("-geometry WxH set Xwayland window size when rootful\n");
ErrorF("-host-grab disable host keyboard shortcuts when rootful\n"); ErrorF("-host-grab disable host keyboard shortcuts when rootful\n");
ErrorF("-nokeymap ignore keymap from the Wayland compositor\n");
ErrorF("-output specify which output to use for fullscreen when rootful\n"); ErrorF("-output specify which output to use for fullscreen when rootful\n");
ErrorF("-wm fd create X client for wm on given fd\n"); ErrorF("-wm fd create X client for wm on given fd\n");
ErrorF("-initfd fd add given fd as a listen socket for initialization clients\n"); ErrorF("-initfd fd add given fd as a listen socket for initialization clients\n");
@ -267,6 +268,9 @@ ddxProcessArgument(int argc, char *argv[], int i)
CHECK_FOR_REQUIRED_ARGUMENTS(1); CHECK_FOR_REQUIRED_ARGUMENTS(1);
return 2; return 2;
} }
else if (strcmp(argv[i], "-nokeymap") == 0) {
return 1;
}
return 0; return 0;
} }