-rw-r--r-- | library/qpeapplication.cpp | 121 | ||||
-rw-r--r-- | library/qpeapplication.h | 1 | ||||
-rw-r--r-- | library/qpemenubar.cpp | 4 |
3 files changed, 54 insertions, 72 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index b26933b..e7e210a 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -93,7 +93,8 @@ class QPEApplicationData | |||
93 | { | 93 | { |
94 | public: | 94 | public: |
95 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), kbgrabber( 0 ), | 95 | QPEApplicationData ( ) |
96 | rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 96 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
97 | forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), qpe_main_widget( 0 ) | 97 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
98 | keep_running( true ), qpe_main_widget( 0 ) | ||
98 | 99 | ||
99 | { | 100 | { |
@@ -103,10 +104,8 @@ public: | |||
103 | int presstimer; | 104 | int presstimer; |
104 | QWidget* presswidget; | 105 | QWidget* presswidget; |
105 | int kbgrabber; | ||
106 | QString kbgrabber_appname; | ||
107 | QPoint presspos; | 106 | QPoint presspos; |
108 | 107 | ||
109 | bool rightpressed : 1; | 108 | bool rightpressed : 1; |
110 | bool kbregrab : 1; | 109 | bool kbgrabbed : 1; |
111 | bool notbusysent : 1; | 110 | bool notbusysent : 1; |
112 | bool preloaded : 1; | 111 | bool preloaded : 1; |
@@ -756,6 +755,4 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
756 | } | 755 | } |
757 | if ( e->type == QWSEvent::Key ) { | 756 | if ( e->type == QWSEvent::Key ) { |
758 | if ( d->kbgrabber == 1 ) | ||
759 | return TRUE; | ||
760 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 757 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
761 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 758 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
@@ -810,16 +807,39 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
810 | } | 807 | } |
811 | } | 808 | } |
812 | 809 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | |
813 | #if QT_VERSION < 231 | 810 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
814 | // Filter out the F4/Launcher key from apps | 811 | // but we cannot access libopie function within libqpe :( |
815 | // ### The launcher key may not always be F4 on all devices | 812 | |
816 | if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) | 813 | QWidget * active = activeWindow ( ); |
817 | return TRUE; | 814 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
818 | #endif | 815 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
819 | 816 | QChar ch ( ke-> simpleData.unicode ); | |
817 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | ||
818 | ke-> simpleData.keycode, | ||
819 | ch. latin1 ( ), | ||
820 | ke-> simpleData.modifiers, | ||
821 | QString ( ch ), | ||
822 | ke-> simpleData.is_auto_repeat, 1 ); | ||
823 | |||
824 | QObject *which = QWidget::keyboardGrabber ( ); | ||
825 | if ( !which ) | ||
826 | which = QApplication::focusWidget ( ); | ||
827 | if ( !which ) | ||
828 | which = QApplication::activeWindow ( ); | ||
829 | if ( !which ) | ||
830 | which = qApp; | ||
831 | |||
832 | QApplication::sendEvent ( which, &qke ); | ||
833 | } | ||
834 | else { // we didn't grab the keyboard, so send the event to the launcher | ||
835 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | ||
836 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | ||
837 | } | ||
838 | } | ||
839 | return true; | ||
840 | } | ||
820 | } | 841 | } |
821 | if ( e->type == QWSEvent::Focus ) { | 842 | if ( e->type == QWSEvent::Focus ) { |
822 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 843 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
823 | QWidget* nfw = QWidget::find( e->window() ); | ||
824 | if ( !fe->simpleData.get_focus ) { | 844 | if ( !fe->simpleData.get_focus ) { |
825 | QWidget * active = activeWindow(); | 845 | QWidget * active = activeWindow(); |
@@ -828,8 +848,4 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
828 | active = activeWindow(); | 848 | active = activeWindow(); |
829 | } | 849 | } |
830 | if ( !nfw && d->kbgrabber == 2 ) { | ||
831 | ungrabKeyboard(); | ||
832 | d->kbregrab = TRUE; // want kb back when we're active | ||
833 | } | ||
834 | } | 850 | } |
835 | else { | 851 | else { |
@@ -839,8 +855,4 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
839 | topm->raise(); | 855 | topm->raise(); |
840 | } | 856 | } |
841 | if ( d->kbregrab ) { | ||
842 | grabKeyboard(); | ||
843 | d->kbregrab = FALSE; | ||
844 | } | ||
845 | } | 857 | } |
846 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 858 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
@@ -1034,4 +1046,18 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
1034 | applyStyle(); | 1046 | applyStyle(); |
1035 | } | 1047 | } |
1048 | else if ( msg == "toggleApplicationMenu()" ) { | ||
1049 | QWidget *active = activeWindow ( ); | ||
1050 | |||
1051 | if ( active ) { | ||
1052 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | ||
1053 | bool oldactive = man-> isActive ( ); | ||
1054 | |||
1055 | man-> setActive( !man-> isActive() ); | ||
1056 | |||
1057 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | ||
1058 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | ||
1059 | } | ||
1060 | } | ||
1061 | } | ||
1036 | else if ( msg == "setDefaultRotation(int)" ) { | 1062 | else if ( msg == "setDefaultRotation(int)" ) { |
1037 | if ( type() == GuiServer ) { | 1063 | if ( type() == GuiServer ) { |
@@ -1057,16 +1083,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
1057 | restart(); | 1083 | restart(); |
1058 | } | 1084 | } |
1059 | else if ( msg == "grabKeyboard(QString)" ) { | ||
1060 | QString who; | ||
1061 | stream >> who; | ||
1062 | if ( who.isEmpty() ) | ||
1063 | d->kbgrabber = 0; | ||
1064 | else if ( who != d->appName ) | ||
1065 | d->kbgrabber = 1; | ||
1066 | else | ||
1067 | d->kbgrabber = 2; | ||
1068 | |||
1069 | d-> kbgrabber_appname = who; | ||
1070 | } | ||
1071 | else if ( msg == "language(QString)" ) { | 1085 | else if ( msg == "language(QString)" ) { |
1072 | if ( type() == GuiServer ) { | 1086 | if ( type() == GuiServer ) { |
@@ -1625,13 +1639,5 @@ void QPEApplication::removeSenderFromStylusDict() | |||
1625 | bool QPEApplication::keyboardGrabbed() const | 1639 | bool QPEApplication::keyboardGrabbed() const |
1626 | { | 1640 | { |
1627 | return d->kbgrabber; | 1641 | return d->kbgrabbed; |
1628 | } | ||
1629 | |||
1630 | /*! | ||
1631 | \internal | ||
1632 | */ | ||
1633 | QString QPEApplication::keyboardGrabbedBy() const | ||
1634 | { | ||
1635 | return d->kbgrabber_appname; | ||
1636 | } | 1642 | } |
1637 | 1643 | ||
@@ -1643,14 +1649,5 @@ QString QPEApplication::keyboardGrabbedBy() const | |||
1643 | void QPEApplication::ungrabKeyboard() | 1649 | void QPEApplication::ungrabKeyboard() |
1644 | { | 1650 | { |
1645 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1651 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
1646 | if ( d->kbgrabber == 2 ) { | ||
1647 | #ifndef QT_NO_COP | ||
1648 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | ||
1649 | e << QString::null; | ||
1650 | #endif | ||
1651 | |||
1652 | d->kbregrab = FALSE; | ||
1653 | d->kbgrabber = 0; | ||
1654 | } | ||
1655 | } | 1652 | } |
1656 | 1653 | ||
@@ -1666,15 +1663,5 @@ void QPEApplication::ungrabKeyboard() | |||
1666 | void QPEApplication::grabKeyboard() | 1663 | void QPEApplication::grabKeyboard() |
1667 | { | 1664 | { |
1668 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1665 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
1669 | if ( qApp->type() == QApplication::GuiServer ) | ||
1670 | d->kbgrabber = 0; | ||
1671 | else { | ||
1672 | #ifndef QT_NO_COP | ||
1673 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | ||
1674 | e << d->appName; | ||
1675 | #endif | ||
1676 | |||
1677 | d->kbgrabber = 2; // me | ||
1678 | } | ||
1679 | } | 1666 | } |
1680 | 1667 | ||
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index f712077..7d956a3 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -84,5 +84,4 @@ public: | |||
84 | 84 | ||
85 | bool keyboardGrabbed() const; | 85 | bool keyboardGrabbed() const; |
86 | QString keyboardGrabbedBy ( ) const; | ||
87 | 86 | ||
88 | int exec(); | 87 | int exec(); |
diff --git a/library/qpemenubar.cpp b/library/qpemenubar.cpp index 4aa0bf3..3e5bad5 100644 --- a/library/qpemenubar.cpp +++ b/library/qpemenubar.cpp | |||
@@ -226,8 +226,4 @@ bool QPEMenuToolFocusManager::eventFilter( QObject *object, QEvent *event ) | |||
226 | } | 226 | } |
227 | } | 227 | } |
228 | if ( ke->key() == Key_F11 ) { | ||
229 | setActive( !isActive() ); | ||
230 | return TRUE; | ||
231 | } | ||
232 | } else if ( event->type() == QEvent::KeyRelease ) { | 228 | } else if ( event->type() == QEvent::KeyRelease ) { |
233 | QKeyEvent *ke = (QKeyEvent *)event; | 229 | QKeyEvent *ke = (QKeyEvent *)event; |