-rw-r--r-- | library/qpeapplication.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 852671a..b26933b 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -74,64 +74,65 @@ | |||
74 | #ifdef QWS | 74 | #ifdef QWS |
75 | #include "fontmanager.h" | 75 | #include "fontmanager.h" |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #include "alarmserver.h" | 78 | #include "alarmserver.h" |
79 | #include "applnk.h" | 79 | #include "applnk.h" |
80 | #include "qpemenubar.h" | 80 | #include "qpemenubar.h" |
81 | #include "textcodecinterface.h" | 81 | #include "textcodecinterface.h" |
82 | #include "imagecodecinterface.h" | 82 | #include "imagecodecinterface.h" |
83 | 83 | ||
84 | #include <unistd.h> | 84 | #include <unistd.h> |
85 | #include <sys/file.h> | 85 | #include <sys/file.h> |
86 | #include <sys/ioctl.h> | 86 | #include <sys/ioctl.h> |
87 | #include <sys/soundcard.h> | 87 | #include <sys/soundcard.h> |
88 | 88 | ||
89 | #include "qt_override_p.h" | 89 | #include "qt_override_p.h" |
90 | 90 | ||
91 | 91 | ||
92 | class QPEApplicationData | 92 | class QPEApplicationData |
93 | { | 93 | { |
94 | public: | 94 | public: |
95 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), kbgrabber( 0 ), | 95 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), kbgrabber( 0 ), |
96 | rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 96 | rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
97 | forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), qpe_main_widget( 0 ) | 97 | forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), qpe_main_widget( 0 ) |
98 | 98 | ||
99 | { | 99 | { |
100 | qcopq.setAutoDelete( TRUE ); | 100 | qcopq.setAutoDelete( TRUE ); |
101 | } | 101 | } |
102 | 102 | ||
103 | int presstimer; | 103 | int presstimer; |
104 | QWidget* presswidget; | 104 | QWidget* presswidget; |
105 | int kbgrabber; | 105 | int kbgrabber; |
106 | QString kbgrabber_appname; | ||
106 | QPoint presspos; | 107 | QPoint presspos; |
107 | 108 | ||
108 | bool rightpressed : 1; | 109 | bool rightpressed : 1; |
109 | bool kbregrab : 1; | 110 | bool kbregrab : 1; |
110 | bool notbusysent : 1; | 111 | bool notbusysent : 1; |
111 | bool preloaded : 1; | 112 | bool preloaded : 1; |
112 | bool forceshow : 1; | 113 | bool forceshow : 1; |
113 | bool nomaximize : 1; | 114 | bool nomaximize : 1; |
114 | bool keep_running : 1; | 115 | bool keep_running : 1; |
115 | 116 | ||
116 | QString appName; | 117 | QString appName; |
117 | struct QCopRec | 118 | struct QCopRec |
118 | { | 119 | { |
119 | QCopRec( const QCString &ch, const QCString &msg, | 120 | QCopRec( const QCString &ch, const QCString &msg, |
120 | const QByteArray &d ) : | 121 | const QByteArray &d ) : |
121 | channel( ch ), message( msg ), data( d ) | 122 | channel( ch ), message( msg ), data( d ) |
122 | { } | 123 | { } |
123 | 124 | ||
124 | QCString channel; | 125 | QCString channel; |
125 | QCString message; | 126 | QCString message; |
126 | QByteArray data; | 127 | QByteArray data; |
127 | }; | 128 | }; |
128 | QWidget* qpe_main_widget; | 129 | QWidget* qpe_main_widget; |
129 | QList<QCopRec> qcopq; | 130 | QList<QCopRec> qcopq; |
130 | 131 | ||
131 | void enqueueQCop( const QCString &ch, const QCString &msg, | 132 | void enqueueQCop( const QCString &ch, const QCString &msg, |
132 | const QByteArray &data ) | 133 | const QByteArray &data ) |
133 | { | 134 | { |
134 | qcopq.append( new QCopRec( ch, msg, data ) ); | 135 | qcopq.append( new QCopRec( ch, msg, data ) ); |
135 | } | 136 | } |
136 | void sendQCopQ() | 137 | void sendQCopQ() |
137 | { | 138 | { |
@@ -1035,64 +1036,66 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
1035 | else if ( msg == "setDefaultRotation(int)" ) { | 1036 | else if ( msg == "setDefaultRotation(int)" ) { |
1036 | if ( type() == GuiServer ) { | 1037 | if ( type() == GuiServer ) { |
1037 | int r; | 1038 | int r; |
1038 | stream >> r; | 1039 | stream >> r; |
1039 | setDefaultRotation( r ); | 1040 | setDefaultRotation( r ); |
1040 | } | 1041 | } |
1041 | } | 1042 | } |
1042 | else if ( msg == "shutdown()" ) { | 1043 | else if ( msg == "shutdown()" ) { |
1043 | if ( type() == GuiServer ) | 1044 | if ( type() == GuiServer ) |
1044 | shutdown(); | 1045 | shutdown(); |
1045 | } | 1046 | } |
1046 | else if ( msg == "quit()" ) { | 1047 | else if ( msg == "quit()" ) { |
1047 | if ( type() != GuiServer ) | 1048 | if ( type() != GuiServer ) |
1048 | tryQuit(); | 1049 | tryQuit(); |
1049 | } | 1050 | } |
1050 | else if ( msg == "forceQuit()" ) { | 1051 | else if ( msg == "forceQuit()" ) { |
1051 | if ( type() != GuiServer ) | 1052 | if ( type() != GuiServer ) |
1052 | quit(); | 1053 | quit(); |
1053 | } | 1054 | } |
1054 | else if ( msg == "restart()" ) { | 1055 | else if ( msg == "restart()" ) { |
1055 | if ( type() == GuiServer ) | 1056 | if ( type() == GuiServer ) |
1056 | restart(); | 1057 | restart(); |
1057 | } | 1058 | } |
1058 | else if ( msg == "grabKeyboard(QString)" ) { | 1059 | else if ( msg == "grabKeyboard(QString)" ) { |
1059 | QString who; | 1060 | QString who; |
1060 | stream >> who; | 1061 | stream >> who; |
1061 | if ( who.isEmpty() ) | 1062 | if ( who.isEmpty() ) |
1062 | d->kbgrabber = 0; | 1063 | d->kbgrabber = 0; |
1063 | else if ( who != d->appName ) | 1064 | else if ( who != d->appName ) |
1064 | d->kbgrabber = 1; | 1065 | d->kbgrabber = 1; |
1065 | else | 1066 | else |
1066 | d->kbgrabber = 2; | 1067 | d->kbgrabber = 2; |
1068 | |||
1069 | d-> kbgrabber_appname = who; | ||
1067 | } | 1070 | } |
1068 | else if ( msg == "language(QString)" ) { | 1071 | else if ( msg == "language(QString)" ) { |
1069 | if ( type() == GuiServer ) { | 1072 | if ( type() == GuiServer ) { |
1070 | QString l; | 1073 | QString l; |
1071 | stream >> l; | 1074 | stream >> l; |
1072 | QString cl = getenv( "LANG" ); | 1075 | QString cl = getenv( "LANG" ); |
1073 | if ( cl != l ) { | 1076 | if ( cl != l ) { |
1074 | if ( l.isNull() ) | 1077 | if ( l.isNull() ) |
1075 | unsetenv( "LANG" ); | 1078 | unsetenv( "LANG" ); |
1076 | else | 1079 | else |
1077 | setenv( "LANG", l.latin1(), 1 ); | 1080 | setenv( "LANG", l.latin1(), 1 ); |
1078 | restart(); | 1081 | restart(); |
1079 | } | 1082 | } |
1080 | } | 1083 | } |
1081 | } | 1084 | } |
1082 | else if ( msg == "timeChange(QString)" ) { | 1085 | else if ( msg == "timeChange(QString)" ) { |
1083 | QString t; | 1086 | QString t; |
1084 | stream >> t; | 1087 | stream >> t; |
1085 | if ( t.isNull() ) | 1088 | if ( t.isNull() ) |
1086 | unsetenv( "TZ" ); | 1089 | unsetenv( "TZ" ); |
1087 | else | 1090 | else |
1088 | setenv( "TZ", t.latin1(), 1 ); | 1091 | setenv( "TZ", t.latin1(), 1 ); |
1089 | // emit the signal so everyone else knows... | 1092 | // emit the signal so everyone else knows... |
1090 | emit timeChanged(); | 1093 | emit timeChanged(); |
1091 | } | 1094 | } |
1092 | else if ( msg == "execute(QString)" ) { | 1095 | else if ( msg == "execute(QString)" ) { |
1093 | if ( type() == GuiServer ) { | 1096 | if ( type() == GuiServer ) { |
1094 | QString t; | 1097 | QString t; |
1095 | stream >> t; | 1098 | stream >> t; |
1096 | Global::execute( t ); | 1099 | Global::execute( t ); |
1097 | } | 1100 | } |
1098 | } | 1101 | } |
@@ -1595,64 +1598,72 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
1595 | /*! | 1598 | /*! |
1596 | \reimp | 1599 | \reimp |
1597 | */ | 1600 | */ |
1598 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1601 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1599 | { | 1602 | { |
1600 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1603 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1601 | // Right pressed | 1604 | // Right pressed |
1602 | postEvent( d->presswidget, | 1605 | postEvent( d->presswidget, |
1603 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1606 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1604 | RightButton, LeftButton ) ); | 1607 | RightButton, LeftButton ) ); |
1605 | killTimer( d->presstimer ); | 1608 | killTimer( d->presstimer ); |
1606 | d->presstimer = 0; | 1609 | d->presstimer = 0; |
1607 | d->rightpressed = TRUE; | 1610 | d->rightpressed = TRUE; |
1608 | } | 1611 | } |
1609 | } | 1612 | } |
1610 | 1613 | ||
1611 | void QPEApplication::removeSenderFromStylusDict() | 1614 | void QPEApplication::removeSenderFromStylusDict() |
1612 | { | 1615 | { |
1613 | stylusDict->remove | 1616 | stylusDict->remove |
1614 | ( ( void* ) sender() ); | 1617 | ( ( void* ) sender() ); |
1615 | if ( d->presswidget == sender() ) | 1618 | if ( d->presswidget == sender() ) |
1616 | d->presswidget = 0; | 1619 | d->presswidget = 0; |
1617 | } | 1620 | } |
1618 | 1621 | ||
1619 | /*! | 1622 | /*! |
1620 | \internal | 1623 | \internal |
1621 | */ | 1624 | */ |
1622 | bool QPEApplication::keyboardGrabbed() const | 1625 | bool QPEApplication::keyboardGrabbed() const |
1623 | { | 1626 | { |
1624 | return d->kbgrabber; | 1627 | return d->kbgrabber; |
1625 | } | 1628 | } |
1626 | 1629 | ||
1630 | /*! | ||
1631 | \internal | ||
1632 | */ | ||
1633 | QString QPEApplication::keyboardGrabbedBy() const | ||
1634 | { | ||
1635 | return d->kbgrabber_appname; | ||
1636 | } | ||
1637 | |||
1627 | 1638 | ||
1628 | /*! | 1639 | /*! |
1629 | Reverses the effect of grabKeyboard(). This is called automatically | 1640 | Reverses the effect of grabKeyboard(). This is called automatically |
1630 | on program exit. | 1641 | on program exit. |
1631 | */ | 1642 | */ |
1632 | void QPEApplication::ungrabKeyboard() | 1643 | void QPEApplication::ungrabKeyboard() |
1633 | { | 1644 | { |
1634 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1645 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1635 | if ( d->kbgrabber == 2 ) { | 1646 | if ( d->kbgrabber == 2 ) { |
1636 | #ifndef QT_NO_COP | 1647 | #ifndef QT_NO_COP |
1637 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1648 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1638 | e << QString::null; | 1649 | e << QString::null; |
1639 | #endif | 1650 | #endif |
1640 | 1651 | ||
1641 | d->kbregrab = FALSE; | 1652 | d->kbregrab = FALSE; |
1642 | d->kbgrabber = 0; | 1653 | d->kbgrabber = 0; |
1643 | } | 1654 | } |
1644 | } | 1655 | } |
1645 | 1656 | ||
1646 | /*! | 1657 | /*! |
1647 | Grabs the physical keyboard keys, e.g. the application's launching | 1658 | Grabs the physical keyboard keys, e.g. the application's launching |
1648 | keys. Instead of launching applications when these keys are pressed | 1659 | keys. Instead of launching applications when these keys are pressed |
1649 | the signals emitted are sent to this application instead. Some games | 1660 | the signals emitted are sent to this application instead. Some games |
1650 | programs take over the launch keys in this way to make interaction | 1661 | programs take over the launch keys in this way to make interaction |
1651 | easier. | 1662 | easier. |
1652 | 1663 | ||
1653 | \sa ungrabKeyboard() | 1664 | \sa ungrabKeyboard() |
1654 | */ | 1665 | */ |
1655 | void QPEApplication::grabKeyboard() | 1666 | void QPEApplication::grabKeyboard() |
1656 | { | 1667 | { |
1657 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1668 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1658 | if ( qApp->type() == QApplication::GuiServer ) | 1669 | if ( qApp->type() == QApplication::GuiServer ) |