Commit Graph

7 Commits

Author SHA1 Message Date
Philip Zander
4e9ddaf086 gdkkeys-win32: Fix handling of SGCAPS
Contrary to what you can read on the internet, SGCAPS keys don't work
by having capslock toggle the KBDCTRL bit, they actually have two
consecutive table entries, the first of which is for the normal
version and the second of which is for the capslocked version.

Background: SGCAPS is short for Swiss German caps because Swiss German
was the first layout to use this feature. For keys with the SGCAPS flag,
capslock has a different effect than pressing shift. For example:
Shift + ü = è,  CapsLock + ü = Ü,  CapsLock + Shift + ü = È
2022-01-09 12:36:47 +01:00
Philip Zander
8b1c334c4a gdkkeys-win32: Fix crash when keyboard DLL failed to load
DLL loading failures should not happen under normal circumstances, but
we should at least try not to crash and and print better diagnostic
messages if they do happen.

See #4610
2022-01-09 12:36:47 +01:00
Philip Zander
acf5db32f1 gdkkeys-win32: Fix capslock handling
Previously, we treated CapsLock and KanaLock as part of the global
keyboard state, much like NumLock and ScrollLock, rather than using
the supplied modifier mask. This was because GDK does not have a
modifier mask for KanaLock, only for CapsLock, so it would not have been
possible to properly support it.

However, this approach ended up causing problems, with certain keyboard
shortcuts not registering when capslock was active. This was first
observed in Inkscape [0] and appears to affect shortcuts consisting of a
single key (like 'a') with no additional modifiers (wheareas shortcuts
like 'ctrl+a' work).

So now we are using the supplied GDK_LOCK_MASK instead, and dropped
support for KanaLock, which we probably don't need anyway (since regular
text input should be handled by the IME input module -- the keymap is
mainly for shortcuts and keybindings, where you don't really want
KanaLock).

[0] https://gitlab.com/inkscape/inkscape/-/issues/3082
2022-01-09 12:36:32 +01:00
Philip Zander
e658e3c449 gdk/win32: Fix modifiers sometimes being consumed for special keys
Windows keymaps contain some bogus mappings, e.g. Ctrl+Backspace=Delete.
Previously, we correctly identified the key as Backspace, but the Ctrl
was still consumed, so the Ctrl+Backspace keybinding did not work.
2021-12-10 01:14:47 +01:00
Philip Zander
4601d3aee4 gdk/win32: Add licensing boilerplate to gdkkeys-win32 2021-12-09 12:29:15 +01:00
Philip Zander
aa3e6bb0a3 GdkWin32Keymap: Be more robust against DLL loading failures
Fixes failure on the CI servers when generating GIR files
2021-12-08 22:44:20 +01:00
Philip Zander
4039153ca7 Rewrite GdkWin32Keymap (load table directly from layout DLL)
The old code used repeated calls to `ToUnicodeEx` to populate
the translation table, which is slow and buggy. The new code
directly loads the layout driver DLLs from Windows.

Associated issues: #2055 #1033
Merge request: !1051

GdkWin32Keymap cleanup

Conform to C89, improve comments, whitespace
2021-12-08 22:44:17 +01:00