Guest User

Untitled

a guest
Oct 16th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. The syntax for setting up a third level key in a .xkb file seems to be vey
  2. picky, I still need to explore more xkbcomp's source code to know how things
  3. work.
  4.  
  5. I noticed this because recently the way I used to define the AltGr key in my
  6. custom layout stopped working. I'm not sure which commit in which project
  7. caused this to stop working, could have been libxkbcommon (xkbcomp), xserver,
  8. Gdk among others. What I do know is that suddenly pressing AltGr would set
  9. GDK_MOD1_MASK in the received key release event. This modifier is treated by
  10. Gdk (Together with GDK_CONTROL_MASK) as one that will NEVER serve to translate
  11. a keycode into a keysym as its intent is GDK_MODIFIER_INTENT_NO_TEXT_INPUT.
  12. This makes Gdk bail out in the translation of any keysym in the third level.
  13.  
  14. I tracked the bug down through several projects, by comparing my custom layout
  15. with the latam layout that worked fine in all cases. In the end I discovered it
  16. was an issue with the syntax I was using to assign the <RALT> key in my custom
  17. layout.
  18.  
  19. xkb_symbols "basic" {
  20.  
  21. // Does not work
  22. //key <RALT> {
  23. // type= "TWO_LEVEL",
  24. // symbols[Group1]= [ ISO_Level3_Shift, Meta_R ]
  25. //};
  26.  
  27. // Does not work
  28. //key <RALT> {
  29. // type[Group1]= "TWO_LEVEL",
  30. // symbols[Group1]= [ ISO_Level3_Shift, Meta_R ]
  31. //};
  32.  
  33. // Does not work
  34. //key <RALT> {
  35. // type="ONE_LEVEL",
  36. // symbols[Group1]= [ ISO_Level3_Shift ]
  37. //};
  38.  
  39. // Works fine
  40. key <RALT> {
  41. type[Group1]="ONE_LEVEL",
  42. symbols[Group1]= [ ISO_Level3_Shift ]
  43. };
  44.  
  45. modifier_map Mod5 { <LVL3> };
  46. modifier_map Mod1 { <LALT>, <META> };
  47. };
  48.  
  49. I tested these symbols by using libxkbcommon's test suite. I added the symbols
  50. into the file <libxkbcommmon repo>/test/data/altgr_decl_test. Then I tested
  51. each of the 4 declarations for <RALT> by uncommenting it and running the
  52. print-compiled-keymap test as follows:
  53.  
  54. $ cd <libxkbcommmon repo>
  55. $ ./build/print-compiled-keymap -l altgr_decl_test,us
  56.  
  57. The expected modifier mapping for Mod1 is
  58.  
  59. modifier_map Mod1 { <LALT>, <META> };
  60.  
  61. but in all non-working options I got
  62.  
  63. modifier_map Mod1 { <LALT>, <RALT>, <META> };
  64.  
  65. The issue seems to be related to how different layouts are merged into each
  66. other. Even though in the example above it looks like nothing is being merged,
  67. two things have to be taken into account:
  68.  
  69. 1. All layouts by default use the "pc" layout as base, so everything gets
  70. merged on top of it.
  71. 2. In elementary OS to make keybindings work in internationalized keyboards
  72. we copied a hack from GNOME, where the "us" layout is added in the last
  73. group (which is why I tested with '-l altgr_decl_test,us' and not just
  74. '-l altgr_decl_test'). Then, when an application is trying to match a
  75. keybinding, it can lookup through all groups and the "us" keysym will be
  76. the fallback. I think GNOME doesn't do this anymore, so elementary
  77. shouldn't either, but last time I checked this was still being used.
  78.  
  79. As a result of this, until I have a better understanding of why only the last
  80. declaration works fine, I'll make the following assumptions:
  81.  
  82. - A custom keyboard layout will usually be merged with other ones. I need
  83. to test at least against "pc" and "us".
  84. - A modifier key MUST be declared as above. Which means all modifier keys
  85. will be of type ONE_LEVEL.
  86.  
  87. NOTE: I should create better tools to explore these kinds of issues.
Add Comment
Please, Sign In to add comment