author | zecke <zecke> | 2004-09-21 18:56:53 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-21 18:56:53 (UTC) |
commit | 1b6a3549317fd895965f0ac22d08e640b94eb741 (patch) (unidiff) | |
tree | 9898c5238c2f76d2a5af5afa913eb141bd0d37b2 | |
parent | 95b81f3c2c9ae5f48f9aeca4dafea9400f9bb3f0 (diff) | |
download | opie-1b6a3549317fd895965f0ac22d08e640b94eb741.zip opie-1b6a3549317fd895965f0ac22d08e640b94eb741.tar.gz opie-1b6a3549317fd895965f0ac22d08e640b94eb741.tar.bz2 |
SIMpad:
-Update all Widgets if we suspended the device. We implement
it by iterating over QApplication::allWidgets and calling
QWidget::update(). This approach should be more reliable
than the system and echo hack
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 30 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.h | 2 |
2 files changed, 23 insertions, 9 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index 4ae3c4f..ebf0cbb 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -29,16 +29,17 @@ | |||
29 | 29 | ||
30 | #include "odevice_simpad.h" | 30 | #include "odevice_simpad.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | #include <qwidgetlist.h> | ||
37 | 38 | ||
38 | /* OPIE */ | 39 | /* OPIE */ |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 42 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
43 | #include <opie2/okeyfilter.h> | 44 | #include <opie2/okeyfilter.h> |
44 | 45 | ||
@@ -310,33 +311,27 @@ void SIMpad::playAlarmSound() | |||
310 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); | 311 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); |
311 | snd. play(); | 312 | snd. play(); |
312 | #endif | 313 | #endif |
313 | } | 314 | } |
314 | 315 | ||
315 | 316 | ||
316 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 317 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
317 | { | 318 | { |
318 | qDebug( "ODevice for SIMpad: suspend()" ); | ||
319 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 319 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
320 | return false; | 320 | return false; |
321 | 321 | ||
322 | /* | ||
323 | * we need to save the screen content | ||
324 | * then go to suspend using ODevice::suspend | ||
325 | * and finally restore the screen content | ||
326 | */ | ||
327 | (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); | ||
328 | bool res = ODevice::suspend(); | 322 | bool res = ODevice::suspend(); |
329 | 323 | ||
330 | /* | 324 | /* |
331 | * restore | 325 | * restore the screen content if we really |
326 | * supended the device | ||
332 | */ | 327 | */ |
333 | if ( res ) | 328 | if ( res ) |
334 | ::system( "cat /tmp/.buffer > /dev/fb/0" ); | 329 | updateAllWidgets(); |
335 | 330 | ||
336 | return res; | 331 | return res; |
337 | } | 332 | } |
338 | 333 | ||
339 | bool SIMpad::setDisplayStatus ( bool on ) | 334 | bool SIMpad::setDisplayStatus ( bool on ) |
340 | { | 335 | { |
341 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 336 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
342 | 337 | ||
@@ -364,8 +359,25 @@ bool SIMpad::setDisplayBrightness ( int bright ) | |||
364 | } | 359 | } |
365 | 360 | ||
366 | 361 | ||
367 | int SIMpad::displayBrightnessResolution() const | 362 | int SIMpad::displayBrightnessResolution() const |
368 | { | 363 | { |
369 | return 255; // All SIMpad models share the same display | 364 | return 255; // All SIMpad models share the same display |
370 | } | 365 | } |
371 | 366 | ||
367 | |||
368 | /* | ||
369 | * The MQ200 DRAM content is lost during suspend | ||
370 | * so we will just repaint every widget on resume | ||
371 | */ | ||
372 | void SIMpad::updateAllWidgets() { | ||
373 | QWidgetList *list = QApplication::allWidgets(); | ||
374 | QWidgetListIt it( *list ); | ||
375 | QWidget *wid; | ||
376 | |||
377 | while ((wid=it.current()) != 0 ) { | ||
378 | wid->update(); | ||
379 | ++it; | ||
380 | } | ||
381 | |||
382 | delete list; | ||
383 | } | ||
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h index dbcbbb4..c25b911 100644 --- a/libopie2/opiecore/device/odevice_simpad.h +++ b/libopie2/opiecore/device/odevice_simpad.h | |||
@@ -60,16 +60,18 @@ class SIMpad : public ODevice | |||
60 | virtual bool setLedState( OLed led, OLedState st ); | 60 | virtual bool setLedState( OLed led, OLedState st ); |
61 | 61 | ||
62 | protected: | 62 | protected: |
63 | virtual void timerEvent( QTimerEvent *te ); | 63 | virtual void timerEvent( QTimerEvent *te ); |
64 | 64 | ||
65 | int m_power_timer; | 65 | int m_power_timer; |
66 | 66 | ||
67 | OLedState m_leds [2]; | 67 | OLedState m_leds [2]; |
68 | private: | ||
69 | static void updateAllWidgets(); | ||
68 | }; | 70 | }; |
69 | 71 | ||
70 | struct s_button { | 72 | struct s_button { |
71 | uint model; | 73 | uint model; |
72 | Qt::Key code; | 74 | Qt::Key code; |
73 | char *utext; | 75 | char *utext; |
74 | char *pix; | 76 | char *pix; |
75 | char *fpressedservice; | 77 | char *fpressedservice; |