summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/serverapp.cpp22
-rw-r--r--core/launcher/serverapp.h2
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()
/*
Priority is number of alerts that are needed to pop up
alert.
*/
class DesktopPowerAlerter : public QMessageBox
{
Q_OBJECT
public:
DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
: QMessageBox( tr("Battery Status"), tr("Low Battery"),
QMessageBox::Critical,
QMessageBox::Ok | QMessageBox::Default,
QMessageBox::NoButton, QMessageBox::NoButton,
parent, name, FALSE )
{
currentPriority = INT_MAX;
alertCount = 0;
}
void alert( const QString &text, int priority );
void hideEvent( QHideEvent * );
private:
int currentPriority;
int alertCount;
};
void DesktopPowerAlerter::alert( const QString &text, int priority )
{
alertCount++;
if ( alertCount < priority )
return;
if ( priority > currentPriority )
return;
currentPriority = priority;
setText( text );
show();
}
void DesktopPowerAlerter::hideEvent( QHideEvent *e )
{
QMessageBox::hideEvent( e );
alertCount = 0;
currentPriority = INT_MAX;
}
//---------------------------------------------------------------------------
-KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0)
+KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0),firedHeldButton(0)
{
/* We don't do this cause it would interfere with ODevice */
#if 0
qwsServer->setKeyboardFilter(this);
#endif
}
void KeyFilter::timerEvent(QTimerEvent* e)
{
if ( e->timerId() == held_tid ) {
killTimer(held_tid);
// button held
if ( heldButton ) {
emit activate(heldButton, TRUE);
+ firedHeldButton = heldButton;
heldButton = 0;
}
held_tid = 0;
}
}
void KeyFilter::registerKey( const QCopKeyRegister& key )
{
m_keys.insert( key.keyCode(), key );
}
void KeyFilter::unregisterKey( const QCopKeyRegister& key )
{
m_keys.remove( key.keyCode() );
}
bool KeyFilter::keyRegistered( int key )
{
/*
* Check if we've a key registered
*/
if ( !m_keys[key].send())
return false;
else
return true;
}
bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat)
{
if ( !loggedin
// Permitted keys
&& keycode != Key_F34 // power
&& keycode != Key_F30 // select
&& keycode != Key_Enter
&& keycode != Key_Return
&& keycode != Key_Space
&& keycode != Key_Left
&& keycode != Key_Right
&& keycode != Key_Up
&& keycode != Key_Down )
return TRUE;
+// odebug << " KeyFilter::checkButtonAction("<<db<<","<<keycode<<","<<press<<","<<autoRepeat<<")"<<oendl;
/* check if it was registered */
if (!db ) {
if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) )
return true;
} else {
-
// First check to see if DeviceButtonManager knows something about this button:
const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode);
if (button && !autoRepeat) {
- if ( held_tid ) {
+ if (firedHeldButton) {
+ if (held_tid) {
+ killTimer(held_tid);
+ held_tid = 0;
+ }
+ if (!press && button == firedHeldButton) {
+ firedHeldButton = 0;
+ return TRUE;
+ }
+ } else if ( held_tid && heldButton != button) {
killTimer(held_tid);
held_tid = 0;
}
if ( button->heldAction().isNull() ) {
if ( press )
emit activate(button, FALSE);
} else if ( press ) {
- heldButton = button;
- held_tid = startTimer( ODevice::inst ()->buttonHoldTime () );
+ if (heldButton != button) {
+ heldButton = button;
+ held_tid = startTimer( ODevice::inst ()->buttonHoldTime () );
+ }
} else if ( heldButton ) {
heldButton = 0;
emit activate(button, FALSE);
}
QWSServer::screenSaverActivate(FALSE);
return TRUE;
}
return false;
}
if ( keycode == HardKey_Suspend ) {
if ( press ) emit power();
return TRUE;
}
if ( keycode == HardKey_Backlight ) {
if ( press ) emit backlight();
return TRUE;
}
if ( keycode == Key_F32 ) {
#ifndef QT_NO_COP
if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
#endif
return TRUE;
}
if ( keycode == Key_F31 ) {
if ( press ) emit symbol();
QWSServer::screenSaverActivate(FALSE);
return TRUE;
}
if ( keycode == Key_NumLock )
if ( press ) emit numLockStateToggle();
if ( keycode == Key_CapsLock )
if ( press ) emit capsLockStateToggle();
if ( serverApp )
serverApp->keyClick(keycode,press,autoRepeat);
return FALSE;
}
enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown;
#if defined(QPE_HAVE_MEMALERTER)
QPE_MEMALERTER_IMPL
#endif
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;
class OpieScreenSaver;
namespace Opie {
namespace Core {
class ODeviceButton;
}
}
struct QCopKeyRegister {
QCopKeyRegister();
QCopKeyRegister( int k, const QCString&, const QCString& );
int keyCode()const;
QCString channel()const;
QCString message()const;
inline bool send();
private:
int m_keyCode;
QCString m_channel, m_message;
};
typedef QMap<int, QCopKeyRegister> KeyRegisterList;
class KeyFilter : public QObject {
Q_OBJECT
public:
KeyFilter(QObject* parent);
void registerKey( const QCopKeyRegister& );
void unregisterKey( const QCopKeyRegister& );
bool checkButtonAction( bool, int, int, int );
protected:
void timerEvent(QTimerEvent*);
signals:
void launch();
void power();
void backlight();
void symbol();
void numLockStateToggle();
void capsLockStateToggle();
void activate(const Opie::Core::ODeviceButton*,bool);
private:
bool keyRegistered( int key );
int held_tid;
- const Opie::Core::ODeviceButton* heldButton;
+ const Opie::Core::ODeviceButton* heldButton,*firedHeldButton;
KeyRegisterList m_keys;
};
class ServerApplication : public Opie::Core::OApplication
{
Q_OBJECT
public:
ServerApplication( int& argc, char **argv, Type t );
~ServerApplication();
static bool doRestart;
static bool allowRestart;
static bool screenLocked();
static void login(bool at_poweron);
static bool isStarting();
static void switchLCD ( bool on ); // only for togglePower in Desktop
static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar
void restart();
int exec();
signals:
void menu();
void home();
void launch();
void power();
void backlight();
void symbol();
void numLockStateToggle();
void capsLockStateToggle();
void prepareForRestart();
void activate(const Opie::Core::ODeviceButton*,bool);
public slots:
virtual void systemMessage( const QCString& msg, const QByteArray& );
virtual void launcherMessage( const QCString& msg, const QByteArray& );
void rereadVolumes();
protected:
bool eventFilter( QObject*, QEvent* );
#ifdef Q_WS_QWS
bool qwsEventFilter( QWSEvent * );
#endif
void shutdown();
void checkMemory();
bool recoverMemory();