3 # Patch managed by http://www.holgerschurig.de/patcher.html
6 --- qt-2.3.9-snapshot-20041221/src/kernel/qapplication_qws.cpp~vt-switch.patch
7 +++ qt-2.3.9-snapshot-20041221/src/kernel/qapplication_qws.cpp
9 static int qt_thread_pipe[2];
12 +#if defined(_OS_LINUX_)
13 +#include <sys/ioctl.h>
14 +#include <linux/vt.h>
15 +#include <linux/kd.h>
18 const int qwsSharedRamSize = 32 * 1024; //Small amount to fit on small devices.
20 // These are in qapplication.cpp in qt/main
22 bool qws_accel = TRUE; // ### never set
23 const char *qws_display_spec = ":0";
24 int qws_display_id = 0;
25 +int qws_terminal_id = 0;
26 +int qws_terminal_old = 0;
27 int qws_client_id = 0;
28 QWidget *qt_pressGrab = 0;
29 QWidget *qt_mouseGrb = 0;
30 @@ -1700,6 +1708,15 @@
31 type = QApplication::GuiServer;
32 } else if ( arg == "-interlaced" ) {
33 qws_screen_is_interlaced = TRUE;
34 + } else if ( arg == "-terminal" ) {
37 + if ( ( qws_terminal_id = atoi( argv[i] ) ) < 1 )
39 + qWarning( "Ignoring Invalid Terminal Specification." );
40 + qws_terminal_id = 0;
43 } else if ( arg == "-display" ) {
45 qws_display_spec = argv[i];
46 @@ -1724,6 +1741,53 @@
47 if ( type == QApplication::GuiServer ) {
49 qws_single_process = TRUE;
51 + /* Allocate a dedicated virtual terminal -- (C) Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
52 + * Added a new command line option which only is relevant if the application is created as a GuiServer.
53 + * The option is -terminal <num>, where <num> specifies the virtual terminal to be occupied by the server.
54 + * As default in Linux, 0 means the current virtual terminal.
56 + #if defined(_OS_LINUX_)
57 + if ( qws_terminal_id )
59 + qDebug( "qt_init() - terminal specification is '%d'.", qws_terminal_id );
60 + struct vt_stat console_stat;
61 + int console_fd = ::open( QString().sprintf( "/dev/tty%d", qws_terminal_id ).latin1(), O_RDWR );
62 + if ( console_fd == -1)
64 + qWarning( "qt_init() - can't open tty: %s", strerror( errno ) );
67 + if ( ioctl( console_fd, VT_GETSTATE, &console_stat ) == -1 )
69 + qWarning( "qt_init() - can't ioctl(VT_GETSTATE): %s", strerror( errno ) );
72 + qws_terminal_old = console_stat.v_active;
73 + qDebug( "qt_init() - active vt is #%d, switching to #%d as requested...", qws_terminal_old, qws_terminal_id );
75 + if ( ioctl( console_fd, VT_ACTIVATE, qws_terminal_id ) == -1 )
77 + qWarning( "qt_init() - can't ioctl(VT_ACTIVATE): %s", strerror( errno ) );
80 + if ( ioctl( console_fd, VT_WAITACTIVE, qws_terminal_id ) == -1 )
82 + qWarning( "qt_init() - can't ioctl(VT_WAITACTIVE): %s", strerror( errno ) );
85 + if ( ioctl( console_fd, KDSETMODE, KD_GRAPHICS ) == -1 )
87 + qWarning( "qt_init() - can't ioctl(KDSETMODE:KD_GRAPHICS): %s", strerror( errno ) );
90 + ::close( console_fd );
94 + qDebug( "QWSApplication::qt_init() - current terminal specified." );
97 QWSServer::startup(flags);
98 setenv("QWS_DISPLAY", qws_display_spec, 0);
100 @@ -1774,7 +1838,36 @@
101 QFontManager::cleanup();
103 if ( qws_single_process ) {
104 - QWSServer::closedown();
105 + qDebug( "qt_cleanup() - shutting down QWSServer..." );
106 +#ifndef QT_NO_QWS_KEYBOARD
108 + qwsServer->closeKeyboard();
110 + QWSServer::closedown();
111 +#if defined(_OS_LINUX_)
112 + if ( qws_terminal_old > 0 )
114 + qDebug( "qt_cleanup() - switching back to virtual terminal #%d", qws_terminal_old );
116 + int console_fd = ::open( "/dev/tty0", O_RDWR );
117 + if ( console_fd == -1)
119 + qWarning( "qt_init() - can't open tty: %s", strerror( errno ) );
123 + if ( ioctl( console_fd, KDSETMODE, KD_TEXT ) == -1 )
125 + qWarning( "qt_init() - can't ioctl(KDSETMODE:KD_TEXT): %s", strerror( errno ) );
127 + if ( ioctl( console_fd, VT_ACTIVATE, qws_terminal_old ) == -1 )
129 + qWarning( "qt_init() - can't ioctl(VT_ACTIVATE): %s", strerror( errno ) );
131 + ::close( console_fd );
136 if ( qt_is_gui_used ) {
138 --- qt-2.3.9-snapshot-20041221/src/kernel/qkeyboard_qws.cpp~vt-switch.patch
139 +++ qt-2.3.9-snapshot-20041221/src/kernel/qkeyboard_qws.cpp
140 @@ -1247,6 +1247,24 @@
145 +#if !defined(_OS_FREEBSD_) && !defined(_OS_SOLARIS_)
146 + struct vt_mode vtMode;
147 + ioctl(kbdFD, VT_GETMODE, &vtMode);
149 + /* Mickey says: "Better give up control of VT switching.
150 + * Hey, I really hate that OS-will-reacquire-resources on process-death
151 + * kind of thinking!
153 + vtMode.mode = VT_AUTO;
156 + ioctl(kbdFD, VT_SETMODE, &vtMode);
158 + signal(VTSWITCHSIG, 0);
159 + qDebug( "~QWSTtyKeyboardHandler() - released VT." );
162 #if !defined(_OS_FREEBSD_) && !defined(_OS_SOLARIS_)
163 ioctl(kbdFD, KDSKBMODE, K_XLATE);
165 --- qt-2.3.9-snapshot-20041221/src/kernel/qgfxlinuxfb_qws.cpp~vt-switch.patch
166 +++ qt-2.3.9-snapshot-20041221/src/kernel/qgfxlinuxfb_qws.cpp
169 bool QLinuxFbScreen::initDevice()
171 - // No blankin' screen, no blinkin' cursor!, no cursor!
172 + /* Setting up the VT parameters is done in qapplication_qws.cpp
173 const char termctl[]="\033[9;0]\033[?33l\033[?25l";
174 - writeTerm(termctl,sizeof(termctl));
175 + writeTerm(termctl,sizeof(termctl)); */
177 // Grab current mode so we can reset it
178 fb_var_screeninfo vinfo;