summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp30
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h2
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
@@ -13,48 +13,49 @@
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_simpad.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
+#include <qwidgetlist.h>
/* OPIE */
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/sound.h>
#include <qpe/qcopenvelope_qws.h>
#include <opie2/okeyfilter.h>
/* STD */
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#ifndef QT_NO_SOUND
#include <linux/soundcard.h>
#endif
using namespace Opie::Core;
using namespace Opie::Core::Internal;
struct s_button simpad_buttons [] = {
@@ -294,78 +295,89 @@ void SIMpad::timerEvent ( QTimerEvent * )
{
killTimer ( m_power_timer );
m_power_timer = 0;
QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
}
void SIMpad::playAlarmSound()
{
#ifndef QT_NO_SOUND
static Sound snd ( "alarm" );
if(!snd.isFinished())
return;
/* save as the Sound is static! */
changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
snd. play();
#endif
}
bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
{
- qDebug( "ODevice for SIMpad: suspend()" );
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
- /*
- * we need to save the screen content
- * then go to suspend using ODevice::suspend
- * and finally restore the screen content
- */
- (void)::system( "cat /dev/fb/0 > /tmp/.buffer" );
bool res = ODevice::suspend();
/*
- * restore
+ * restore the screen content if we really
+ * supended the device
*/
if ( res )
- ::system( "cat /tmp/.buffer > /dev/fb/0" );
+ updateAllWidgets();
return res;
}
bool SIMpad::setDisplayStatus ( bool on )
{
qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
return setCS3Bit(on, SIMPAD_DISPLAY_ON);
}
bool SIMpad::setDisplayBrightness ( int bright )
{
qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
bool res = false;
int fd;
if ( bright > 255 )
bright = 255;
if ( bright < 1 )
bright = 0;
if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
QCString str = QFile::encodeName( QString::number(bright));
res = ( ::write(fd, str, str.length()) != -1 );
::close ( fd );
}
return res;
}
int SIMpad::displayBrightnessResolution() const
{
return 255; // All SIMpad models share the same display
}
+
+/*
+ * The MQ200 DRAM content is lost during suspend
+ * so we will just repaint every widget on resume
+ */
+void SIMpad::updateAllWidgets() {
+ QWidgetList *list = QApplication::allWidgets();
+ QWidgetListIt it( *list );
+ QWidget *wid;
+
+ while ((wid=it.current()) != 0 ) {
+ wid->update();
+ ++it;
+ }
+
+ delete list;
+}
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
@@ -44,42 +44,44 @@ class SIMpad : public ODevice
protected:
virtual void init(const QString&);
virtual void initButtons();
public:
virtual bool suspend();
virtual bool setDisplayStatus( bool on );
virtual bool setDisplayBrightness( int b );
virtual int displayBrightnessResolution() const;
virtual void playAlarmSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList( OLed led ) const;
virtual OLedState ledState( OLed led ) const;
virtual bool setLedState( OLed led, OLedState st );
protected:
virtual void timerEvent( QTimerEvent *te );
int m_power_timer;
OLedState m_leds [2];
+private:
+ static void updateAllWidgets();
};
struct s_button {
uint model;
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
};
}
}
}
#endif