Bug 96282 - Wish: <Super> and <Hyper> prefix option
Summary: Wish: <Super> and <Hyper> prefix option
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: keyboard (show other bugs)
Version: unspecified
Platform: RedHat Enterprise Linux Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-04 12:17 UTC by H. Peter Anvin
Modified: 2023-12-29 08:55 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H. Peter Anvin 2005-01-04 12:17:27 UTC
Version:            (using KDE KDE 3.3.1)
Installed from:    RedHat RPMs
OS:                Linux

Newer PC keyboards have a couple of unlabelled keys, which are convenient to bind to the <Super> and <Hyper> extra bucky bits.  This allows for more macro keys that can be easily remembered, especially in keystroke-rich editors like emacs.

It would be nice to be able to use these when not interfacing directly to an X window, i.e. via a terminal.  The obvious way to do that is to emit a prefix when, for example Super-s is pressed.

For the particular purpose of Emacs, the sequence ^X @ s is already recognized as a <Super> prefix, and ^X @ h as a <Hyper> prefix, so it would be nice to at least have the ability to generate those sequences.  Otherwise it's not a huge deal to create a .emacs file which will recognize just about any arbitrary prefix.  (Emacs also recognizes ^X @ c as a <Ctrl> prefix, mainly for non-numeric keys, e.g. ^X @ c ^[ O P will be recognized as <Ctrl><F1>.
Comment 1 H. Peter Anvin 2007-05-08 03:45:49 UTC
Still missing this one very much :(
Comment 2 H. Peter Anvin 2007-05-08 03:52:21 UTC
In addition to the prefixes listed in the summary, Emacs also has "^X @ m" for Meta prefix (heavily used in Emacs) and "^X @ a" for Alt prefix (not normally used in Emacs; the Alt keys on a PC keyboard are used as Meta keys.)
Comment 3 Robert Knight 2007-07-09 00:38:15 UTC
I do not understand what this bug report is asking for.  Could you clarify, bearing in mind that I am not an Emacs user.
Comment 4 H. Peter Anvin 2007-07-09 02:44:38 UTC
Absolutely.  X11 recognizes the following modifier keys: Mode_switch, Shift, Ctrl, Alt, Meta, Super, Hyper.  These can be bound to keys at will.  Mode_switch and Shift are generally used to produce additional printable character, Ctrl generates special character codes, Alt and Meta are generally treated as the same (few if any keyboards have both Alt and Meta keys), and produce an <ESC> prefix when used in a terminal; e.g. on a U.S. PC keyboard Alt-g generates "ESC g" (1b 67) ; Alt-Shift-6 generates "ESC ^" (1b 5e).

Super and Hyper are usually not bound to keys in the default configuration, but I find it useful to bind them to the otherwise useless Windoze keys.  Thus, I have Emacs macros bound to those key combinations, e.g. I can press Hyper-s to generate a "Signed-off-by:" line.  Now, when dealing with a terminal session, that has to be converted to some kind of byte sequence.  Right now, Konsole simply ignores the Super and Hyper keys, and transmit Hyper-s as just plain "s" (73).  If it instead sent "<Ctrl-X> <at> h s" (18 40 68 73) -- the 18 40 68 prefix representing the Hyper key -- then all current Emacs would handle it already.  However, any reasonable prefix would do.

The sequences that Emacs currently handles are:

"<Ctrl-X> <at> h" (18 40 68) -- Hyper prefix
"<Ctrl-X> <at> s" (18 40 73) -- Super prefix
"<Ctrl-X> <at> a" (18 40 61) -- Alt prefix
"<Ctrl-X> <at> m" (18 40 6d) -- Alt prefix
"<Ctrl-X> <at> c" (18 40 63) -- Ctrl prefix

Out of those, the Alt/Meta prefixes are pretty pointless, since it is long-since standard to instead just transmit ESC (1b) as a prefix for Alt- or Meta-keys.  The Ctrl prefix is potentially useful for combinations where the Ctrl key would normally be meaningless, e.g. Ctrl-6 could be transmitted as "18 40 63 36".

Does this make sense?
Comment 5 Robert Knight 2007-07-10 17:24:19 UTC
Thanks, I think I understand.

At the moment it appears that if I press the Super key ( which is bound to the Windows key here ) then Qt translates that as Meta.  I haven't tried binding something to Hyper yet.

At the moment in KDE 4 only the Alt modifier results in ESC being added as a prefix.  Which means that it is possible to still make use of the Super/Windows key ( which is translated as Meta ).

Qt's list of keyboard modifiers does not include Super or Hyper.  This could be worked around in Konsole, but it would be much better to have it in Qt.  I'll have to find the Troll to talk to.





Comment 6 Jekyll Wu 2012-04-30 03:13:43 UTC
Well, an quite old report :)

If I undertand it correctly, Qt still translates the super key as Qt::Key_Meta(although there are the definitions of Qt::Key_Super_L and Qt::Key_Super_R) and Qt::MetaModifier.

For the hyper key, although Qt detects it as Qt::Key_Hyper_L and Qt::Key_Hyper_R, there is no corresponding Qt::HyperModifier.

So the easy thing to do at the moment is to support the Super key(Qt::Key_Meta), which means adding the prefix "<Ctrl-X> <at> s (18 40 73)".

But I'm not a emacs user, either. If the reporter is still watching this report, you are welcome to try the experimetal code at https://github.com/adaptee/konsole/tree/meta-modifer-prefix and leave your feedback here.
Comment 7 Jekyll Wu 2012-05-03 16:17:20 UTC
Git commit 5ba344714b8da55dfcc84823abac6f059a288386 by Jekyll Wu.
Committed on 24/04/2012 at 08:35.
Pushed by jekyllwu into branch 'master'.

Translate the "Super" modifier into bytes prefix understood by Emacs.

Note: although it is Qt::MetaModifier in the code, the actual pressed
key is the "Super/Windows" key.

M  +6    -0    src/Vt102Emulation.cpp

http://commits.kde.org/konsole/5ba344714b8da55dfcc84823abac6f059a288386
Comment 8 Kurt Hindenburg 2017-02-13 02:51:44 UTC
please open a new report if the below commit didn't accomplish what you wanted.
Comment 9 Sergio 2023-12-29 08:55:59 UTC
Please put this under a configuration option.

There are some cheap laptops and dual-in-one that have weird keyboard/touchpad controllers. These controllers appear to be designed for windows and do gesture control in a particular way, by translating them into key sequences that are "standard" on windows. These keyboard sequences typically involve the windows key (which is left meta on most systems). It is not nice to have this mapped into things that are improperly understood by the shell or by other applications.

Even when not on one of these machines, having this behavior hardwired in the konsole makes for hardly discoverable and confusing behaviors (see https://superuser.com/questions/1238236/super-key-combinations-cause-weird-input-in-konsole).