Skip to content

Commit

Permalink
WaylandBackend: Fix hotkeys failing to bind on Wayland desktops
Browse files Browse the repository at this point in the history
Per Wayland protocol specsheet regarding keymapping:
"From version 7 onwards, the fd must be mapped with MAP_PRIVATE by the
recipient, as MAP_SHARED may fail."

This matches up exactly with what we're seeing with this error:
[gamescope] [Error] xdg_backend: Failed to map keymap fd.

Changing MAP_SHARED to MAP_PRIVATE per the spec addresses this error.

Fixes: #1658
(hopefully) fixes: #1637
  • Loading branch information
matte-schwartz authored and misyltoad committed Dec 16, 2024
1 parent 4da5e4a commit 1c9495c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Backends/WaylandBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2730,7 +2730,7 @@ namespace gamescope
defer( close( nFd ) );
assert( uFormat == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1 );

char *pMap = (char *)mmap( nullptr, uSize, PROT_READ, MAP_SHARED, nFd, 0 );
char *pMap = (char *)mmap( nullptr, uSize, PROT_READ, MAP_PRIVATE, nFd, 0 );
if ( !pMap || pMap == MAP_FAILED )
{
xdg_log.errorf( "Failed to map keymap fd." );
Expand Down

1 comment on commit 1c9495c

@zrooda
Copy link

@zrooda zrooda commented on 1c9495c Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're amazing for fixing this btw 😘

Please sign in to comment.