author | llornkcor <llornkcor> | 2002-06-23 20:19:27 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-06-23 20:19:27 (UTC) |
commit | e611ad323de0bc155d52704545378c948bdbadfa (patch) (unidiff) | |
tree | 1f7e109526722dda80261a9ec1bfe79926f1389f | |
parent | 7b861d2f14bdb50558863354522dee7c7a9ef34d (diff) | |
download | opie-e611ad323de0bc155d52704545378c948bdbadfa.zip opie-e611ad323de0bc155d52704545378c948bdbadfa.tar.gz opie-e611ad323de0bc155d52704545378c948bdbadfa.tar.bz2 |
fix for keyboard handling under certain conditions, like when grabkeyboard is requested by a user app, so apps such as konsole will have proper keyboard input.
-rw-r--r-- | core/launcher/desktop.cpp | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 7662e48..24dce73 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -149,104 +149,110 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | |||
149 | ps = new PowerStatus; | 149 | ps = new PowerStatus; |
150 | pa = new DesktopPowerAlerter( 0 ); | 150 | pa = new DesktopPowerAlerter( 0 ); |
151 | 151 | ||
152 | channel = new QCopChannel( "QPE/Desktop", this ); | 152 | channel = new QCopChannel( "QPE/Desktop", this ); |
153 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 153 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
154 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 154 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
155 | } | 155 | } |
156 | 156 | ||
157 | 157 | ||
158 | DesktopApplication::~DesktopApplication() | 158 | DesktopApplication::~DesktopApplication() |
159 | { | 159 | { |
160 | delete ps; | 160 | delete ps; |
161 | delete pa; | 161 | delete pa; |
162 | } | 162 | } |
163 | 163 | ||
164 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | 164 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) |
165 | { | 165 | { |
166 | QDataStream stream( data, IO_ReadOnly ); | 166 | QDataStream stream( data, IO_ReadOnly ); |
167 | if (msg == "keyRegister(int key, QString channel, QString message)") | 167 | if (msg == "keyRegister(int key, QString channel, QString message)") |
168 | { | 168 | { |
169 | int k; | 169 | int k; |
170 | QString c, m; | 170 | QString c, m; |
171 | stream >> k; | 171 | stream >> k; |
172 | stream >> c; | 172 | stream >> c; |
173 | stream >> m; | 173 | stream >> m; |
174 | 174 | ||
175 | qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); | 175 | qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); |
176 | keyRegisterList.append(QCopKeyRegister(k,c,m)); | 176 | keyRegisterList.append(QCopKeyRegister(k,c,m)); |
177 | } | 177 | } |
178 | else if (msg == "suspend()"){ | 178 | else if (msg == "suspend()"){ |
179 | emit power(); | 179 | emit power(); |
180 | } | 180 | } |
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; | 184 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; |
185 | 185 | ||
186 | #ifdef Q_WS_QWS | 186 | #ifdef Q_WS_QWS |
187 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 187 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
188 | { | 188 | { |
189 | qpedesktop->checkMemory(); | 189 | qpedesktop->checkMemory(); |
190 | 190 | ||
191 | if ( e->type == QWSEvent::Key ) { | 191 | if ( e->type == QWSEvent::Key ) { |
192 | QWSKeyEvent *ke = (QWSKeyEvent *)e; | 192 | QWSKeyEvent *ke = (QWSKeyEvent *)e; |
193 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 193 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
194 | return TRUE; | 194 | return TRUE; |
195 | bool press = ke->simpleData.is_press; | 195 | bool press = ke->simpleData.is_press; |
196 | bool autoRepeat= ke->simpleData.is_auto_repeat; | 196 | bool autoRepeat= ke->simpleData.is_auto_repeat; |
197 | if (!keyRegisterList.isEmpty()) | 197 | |
198 | { | 198 | /* |
199 | app that registers key/message to be sent back to the app, when it doesn't have focus, | ||
200 | when user presses key, unless keyboard has been requested from app. | ||
201 | will not send multiple repeats if user holds key | ||
202 | i.e. one shot | ||
203 | |||
204 | */ | ||
205 | if (!keyRegisterList.isEmpty()) { | ||
199 | KeyRegisterList::Iterator it; | 206 | KeyRegisterList::Iterator it; |
200 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) | 207 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
201 | { | 208 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed()) { |
202 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) { | 209 | if(press) qDebug("press"); else qDebug("release"); |
203 | if(press) qDebug("press"); else qDebug("release"); | 210 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); |
204 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | ||
205 | } | 211 | } |
206 | } | 212 | } |
207 | } | 213 | } |
208 | 214 | ||
209 | if ( !keyboardGrabbed() ) { | 215 | if ( !keyboardGrabbed() ) { |
210 | if ( ke->simpleData.keycode == Key_F9 ) { | 216 | if ( ke->simpleData.keycode == Key_F9 ) { |
211 | if ( press ) emit datebook(); | 217 | if ( press ) emit datebook(); |
212 | return TRUE; | 218 | return TRUE; |
213 | } | 219 | } |
214 | if ( ke->simpleData.keycode == Key_F10 ) { | 220 | if ( ke->simpleData.keycode == Key_F10 ) { |
215 | if ( !press && cardSendTimer ) { | 221 | if ( !press && cardSendTimer ) { |
216 | emit contacts(); | 222 | emit contacts(); |
217 | delete cardSendTimer; | 223 | delete cardSendTimer; |
218 | } else if ( press ) { | 224 | } else if ( press ) { |
219 | cardSendTimer = new QTimer(); | 225 | cardSendTimer = new QTimer(); |
220 | cardSendTimer->start( 2000, TRUE ); | 226 | cardSendTimer->start( 2000, TRUE ); |
221 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 227 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
222 | } | 228 | } |
223 | return TRUE; | 229 | return TRUE; |
224 | } | 230 | } |
225 | /* menu key now opens application menu/toolbar | 231 | /* menu key now opens application menu/toolbar |
226 | if ( ke->simpleData.keycode == Key_F11 ) { | 232 | if ( ke->simpleData.keycode == Key_F11 ) { |
227 | if ( press ) emit menu(); | 233 | if ( press ) emit menu(); |
228 | return TRUE; | 234 | return TRUE; |
229 | } | 235 | } |
230 | */ | 236 | */ |
231 | if ( ke->simpleData.keycode == Key_F12 ) { | 237 | if ( ke->simpleData.keycode == Key_F12 ) { |
232 | while( activePopupWidget() ) | 238 | while( activePopupWidget() ) |
233 | activePopupWidget()->close(); | 239 | activePopupWidget()->close(); |
234 | if ( press ) emit launch(); | 240 | if ( press ) emit launch(); |
235 | return TRUE; | 241 | return TRUE; |
236 | } | 242 | } |
237 | if ( ke->simpleData.keycode == Key_F13 ) { | 243 | if ( ke->simpleData.keycode == Key_F13 ) { |
238 | if ( press ) emit email(); | 244 | if ( press ) emit email(); |
239 | return TRUE; | 245 | return TRUE; |
240 | } | 246 | } |
241 | } | 247 | } |
242 | 248 | ||
243 | if ( ke->simpleData.keycode == Key_F34 ) { | 249 | if ( ke->simpleData.keycode == Key_F34 ) { |
244 | if ( press ) emit power(); | 250 | if ( press ) emit power(); |
245 | return TRUE; | 251 | return TRUE; |
246 | } | 252 | } |
247 | // This was used for the iPAQ PowerButton | 253 | // This was used for the iPAQ PowerButton |
248 | // See main.cpp for new KeyboardFilter | 254 | // See main.cpp for new KeyboardFilter |
249 | // | 255 | // |
250 | // if ( ke->simpleData.keycode == Key_SysReq ) { | 256 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
251 | // if ( press ) emit power(); | 257 | // if ( press ) emit power(); |
252 | // return TRUE; | 258 | // return TRUE; |
@@ -705,80 +711,80 @@ void DesktopApplication::restart() | |||
705 | 711 | ||
706 | void Desktop::startTransferServer() | 712 | void Desktop::startTransferServer() |
707 | { | 713 | { |
708 | // start qcop bridge server | 714 | // start qcop bridge server |
709 | qcopBridge = new QCopBridge( 4243 ); | 715 | qcopBridge = new QCopBridge( 4243 ); |
710 | if ( !qcopBridge->ok() ) { | 716 | if ( !qcopBridge->ok() ) { |
711 | delete qcopBridge; | 717 | delete qcopBridge; |
712 | qcopBridge = 0; | 718 | qcopBridge = 0; |
713 | } | 719 | } |
714 | // start transfer server | 720 | // start transfer server |
715 | transferServer = new TransferServer( 4242 ); | 721 | transferServer = new TransferServer( 4242 ); |
716 | if ( !transferServer->ok() ) { | 722 | if ( !transferServer->ok() ) { |
717 | delete transferServer; | 723 | delete transferServer; |
718 | transferServer = 0; | 724 | transferServer = 0; |
719 | } | 725 | } |
720 | if ( !transferServer || !qcopBridge ) | 726 | if ( !transferServer || !qcopBridge ) |
721 | startTimer( 2000 ); | 727 | startTimer( 2000 ); |
722 | } | 728 | } |
723 | 729 | ||
724 | void Desktop::timerEvent( QTimerEvent *e ) | 730 | void Desktop::timerEvent( QTimerEvent *e ) |
725 | { | 731 | { |
726 | killTimer( e->timerId() ); | 732 | killTimer( e->timerId() ); |
727 | startTransferServer(); | 733 | startTransferServer(); |
728 | } | 734 | } |
729 | 735 | ||
730 | void Desktop::terminateServers() | 736 | void Desktop::terminateServers() |
731 | { | 737 | { |
732 | delete transferServer; | 738 | delete transferServer; |
733 | delete qcopBridge; | 739 | delete qcopBridge; |
734 | transferServer = 0; | 740 | transferServer = 0; |
735 | qcopBridge = 0; | 741 | qcopBridge = 0; |
736 | } | 742 | } |
737 | 743 | ||
738 | void Desktop::rereadVolumes() | 744 | void Desktop::rereadVolumes() |
739 | { | 745 | { |
740 | Config cfg("qpe"); | 746 | Config cfg("qpe"); |
741 | cfg.setGroup("Volume"); | 747 | cfg.setGroup("Volume"); |
742 | touchclick = cfg.readBoolEntry("TouchSound"); | 748 | touchclick = cfg.readBoolEntry("TouchSound"); |
743 | keyclick = cfg.readBoolEntry("KeySound"); | 749 | keyclick = cfg.readBoolEntry("KeySound"); |
744 | alarmsound = cfg.readBoolEntry("AlarmSound"); | 750 | alarmsound = cfg.readBoolEntry("AlarmSound"); |
745 | // Config cfg("Sound"); | 751 | // Config cfg("Sound"); |
746 | // cfg.setGroup("System"); | 752 | // cfg.setGroup("System"); |
747 | // touchclick = cfg.readBoolEntry("Touch"); | 753 | // touchclick = cfg.readBoolEntry("Touch"); |
748 | // keyclick = cfg.readBoolEntry("Key"); | 754 | // keyclick = cfg.readBoolEntry("Key"); |
749 | } | 755 | } |
750 | 756 | ||
751 | void Desktop::keyClick() | 757 | void Desktop::keyClick() |
752 | { | 758 | { |
753 | if ( keyclick ) | 759 | if ( keyclick ) |
754 | ODevice::inst ( )-> keySound ( ); | 760 | ODevice::inst ( )-> keySound ( ); |
755 | } | 761 | } |
756 | 762 | ||
757 | void Desktop::screenClick() | 763 | void Desktop::screenClick() |
758 | { | 764 | { |
759 | if ( touchclick ) | 765 | if ( touchclick ) |
760 | ODevice::inst ( )-> touchSound ( ); | 766 | ODevice::inst ( )-> touchSound ( ); |
761 | } | 767 | } |
762 | 768 | ||
763 | void Desktop::soundAlarm() | 769 | void Desktop::soundAlarm() |
764 | { | 770 | { |
765 | if ( qpedesktop-> alarmsound ) | 771 | if ( qpedesktop-> alarmsound ) |
766 | ODevice::inst ( )-> alarmSound ( ); | 772 | ODevice::inst ( )-> alarmSound ( ); |
767 | } | 773 | } |
768 | 774 | ||
769 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | 775 | bool Desktop::eventFilter( QObject *, QEvent *ev ) |
770 | { | 776 | { |
771 | if ( ev-> type ( ) == QEvent::KeyPress ) { | 777 | if ( ev-> type ( ) == QEvent::KeyPress ) { |
772 | QKeyEvent *ke = (QKeyEvent *) ev; | 778 | QKeyEvent *ke = (QKeyEvent *) ev; |
773 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key | 779 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key |
774 | QWidget *active = qApp-> activeWindow ( ); | 780 | QWidget *active = qApp-> activeWindow ( ); |
775 | 781 | ||
776 | if ( active && active-> isPopup ( )) | 782 | if ( active && active-> isPopup ( )) |
777 | active->close(); | 783 | active->close(); |
778 | 784 | ||
779 | raiseMenu ( ); | 785 | raiseMenu ( ); |
780 | return true; | 786 | return true; |
781 | } | 787 | } |
782 | } | 788 | } |
783 | return false; | 789 | return false; |
784 | } | 790 | } |