summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2012-11-16 13:46:32 -0500
committerPeter Hutterer <peter.hutterer@who-t.net>2012-11-19 12:13:39 +1000
commit6f145084d5b9ca4a023dfc538a69bbf30edeac4a (patch)
tree0f769d4c22290d9f960c72b1726fb8fed9eb563a /hw
parent0ff1c77b17062a3a3ff520709ef719316bc1d8bb (diff)
linux: Prefer ioctl(KDSKBMUTE, 1) over ioctl(KDSKBMODE, K_OFF)
K_OFF is a slightly broken interface, since if some other process (cough, systemd) sets the console state to K_UNICODE then it undoes K_OFF, and now Alt-F2 will switch terminals instead of summoning the Gnome "run command" dialog. KDSKBMUTE separates the "don't enqueue events" logic from the keymap, so doesn't have this problem. Try it first, then continue falling back to older methods. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=859485 Tested-by: Josh Boyer <jwboyer@redhat.com> Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'hw')
-rw-r--r--hw/xfree86/os-support/linux/lnx_init.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 68c296b0f..bcb039f3f 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -38,6 +38,14 @@
#include <sys/stat.h>
+#ifndef K_OFF
+#define K_OFF 0x4
+#endif
+
+#ifndef KDSKBMUTE
+#define KDSKBMUTE 0x4B51
+#endif
+
static Bool KeepTty = FALSE;
static int activeVT = -1;
@@ -213,19 +221,23 @@ xf86OpenConsole(void)
tcgetattr(xf86Info.consoleFd, &tty_attr);
SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode));
-#ifdef K_OFF
- /* disable kernel special keys and buffering */
- SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_OFF));
+ /* disable kernel special keys and buffering, new style */
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMUTE, 1));
if (ret < 0)
-#endif
{
- SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
+ /* disable kernel special keys and buffering, old style */
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_OFF));
if (ret < 0)
- FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
- strerror(errno));
-
- /* need to keep the buffer clean, else the kernel gets angry */
- xf86SetConsoleHandler(drain_console, NULL);
+ {
+ /* fine, just disable special keys */
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
+ strerror(errno));
+
+ /* ... and drain events, else the kernel gets angry */
+ xf86SetConsoleHandler(drain_console, NULL);
+ }
}
nTty = tty_attr;
@@ -271,6 +283,7 @@ xf86CloseConsole(void)
xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
strerror(errno));
+ SYSCALL(ioctl(xf86Info.consoleFd, KDSKBMUTE, 0));
SYSCALL(ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode));
tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);