author | alwin <alwin> | 2005-03-15 11:24:43 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-15 11:24:43 (UTC) |
commit | 90d940ea8244140b25552bb8a28eacb7d3db01e8 (patch) (unidiff) | |
tree | 5de47f91c534f8c034f101ee6344af104d4cd31d | |
parent | 81989dcd316065c2e72ecf43fc2cb8bfbf82763f (diff) | |
download | opie-90d940ea8244140b25552bb8a28eacb7d3db01e8.zip opie-90d940ea8244140b25552bb8a28eacb7d3db01e8.tar.gz opie-90d940ea8244140b25552bb8a28eacb7d3db01e8.tar.bz2 |
setup a workaround for missing autorepeat flag on specialbuttons.
eg, keyfilter of serverapp stores the last pressed button itself and checks
against holdtime and releases itself. on c7x0/c8x0 it works with 2.6 kernel
cause keys are repeated without this flag - on 2.4 kernel I don't know
what happen (may that keys are not repeated)
-rw-r--r-- | core/launcher/serverapp.cpp | 22 | ||||
-rw-r--r-- | core/launcher/serverapp.h | 2 |
2 files changed, 18 insertions, 6 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index 75d4ac1..6fe0479 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -99,173 +99,185 @@ bool QCopKeyRegister::send() | |||
99 | /* | 99 | /* |
100 | Priority is number of alerts that are needed to pop up | 100 | Priority is number of alerts that are needed to pop up |
101 | alert. | 101 | alert. |
102 | */ | 102 | */ |
103 | class DesktopPowerAlerter : public QMessageBox | 103 | class DesktopPowerAlerter : public QMessageBox |
104 | { | 104 | { |
105 | Q_OBJECT | 105 | Q_OBJECT |
106 | public: | 106 | public: |
107 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 107 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
108 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), | 108 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), |
109 | QMessageBox::Critical, | 109 | QMessageBox::Critical, |
110 | QMessageBox::Ok | QMessageBox::Default, | 110 | QMessageBox::Ok | QMessageBox::Default, |
111 | QMessageBox::NoButton, QMessageBox::NoButton, | 111 | QMessageBox::NoButton, QMessageBox::NoButton, |
112 | parent, name, FALSE ) | 112 | parent, name, FALSE ) |
113 | { | 113 | { |
114 | currentPriority = INT_MAX; | 114 | currentPriority = INT_MAX; |
115 | alertCount = 0; | 115 | alertCount = 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | void alert( const QString &text, int priority ); | 118 | void alert( const QString &text, int priority ); |
119 | void hideEvent( QHideEvent * ); | 119 | void hideEvent( QHideEvent * ); |
120 | private: | 120 | private: |
121 | int currentPriority; | 121 | int currentPriority; |
122 | int alertCount; | 122 | int alertCount; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 125 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
126 | { | 126 | { |
127 | alertCount++; | 127 | alertCount++; |
128 | if ( alertCount < priority ) | 128 | if ( alertCount < priority ) |
129 | return; | 129 | return; |
130 | if ( priority > currentPriority ) | 130 | if ( priority > currentPriority ) |
131 | return; | 131 | return; |
132 | currentPriority = priority; | 132 | currentPriority = priority; |
133 | setText( text ); | 133 | setText( text ); |
134 | show(); | 134 | show(); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 138 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
139 | { | 139 | { |
140 | QMessageBox::hideEvent( e ); | 140 | QMessageBox::hideEvent( e ); |
141 | alertCount = 0; | 141 | alertCount = 0; |
142 | currentPriority = INT_MAX; | 142 | currentPriority = INT_MAX; |
143 | } | 143 | } |
144 | 144 | ||
145 | //--------------------------------------------------------------------------- | 145 | //--------------------------------------------------------------------------- |
146 | 146 | ||
147 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) | 147 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0),firedHeldButton(0) |
148 | { | 148 | { |
149 | /* We don't do this cause it would interfere with ODevice */ | 149 | /* We don't do this cause it would interfere with ODevice */ |
150 | #if 0 | 150 | #if 0 |
151 | qwsServer->setKeyboardFilter(this); | 151 | qwsServer->setKeyboardFilter(this); |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | 154 | ||
155 | void KeyFilter::timerEvent(QTimerEvent* e) | 155 | void KeyFilter::timerEvent(QTimerEvent* e) |
156 | { | 156 | { |
157 | if ( e->timerId() == held_tid ) { | 157 | if ( e->timerId() == held_tid ) { |
158 | killTimer(held_tid); | 158 | killTimer(held_tid); |
159 | // button held | 159 | // button held |
160 | if ( heldButton ) { | 160 | if ( heldButton ) { |
161 | emit activate(heldButton, TRUE); | 161 | emit activate(heldButton, TRUE); |
162 | firedHeldButton = heldButton; | ||
162 | heldButton = 0; | 163 | heldButton = 0; |
163 | } | 164 | } |
164 | held_tid = 0; | 165 | held_tid = 0; |
165 | } | 166 | } |
166 | } | 167 | } |
167 | 168 | ||
168 | void KeyFilter::registerKey( const QCopKeyRegister& key ) | 169 | void KeyFilter::registerKey( const QCopKeyRegister& key ) |
169 | { | 170 | { |
170 | 171 | ||
171 | m_keys.insert( key.keyCode(), key ); | 172 | m_keys.insert( key.keyCode(), key ); |
172 | } | 173 | } |
173 | 174 | ||
174 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) | 175 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) |
175 | { | 176 | { |
176 | m_keys.remove( key.keyCode() ); | 177 | m_keys.remove( key.keyCode() ); |
177 | } | 178 | } |
178 | 179 | ||
179 | bool KeyFilter::keyRegistered( int key ) | 180 | bool KeyFilter::keyRegistered( int key ) |
180 | { | 181 | { |
181 | /* | 182 | /* |
182 | * Check if we've a key registered | 183 | * Check if we've a key registered |
183 | */ | 184 | */ |
184 | if ( !m_keys[key].send()) | 185 | if ( !m_keys[key].send()) |
185 | return false; | 186 | return false; |
186 | else | 187 | else |
187 | return true; | 188 | return true; |
188 | } | 189 | } |
189 | 190 | ||
190 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | 191 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) |
191 | { | 192 | { |
192 | if ( !loggedin | 193 | if ( !loggedin |
193 | // Permitted keys | 194 | // Permitted keys |
194 | && keycode != Key_F34 // power | 195 | && keycode != Key_F34 // power |
195 | && keycode != Key_F30 // select | 196 | && keycode != Key_F30 // select |
196 | && keycode != Key_Enter | 197 | && keycode != Key_Enter |
197 | && keycode != Key_Return | 198 | && keycode != Key_Return |
198 | && keycode != Key_Space | 199 | && keycode != Key_Space |
199 | && keycode != Key_Left | 200 | && keycode != Key_Left |
200 | && keycode != Key_Right | 201 | && keycode != Key_Right |
201 | && keycode != Key_Up | 202 | && keycode != Key_Up |
202 | && keycode != Key_Down ) | 203 | && keycode != Key_Down ) |
203 | return TRUE; | 204 | return TRUE; |
204 | 205 | ||
206 | // odebug << " KeyFilter::checkButtonAction("<<db<<","<<keycode<<","<<press<<","<<autoRepeat<<")"<<oendl; | ||
205 | /* check if it was registered */ | 207 | /* check if it was registered */ |
206 | if (!db ) { | 208 | if (!db ) { |
207 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | 209 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) |
208 | return true; | 210 | return true; |
209 | } else { | 211 | } else { |
210 | |||
211 | // First check to see if DeviceButtonManager knows something about this button: | 212 | // First check to see if DeviceButtonManager knows something about this button: |
212 | const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); | 213 | const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); |
213 | if (button && !autoRepeat) { | 214 | if (button && !autoRepeat) { |
214 | if ( held_tid ) { | 215 | if (firedHeldButton) { |
216 | if (held_tid) { | ||
217 | killTimer(held_tid); | ||
218 | held_tid = 0; | ||
219 | } | ||
220 | if (!press && button == firedHeldButton) { | ||
221 | firedHeldButton = 0; | ||
222 | return TRUE; | ||
223 | } | ||
224 | } else if ( held_tid && heldButton != button) { | ||
215 | killTimer(held_tid); | 225 | killTimer(held_tid); |
216 | held_tid = 0; | 226 | held_tid = 0; |
217 | } | 227 | } |
218 | if ( button->heldAction().isNull() ) { | 228 | if ( button->heldAction().isNull() ) { |
219 | if ( press ) | 229 | if ( press ) |
220 | emit activate(button, FALSE); | 230 | emit activate(button, FALSE); |
221 | } else if ( press ) { | 231 | } else if ( press ) { |
222 | heldButton = button; | 232 | if (heldButton != button) { |
223 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); | 233 | heldButton = button; |
234 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); | ||
235 | } | ||
224 | } else if ( heldButton ) { | 236 | } else if ( heldButton ) { |
225 | heldButton = 0; | 237 | heldButton = 0; |
226 | emit activate(button, FALSE); | 238 | emit activate(button, FALSE); |
227 | } | 239 | } |
228 | QWSServer::screenSaverActivate(FALSE); | 240 | QWSServer::screenSaverActivate(FALSE); |
229 | return TRUE; | 241 | return TRUE; |
230 | } | 242 | } |
231 | return false; | 243 | return false; |
232 | } | 244 | } |
233 | if ( keycode == HardKey_Suspend ) { | 245 | if ( keycode == HardKey_Suspend ) { |
234 | if ( press ) emit power(); | 246 | if ( press ) emit power(); |
235 | return TRUE; | 247 | return TRUE; |
236 | } | 248 | } |
237 | if ( keycode == HardKey_Backlight ) { | 249 | if ( keycode == HardKey_Backlight ) { |
238 | if ( press ) emit backlight(); | 250 | if ( press ) emit backlight(); |
239 | return TRUE; | 251 | return TRUE; |
240 | } | 252 | } |
241 | if ( keycode == Key_F32 ) { | 253 | if ( keycode == Key_F32 ) { |
242 | #ifndef QT_NO_COP | 254 | #ifndef QT_NO_COP |
243 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 255 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
244 | #endif | 256 | #endif |
245 | return TRUE; | 257 | return TRUE; |
246 | } | 258 | } |
247 | if ( keycode == Key_F31 ) { | 259 | if ( keycode == Key_F31 ) { |
248 | if ( press ) emit symbol(); | 260 | if ( press ) emit symbol(); |
249 | QWSServer::screenSaverActivate(FALSE); | 261 | QWSServer::screenSaverActivate(FALSE); |
250 | return TRUE; | 262 | return TRUE; |
251 | } | 263 | } |
252 | 264 | ||
253 | if ( keycode == Key_NumLock ) | 265 | if ( keycode == Key_NumLock ) |
254 | if ( press ) emit numLockStateToggle(); | 266 | if ( press ) emit numLockStateToggle(); |
255 | 267 | ||
256 | if ( keycode == Key_CapsLock ) | 268 | if ( keycode == Key_CapsLock ) |
257 | if ( press ) emit capsLockStateToggle(); | 269 | if ( press ) emit capsLockStateToggle(); |
258 | 270 | ||
259 | if ( serverApp ) | 271 | if ( serverApp ) |
260 | serverApp->keyClick(keycode,press,autoRepeat); | 272 | serverApp->keyClick(keycode,press,autoRepeat); |
261 | 273 | ||
262 | return FALSE; | 274 | return FALSE; |
263 | } | 275 | } |
264 | 276 | ||
265 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; | 277 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; |
266 | 278 | ||
267 | #if defined(QPE_HAVE_MEMALERTER) | 279 | #if defined(QPE_HAVE_MEMALERTER) |
268 | QPE_MEMALERTER_IMPL | 280 | QPE_MEMALERTER_IMPL |
269 | #endif | 281 | #endif |
270 | 282 | ||
271 | 283 | ||
diff --git a/core/launcher/serverapp.h b/core/launcher/serverapp.h index 27be28b..98c5633 100644 --- a/core/launcher/serverapp.h +++ b/core/launcher/serverapp.h | |||
@@ -36,97 +36,97 @@ class DesktopPowerAlerter; | |||
36 | class OpieScreenSaver; | 36 | class OpieScreenSaver; |
37 | namespace Opie { | 37 | namespace Opie { |
38 | namespace Core { | 38 | namespace Core { |
39 | class ODeviceButton; | 39 | class ODeviceButton; |
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | struct QCopKeyRegister { | 43 | struct QCopKeyRegister { |
44 | QCopKeyRegister(); | 44 | QCopKeyRegister(); |
45 | QCopKeyRegister( int k, const QCString&, const QCString& ); | 45 | QCopKeyRegister( int k, const QCString&, const QCString& ); |
46 | int keyCode()const; | 46 | int keyCode()const; |
47 | QCString channel()const; | 47 | QCString channel()const; |
48 | QCString message()const; | 48 | QCString message()const; |
49 | inline bool send(); | 49 | inline bool send(); |
50 | 50 | ||
51 | private: | 51 | private: |
52 | int m_keyCode; | 52 | int m_keyCode; |
53 | QCString m_channel, m_message; | 53 | QCString m_channel, m_message; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | typedef QMap<int, QCopKeyRegister> KeyRegisterList; | 56 | typedef QMap<int, QCopKeyRegister> KeyRegisterList; |
57 | 57 | ||
58 | class KeyFilter : public QObject { | 58 | class KeyFilter : public QObject { |
59 | Q_OBJECT | 59 | Q_OBJECT |
60 | public: | 60 | public: |
61 | KeyFilter(QObject* parent); | 61 | KeyFilter(QObject* parent); |
62 | void registerKey( const QCopKeyRegister& ); | 62 | void registerKey( const QCopKeyRegister& ); |
63 | void unregisterKey( const QCopKeyRegister& ); | 63 | void unregisterKey( const QCopKeyRegister& ); |
64 | bool checkButtonAction( bool, int, int, int ); | 64 | bool checkButtonAction( bool, int, int, int ); |
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | void timerEvent(QTimerEvent*); | 69 | void timerEvent(QTimerEvent*); |
70 | 70 | ||
71 | signals: | 71 | signals: |
72 | void launch(); | 72 | void launch(); |
73 | void power(); | 73 | void power(); |
74 | void backlight(); | 74 | void backlight(); |
75 | void symbol(); | 75 | void symbol(); |
76 | void numLockStateToggle(); | 76 | void numLockStateToggle(); |
77 | void capsLockStateToggle(); | 77 | void capsLockStateToggle(); |
78 | void activate(const Opie::Core::ODeviceButton*,bool); | 78 | void activate(const Opie::Core::ODeviceButton*,bool); |
79 | 79 | ||
80 | 80 | ||
81 | private: | 81 | private: |
82 | bool keyRegistered( int key ); | 82 | bool keyRegistered( int key ); |
83 | int held_tid; | 83 | int held_tid; |
84 | const Opie::Core::ODeviceButton* heldButton; | 84 | const Opie::Core::ODeviceButton* heldButton,*firedHeldButton; |
85 | KeyRegisterList m_keys; | 85 | KeyRegisterList m_keys; |
86 | }; | 86 | }; |
87 | 87 | ||
88 | class ServerApplication : public Opie::Core::OApplication | 88 | class ServerApplication : public Opie::Core::OApplication |
89 | { | 89 | { |
90 | Q_OBJECT | 90 | Q_OBJECT |
91 | public: | 91 | public: |
92 | ServerApplication( int& argc, char **argv, Type t ); | 92 | ServerApplication( int& argc, char **argv, Type t ); |
93 | ~ServerApplication(); | 93 | ~ServerApplication(); |
94 | 94 | ||
95 | static bool doRestart; | 95 | static bool doRestart; |
96 | static bool allowRestart; | 96 | static bool allowRestart; |
97 | static bool screenLocked(); | 97 | static bool screenLocked(); |
98 | static void login(bool at_poweron); | 98 | static void login(bool at_poweron); |
99 | 99 | ||
100 | static bool isStarting(); | 100 | static bool isStarting(); |
101 | 101 | ||
102 | static void switchLCD ( bool on ); // only for togglePower in Desktop | 102 | static void switchLCD ( bool on ); // only for togglePower in Desktop |
103 | static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar | 103 | static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar |
104 | 104 | ||
105 | void restart(); | 105 | void restart(); |
106 | int exec(); | 106 | int exec(); |
107 | 107 | ||
108 | signals: | 108 | signals: |
109 | void menu(); | 109 | void menu(); |
110 | void home(); | 110 | void home(); |
111 | void launch(); | 111 | void launch(); |
112 | void power(); | 112 | void power(); |
113 | void backlight(); | 113 | void backlight(); |
114 | void symbol(); | 114 | void symbol(); |
115 | void numLockStateToggle(); | 115 | void numLockStateToggle(); |
116 | void capsLockStateToggle(); | 116 | void capsLockStateToggle(); |
117 | void prepareForRestart(); | 117 | void prepareForRestart(); |
118 | void activate(const Opie::Core::ODeviceButton*,bool); | 118 | void activate(const Opie::Core::ODeviceButton*,bool); |
119 | 119 | ||
120 | public slots: | 120 | public slots: |
121 | virtual void systemMessage( const QCString& msg, const QByteArray& ); | 121 | virtual void systemMessage( const QCString& msg, const QByteArray& ); |
122 | virtual void launcherMessage( const QCString& msg, const QByteArray& ); | 122 | virtual void launcherMessage( const QCString& msg, const QByteArray& ); |
123 | void rereadVolumes(); | 123 | void rereadVolumes(); |
124 | 124 | ||
125 | protected: | 125 | protected: |
126 | bool eventFilter( QObject*, QEvent* ); | 126 | bool eventFilter( QObject*, QEvent* ); |
127 | #ifdef Q_WS_QWS | 127 | #ifdef Q_WS_QWS |
128 | bool qwsEventFilter( QWSEvent * ); | 128 | bool qwsEventFilter( QWSEvent * ); |
129 | #endif | 129 | #endif |
130 | void shutdown(); | 130 | void shutdown(); |
131 | void checkMemory(); | 131 | void checkMemory(); |
132 | bool recoverMemory(); | 132 | bool recoverMemory(); |