author | zecke <zecke> | 2003-09-20 12:42:21 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-09-20 12:42:21 (UTC) |
commit | af02302ec3615007e34cedfb8d91dd3a55832fbb (patch) (unidiff) | |
tree | 01fcb010245fb7fcba29389f128b3e652b4df9e7 | |
parent | 0468cfef459d613ae0a32a3fa03e67726d19f6e9 (diff) | |
download | opie-af02302ec3615007e34cedfb8d91dd3a55832fbb.zip opie-af02302ec3615007e34cedfb8d91dd3a55832fbb.tar.gz opie-af02302ec3615007e34cedfb8d91dd3a55832fbb.tar.bz2 |
Fix double suspend on key input
ServerApp proxied the power() signal from KeyFilter and we've
connected togglePower() twice to it. We only need to connect
to the ServerApp power signal and not to keyfilter because we emit
power() from ServerApp on QCOP
-rw-r--r-- | core/launcher/serverapp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index 28316a4..69e083d 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -240,193 +240,193 @@ bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepe | |||
240 | 240 | ||
241 | if ( keycode == Key_NumLock ) | 241 | if ( keycode == Key_NumLock ) |
242 | if ( press ) emit numLockStateToggle(); | 242 | if ( press ) emit numLockStateToggle(); |
243 | 243 | ||
244 | if ( keycode == Key_CapsLock ) | 244 | if ( keycode == Key_CapsLock ) |
245 | if ( press ) emit capsLockStateToggle(); | 245 | if ( press ) emit capsLockStateToggle(); |
246 | 246 | ||
247 | if ( serverApp ) | 247 | if ( serverApp ) |
248 | serverApp->keyClick(keycode,press,autoRepeat); | 248 | serverApp->keyClick(keycode,press,autoRepeat); |
249 | 249 | ||
250 | return FALSE; | 250 | return FALSE; |
251 | } | 251 | } |
252 | 252 | ||
253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; | 253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; |
254 | 254 | ||
255 | #if defined(QPE_HAVE_MEMALERTER) | 255 | #if defined(QPE_HAVE_MEMALERTER) |
256 | QPE_MEMALERTER_IMPL | 256 | QPE_MEMALERTER_IMPL |
257 | #endif | 257 | #endif |
258 | 258 | ||
259 | 259 | ||
260 | 260 | ||
261 | //--------------------------------------------------------------------------- | 261 | //--------------------------------------------------------------------------- |
262 | 262 | ||
263 | bool ServerApplication::doRestart = FALSE; | 263 | bool ServerApplication::doRestart = FALSE; |
264 | bool ServerApplication::allowRestart = TRUE; | 264 | bool ServerApplication::allowRestart = TRUE; |
265 | 265 | ||
266 | void ServerApplication::switchLCD( bool on ) { | 266 | void ServerApplication::switchLCD( bool on ) { |
267 | if ( !qApp ) | 267 | if ( !qApp ) |
268 | return; | 268 | return; |
269 | 269 | ||
270 | ServerApplication *dapp = ServerApplication::me() ; | 270 | ServerApplication *dapp = ServerApplication::me() ; |
271 | 271 | ||
272 | if ( !dapp-> m_screensaver ) | 272 | if ( !dapp-> m_screensaver ) |
273 | return; | 273 | return; |
274 | 274 | ||
275 | if ( on ) { | 275 | if ( on ) { |
276 | dapp-> m_screensaver-> setDisplayState ( true ); | 276 | dapp-> m_screensaver-> setDisplayState ( true ); |
277 | dapp-> m_screensaver-> setBacklight ( -3 ); | 277 | dapp-> m_screensaver-> setBacklight ( -3 ); |
278 | }else | 278 | }else |
279 | dapp-> m_screensaver-> setDisplayState ( false ); | 279 | dapp-> m_screensaver-> setDisplayState ( false ); |
280 | 280 | ||
281 | 281 | ||
282 | } | 282 | } |
283 | 283 | ||
284 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | 284 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) |
285 | : QPEApplication( argc, argv, t ) | 285 | : QPEApplication( argc, argv, t ) |
286 | { | 286 | { |
287 | 287 | ||
288 | 288 | ||
289 | // We know we'll have lots of cached pixmaps due to App/DocLnks | 289 | // We know we'll have lots of cached pixmaps due to App/DocLnks |
290 | QPixmapCache::setCacheLimit(512); | 290 | QPixmapCache::setCacheLimit(512); |
291 | 291 | ||
292 | m_ps = new PowerStatus; | 292 | m_ps = new PowerStatus; |
293 | m_ps_last = new PowerStatus; | 293 | m_ps_last = new PowerStatus; |
294 | pa = new DesktopPowerAlerter( 0 ); | 294 | pa = new DesktopPowerAlerter( 0 ); |
295 | 295 | ||
296 | m_apm_timer = new QTimer( this ); | 296 | m_apm_timer = new QTimer( this ); |
297 | connect(m_apm_timer, SIGNAL( timeout() ), | 297 | connect(m_apm_timer, SIGNAL( timeout() ), |
298 | this, SLOT( apmTimeout() ) ); | 298 | this, SLOT( apmTimeout() ) ); |
299 | 299 | ||
300 | reloadPowerWarnSettings(); | 300 | reloadPowerWarnSettings(); |
301 | 301 | ||
302 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 302 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
303 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | 303 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), |
304 | this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); | 304 | this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); |
305 | 305 | ||
306 | channel = new QCopChannel("QPE/Launcher", this ); | 306 | channel = new QCopChannel("QPE/Launcher", this ); |
307 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | 307 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), |
308 | this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); | 308 | this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); |
309 | 309 | ||
310 | m_screensaver = new OpieScreenSaver(); | 310 | m_screensaver = new OpieScreenSaver(); |
311 | m_screensaver->setInterval( -1 ); | 311 | m_screensaver->setInterval( -1 ); |
312 | QWSServer::setScreenSaver( m_screensaver ); | 312 | QWSServer::setScreenSaver( m_screensaver ); |
313 | 313 | ||
314 | connect( qApp, SIGNAL( volumeChanged( bool ) ), | 314 | connect( qApp, SIGNAL( volumeChanged( bool ) ), |
315 | this, SLOT( rereadVolumes() ) ); | 315 | this, SLOT( rereadVolumes() ) ); |
316 | 316 | ||
317 | 317 | ||
318 | /* ### PluginLoader libqtopia SafeMode */ | 318 | /* ### PluginLoader libqtopia SafeMode */ |
319 | #if 0 | 319 | #if 0 |
320 | if ( PluginLoader::inSafeMode() ) | 320 | if ( PluginLoader::inSafeMode() ) |
321 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); | 321 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); |
322 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); | 322 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); |
323 | #endif | 323 | #endif |
324 | 324 | ||
325 | kf = new KeyFilter(this); | 325 | kf = new KeyFilter(this); |
326 | 326 | ||
327 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); | 327 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); |
328 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); | 328 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); |
329 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); | 329 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); |
330 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); | 330 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); |
331 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); | 331 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); |
332 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); | 332 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); |
333 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), | 333 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), |
334 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); | 334 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); |
335 | 335 | ||
336 | connect( kf, SIGNAL(power()), this, SLOT(togglePower()) ); | 336 | |
337 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); | 337 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); |
338 | 338 | ||
339 | connect( this, SIGNAL(power() ), | 339 | connect( this, SIGNAL(power() ), |
340 | SLOT(togglePower() ) ); | 340 | SLOT(togglePower() ) ); |
341 | 341 | ||
342 | rereadVolumes(); | 342 | rereadVolumes(); |
343 | 343 | ||
344 | serverApp = this; | 344 | serverApp = this; |
345 | 345 | ||
346 | apmTimeout(); | 346 | apmTimeout(); |
347 | grabKeyboard(); | 347 | grabKeyboard(); |
348 | 348 | ||
349 | /* make sure the event filter is installed */ | 349 | /* make sure the event filter is installed */ |
350 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); | 350 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | ServerApplication::~ServerApplication() | 354 | ServerApplication::~ServerApplication() |
355 | { | 355 | { |
356 | ungrabKeyboard(); | 356 | ungrabKeyboard(); |
357 | 357 | ||
358 | 358 | ||
359 | delete pa; | 359 | delete pa; |
360 | delete m_ps; | 360 | delete m_ps; |
361 | delete m_ps_last; | 361 | delete m_ps_last; |
362 | } | 362 | } |
363 | 363 | ||
364 | void ServerApplication::apmTimeout() { | 364 | void ServerApplication::apmTimeout() { |
365 | serverApp-> checkMemory( ); // in case no events are generated | 365 | serverApp-> checkMemory( ); // in case no events are generated |
366 | *m_ps_last = *m_ps; | 366 | *m_ps_last = *m_ps; |
367 | *m_ps = PowerStatusManager::readStatus(); | 367 | *m_ps = PowerStatusManager::readStatus(); |
368 | 368 | ||
369 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) | 369 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) |
370 | m_screensaver-> powerStatusChanged( *m_ps ); | 370 | m_screensaver-> powerStatusChanged( *m_ps ); |
371 | 371 | ||
372 | if ( m_ps->acStatus() == PowerStatus::Online ) | 372 | if ( m_ps->acStatus() == PowerStatus::Online ) |
373 | return; | 373 | return; |
374 | 374 | ||
375 | int bat = m_ps-> batteryPercentRemaining(); | 375 | int bat = m_ps-> batteryPercentRemaining(); |
376 | 376 | ||
377 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { | 377 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { |
378 | if ( bat <= m_powerCritical ) | 378 | if ( bat <= m_powerCritical ) |
379 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); | 379 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); |
380 | else if ( bat <= m_powerVeryLow ) | 380 | else if ( bat <= m_powerVeryLow ) |
381 | pa->alert( tr( "Battery is running very low. "), 2 ); | 381 | pa->alert( tr( "Battery is running very low. "), 2 ); |
382 | } | 382 | } |
383 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) | 383 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) |
384 | pa->alert( tr("The Back-up battery is very low.\nPlease charge the back-up battery." ), 2); | 384 | pa->alert( tr("The Back-up battery is very low.\nPlease charge the back-up battery." ), 2); |
385 | 385 | ||
386 | } | 386 | } |
387 | 387 | ||
388 | void ServerApplication::systemMessage( const QCString& msg, | 388 | void ServerApplication::systemMessage( const QCString& msg, |
389 | const QByteArray& data ) { | 389 | const QByteArray& data ) { |
390 | QDataStream stream ( data, IO_ReadOnly ); | 390 | QDataStream stream ( data, IO_ReadOnly ); |
391 | 391 | ||
392 | if ( msg == "setScreenSaverInterval(int)" ) { | 392 | if ( msg == "setScreenSaverInterval(int)" ) { |
393 | int time; | 393 | int time; |
394 | stream >> time; | 394 | stream >> time; |
395 | m_screensaver-> setInterval( time ); | 395 | m_screensaver-> setInterval( time ); |
396 | } | 396 | } |
397 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 397 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
398 | int t1, t2, t3; | 398 | int t1, t2, t3; |
399 | stream >> t1 >> t2 >> t3; | 399 | stream >> t1 >> t2 >> t3; |
400 | m_screensaver-> setIntervals( t1, t2, t3 ); | 400 | m_screensaver-> setIntervals( t1, t2, t3 ); |
401 | } | 401 | } |
402 | else if ( msg == "setBacklight(int)" ) { | 402 | else if ( msg == "setBacklight(int)" ) { |
403 | int bright; | 403 | int bright; |
404 | stream >> bright; | 404 | stream >> bright; |
405 | m_screensaver-> setBacklight( bright ); | 405 | m_screensaver-> setBacklight( bright ); |
406 | } | 406 | } |
407 | else if ( msg == "setScreenSaverMode(int)" ) { | 407 | else if ( msg == "setScreenSaverMode(int)" ) { |
408 | int mode; | 408 | int mode; |
409 | stream >> mode; | 409 | stream >> mode; |
410 | m_screensaver-> setMode ( mode ); | 410 | m_screensaver-> setMode ( mode ); |
411 | } | 411 | } |
412 | else if ( msg == "reloadPowerWarnSettings()" ) { | 412 | else if ( msg == "reloadPowerWarnSettings()" ) { |
413 | reloadPowerWarnSettings(); | 413 | reloadPowerWarnSettings(); |
414 | } | 414 | } |
415 | else if ( msg == "setDisplayState(int)" ) { | 415 | else if ( msg == "setDisplayState(int)" ) { |
416 | int state; | 416 | int state; |
417 | stream >> state; | 417 | stream >> state; |
418 | m_screensaver-> setDisplayState ( state != 0 ); | 418 | m_screensaver-> setDisplayState ( state != 0 ); |
419 | } | 419 | } |
420 | else if ( msg == "suspend()" ) { | 420 | else if ( msg == "suspend()" ) { |
421 | emit power(); | 421 | emit power(); |
422 | } | 422 | } |
423 | else if ( msg == "sendBusinessCard()" ) { | 423 | else if ( msg == "sendBusinessCard()" ) { |
424 | QString card = ::getenv ( "HOME" ); | 424 | QString card = ::getenv ( "HOME" ); |
425 | card += "/Applications/addressbook/businesscard.vcf"; | 425 | card += "/Applications/addressbook/businesscard.vcf"; |
426 | 426 | ||
427 | if ( QFile::exists( card ) ) { | 427 | if ( QFile::exists( card ) ) { |
428 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | 428 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); |
429 | QString mimetype = "text/x-vCard"; | 429 | QString mimetype = "text/x-vCard"; |
430 | e << tr( "business card" ) << card << mimetype; | 430 | e << tr( "business card" ) << card << mimetype; |
431 | } | 431 | } |
432 | } | 432 | } |