diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-12-15 19:07:38 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2010-01-25 11:10:00 -0800 |
commit | 39ab474197bdad7d8e9ef496df2d61cbea39d370 (patch) | |
tree | 75106951043ea5e25e7fdeb4d17bfc6546bdd388 | |
parent | 15ca3312c069526b7f2207de9dfb9b9e851caf95 (diff) |
Move OS-specific VT key handler code from common to os-support
Adds new function xf86Activate to the OS-specific *VTsw*.c files
and calls it from xf86ProcessActionEvent
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com> (GNU/Linux)
-rw-r--r-- | hw/xfree86/common/xf86Events.c | 55 | ||||
-rw-r--r-- | hw/xfree86/os-support/bsd/bsd_VTsw.c | 9 | ||||
-rw-r--r-- | hw/xfree86/os-support/sco/VTsw_sco.c | 10 | ||||
-rw-r--r-- | hw/xfree86/os-support/shared/VTsw_noop.c | 6 | ||||
-rw-r--r-- | hw/xfree86/os-support/shared/VTsw_usl.c | 11 | ||||
-rw-r--r-- | hw/xfree86/os-support/solaris/sun_VTsw.c | 17 | ||||
-rw-r--r-- | hw/xfree86/os-support/xf86_OSproc.h | 1 |
7 files changed, 74 insertions, 35 deletions
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 8e6a15be8..ebf03bfe7 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -194,55 +194,40 @@ xf86ProcessActionEvent(ActionEvent action, void *arg) if (!xf86Info.dontZoom) xf86ZoomViewport(xf86Info.currentScreen, -1); break; -#if defined(VT_ACTIVATE) case ACTION_SWITCHSCREEN: if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) { int vtno = *((int *) arg); -#if defined(__SCO__) || defined(__UNIXWARE__) - vtno--; -#endif -#if defined(sun) - if (vtno == xf86Info.vtno) { - break; - } else { - struct vt_stat state; - if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &state) < 0) - break; - - if ((state.v_state & (1 << vtno)) == 0) - break; - } - xf86Info.vtRequestsPending = TRUE; - xf86Info.vtPendingNum = vtno; -#else - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0) - ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); -#endif + if (vtno != xf86Info.vtno) { + if (!xf86VTActivate(vtno)) { + ErrorF("Failed to switch from vt%02d to vt%02d: %s\n", + xf86Info.vtno, vtno, strerror(errno)); + } + } } break; case ACTION_SWITCHSCREEN_NEXT: if (VTSwitchEnabled && !xf86Info.dontVTSwitch) { -#if defined(__SCO__) || defined(__UNIXWARE__) - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0) -#else - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno + 1) < 0) -#endif -#if defined (__SCO__) || (defined(sun) && defined (__i386__) && defined (SVR4)) || defined(__UNIXWARE__) - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0) < 0) -#else - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) < 0) -#endif - ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); + if (!xf86VTActivate(xf86Info.vtno + 1)) { + /* If first try failed, assume this is the last VT and + * try wrapping around to the first vt. + */ + if (!xf86VTActivate(1)) { + ErrorF("Failed to switch from vt%02d to next vt: %s\n", + xf86Info.vtno, strerror(errno)); + } + } } break; case ACTION_SWITCHSCREEN_PREV: if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) { - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno - 1) < 0) - ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); + if (!xf86VTActivate(xf86Info.vtno - 1)) { + /* Don't know what the maximum VT is, so can't wrap around */ + ErrorF("Failed to switch from vt%02d to previous vt: %s\n", + xf86Info.vtno, strerror(errno)); + } } break; -#endif default: break; } diff --git a/hw/xfree86/os-support/bsd/bsd_VTsw.c b/hw/xfree86/os-support/bsd/bsd_VTsw.c index 476a0e957..4842be5c9 100644 --- a/hw/xfree86/os-support/bsd/bsd_VTsw.c +++ b/hw/xfree86/os-support/bsd/bsd_VTsw.c @@ -92,3 +92,12 @@ xf86VTSwitchTo() #endif return(TRUE); } + +Bool +xf86VTActivate(int vtno) +{ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0) { + return(FALSE); + } + return(TRUE); +} diff --git a/hw/xfree86/os-support/sco/VTsw_sco.c b/hw/xfree86/os-support/sco/VTsw_sco.c index d126e7869..0a59fb965 100644 --- a/hw/xfree86/os-support/sco/VTsw_sco.c +++ b/hw/xfree86/os-support/sco/VTsw_sco.c @@ -115,3 +115,13 @@ xf86VTSwitchTo(void) return TRUE; } } + +Bool +xf86VTActivate(int vtno) +{ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno - 1) < 0) { + return(FALSE); + } + + return(TRUE); +} diff --git a/hw/xfree86/os-support/shared/VTsw_noop.c b/hw/xfree86/os-support/shared/VTsw_noop.c index 78cbe0e34..3425840a2 100644 --- a/hw/xfree86/os-support/shared/VTsw_noop.c +++ b/hw/xfree86/os-support/shared/VTsw_noop.c @@ -52,3 +52,9 @@ xf86VTSwitchTo(void) { return(TRUE); } + +Bool +xf86VTActivate(int vtno) +{ + return(TRUE); +} diff --git a/hw/xfree86/os-support/shared/VTsw_usl.c b/hw/xfree86/os-support/shared/VTsw_usl.c index 9308640e2..393f1c0b9 100644 --- a/hw/xfree86/os-support/shared/VTsw_usl.c +++ b/hw/xfree86/os-support/shared/VTsw_usl.c @@ -88,3 +88,14 @@ xf86VTSwitchTo(void) return(TRUE); } } + +Bool +xf86VTActivate(int vtno) +{ +#ifdef VT_ACTIVATE + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0) { + return(FALSE); + } +#endif + return(TRUE); +} diff --git a/hw/xfree86/os-support/solaris/sun_VTsw.c b/hw/xfree86/os-support/solaris/sun_VTsw.c index 7f4e08e1e..1e2774b11 100644 --- a/hw/xfree86/os-support/solaris/sun_VTsw.c +++ b/hw/xfree86/os-support/solaris/sun_VTsw.c @@ -118,3 +118,20 @@ xf86VTSwitchTo(void) return(TRUE); } } + +Bool +xf86VTActivate(int vtno) +{ + struct vt_stat state; + + if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &state) < 0) + return(FALSE); + + if ((state.v_state & (1 << vtno)) == 0) + return(FALSE); + + xf86Info.vtRequestsPending = TRUE; + xf86Info.vtPendingNum = vtno; + + return(TRUE); +} diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h index c1a117334..f0cb768be 100644 --- a/hw/xfree86/os-support/xf86_OSproc.h +++ b/hw/xfree86/os-support/xf86_OSproc.h @@ -199,6 +199,7 @@ extern _X_EXPORT Bool xf86SIGIOSupported (void); typedef void (*PMClose)(void); extern _X_EXPORT void xf86OpenConsole(void); extern _X_EXPORT void xf86CloseConsole(void); +extern _X_HIDDEN Bool xf86VTActivate(int vtno); extern _X_EXPORT Bool xf86VTSwitchPending(void); extern _X_EXPORT Bool xf86VTSwitchAway(void); extern _X_EXPORT Bool xf86VTSwitchTo(void); |