summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index fbcce7c..86527f6 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -305,127 +305,132 @@ void DesktopApplication::reloadPowerWarnSettings ( )
305 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); 305 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 );
306 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); 306 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 );
307} 307}
308 308
309 309
310enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 310enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
311 311
312 312
313void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data ) 313void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data )
314{ 314{
315 QDataStream stream ( data, IO_ReadOnly ); 315 QDataStream stream ( data, IO_ReadOnly );
316 316
317 if ( msg == "deviceButton(int,int,int)" ) { 317 if ( msg == "deviceButton(int,int,int)" ) {
318 int keycode, press, autoRepeat; 318 int keycode, press, autoRepeat;
319 stream >> keycode >> press >> autoRepeat; 319 stream >> keycode >> press >> autoRepeat;
320 320
321 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode ); 321 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode );
322 322
323 if ( db ) 323 if ( db )
324 checkButtonAction ( db, keycode, press, autoRepeat ); 324 checkButtonAction ( db, keycode, press, autoRepeat );
325 } 325 }
326 else if ( msg == "keyRegister(int,QCString,QCString)" ) { 326 else if ( msg == "keyRegister(int,QCString,QCString)" ) {
327 int k; 327 int k;
328 QCString c, m; 328 QCString c, m;
329 stream >> k >> c >> m; 329 stream >> k >> c >> m;
330 330
331 keyRegisterList.append ( QCopKeyRegister ( k, c, m )); 331 keyRegisterList.append ( QCopKeyRegister ( k, c, m ));
332 } 332 }
333} 333}
334 334
335void DesktopApplication::sendHeldAction ( ) 335void DesktopApplication::sendHeldAction ( )
336{ 336{
337 if ( m_last_button ) { 337 if ( m_last_button ) {
338 m_last_button-> heldAction ( ). send ( ); 338 m_last_button-> heldAction ( ). send ( );
339 m_last_button = 0; 339 m_last_button = 0;
340 } 340 }
341} 341}
342 342
343 343
344 344
345bool DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat ) 345bool DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat )
346 { 346 {
347 if ( db ) { 347 if ( db ) {
348 if ( !press && !autoRepeat && m_button_timer-> isActive ( )) { 348 if ( !press && !autoRepeat && m_button_timer-> isActive ( )) {
349 m_button_timer-> stop ( ); 349 m_button_timer-> stop ( );
350 350
351 if (!db-> pressedAction ( ). channel ( ) .isEmpty()) 351 if (!db-> pressedAction ( ). channel ( ) .isEmpty())
352 { 352 {
353
353 if ( db-> pressedAction ( ). channel ( )!="ignore") { 354 if ( db-> pressedAction ( ). channel ( )!="ignore") {
355
354 db-> pressedAction ( ). send ( ); 356 db-> pressedAction ( ). send ( );
355 } 357 }
356 else return false; 358 else
359 return false;
357 } 360 }
358 } 361 }
359 else if ( press && !autoRepeat ) { 362 else if ( press && !autoRepeat ) {
360 m_button_timer-> stop ( ); 363 m_button_timer-> stop ( );
361 if (!db-> pressedAction ( ). channel ( ) .isEmpty()) 364 if (!db-> pressedAction ( ). channel ( ) .isEmpty())
362 { 365 {
363 366
364 if ( db-> heldAction ( ). channel ( )!="ignore") { 367 if ( db-> heldAction ( ). channel ( )!="ignore") {
365 m_last_button = db; 368 m_last_button = db;
366 m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); 369 m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true );
367 } 370 }
368 else return false; 371 else return false;
369 } 372 }
370 } 373 }
371 } 374 }
372 return true; 375 return true;
373} 376}
374 377
375bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) 378bool DesktopApplication::eventFilter ( QObject *o, QEvent *e )
376{ 379{
380
377 if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { 381 if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) {
378 QKeyEvent *ke = (QKeyEvent *) e; 382 QKeyEvent *ke = (QKeyEvent *) e;
379 383
380 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); 384 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( ));
381 385
382 if ( db ) { 386 if ( db ) {
383 return checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )); 387 if (checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )))
388 return true; //checkButtonAction retrune false if events should be routed through
384 } 389 }
385 } 390 }
386 return QPEApplication::eventFilter ( o, e ); 391 return QPEApplication::eventFilter ( o, e );
387} 392}
388 393
389#ifdef Q_WS_QWS 394#ifdef Q_WS_QWS
390 395
391bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 396bool DesktopApplication::qwsEventFilter( QWSEvent *e )
392{ 397{
393 qpedesktop->checkMemory(); 398 qpedesktop->checkMemory();
394 399
395 if ( e->type == QWSEvent::Key ) { 400 if ( e->type == QWSEvent::Key ) {
396 QWSKeyEvent * ke = (QWSKeyEvent *) e; 401 QWSKeyEvent * ke = (QWSKeyEvent *) e;
397 ushort keycode = ke-> simpleData. keycode; 402 ushort keycode = ke-> simpleData. keycode;
398 403
399 if ( !loggedin && keycode != Key_F34 ) 404 if ( !loggedin && keycode != Key_F34 )
400 return true; 405 return true;
401 406
402 bool press = ke-> simpleData. is_press; 407 bool press = ke-> simpleData. is_press;
403 bool autoRepeat = ke-> simpleData. is_auto_repeat; 408 bool autoRepeat = ke-> simpleData. is_auto_repeat;
404 409
405 if ( !keyboardGrabbed ( )) { 410 if ( !keyboardGrabbed ( )) {
406 // app that registers key/message to be sent back to the app, when it doesn't have focus, 411 // app that registers key/message to be sent back to the app, when it doesn't have focus,
407 // when user presses key, unless keyboard has been requested from app. 412 // when user presses key, unless keyboard has been requested from app.
408 // will not send multiple repeats if user holds key 413 // will not send multiple repeats if user holds key
409 // i.e. one shot 414 // i.e. one shot
410 415
411 if ( keycode != 0 && press && !autoRepeat ) { 416 if ( keycode != 0 && press && !autoRepeat ) {
412 for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 417 for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
413 if (( *it ). getKeyCode ( ) == keycode ) { 418 if (( *it ). getKeyCode ( ) == keycode ) {
414 QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); 419 QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( ));
415 return true; 420 return true;
416 } 421 }
417 } 422 }
418 } 423 }
419 } 424 }
420 425
421 if ( keycode == HardKey_Suspend ) { 426 if ( keycode == HardKey_Suspend ) {
422 if ( press ) 427 if ( press )
423 emit power ( ); 428 emit power ( );
424 return true; 429 return true;
425 } 430 }
426 else if ( keycode == HardKey_Backlight ) { 431 else if ( keycode == HardKey_Backlight ) {
427 if ( press ) 432 if ( press )
428 emit backlight ( ); 433 emit backlight ( );
429 return true; 434 return true;
430 } 435 }
431 else if ( keycode == Key_F32 ) { 436 else if ( keycode == Key_F32 ) {
@@ -620,98 +625,96 @@ void Desktop::executeOrModify( const QString& appLnkFile )
620 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { 625 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) {
621 // MRUList::addTask( &lnk ); 626 // MRUList::addTask( &lnk );
622 if ( hasVisibleWindow( app ) ) 627 if ( hasVisibleWindow( app ) )
623 QCopChannel::send( "QPE/Application/" + app, "nextView()" ); 628 QCopChannel::send( "QPE/Application/" + app, "nextView()" );
624 else 629 else
625 QCopChannel::send( "QPE/Application/" + app, "raise()" ); 630 QCopChannel::send( "QPE/Application/" + app, "raise()" );
626 } 631 }
627 else { 632 else {
628 lnk.execute(); 633 lnk.execute();
629 } 634 }
630 } 635 }
631} 636}
632 637
633// autoStarts apps on resume and start 638// autoStarts apps on resume and start
634void Desktop::execAutoStart() 639void Desktop::execAutoStart()
635{ 640{
636 QString appName; 641 QString appName;
637 int delay; 642 int delay;
638 QDateTime now = QDateTime::currentDateTime(); 643 QDateTime now = QDateTime::currentDateTime();
639 Config cfg( "autostart" ); 644 Config cfg( "autostart" );
640 cfg.setGroup( "AutoStart" ); 645 cfg.setGroup( "AutoStart" );
641 appName = cfg.readEntry( "Apps", "" ); 646 appName = cfg.readEntry( "Apps", "" );
642 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); 647 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt();
643 // If the time between suspend and resume was longer then the 648 // If the time between suspend and resume was longer then the
644 // value saved as delay, start the app 649 // value saved as delay, start the app
645 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 650 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
646 QCopEnvelope e( "QPE/System", "execute(QString)" ); 651 QCopEnvelope e( "QPE/System", "execute(QString)" );
647 e << QString( appName ); 652 e << QString( appName );
648 } 653 }
649} 654}
650 655
651#if defined(QPE_HAVE_TOGGLELIGHT) 656#if defined(QPE_HAVE_TOGGLELIGHT)
652#include <qpe/config.h> 657#include <qpe/config.h>
653 658
654#include <sys/ioctl.h> 659#include <sys/ioctl.h>
655#include <sys/types.h> 660#include <sys/types.h>
656#include <fcntl.h> 661#include <fcntl.h>
657#include <unistd.h> 662#include <unistd.h>
658#include <errno.h> 663#include <errno.h>
659#include <linux/ioctl.h> 664#include <linux/ioctl.h>
660#include <time.h> 665#include <time.h>
661#endif 666#endif
662 667
663 668
664void Desktop::togglePower() 669void Desktop::togglePower()
665{ 670{
666 static bool excllock = false; 671 static bool excllock = false;
667 672
668 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 );
669
670 if ( excllock ) 673 if ( excllock )
671 return ; 674 return ;
672 675
673 excllock = true; 676 excllock = true;
674 677
675 bool wasloggedin = loggedin; 678 bool wasloggedin = loggedin;
676 loggedin = 0; 679 loggedin = 0;
677 suspendTime = QDateTime::currentDateTime(); 680 suspendTime = QDateTime::currentDateTime();
678 681
679#ifdef QWS 682#ifdef QWS
680 683
681 if ( Password::needToAuthenticate ( true ) && qt_screen ) { 684 if ( Password::needToAuthenticate ( true ) && qt_screen ) {
682 // Should use a big black window instead. 685 // Should use a big black window instead.
683 // But this would not show up fast enough 686 // But this would not show up fast enough
684 QGfx *g = qt_screen-> screenGfx ( ); 687 QGfx *g = qt_screen-> screenGfx ( );
685 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); 688 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
686 delete g; 689 delete g;
687 } 690 }
688#endif 691#endif
689 692
690 ODevice::inst ( )-> suspend ( ); 693 ODevice::inst ( )-> suspend ( );
691 694
692 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call 695 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
693 QWSServer::screenSaverActivate ( false ); 696 QWSServer::screenSaverActivate ( false );
694 697
695 { 698 {
696 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 699 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
697 } 700 }
698 701
699 if ( wasloggedin ) 702 if ( wasloggedin )
700 login ( true ); 703 login ( true );
701 704
702 execAutoStart(); 705 execAutoStart();
703 //qcopBridge->closeOpenConnections(); 706 //qcopBridge->closeOpenConnections();
704 707
705 excllock = false; 708 excllock = false;
706} 709}
707 710
708void Desktop::toggleLight() 711void Desktop::toggleLight()
709{ 712{
710 QCopEnvelope e( "QPE/System", "setBacklight(int)" ); 713 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
711 e << -2; // toggle 714 e << -2; // toggle
712} 715}
713 716
714void Desktop::toggleSymbolInput() 717void Desktop::toggleSymbolInput()
715{ 718{
716 tb->toggleSymbolInput(); 719 tb->toggleSymbolInput();
717} 720}