tty: the switch chord is a setting, because only the host knows the answer
Third guess at a chord, and the third one would have been wrong too: a display
manager that grabs Ctrl+Alt+F<n> matches loosely, so Ctrl+Alt+Shift+F2 never
reaches the guest either. Extra modifiers do not get past a loose grab.
The real problem is that this is not knowable from inside. A key the host
swallowed is indistinguishable from a key nobody pressed, so the guest cannot
probe for a free combination, and there is no combination that is free
everywhere:
the HOST takes Alt+F4, Alt+F2, Ctrl+Alt+F1..F6 (loosely matched),
Ctrl+Alt+digit (QEMU's own console tabs)
APPLICATIONS want Alt+anything (Meta -- zsh binds Meta-digit as
digit-argument), Ctrl+letter, Ctrl+Shift+digit
(Ctrl+Shift+2 types ^@), bare F-keys
the LAYOUT wants AltGr+letter
So it is a setting. VT_SETCHORD/VT_GETCHORD, and in userspace:
chvt -c ctrl+shift+F Ctrl+Shift+F1..F6 (the new default)
chvt -c ctrl+alt+shift+F
chvt -c alt+1
chvt -c off no chord; chvt N is then the only way
chvt report the active terminal and the chord
`off` is a legitimate setting rather than a failure mode. On a machine whose
host grabs everything worth binding, `chvt N` is the honest answer.
The default moved to Ctrl+Shift+F1..F6: display managers bind Ctrl+Alt+F<n>,
not Ctrl+Shift+F<n>, and Ctrl+Shift with a *function* key is not a character
on any layout -- unlike Ctrl+Shift+digit, which is.
Caught while writing it: VTC_RALT was 0x08 while kbd.h's RALT is (1<<7), since
(1<<3) is CAPSLOCK. A chord set from userspace with AltGr would simply never
have matched, and the only symptom would have been a key that does nothing.
A _Static_assert now holds the two headers together.
Verified: Ctrl+Alt+F2 leaves the screen byte-identical, Ctrl+Shift+F2 switches,
Ctrl+Shift+F1 returns to a pixel-identical tty1, and chvt -c round-trips
through alt+1 and off and back. schfs-check passes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2
This commit is contained in:
parent
fe2f5e1bf8
commit
7c0f7c7d01
8 changed files with 256 additions and 60 deletions
|
|
@ -140,6 +140,32 @@ struct rlimit {
|
|||
#define VT_PROCESS 0x01
|
||||
#define VT_ACKACQ 0x02
|
||||
|
||||
// VT_SETCHORD / VT_GETCHORD -- which key combination the kernel switches on.
|
||||
// SchOS's own, not Linux's: Linux hardcodes Ctrl+Alt+F<n> and nobody has ever
|
||||
// needed to move it, because Linux is the host. A guest does need to move it,
|
||||
// because the right answer depends entirely on what the host grabs first --
|
||||
// and that is not something the guest can discover.
|
||||
#define VT_GETCHORD 0x5620
|
||||
#define VT_SETCHORD 0x5621
|
||||
|
||||
// Modifier bits, matched exactly. These mirror kernel/dev/kbd.h's values so
|
||||
// that userspace and the keyboard driver cannot drift apart.
|
||||
#define VTC_SHIFT 0x01 // kbd.h SHIFT (1<<0)
|
||||
#define VTC_CTRL 0x02 // kbd.h CTL (1<<1)
|
||||
#define VTC_ALT 0x04 // kbd.h ALT (1<<2)
|
||||
#define VTC_RALT 0x80 // kbd.h RALT (1<<7) -- NOT (1<<3); that is
|
||||
// CAPSLOCK, and bits 3..6 are the other locks
|
||||
// and the E0 prefix flag
|
||||
|
||||
// Well-known base scancodes for the `base` field below.
|
||||
#define VTC_BASE_F1 0x3B // F1..F6
|
||||
#define VTC_BASE_1 0x02 // the number row, 1..6
|
||||
|
||||
struct vt_chord {
|
||||
uint16 mods; // exactly these modifiers held, and no others
|
||||
uint16 base; // scancode of the key meaning terminal 1
|
||||
};
|
||||
|
||||
struct vt_mode {
|
||||
char mode; // VT_AUTO or VT_PROCESS
|
||||
char waitv; // unused here
|
||||
|
|
|
|||
Loading…
Reference in a new issue