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
@@ -289,159 +289,164 @@ void DesktopApplication::systemMessage( const QCString & msg, const QByteArray &
289 e << tr( "business card" ) << card << mimetype; 289 e << tr( "business card" ) << card << mimetype;
290 } 290 }
291 } 291 }
292} 292}
293 293
294void DesktopApplication::reloadPowerWarnSettings ( ) 294void DesktopApplication::reloadPowerWarnSettings ( )
295{ 295{
296 Config cfg ( "apm" ); 296 Config cfg ( "apm" );
297 cfg. setGroup ( "Warnings" ); 297 cfg. setGroup ( "Warnings" );
298 298
299 int iv = cfg. readNumEntry ( "checkinterval", 10000 ); 299 int iv = cfg. readNumEntry ( "checkinterval", 10000 );
300 300
301 m_apm_timer-> stop ( ); 301 m_apm_timer-> stop ( );
302 if ( iv ) 302 if ( iv )
303 m_apm_timer-> start ( iv ); 303 m_apm_timer-> start ( iv );
304 304
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 ) {
432 if ( press ) 437 if ( press )
433 QCopEnvelope e( "QPE/Desktop", "startSync()" ); 438 QCopEnvelope e( "QPE/Desktop", "startSync()" );
434 return true; 439 return true;
435 } 440 }
436 else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM 441 else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM
437 if ( press ) 442 if ( press )
438 emit symbol ( ); 443 emit symbol ( );
439 return true; 444 return true;
440 } 445 }
441 else if ( keycode == Key_NumLock ) { 446 else if ( keycode == Key_NumLock ) {
442 if ( press ) 447 if ( press )
443 emit numLockStateToggle ( ); 448 emit numLockStateToggle ( );
444 } 449 }
445 else if ( keycode == Key_CapsLock ) { 450 else if ( keycode == Key_CapsLock ) {
446 if ( press ) 451 if ( press )
447 emit capsLockStateToggle(); 452 emit capsLockStateToggle();
@@ -604,130 +609,128 @@ static bool hasVisibleWindow( const QString& clientname )
604 QWSWindow* w; 609 QWSWindow* w;
605 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 610 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
606 if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) 611 if ( w->client() ->identity() == clientname && !w->isFullyObscured() )
607 return TRUE; 612 return TRUE;
608 } 613 }
609#endif 614#endif
610 return FALSE; 615 return FALSE;
611} 616}
612 617
613 618
614void Desktop::executeOrModify( const QString& appLnkFile ) 619void Desktop::executeOrModify( const QString& appLnkFile )
615{ 620{
616 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); 621 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile );
617 if ( lnk.isValid() ) { 622 if ( lnk.isValid() ) {
618 QCString app = lnk.exec().utf8(); 623 QCString app = lnk.exec().utf8();
619 Global::terminateBuiltin( "calibrate" ); 624 Global::terminateBuiltin( "calibrate" );
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}
718 721
719void Desktop::toggleNumLockState() 722void Desktop::toggleNumLockState()
720{ 723{
721 tb->toggleNumLockState(); 724 tb->toggleNumLockState();
722} 725}
723 726
724void Desktop::toggleCapsLockState() 727void Desktop::toggleCapsLockState()
725{ 728{
726 tb->toggleCapsLockState(); 729 tb->toggleCapsLockState();
727} 730}
728 731
729void Desktop::styleChange( QStyle &s ) 732void Desktop::styleChange( QStyle &s )
730{ 733{
731 QWidget::styleChange( s ); 734 QWidget::styleChange( s );
732 int displayw = qApp->desktop() ->width(); 735 int displayw = qApp->desktop() ->width();
733 int displayh = qApp->desktop() ->height(); 736 int displayh = qApp->desktop() ->height();