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

Linux: getLanguageGroupID() returns wrong group #7342

Open
CheeseSucker opened this issue Mar 31, 2024 · 0 comments
Open

Linux: getLanguageGroupID() returns wrong group #7342

CheeseSucker opened this issue Mar 31, 2024 · 0 comments
Labels

Comments

@CheeseSucker
Copy link

CheeseSucker commented Mar 31, 2024

Operating Systems

Server: Windows 10
Client: Ubuntu 23.10

Synergy Version

Synergy 3 RC3 - v3.0.79.1-rc3

Steps to Reproduce

  1. Set keyboard layout to "Norwegian" in both server and client
  2. Type any special character. E.g. å

Expected: The same character appears in the client, å.
Actual: The client tries to use the english layout keystrokes to represent the letter, resulting in ˚ª instead of å and + instead of -.

Extra info

This appears to be related to how X11LayoutParser does mapping from layout names "no,us" to ISO-639-1 language codes.

Calculations in X11LayoutParser.getX11LanguageList():

From XkbRF_GetNamesProp():
  - Layouts: `no,us,us`
  - Variants: `,,`
Intermediate: nor, nob, nno, eng, eng   # In `evdev.xml` the norwegian keyboard layout has three associated languages
Result:       no, nb, nn, us            # After mapping to ISO-639-1 and removing duplicates

getLanguageGroupID(lang) returns the index of the language in the X11LanguageList resulting in this incorrect mapping:

getLanguageGroupID("no") => 0,
getLanguageGroupID("nb") => 1,
getLanguageGroupID("nn") => 2,
getLanguageGroupID("us") => 0, // After modulo operation

Correct mapping should be:

getLanguageGroupID("no") => 0,
getLanguageGroupID("nb") => 0,
getLanguageGroupID("nn") => 0,
getLanguageGroupID("us") => 1, //  2 is also fine in this case

Relevant logs

Startup (with extra logs):

synergy-core     [2024-03-31T11:50:10] - DEBUG1  - keyboard.getLayout(): "no,us,us"
synergy-core     [2024-03-31T11:50:10] - DEBUG1  - keyboard.getVariant(): ",,"
synergy-core     [2024-03-31T11:50:10] - INFO    - local languages: no, nb, nn, en
synergy-core     [2024-03-31T11:50:10] - INFO    - remote languages: nb, en
synergy-core     [2024-03-31T11:50:10] - DEBUG1  - xkb mapping
synergy-core     [2024-03-31T11:50:10] - DEBUG1  - Group names: 3
synergy-core     [2024-03-31T11:50:10] - DEBUG1  - Group name 0: Norwegian
synergy-core     [2024-03-31T11:50:10] - DEBUG1  - Group name 1: English (US)
synergy-core     [2024-03-31T11:50:10] - DEBUG1  - Group name 2: English (US)

Pressing å: (with extra logs)

synergy-core [2024-03-31T11:58:14] - DEBUG1 - mapKey 00e5 (229 | å) with mask 2000, start state: 0000, group: 0
synergy-core [2024-03-31T11:58:14] - DEBUG1 - language nb has group id 1
synergy-core [2024-03-31T11:58:14] - DEBUG1 - best key index 1 of 1 (exact)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - found key in group 1
synergy-core [2024-03-31T11:58:14] - DEBUG1 - language nb has group id 1
synergy-core [2024-03-31T11:58:14] - DEBUG1 - key item list count 2
synergy-core [2024-03-31T11:58:14] - DEBUG1 - item 0 0022
synergy-core [2024-03-31T11:58:14] - DEBUG1 - item 1 0026
synergy-core [2024-03-31T11:58:14] - DEBUG1 - flip: 0021 (0000 vs 0021 in 1021 - 0000)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - state: 0021,0000,1001
synergy-core [2024-03-31T11:58:14] - DEBUG1 - flip: 0001 (0021 vs 0000 in 1001 - 0000)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - desired state: 2000 0020,0000,1001
synergy-core [2024-03-31T11:58:14] - DEBUG1 - flip: 0000 (0020 vs 2000 in effe - 6020)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - mapped to 026, new state 0000
synergy-core [2024-03-31T11:58:14] - DEBUG1 - keystrokes:
synergy-core [2024-03-31T11:58:14] - DEBUG1 - - 0x00005c (92)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - - 0x000032 (50)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - - 0x000022 (34)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - - 0x000022 (34)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - skipping keystroke, language sync is disabled
synergy-core [2024-03-31T11:58:14] - DEBUG1 - - 0x000032 (50)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - - 0x000026 (38)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - - 0x00005c (92)
synergy-core [2024-03-31T11:58:14] - DEBUG1 - recv key up id=0x000000e5, mask=0x2000, button=0x001a
synergy-core [2024-03-31T11:58:14] - DEBUG1 - keystrokes:
synergy-core [2024-03-31T11:58:14] - DEBUG1 - - 0x000026 (38)

Correct keystrokes:

synergy-core [2024-03-31T12:01:50] - DEBUG1 - mapKey 00e5 (229 | å) with mask 2000, start state: 0000, group: 0
synergy-core [2024-03-31T12:01:50] - DEBUG1 - Forced selection of group 0
synergy-core [2024-03-31T12:01:50] - DEBUG1 - best key index 1 of 1 (exact)
synergy-core [2024-03-31T12:01:50] - DEBUG1 - found key in group 0
synergy-core [2024-03-31T12:01:50] - DEBUG1 - language nb has group id 1
synergy-core [2024-03-31T12:01:50] - DEBUG1 - key item list count 1
synergy-core [2024-03-31T12:01:50] - DEBUG1 - item 0 0022
synergy-core [2024-03-31T12:01:50] - DEBUG1 - state: 0000,0000,1021
synergy-core [2024-03-31T12:01:50] - DEBUG1 - flip: 0000 (0000 vs 0000 in 1021 - 0000)
synergy-core [2024-03-31T12:01:50] - DEBUG1 - desired state: 2000 0000,0000,1021
synergy-core [2024-03-31T12:01:50] - DEBUG1 - flip: 0000 (0000 vs 2000 in efde - 6020)
synergy-core [2024-03-31T12:01:50] - DEBUG1 - mapped to 022, new state 0000
synergy-core [2024-03-31T12:01:50] - DEBUG1 - keystrokes:
synergy-core [2024-03-31T12:01:50] - DEBUG1 - - 0x000022 (34)
synergy-core [2024-03-31T12:01:50] - DEBUG1 - recv key up id=0x000000e5, mask=0x2000, button=0x001a
synergy-core [2024-03-31T12:01:50] - DEBUG1 - keystrokes:
synergy-core [2024-03-31T12:01:50] - DEBUG1 - - 0x000022 (34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant