summaryrefslogtreecommitdiff
path: root/core
authorjeremy <jeremy>2002-02-15 21:12:53 (UTC)
committer jeremy <jeremy>2002-02-15 21:12:53 (UTC)
commitb0768575b7bc1e4fe477d37a49cccc7e3d92bf85 (patch) (unidiff)
tree4c66c26f74ec710204f3f2e4303a6d6d8968c6a7 /core
parentb15950bcf97b5590d37373ec2beedab80e40ded6 (diff)
downloadopie-b0768575b7bc1e4fe477d37a49cccc7e3d92bf85.zip
opie-b0768575b7bc1e4fe477d37a49cccc7e3d92bf85.tar.gz
opie-b0768575b7bc1e4fe477d37a49cccc7e3d92bf85.tar.bz2
Added new QCop support. Desktop now listens on channel QPE/Desktop to the
keyRegister(int key, QString channel, QString message) message. What this will do is allow an app to reiceve keyboard input for a particular key no matter if they have focus or not.
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp132
-rw-r--r--core/launcher/desktop.h4
-rw-r--r--core/launcher/opie-taskbar.control4
3 files changed, 100 insertions, 40 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index d39af25..ce99bad 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -47,9 +47,31 @@
47#include <qtimer.h> 47#include <qtimer.h>
48#include <qwindowsystem_qws.h> 48#include <qwindowsystem_qws.h>
49 49
50#include <qvaluelist.h>
51
50#include <stdlib.h> 52#include <stdlib.h>
51#include <unistd.h> 53#include <unistd.h>
52 54
55
56class QCopKeyRegister
57{
58public:
59 QCopKeyRegister() : keyCode(0) { }
60 QCopKeyRegister(int k, const QString &c, const QString &m)
61 : keyCode(k), channel(c), message(m) { }
62
63 int getKeyCode() const { return keyCode; }
64 QString getChannel() const { return channel; }
65 QString getMessage() const { return message; }
66
67private:
68 int keyCode;
69 QString channel, message;
70};
71
72typedef QValueList<QCopKeyRegister> KeyRegisterList;
73KeyRegisterList keyRegisterList;
74
53static Desktop* qpedesktop = 0; 75static Desktop* qpedesktop = 0;
54static int loggedin=0; 76static int loggedin=0;
55static void login(bool at_poweron) 77static void login(bool at_poweron)
@@ -123,6 +145,10 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type t )
123 t->start( 10000 ); 145 t->start( 10000 );
124 ps = new PowerStatus; 146 ps = new PowerStatus;
125 pa = new DesktopPowerAlerter( 0 ); 147 pa = new DesktopPowerAlerter( 0 );
148
149 channel = new QCopChannel( "QPE/Desktop", this );
150 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
151 this, SLOT(receive(const QCString&, const QByteArray&)) );
126} 152}
127 153
128 154
@@ -132,6 +158,22 @@ DesktopApplication::~DesktopApplication()
132 delete pa; 158 delete pa;
133} 159}
134 160
161void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
162{
163 QDataStream stream( data, IO_ReadOnly );
164 if (msg == "keyRegister(int key, QString channel, QString message)")
165 {
166 int k;
167 QString c, m;
168
169 stream >> k;
170 stream >> c;
171 stream >> m;
172
173 qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m);
174 keyRegisterList.append(QCopKeyRegister(k,c,m));
175 }
176}
135 177
136enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 178enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
137 179
@@ -141,82 +183,96 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
141 qpedesktop->checkMemory(); 183 qpedesktop->checkMemory();
142 184
143 if ( e->type == QWSEvent::Key ) { 185 if ( e->type == QWSEvent::Key ) {
144 QWSKeyEvent *ke = (QWSKeyEvent *)e; 186 QWSKeyEvent *ke = (QWSKeyEvent *)e;
145 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 187 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
146 return TRUE; 188 return TRUE;
147 bool press = ke->simpleData.is_press; 189 bool press = ke->simpleData.is_press;
148 if ( !keyboardGrabbed() ) { 190
191 KeyRegisterList::Iterator it;
192 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
193 {
194 if ((*it).getKeyCode() == ke->simpleData.keycode)
195 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
196 }
197
198 if ( !keyboardGrabbed() ) {
149 if ( ke->simpleData.keycode == Key_F9 ) { 199 if ( ke->simpleData.keycode == Key_F9 ) {
150 if ( press ) emit datebook(); 200 if ( press ) emit datebook();
151 return TRUE; 201 return TRUE;
152 } 202 }
153 if ( ke->simpleData.keycode == Key_F10 ) { 203 if ( ke->simpleData.keycode == Key_F10 ) {
154 if ( !press && cardSendTimer ) { 204 if ( !press && cardSendTimer ) {
155 emit contacts(); 205 emit contacts();
156 delete cardSendTimer; 206 delete cardSendTimer;
157 } else if ( press ) { 207 } else if ( press ) {
158 cardSendTimer = new QTimer(); 208 cardSendTimer = new QTimer();
159 cardSendTimer->start( 2000, TRUE ); 209 cardSendTimer->start( 2000, TRUE );
160 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 210 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
161 } 211 }
162 return TRUE; 212 return TRUE;
163 } 213 }
164 /* menu key now opens application menu/toolbar 214 /* menu key now opens application menu/toolbar
165 if ( ke->simpleData.keycode == Key_F11 ) { 215 if ( ke->simpleData.keycode == Key_F11 ) {
166 if ( press ) emit menu(); 216 if ( press ) emit menu();
167 return TRUE; 217 return TRUE;
168 } 218 }
169 */ 219 */
170 if ( ke->simpleData.keycode == Key_F12 ) { 220 if ( ke->simpleData.keycode == Key_F12 ) {
171 while( activePopupWidget() ) 221 while( activePopupWidget() )
172 activePopupWidget()->close(); 222 activePopupWidget()->close();
173 if ( press ) emit launch(); 223 if ( press ) emit launch();
174 return TRUE; 224 return TRUE;
175 } 225 }
176 if ( ke->simpleData.keycode == Key_F13 ) { 226 if ( ke->simpleData.keycode == Key_F13 ) {
177 if ( press ) emit email(); 227 if ( press ) emit email();
178 return TRUE; 228 return TRUE;
179 } 229 }
180 } 230 }
181 if ( ke->simpleData.keycode == Key_F34 ) { 231 /*
232 if ( ke->simpleData.keycode == 4096 ) {
233 QCopEnvelope e("QPE/VMemo", "toggleRecord()");
234 return TRUE;
235 }
236 */
237 if ( ke->simpleData.keycode == Key_F34 ) {
182 if ( press ) emit power(); 238 if ( press ) emit power();
183 return TRUE; 239 return TRUE;
184 } 240 }
185 if ( ke->simpleData.keycode == Key_F35 ) { 241 if ( ke->simpleData.keycode == Key_F35 ) {
186 if ( press ) emit backlight(); 242 if ( press ) emit backlight();
187 return TRUE; 243 return TRUE;
188 } 244 }
189 if ( ke->simpleData.keycode == Key_F32 ) { 245 if ( ke->simpleData.keycode == Key_F32 ) {
190 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 246 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
191 return TRUE; 247 return TRUE;
192 } 248 }
193 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 249 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
194 if ( press ) emit symbol(); 250 if ( press ) emit symbol();
195 return TRUE; 251 return TRUE;
196 } 252 }
197 if ( ke->simpleData.keycode == Key_NumLock ) { 253 if ( ke->simpleData.keycode == Key_NumLock ) {
198 if ( press ) emit numLockStateToggle(); 254 if ( press ) emit numLockStateToggle();
199 } 255 }
200 if ( ke->simpleData.keycode == Key_CapsLock ) { 256 if ( ke->simpleData.keycode == Key_CapsLock ) {
201 if ( press ) emit capsLockStateToggle(); 257 if ( press ) emit capsLockStateToggle();
202 } 258 }
203 if ( press ) 259 if ( press )
204 qpedesktop->keyClick(); 260 qpedesktop->keyClick();
205 } else { 261 } else {
206 if ( e->type == QWSEvent::Mouse ) { 262 if ( e->type == QWSEvent::Mouse ) {
207 QWSMouseEvent *me = (QWSMouseEvent *)e; 263 QWSMouseEvent *me = (QWSMouseEvent *)e;
208 static bool up = TRUE; 264 static bool up = TRUE;
209 if ( me->simpleData.state&LeftButton ) { 265 if ( me->simpleData.state&LeftButton ) {
210 if ( up ) { 266 if ( up ) {
211 up = FALSE; 267 up = FALSE;
212 qpedesktop->screenClick(); 268 qpedesktop->screenClick();
213 } 269 }
214 } else { 270 } else {
215 up = TRUE; 271 up = TRUE;
216 } 272 }
217 } 273 }
218 } 274 }
219 275
220 return QPEApplication::qwsEventFilter( e ); 276 return QPEApplication::qwsEventFilter( e );
221} 277}
222#endif 278#endif
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index dfdbeab..f0a7cba 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -63,6 +63,9 @@ protected:
63 void shutdown(); 63 void shutdown();
64 void restart(); 64 void restart();
65 65
66public slots:
67 void receive( const QCString &msg, const QByteArray &data );
68
66protected slots: 69protected slots:
67 void shutdown(ShutdownImpl::Type); 70 void shutdown(ShutdownImpl::Type);
68 void psTimeout(); 71 void psTimeout();
@@ -71,6 +74,7 @@ private:
71 DesktopPowerAlerter *pa; 74 DesktopPowerAlerter *pa;
72 PowerStatus *ps; 75 PowerStatus *ps;
73 QTimer *cardSendTimer; 76 QTimer *cardSendTimer;
77 QCopChannel *channel;
74}; 78};
75 79
76 80
diff --git a/core/launcher/opie-taskbar.control b/core/launcher/opie-taskbar.control
index 53daa82..3db0480 100644
--- a/core/launcher/opie-taskbar.control
+++ b/core/launcher/opie-taskbar.control
@@ -3,7 +3,7 @@ Priority: required
3Section: opie/system 3Section: opie/system
4Maintainer: Warwick Allison <warwick@trolltech.com> 4Maintainer: Warwick Allison <warwick@trolltech.com>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION.1
7Depends: qt-embedded (>=$QTE_VERSION) 7Depends: qt-embedded (>=$QTE_VERSION)
8Description: Launcher for Opie 8Description: Launcher for Opie
9 The "finder" or "explorer", or whatever you want to call it. 9 The "finder" or "explorer", or whatever you want to call it. \ No newline at end of file