Skip to content
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

Merged
merged 1 commit into from
Mar 25, 2020
Merged

Take into account keymap #52

merged 1 commit into from
Mar 25, 2020

Conversation

NilsIrl
Copy link
Contributor

@NilsIrl NilsIrl commented Mar 25, 2020

Fix #36

The first commit contains debug code.

}

static const struct wl_keyboard_listener keyboard_listener = {
.keymap = noop,
.keymap = keyboard_handle_keymap,
Copy link
Owner

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.

Copy link
Contributor Author

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

Copy link
Owner

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.

Copy link
Contributor Author

@NilsIrl NilsIrl Mar 25, 2020

Choose a reason for hiding this comment

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

addressed by d070c7c

@emersion
Copy link
Owner

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>
Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

Copy link
Contributor Author

@NilsIrl NilsIrl Mar 25, 2020

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) {
Copy link
Owner

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.

Copy link
Contributor Author

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

Copy link
Owner

@emersion emersion left a 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?

@NilsIrl
Copy link
Contributor Author

NilsIrl commented Mar 25, 2020

Can you squash all of these commits into one

done

@emersion emersion merged commit d1f9ad5 into emersion:master Mar 25, 2020
@emersion
Copy link
Owner

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

slurp ignores keyboard layout
2 participants