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 /hw/xfree86/common/xf86Events.c | |
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)
Diffstat (limited to 'hw/xfree86/common/xf86Events.c')
-rw-r--r-- | hw/xfree86/common/xf86Events.c | 55 |
1 files changed, 20 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; } |