summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-18 12:47:45 (UTC)
committer zecke <zecke>2002-10-18 12:47:45 (UTC)
commita574a09dd7b24091a4d2093c8b046ccd32e78d63 (patch) (unidiff)
tree36408789ef101637ed28c1bb5aa8cb00c5197472
parent605e9ccf2bcfa8e16059a1ce023baa2c41d47c88 (diff)
downloadopie-a574a09dd7b24091a4d2093c8b046ccd32e78d63.zip
opie-a574a09dd7b24091a4d2093c8b046ccd32e78d63.tar.gz
opie-a574a09dd7b24091a4d2093c8b046ccd32e78d63.tar.bz2
If a dialog get's accepted call QDialog::accept and not reject
Now Opie is fully working under X11 Thanks mallum for the one and only matchbox
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--x11/libqpe-x11/qpe/qpeapplication.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp
index 75a8189..49115d8 100644
--- a/x11/libqpe-x11/qpe/qpeapplication.cpp
+++ b/x11/libqpe-x11/qpe/qpeapplication.cpp
@@ -547,242 +547,242 @@ QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w) {
547} 547}
548 548
549 549
550void QPEApplication::removeSenderFromStylusDict() { 550void QPEApplication::removeSenderFromStylusDict() {
551 stylusDict->remove( ( void* ) sender() ); 551 stylusDict->remove( ( void* ) sender() );
552 if ( d->presswidget == sender() ) 552 if ( d->presswidget == sender() )
553 d->presswidget = 0; 553 d->presswidget = 0;
554} 554}
555void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) { 555void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) {
556 createDict(); 556 createDict();
557 if ( mode == LeftOnly ) { 557 if ( mode == LeftOnly ) {
558 stylusDict->remove 558 stylusDict->remove
559 ( w ); 559 ( w );
560 w->removeEventFilter( qApp ); 560 w->removeEventFilter( qApp );
561 }else { 561 }else {
562 stylusDict->insert( w, ( void* ) mode ); 562 stylusDict->insert( w, ( void* ) mode );
563 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 563 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
564 w->installEventFilter( qApp ); 564 w->installEventFilter( qApp );
565 } 565 }
566} 566}
567QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) { 567QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) {
568 if ( stylusDict ) 568 if ( stylusDict )
569 return ( StylusMode ) ( int ) stylusDict->find( w ); 569 return ( StylusMode ) ( int ) stylusDict->find( w );
570 return LeftOnly; 570 return LeftOnly;
571} 571}
572 572
573// eventFilter...... 573// eventFilter......
574bool QPEApplication::eventFilter( QObject* o, QEvent* e ) { 574bool QPEApplication::eventFilter( QObject* o, QEvent* e ) {
575 /* 575 /*
576 * We want our WM to show Ok and a X button 576 * We want our WM to show Ok and a X button
577 * on dialogs 577 * on dialogs
578 * our part is to set the _NET_WM_CONTEXT_ACCEPT 578 * our part is to set the _NET_WM_CONTEXT_ACCEPT
579 * propery 579 * propery
580 * and then wait for a client message -zecke 580 * and then wait for a client message -zecke
581 * on show we will add the prop 581 * on show we will add the prop
582 */ 582 */
583 if (o->inherits("QDialog") && e->type() == QEvent::Show ) { 583 if (o->inherits("QDialog") && e->type() == QEvent::Show ) {
584 QDialog* dialog = (QDialog*)o; 584 QDialog* dialog = (QDialog*)o;
585 Atom wm_prot[45]; 585 Atom wm_prot[45];
586 int n = 0; 586 int n = 0;
587 wm_prot[n++] = d->wm_delete_window; 587 wm_prot[n++] = d->wm_delete_window;
588 wm_prot[n++] = d->wm_take_focus; 588 wm_prot[n++] = d->wm_take_focus;
589 wm_prot[n++] = d->wm_context_accept; 589 wm_prot[n++] = d->wm_context_accept;
590 if ( dialog->testWFlags( WStyle_ContextHelp ) ) 590 if ( dialog->testWFlags( WStyle_ContextHelp ) )
591 wm_prot[n++] = d->wm_context_help; 591 wm_prot[n++] = d->wm_context_help;
592 XSetWMProtocols( qt_xdisplay(), dialog->winId(), wm_prot, n ); 592 XSetWMProtocols( qt_xdisplay(), dialog->winId(), wm_prot, n );
593 return TRUE; // should be save 593 return TRUE; // should be save
594 } 594 }
595 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 595 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
596 QMouseEvent * me = ( QMouseEvent* ) e; 596 QMouseEvent * me = ( QMouseEvent* ) e;
597 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 597 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
598 switch (mode) { 598 switch (mode) {
599 case RightOnHold: 599 case RightOnHold:
600 switch ( me->type() ) { 600 switch ( me->type() ) {
601 case QEvent::MouseButtonPress: 601 case QEvent::MouseButtonPress:
602 if ( me->button() == LeftButton ) { 602 if ( me->button() == LeftButton ) {
603 d->presstimer = startTimer(500); // #### pref. 603 d->presstimer = startTimer(500); // #### pref.
604 d->presswidget = (QWidget*)o; 604 d->presswidget = (QWidget*)o;
605 d->presspos = me->pos(); 605 d->presspos = me->pos();
606 d->rightpressed = FALSE; 606 d->rightpressed = FALSE;
607 } 607 }
608 break; 608 break;
609 case QEvent::MouseMove: 609 case QEvent::MouseMove:
610 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 610 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
611 killTimer(d->presstimer); 611 killTimer(d->presstimer);
612 d->presstimer = 0; 612 d->presstimer = 0;
613 } 613 }
614 break; 614 break;
615 case QEvent::MouseButtonRelease: 615 case QEvent::MouseButtonRelease:
616 if ( me->button() == LeftButton ) { 616 if ( me->button() == LeftButton ) {
617 if ( d->presstimer ) { 617 if ( d->presstimer ) {
618 killTimer(d->presstimer); 618 killTimer(d->presstimer);
619 d->presstimer = 0; 619 d->presstimer = 0;
620 } 620 }
621 if ( d->rightpressed && d->presswidget ) { 621 if ( d->rightpressed && d->presswidget ) {
622 // Right released 622 // Right released
623 postEvent( d->presswidget, 623 postEvent( d->presswidget,
624 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 624 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
625 RightButton, LeftButton + RightButton ) ); 625 RightButton, LeftButton + RightButton ) );
626 // Left released, off-widget 626 // Left released, off-widget
627 postEvent( d->presswidget, 627 postEvent( d->presswidget,
628 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 628 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
629 LeftButton, LeftButton ) ); 629 LeftButton, LeftButton ) );
630 postEvent( d->presswidget, 630 postEvent( d->presswidget,
631 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 631 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
632 LeftButton, LeftButton ) ); 632 LeftButton, LeftButton ) );
633 d->rightpressed = FALSE; 633 d->rightpressed = FALSE;
634 return TRUE; // don't send the real Left release 634 return TRUE; // don't send the real Left release
635 } 635 }
636 } 636 }
637 break; 637 break;
638 default: 638 default:
639 break; 639 break;
640 } 640 }
641 break; 641 break;
642 default: 642 default:
643 ; 643 ;
644 } 644 }
645 } 645 }
646 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 646 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
647 QKeyEvent *ke = (QKeyEvent *)e; 647 QKeyEvent *ke = (QKeyEvent *)e;
648 if ( ke->key() == Key_Enter ) { 648 if ( ke->key() == Key_Enter ) {
649 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 649 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
650 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 650 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
651 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 651 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
652 return TRUE; 652 return TRUE;
653 } 653 }
654 } 654 }
655 } 655 }
656 return FALSE; 656 return FALSE;
657} 657}
658 658
659// Quit stuff 659// Quit stuff
660void QPEApplication::restart() { 660void QPEApplication::restart() {
661 661
662} 662}
663void QPEApplication::shutdown() { 663void QPEApplication::shutdown() {
664 664
665} 665}
666void QPEApplication::tryQuit() { 666void QPEApplication::tryQuit() {
667 qWarning("TryQuit!!"); 667 qWarning("TryQuit!!");
668 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 668 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
669 return ; // Inside modal loop or konsole. Too hard to save state. 669 return ; // Inside modal loop or konsole. Too hard to save state.
670 { 670 {
671 QCopEnvelope e( "QPE/System", "closing(QString)" ); 671 QCopEnvelope e( "QPE/System", "closing(QString)" );
672 e << d->appName; 672 e << d->appName;
673 } 673 }
674 processEvents(); 674 processEvents();
675 675
676 quit(); 676 quit();
677} 677}
678void QPEApplication::hideOrQuit() { 678void QPEApplication::hideOrQuit() {
679 qWarning("hide or close"); 679 qWarning("hide or close");
680 processEvents(); 680 processEvents();
681 qWarning("past processing"); 681 qWarning("past processing");
682 682
683 // If we are a preloaded application we don't actually quit, so emit 683 // If we are a preloaded application we don't actually quit, so emit
684 // a System message indicating we're quasi-closing. 684 // a System message indicating we're quasi-closing.
685 if ( d->preloaded && d->qpe_main_widget ) 685 if ( d->preloaded && d->qpe_main_widget )
686 686
687 { 687 {
688 qWarning("hiding"); 688 qWarning("hiding");
689 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 689 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
690 e << d->appName; 690 e << d->appName;
691 d->qpe_main_widget->hide(); 691 d->qpe_main_widget->hide();
692 } 692 }
693 else 693 else
694 quit(); 694 quit();
695} 695}
696 696
697/*! 697/*!
698 \internal 698 \internal
699*/ 699*/
700void QPEApplication::prepareForTermination( bool willrestart ) 700void QPEApplication::prepareForTermination( bool willrestart )
701{ 701{
702 if ( willrestart ) { 702 if ( willrestart ) {
703 // Draw a big wait icon, the image can be altered in later revisions 703 // Draw a big wait icon, the image can be altered in later revisions
704 // QWidget *d = QApplication::desktop(); 704 // QWidget *d = QApplication::desktop();
705 QImage img = Resource::loadImage( "launcher/new_wait" ); 705 QImage img = Resource::loadImage( "launcher/new_wait" );
706 QPixmap pix; 706 QPixmap pix;
707 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 707 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
708 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 708 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
709 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 709 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
710 lblWait->setPixmap( pix ); 710 lblWait->setPixmap( pix );
711 lblWait->setAlignment( QWidget::AlignCenter ); 711 lblWait->setAlignment( QWidget::AlignCenter );
712 lblWait->show(); 712 lblWait->show();
713 lblWait->showMaximized(); 713 lblWait->showMaximized();
714 } 714 }
715#ifndef SINGLE_APP 715#ifndef SINGLE_APP
716 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 716 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
717 } 717 }
718 processEvents(); // ensure the message goes out. 718 processEvents(); // ensure the message goes out.
719 sleep( 1 ); // You have 1 second to comply. 719 sleep( 1 ); // You have 1 second to comply.
720#endif 720#endif
721} 721}
722int QPEApplication::x11ClientMessage(QWidget* w, XEvent* event, bool b ) { 722int QPEApplication::x11ClientMessage(QWidget* w, XEvent* event, bool b ) {
723 qWarning("X11 ClientMessage %d %d", event->type, ClientMessage); 723 qWarning("X11 ClientMessage %d %d", event->type, ClientMessage);
724 if ( event->type == ClientMessage ) { 724 if ( event->type == ClientMessage ) {
725 if ( (event->xclient.message_type == d->wm_protocols) && 725 if ( (event->xclient.message_type == d->wm_protocols) &&
726 (event->xclient.data.l[0] == d->wm_context_accept ) ) { 726 (event->xclient.data.l[0] == d->wm_context_accept ) ) {
727 qWarning("accepted!!!"); 727 qWarning("accepted!!!");
728 /* 728 /*
729 * I'm not sure if we should use activeWidget 729 * I'm not sure if we should use activeWidget
730 * or activeModalWidget 730 * or activeModalWidget
731 * a QDialog could be not modal too 731 * a QDialog could be not modal too
732 */ 732 */
733 if ( w->inherits("QDialog" ) ) { 733 if ( w->inherits("QDialog" ) ) {
734 qWarning("inherits QDialog!!!"); 734 qWarning("inherits QDialog!!!");
735 QDialog* dia = (QDialog*)w; 735 QDialog* dia = (QDialog*)w;
736 /* 736 /*
737 * call it directly or via QTimer::singleShot? 737 * call it directly or via QTimer::singleShot?
738 */ 738 */
739 QTimer::singleShot(0, dia, SLOT(reject() ) ); 739 QTimer::singleShot(0, dia, SLOT(accept() ) );
740 return 0; 740 return 0;
741 } 741 }
742 742
743 } 743 }
744 } 744 }
745 return QApplication::x11ClientMessage(w, event, b ); 745 return QApplication::x11ClientMessage(w, event, b );
746} 746}
747 747
748#define KeyPress XKeyPress 748#define KeyPress XKeyPress
749#define KeyRelease XKeyRelease 749#define KeyRelease XKeyRelease
750 750
751#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 751#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
752 752
753// The libraries with the skiff package (and possibly others) have 753// The libraries with the skiff package (and possibly others) have
754// completely useless implementations of builtin new and delete that 754// completely useless implementations of builtin new and delete that
755// use about 50% of your CPU. Here we revert to the simple libc 755// use about 50% of your CPU. Here we revert to the simple libc
756// functions. 756// functions.
757 757
758void* operator new[]( size_t size ) 758void* operator new[]( size_t size )
759{ 759{
760 return malloc( size ); 760 return malloc( size );
761} 761}
762 762
763void* operator new( size_t size ) 763void* operator new( size_t size )
764{ 764{
765 return malloc( size ); 765 return malloc( size );
766} 766}
767 767
768void operator delete[]( void* p ) 768void operator delete[]( void* p )
769{ 769{
770 free( p ); 770 free( p );
771} 771}
772 772
773void operator delete[]( void* p, size_t /*size*/ ) 773void operator delete[]( void* p, size_t /*size*/ )
774{ 774{
775 free( p ); 775 free( p );
776} 776}
777 777
778void operator delete( void* p ) 778void operator delete( void* p )
779{ 779{
780 free( p ); 780 free( p );
781} 781}
782 782
783void operator delete( void* p, size_t /*size*/ ) 783void operator delete( void* p, size_t /*size*/ )
784{ 784{
785 free( p ); 785 free( p );
786} 786}
787 787
788#endif 788#endif