author | sandman <sandman> | 2002-09-06 19:31:52 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-06 19:31:52 (UTC) |
commit | c9f7e21a3897b4a02c6eb460286eacbfafbba06f (patch) (unidiff) | |
tree | 9fa814c402f35184f029cf4de3e0b69e5c58c958 /core/launcher/desktop.cpp | |
parent | 088a233d52f2b06b6f478e73776eb2b430b2a1a5 (diff) | |
download | opie-c9f7e21a3897b4a02c6eb460286eacbfafbba06f.zip opie-c9f7e21a3897b4a02c6eb460286eacbfafbba06f.tar.gz opie-c9f7e21a3897b4a02c6eb460286eacbfafbba06f.tar.bz2 |
Last part of the LCD control changes:
- Added the screen-saver part of libqpe to the DesktopApplication object
- Cleaned up the remaining mess
- reformated with astyle
-rw-r--r-- | core/launcher/desktop.cpp | 332 |
1 files changed, 276 insertions, 56 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index dee5535..a19e4c6 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <qpe/power.h> | 37 | #include <qpe/power.h> |
38 | #include <qpe/timeconversion.h> | 38 | #include <qpe/timeconversion.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/network.h> | ||
40 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
41 | 42 | ||
42 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 43 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
@@ -55,17 +56,29 @@ | |||
55 | 56 | ||
56 | #include <stdlib.h> | 57 | #include <stdlib.h> |
57 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #include <fcntl.h> | ||
58 | 60 | ||
59 | class QCopKeyRegister | 61 | class QCopKeyRegister |
60 | { | 62 | { |
61 | public: | 63 | public: |
62 | QCopKeyRegister() : keyCode(0) { } | 64 | QCopKeyRegister() : keyCode( 0 ) |
65 | { } | ||
63 | QCopKeyRegister(int k, const QString &c, const QString &m) | 66 | QCopKeyRegister(int k, const QString &c, const QString &m) |
64 | : keyCode(k), channel(c), message(m) { } | 67 | : keyCode( k ), channel( c ), message( m ) |
68 | { } | ||
65 | 69 | ||
66 | int getKeyCode() const { return keyCode; } | 70 | int getKeyCode() const |
67 | QString getChannel() const { return channel; } | 71 | { |
68 | QString getMessage() const { return message; } | 72 | return keyCode; |
73 | } | ||
74 | QString getChannel() const | ||
75 | { | ||
76 | return channel; | ||
77 | } | ||
78 | QString getMessage() const | ||
79 | { | ||
80 | return message; | ||
81 | } | ||
69 | 82 | ||
70 | private: | 83 | private: |
71 | int keyCode; | 84 | int keyCode; |
@@ -138,6 +151,179 @@ void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | |||
138 | } | 151 | } |
139 | 152 | ||
140 | 153 | ||
154 | class QPEScreenSaver : public QWSScreenSaver | ||
155 | { | ||
156 | private: | ||
157 | int LcdOn; | ||
158 | |||
159 | public: | ||
160 | QPEScreenSaver() | ||
161 | { | ||
162 | m_disable_suspend = 100; | ||
163 | m_enable_dim = false; | ||
164 | m_enable_lightoff = false; | ||
165 | m_enable_onlylcdoff = false; | ||
166 | |||
167 | m_lcd_status = true; | ||
168 | |||
169 | m_backlight_bright = -1; | ||
170 | m_backlight_forcedoff = false; | ||
171 | |||
172 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | ||
173 | ODevice::inst ( ) -> setDisplayStatus ( true ); | ||
174 | } | ||
175 | void restore() | ||
176 | { | ||
177 | if ( !m_lcd_status ) // We must have turned it off | ||
178 | ODevice::inst ( ) -> setDisplayStatus ( true ); | ||
179 | |||
180 | setBacklight ( -1 ); | ||
181 | } | ||
182 | bool save( int level ) | ||
183 | { | ||
184 | switch ( level ) { | ||
185 | case 0: | ||
186 | if ( m_disable_suspend > 0 && m_enable_dim ) { | ||
187 | if ( backlight() > 1 ) | ||
188 | setBacklight( 1 ); // lowest non-off | ||
189 | } | ||
190 | return true; | ||
191 | break; | ||
192 | case 1: | ||
193 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { | ||
194 | setBacklight( 0 ); // off | ||
195 | } | ||
196 | return true; | ||
197 | break; | ||
198 | case 2: | ||
199 | if ( m_enable_onlylcdoff ) { | ||
200 | ODevice::inst ( ) -> setDisplayStatus ( false ); | ||
201 | m_lcd_status = false; | ||
202 | return true; | ||
203 | } | ||
204 | else // We're going to suspend the whole machine | ||
205 | { | ||
206 | if ( ( m_disable_suspend > 2 ) && | ||
207 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && | ||
208 | ( !Network::networkOnline ( ) ) ) { | ||
209 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | ||
210 | return true; | ||
211 | } | ||
212 | } | ||
213 | break; | ||
214 | } | ||
215 | return false; | ||
216 | } | ||
217 | |||
218 | private: | ||
219 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) | ||
220 | { | ||
221 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) | ||
222 | return 0; | ||
223 | |||
224 | if ( interval < 0 ) { | ||
225 | // Restore screen blanking and power saving state | ||
226 | interval = config.readNumEntry( value, def ); | ||
227 | } | ||
228 | return interval; | ||
229 | } | ||
230 | |||
231 | public: | ||
232 | void setIntervals( int i1, int i2, int i3 ) | ||
233 | { | ||
234 | Config config( "qpe" ); | ||
235 | config.setGroup( "Screensaver" ); | ||
236 | |||
237 | int v[ 4 ]; | ||
238 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); | ||
239 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); | ||
240 | i3 = ssi( i3, config, "", "Interval", 60 ); | ||
241 | |||
242 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | ||
243 | |||
244 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | ||
245 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | ||
246 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | ||
247 | v [ 3 ] = 0; | ||
248 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); | ||
249 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); | ||
250 | m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); | ||
251 | |||
252 | if ( !i1 && !i2 && !i3 ) | ||
253 | QWSServer::setScreenSaverInterval( 0 ); | ||
254 | else | ||
255 | QWSServer::setScreenSaverIntervals( v ); | ||
256 | } | ||
257 | |||
258 | void setInterval ( int interval ) | ||
259 | { | ||
260 | setIntervals ( -1, -1, interval ); | ||
261 | } | ||
262 | |||
263 | void setMode ( int mode ) | ||
264 | { | ||
265 | if ( mode > m_disable_suspend ) | ||
266 | setInterval( -1 ); | ||
267 | m_disable_suspend = mode; | ||
268 | } | ||
269 | |||
270 | int backlight ( ) | ||
271 | { | ||
272 | if ( m_backlight_bright == -1 ) { | ||
273 | // Read from config | ||
274 | Config config ( "qpe" ); | ||
275 | config. setGroup ( "Screensaver" ); | ||
276 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); | ||
277 | } | ||
278 | return m_backlight_bright; | ||
279 | } | ||
280 | |||
281 | void setBacklight ( int bright ) | ||
282 | { | ||
283 | if ( bright == -3 ) { | ||
284 | // Forced on | ||
285 | m_backlight_forcedoff = false; | ||
286 | bright = -1; | ||
287 | } | ||
288 | if ( m_backlight_forcedoff && bright != -2 ) | ||
289 | return ; | ||
290 | if ( bright == -2 ) { | ||
291 | // Toggle between off and on | ||
292 | bright = m_backlight_bright ? 0 : -1; | ||
293 | m_backlight_forcedoff = !bright; | ||
294 | } | ||
295 | |||
296 | m_backlight_bright = bright; | ||
297 | |||
298 | bright = backlight ( ); | ||
299 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | ||
300 | |||
301 | m_backlight_bright = bright; | ||
302 | } | ||
303 | |||
304 | private: | ||
305 | int m_disable_suspend; | ||
306 | bool m_enable_dim; | ||
307 | bool m_enable_lightoff; | ||
308 | bool m_enable_onlylcdoff; | ||
309 | |||
310 | bool m_lcd_status; | ||
311 | |||
312 | int m_backlight_bright; | ||
313 | bool m_backlight_forcedoff; | ||
314 | }; | ||
315 | |||
316 | |||
317 | void DesktopApplication::switchLCD ( bool on ) | ||
318 | { | ||
319 | if ( qApp ) { | ||
320 | DesktopApplication *dapp = (DesktopApplication *) qApp; | ||
321 | |||
322 | if ( dapp-> m_screensaver ) | ||
323 | dapp-> m_screensaver-> setBacklight ( on ? -3 : -1 ); | ||
324 | } | ||
325 | } | ||
326 | |||
141 | 327 | ||
142 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 328 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
143 | : QPEApplication( argc, argv, appType ) | 329 | : QPEApplication( argc, argv, appType ) |
@@ -151,7 +337,16 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | |||
151 | 337 | ||
152 | channel = new QCopChannel( "QPE/Desktop", this ); | 338 | channel = new QCopChannel( "QPE/Desktop", this ); |
153 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 339 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
154 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 340 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); |
341 | |||
342 | channel = new QCopChannel( "QPE/System", this ); | ||
343 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | ||
344 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | ||
345 | |||
346 | m_screensaver = new QPEScreenSaver; | ||
347 | |||
348 | m_screensaver-> setInterval ( -1 ); | ||
349 | QWSServer::setScreenSaver( m_screensaver ); | ||
155 | } | 350 | } |
156 | 351 | ||
157 | 352 | ||
@@ -161,11 +356,11 @@ DesktopApplication::~DesktopApplication() | |||
161 | delete pa; | 356 | delete pa; |
162 | } | 357 | } |
163 | 358 | ||
164 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | 359 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
165 | { | 360 | { |
361 | #ifdef Q_WS_QWS | ||
166 | QDataStream stream( data, IO_ReadOnly ); | 362 | QDataStream stream( data, IO_ReadOnly ); |
167 | if (msg == "keyRegister(int key, QString channel, QString message)") | 363 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
168 | { | ||
169 | int k; | 364 | int k; |
170 | QString c, m; | 365 | QString c, m; |
171 | stream >> k; | 366 | stream >> k; |
@@ -178,7 +373,36 @@ void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | |||
178 | else if (msg == "suspend()"){ | 373 | else if (msg == "suspend()"){ |
179 | emit power(); | 374 | emit power(); |
180 | } | 375 | } |
376 | #endif | ||
377 | } | ||
378 | |||
181 | 379 | ||
380 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | ||
381 | { | ||
382 | #ifdef Q_WS_QWS | ||
383 | QDataStream stream ( data, IO_ReadOnly ); | ||
384 | |||
385 | if ( msg == "setScreenSaverInterval(int)" ) { | ||
386 | int time; | ||
387 | stream >> time; | ||
388 | m_screensaver-> setInterval( time ); | ||
389 | } | ||
390 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | ||
391 | int t1, t2, t3; | ||
392 | stream >> t1 >> t2 >> t3; | ||
393 | m_screensaver-> setIntervals( t1, t2, t3 ); | ||
394 | } | ||
395 | else if ( msg == "setBacklight(int)" ) { | ||
396 | int bright; | ||
397 | stream >> bright; | ||
398 | m_screensaver-> setBacklight( bright ); | ||
399 | } | ||
400 | else if ( msg == "setScreenSaverMode(int)" ) { | ||
401 | int mode; | ||
402 | stream >> mode; | ||
403 | m_screensaver-> setMode ( mode ); | ||
404 | } | ||
405 | #endif | ||
182 | } | 406 | } |
183 | 407 | ||
184 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; | 408 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; |
@@ -205,7 +429,10 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
205 | KeyRegisterList::Iterator it; | 429 | KeyRegisterList::Iterator it; |
206 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 430 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
207 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { | 431 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { |
208 | if(press) qDebug("press"); else qDebug("release"); | 432 | if ( press ) |
433 | qDebug( "press" ); | ||
434 | else | ||
435 | qDebug( "release" ); | ||
209 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | 436 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); |
210 | } | 437 | } |
211 | } | 438 | } |
@@ -213,14 +440,16 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
213 | 440 | ||
214 | if ( !keyboardGrabbed() ) { | 441 | if ( !keyboardGrabbed() ) { |
215 | if ( ke->simpleData.keycode == Key_F9 ) { | 442 | if ( ke->simpleData.keycode == Key_F9 ) { |
216 | if ( press ) emit datebook(); | 443 | if ( press ) |
444 | emit datebook(); | ||
217 | return TRUE; | 445 | return TRUE; |
218 | } | 446 | } |
219 | if ( ke->simpleData.keycode == Key_F10 ) { | 447 | if ( ke->simpleData.keycode == Key_F10 ) { |
220 | if ( !press && cardSendTimer ) { | 448 | if ( !press && cardSendTimer ) { |
221 | emit contacts(); | 449 | emit contacts(); |
222 | delete cardSendTimer; | 450 | delete cardSendTimer; |
223 | } else if ( press ) { | 451 | } |
452 | else if ( press ) { | ||
224 | cardSendTimer = new QTimer(); | 453 | cardSendTimer = new QTimer(); |
225 | cardSendTimer->start( 2000, TRUE ); | 454 | cardSendTimer->start( 2000, TRUE ); |
226 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 455 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
@@ -236,17 +465,20 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
236 | if ( ke->simpleData.keycode == Key_F12 ) { | 465 | if ( ke->simpleData.keycode == Key_F12 ) { |
237 | while( activePopupWidget() ) | 466 | while( activePopupWidget() ) |
238 | activePopupWidget()->close(); | 467 | activePopupWidget()->close(); |
239 | if ( press ) emit launch(); | 468 | if ( press ) |
469 | emit launch(); | ||
240 | return TRUE; | 470 | return TRUE; |
241 | } | 471 | } |
242 | if ( ke->simpleData.keycode == Key_F13 ) { | 472 | if ( ke->simpleData.keycode == Key_F13 ) { |
243 | if ( press ) emit email(); | 473 | if ( press ) |
474 | emit email(); | ||
244 | return TRUE; | 475 | return TRUE; |
245 | } | 476 | } |
246 | } | 477 | } |
247 | 478 | ||
248 | if ( ke->simpleData.keycode == Key_F34 ) { | 479 | if ( ke->simpleData.keycode == Key_F34 ) { |
249 | if ( press ) emit power(); | 480 | if ( press ) |
481 | emit power(); | ||
250 | return TRUE; | 482 | return TRUE; |
251 | } | 483 | } |
252 | // This was used for the iPAQ PowerButton | 484 | // This was used for the iPAQ PowerButton |
@@ -257,26 +489,32 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
257 | // return TRUE; | 489 | // return TRUE; |
258 | // } | 490 | // } |
259 | if ( ke->simpleData.keycode == Key_F35 ) { | 491 | if ( ke->simpleData.keycode == Key_F35 ) { |
260 | if ( press ) emit backlight(); | 492 | if ( press ) |
493 | emit backlight(); | ||
261 | return TRUE; | 494 | return TRUE; |
262 | } | 495 | } |
263 | if ( ke->simpleData.keycode == Key_F32 ) { | 496 | if ( ke->simpleData.keycode == Key_F32 ) { |
264 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 497 | if ( press ) |
498 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | ||
265 | return TRUE; | 499 | return TRUE; |
266 | } | 500 | } |
267 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 501 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
268 | if ( press ) emit symbol(); | 502 | if ( press ) |
503 | emit symbol(); | ||
269 | return TRUE; | 504 | return TRUE; |
270 | } | 505 | } |
271 | if ( ke->simpleData.keycode == Key_NumLock ) { | 506 | if ( ke->simpleData.keycode == Key_NumLock ) { |
272 | if ( press ) emit numLockStateToggle(); | 507 | if ( press ) |
508 | emit numLockStateToggle(); | ||
273 | } | 509 | } |
274 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 510 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
275 | if ( press ) emit capsLockStateToggle(); | 511 | if ( press ) |
512 | emit capsLockStateToggle(); | ||
276 | } | 513 | } |
277 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) | 514 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) |
278 | qpedesktop->keyClick(); | 515 | qpedesktop->keyClick(); |
279 | } else { | 516 | } |
517 | else { | ||
280 | if ( e->type == QWSEvent::Mouse ) { | 518 | if ( e->type == QWSEvent::Mouse ) { |
281 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 519 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
282 | static bool up = TRUE; | 520 | static bool up = TRUE; |
@@ -285,7 +523,8 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
285 | up = FALSE; | 523 | up = FALSE; |
286 | qpedesktop->screenClick(); | 524 | qpedesktop->screenClick(); |
287 | } | 525 | } |
288 | } else { | 526 | } |
527 | else { | ||
289 | up = TRUE; | 528 | up = TRUE; |
290 | } | 529 | } |
291 | } | 530 | } |
@@ -366,6 +605,7 @@ Desktop::Desktop() : | |||
366 | launcher->show(); | 605 | launcher->show(); |
367 | launcher->raise(); | 606 | launcher->raise(); |
368 | #if defined(QPE_HAVE_MEMALERTER) | 607 | #if defined(QPE_HAVE_MEMALERTER) |
608 | |||
369 | initMemalerter(); | 609 | initMemalerter(); |
370 | #endif | 610 | #endif |
371 | // start services | 611 | // start services |
@@ -473,7 +713,8 @@ void Desktop::raiseLauncher() | |||
473 | launcher->nextView(); | 713 | launcher->nextView(); |
474 | else | 714 | else |
475 | launcher->raise(); | 715 | launcher->raise(); |
476 | } else { | 716 | } |
717 | else { | ||
477 | QCopEnvelope e("QPE/System","execute(QString)"); | 718 | QCopEnvelope e("QPE/System","execute(QString)"); |
478 | e << tempItem; | 719 | e << tempItem; |
479 | } | 720 | } |
@@ -491,7 +732,8 @@ void Desktop::executeOrModify(const QString& appLnkFile) | |||
491 | QCopChannel::send("QPE/Application/" + app, "nextView()"); | 732 | QCopChannel::send("QPE/Application/" + app, "nextView()"); |
492 | else | 733 | else |
493 | QCopChannel::send("QPE/Application/" + app, "raise()"); | 734 | QCopChannel::send("QPE/Application/" + app, "raise()"); |
494 | } else { | 735 | } |
736 | else { | ||
495 | lnk.execute(); | 737 | lnk.execute(); |
496 | } | 738 | } |
497 | } | 739 | } |
@@ -532,7 +774,8 @@ void Desktop::raiseMenu() | |||
532 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { | 774 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { |
533 | Global::terminateBuiltin( "calibrate" ); | 775 | Global::terminateBuiltin( "calibrate" ); |
534 | tb->startMenu()->launch(); | 776 | tb->startMenu()->launch(); |
535 | } else { | 777 | } |
778 | else { | ||
536 | QCopEnvelope e("QPE/System","execute(QString)"); | 779 | QCopEnvelope e("QPE/System","execute(QString)"); |
537 | e << tempItem; | 780 | e << tempItem; |
538 | } | 781 | } |
@@ -581,30 +824,9 @@ void Desktop::execAutoStart() | |||
581 | #include <time.h> | 824 | #include <time.h> |
582 | #endif | 825 | #endif |
583 | 826 | ||
584 | static bool blanked=FALSE; | ||
585 | |||
586 | static void blankScreen() | ||
587 | { | ||
588 | if ( !qt_screen ) return; | ||
589 | /* Should use a big black window instead. | ||
590 | QGfx* g = qt_screen->screenGfx(); | ||
591 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); | ||
592 | delete g; | ||
593 | */ | ||
594 | blanked = TRUE; | ||
595 | } | ||
596 | |||
597 | static void darkScreen() | ||
598 | { | ||
599 | extern void qpe_setBacklight(int); | ||
600 | qpe_setBacklight(0); // force off | ||
601 | } | ||
602 | |||
603 | 827 | ||
604 | void Desktop::togglePower() | 828 | void Desktop::togglePower() |
605 | { | 829 | { |
606 | extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop | ||
607 | |||
608 | static bool excllock = false; | 830 | static bool excllock = false; |
609 | 831 | ||
610 | if ( excllock ) | 832 | if ( excllock ) |
@@ -616,18 +838,10 @@ void Desktop::togglePower() | |||
616 | loggedin=0; | 838 | loggedin=0; |
617 | suspendTime = QDateTime::currentDateTime(); | 839 | suspendTime = QDateTime::currentDateTime(); |
618 | 840 | ||
619 | // qpe_setBacklight ( 0 ); // force LCD off (sandman: why ????) | ||
620 | |||
621 | if ( wasloggedin ) | ||
622 | blankScreen(); | ||
623 | |||
624 | qDebug ( "OPIE suspending\n" ); | ||
625 | |||
626 | ODevice::inst ( )-> suspend ( ); | 841 | ODevice::inst ( )-> suspend ( ); |
627 | 842 | ||
628 | QWSServer::screenSaverActivate ( false ); | 843 | QWSServer::screenSaverActivate ( false ); |
629 | 844 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | |
630 | qpe_setBacklight ( -3 ); // force LCD on | ||
631 | 845 | ||
632 | { | 846 | { |
633 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 847 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
@@ -714,15 +928,20 @@ void DesktopApplication::restart() | |||
714 | prepareForTermination(TRUE); | 928 | prepareForTermination(TRUE); |
715 | 929 | ||
716 | #ifdef Q_WS_QWS | 930 | #ifdef Q_WS_QWS |
931 | |||
717 | for ( int fd = 3; fd < 100; fd++ ) | 932 | for ( int fd = 3; fd < 100; fd++ ) |
718 | close( fd ); | 933 | close( fd ); |
719 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 934 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
935 | |||
720 | execl( "/sbin/init", "qpe", 0 ); | 936 | execl( "/sbin/init", "qpe", 0 ); |
721 | #elif defined(QT_QWS_CASSIOPEIA) | 937 | #elif defined(QT_QWS_CASSIOPEIA) |
938 | |||
722 | execl( "/bin/sh", "sh", 0 ); | 939 | execl( "/bin/sh", "sh", 0 ); |
723 | #else | 940 | #else |
941 | |||
724 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); | 942 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); |
725 | #endif | 943 | #endif |
944 | |||
726 | exit(1); | 945 | exit(1); |
727 | #endif | 946 | #endif |
728 | } | 947 | } |
@@ -804,7 +1023,8 @@ bool Desktop::eventFilter( QObject *, QEvent *ev ) | |||
804 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 1023 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
805 | e << QString( "mail" ); | 1024 | e << QString( "mail" ); |
806 | return true; | 1025 | return true; |
807 | } else { | 1026 | } |
1027 | else { | ||
808 | raiseMenu ( ); | 1028 | raiseMenu ( ); |
809 | return true; | 1029 | return true; |
810 | } | 1030 | } |