maintainer-feedback requested: [Bug 277531] x11/xorg: "Menu" key works on some keyboards not on others

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 06 Mar 2024 15:15:46 UTC
Bugzilla Automation <bugzilla@FreeBSD.org> has asked freebsd-x11 (Nobody)
<x11@FreeBSD.org> for maintainer-feedback:
Bug 277531: x11/xorg: "Menu" key works on some keyboards not on others
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277531



--- Description ---
While it took a while to track down[1], the Menu key (usually to the right of
the spacebar on the standard 105-key keyboard) seems to send two different
key-codes.

I have USB keyboard plugged into my laptop.  Pressing the Menu key on the
laptop keyboard sends keycode 147 which gets translated to "XF86MenuKB" while
pressing the same Menu key on the external USB keyboard sends keycode 135 which
gets translated to the "Menu" keysym:

    $ xev 2>/dev/null | awk '/^Key/{k=$1}/keysym/{sub(/, same_screen.*/,
"");print k, $0}'
    KeyPress	 state 0x10, keycode 147 (keysym 0x1008ff65, XF86MenuKB)
    KeyRelease	   state 0x10, keycode 147 (keysym 0x1008ff65, XF86MenuKB)
    KeyPress	 state 0x10, keycode 135 (keysym 0xff67, Menu)
    KeyRelease	   state 0x10, keycode 135 (keysym 0xff67, Menu)

Critically, AFAICT, most applications expect/respect the "Menu" keysym, but
ignore the "XF86MenuKB" symbol.  Thus, if I'm in Firefox or Chromium and hit
the Menu key on my laptop, it does nothing; if I hit the Menu key on my
external keyboard, it invokes the right-click menu.  In that Reddit thread[1],
it seems to be every application we've thrown at it -- KDE for the OP;
browsers, office applications, and other applications for me.

It looks like some changes were made a couple years ago[2] and someone else
butting their head against the issue[3].

It looks like the solution might involve modifying

    /usr/local/share/X11/xkb/symbols/inet

so that the line currently reading

    key <I147> { [ XF86MenuKB ] };

gets changed, replacing "XF86MenuKB" with "Menu".

(I'm not sure there's a way to update every application that expects "Menu" to
also allow "XF86MenuKB" as a synonym).

I can provide additional detail or debugging output if needed (output of
`xinput --list --long` and `setxkbmap -print` provided at the bottom of this;
the "SEM" is the external USB keyboard).

---------

[1]
original Reddit thread wherein this was tracked down:
https://www.reddit.com/r/freebsd/comments/1b6gi5n/keyboard_menu_key_doesnt_work
_on_freebsd14_kde5/

[2]
https://lists.freebsd.org/pipermail/freebsd-current/2020-March/075495.html

[3]
http://www.lemis.com/grog/diary-mar2020.php?subtitle=Daily%20teevee%20update&ar
ticle=D-20200306-002910#D-20200306-002910


------------

    ⎡ Virtual core pointer			id=2	[master pointer  (3)]
	Reporting 8 classes:
		Class originated from: 12. Type: XIButtonClass
		Buttons supported: 12
		Button labels: "Button Left" "Button Middle" "Button Right"
"Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz
Wheel Right" None None None None None
		Button state:
		Class originated from: 12. Type: XIValuatorClass
		Detail for Valuator 0:
		  Label: Rel X
		  Range: 1472.000000 - 5772.000000
		  Resolution: 69000 units/m
		  Mode: relative
		Class originated from: 12. Type: XIValuatorClass
		Detail for Valuator 1:
		  Label: Rel Y
		  Range: 1408.000000 - 5086.000000
		  Resolution: 118000 units/m
		  Mode: relative
		Class originated from: 12. Type: XIValuatorClass
		Detail for Valuator 2:
		  Label: Rel Horiz Scroll
		  Range: 0.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 12. Type: XIValuatorClass
		Detail for Valuator 3:
		  Label: Rel Vert Scroll
		  Range: 0.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 12. Type: XIValuatorClass
		Detail for Valuator 4:
		  Label: Abs MT Pressure
		  Range: -1.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 12. Type: XIScrollClass
		Scroll info for Valuator 2
		  type: 2 (horizontal)
		  increment: 113.000000
		  flags: 0x0
		Class originated from: 12. Type: XIScrollClass
		Scroll info for Valuator 3
		  type: 1 (vertical)
		  increment: 113.000000
		  flags: 0x0

    ⎜	↳ Virtual core XTEST pointer			id=4	[slave	pointer
 (2)]
	Reporting 3 classes:
		Class originated from: 4. Type: XIButtonClass
		Buttons supported: 10
		Button labels: "Button Left" "Button Middle" "Button Right"
"Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz
Wheel Right" None None None
		Button state:
		Class originated from: 4. Type: XIValuatorClass
		Detail for Valuator 0:
		  Label: Rel X
		  Range: -1.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 4. Type: XIValuatorClass
		Detail for Valuator 1:
		  Label: Rel Y
		  Range: -1.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative

    ⎜	↳ System mouse					id=6	[slave	pointer
 (2)]
	Reporting 7 classes:
		Class originated from: 6. Type: XIButtonClass
		Buttons supported: 12
		Button labels: "Button Left" "Button Middle" "Button Right"
"Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz
Wheel Right" "Button Side" "Button Extra" "Button Forward" "Button Back" None
		Button state:
		Class originated from: 6. Type: XIValuatorClass
		Detail for Valuator 0:
		  Label: Rel X
		  Range: -1.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 6. Type: XIValuatorClass
		Detail for Valuator 1:
		  Label: Rel Y
		  Range: -1.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 6. Type: XIValuatorClass
		Detail for Valuator 2:
		  Label: Rel Horiz Scroll
		  Range: -1.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 6. Type: XIValuatorClass
		Detail for Valuator 3:
		  Label: Rel Vert Scroll
		  Range: -1.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 6. Type: XIScrollClass
		Scroll info for Valuator 2
		  type: 2 (horizontal)
		  increment: 120.000000
		  flags: 0x0
		Class originated from: 6. Type: XIScrollClass
		Scroll info for Valuator 3
		  type: 1 (vertical)
		  increment: 120.000000
		  flags: 0x0

    ⎜	↳ SynPS/2 Synaptics TouchPad			id=12	[slave	pointer
 (2)]
	Reporting 8 classes:
		Class originated from: 12. Type: XIButtonClass
		Buttons supported: 12
		Button labels: "Button Left" "Button Middle" "Button Right"
"Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz
Wheel Right" None None None None None
		Button state:
		Class originated from: 12. Type: XIValuatorClass
		Detail for Valuator 0:
		  Label: Rel X
		  Range: 1472.000000 - 5772.000000
		  Resolution: 69000 units/m
		  Mode: relative
		Class originated from: 12. Type: XIValuatorClass
		Detail for Valuator 1:
		  Label: Rel Y
		  Range: 1408.000000 - 5086.000000
		  Resolution: 118000 units/m
		  Mode: relative
		Class originated from: 12. Type: XIValuatorClass
		Detail for Valuator 2:
		  Label: Rel Horiz Scroll
		  Range: 0.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 12. Type: XIValuatorClass
		Detail for Valuator 3:
		  Label: Rel Vert Scroll
		  Range: 0.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 12. Type: XIValuatorClass
		Detail for Valuator 4:
		  Label: Abs MT Pressure
		  Range: -1.000000 - -1.000000
		  Resolution: 0 units/m
		  Mode: relative
		Class originated from: 12. Type: XIScrollClass
		Scroll info for Valuator 2
		  type: 2 (horizontal)
		  increment: 113.000000
		  flags: 0x0
		Class originated from: 12. Type: XIScrollClass
		Scroll info for Valuator 3
		  type: 1 (vertical)
		  increment: 113.000000
		  flags: 0x0

    ⎣ Virtual core keyboard			id=3	[master keyboard (2)]
	Reporting 1 classes:
		Class originated from: 13. Type: XIKeyClass
		Keycodes supported: 248

	↳ Virtual core XTEST keyboard			id=5	[slave 
keyboard (3)]
	Reporting 1 classes:
		Class originated from: 5. Type: XIKeyClass
		Keycodes supported: 248

	↳ System keyboard multiplexer			id=7	[slave 
keyboard (3)]
	Reporting 1 classes:
		Class originated from: 7. Type: XIKeyClass
		Keycodes supported: 248

	↳ ACPI video extension				id=8	[slave 
keyboard (3)]
	Reporting 1 classes:
		Class originated from: 8. Type: XIKeyClass
		Keycodes supported: 248

	↳ Power Button					id=9	[slave 
keyboard (3)]
	Reporting 1 classes:
		Class originated from: 9. Type: XIKeyClass
		Keycodes supported: 248

	↳ Sleep Button					id=10	[slave 
keyboard (3)]
	Reporting 1 classes:
		Class originated from: 10. Type: XIKeyClass
		Keycodes supported: 248

	↳ AT keyboard					id=11	[slave 
keyboard (3)]
	Reporting 1 classes:
		Class originated from: 11. Type: XIKeyClass
		Keycodes supported: 248

	↳ SEM USB Keyboard				id=13	[slave 
keyboard (3)]
	Reporting 1 classes:
		Class originated from: 13. Type: XIKeyClass
		Keycodes supported: 248



--------------

    xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)" };
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include
"pc+us+inet(evdev)+compose(caps)+shift(both_capslock)"	};
	xkb_geometry  { include "pc(pc105)"	};
    };