-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Take into account keymap #52
Conversation
} | ||
|
||
static const struct wl_keyboard_listener keyboard_listener = { | ||
.keymap = noop, | ||
.keymap = keyboard_handle_keymap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need to listen to the modifiers
event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I thought at first, but aren't modifiers just CTRL, Mod.... which means that we don't really care about them (for the moment), as the only keys we care about are space and escape
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user may have configured his keyboard so that Shift+Caps Lock yields the Esc keysym, for instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed by d070c7c
How swaylock does it, for reference: https://github.com/swaywm/swaylock/blob/master/seat.c#L10 |
main.c
Outdated
#include <time.h> | ||
#include <sys/mman.h> | ||
#include <alloca.h> | ||
#include <err.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a non-standard API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If mmap fails, now exit(EXIT_FAILURE)
happens.
main.c
Outdated
break; | ||
case WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1:; | ||
void *buffer; | ||
if ((buffer = mmap(NULL, size - 1, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this - 1
which could underflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/xkbcommon/libxkbcommon/blob/master/test/interactive-wayland.c#L341
it uses -1 but not for mmap (which is an inconsistency from the example). I guess the buffer should be a valid string so it must have a size of at least 1 (for the '\0').
Here it also uses the length without the '\0' https://github.com/xkbcommon/libxkbcommon/blob/d92a248c48227d09f6fdcfafaf339a5ff586e042/src/keymap.c#L164
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. Can you squash all of these commits into one?
done |
Thanks for your contribution! |
Fix #36
The first commit contains debug code.