summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2009-12-11 09:19:59 +0100
committerJørgen Lind <jorgen.lind@nokia.com>2009-12-11 09:19:59 +0100
commit2a0229375424499b9d83dd3214595efdc624a8a1 (patch)
tree88954ff8d1bcc4399ddbf17ff996a62692f305b2 /src
parenta4c7e91befad73601c0ee6e194a5dfeb6cac61a9 (diff)
Minimaldfb: Added keyboard modifiers to keyevents
and added double click to mouseevents
Diffstat (limited to 'src')
-rw-r--r--src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp22
-rw-r--r--src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h1
-rw-r--r--src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp29
3 files changed, 50 insertions, 2 deletions
diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp
index cd1f5687a8..63ae2894ad 100644
--- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp
+++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.cpp
@@ -72,6 +72,28 @@ Qt::MouseButtons QDirectFbConvenience::mouseButtons(DFBInputDeviceButtonMask mas
return buttons;
}
+Qt::KeyboardModifiers QDirectFbConvenience::keyboardModifiers(DFBInputDeviceModifierMask mask)
+{
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+
+ if (mask & DIMM_SHIFT) {
+ modifiers |= Qt::ShiftModifier;
+ }
+ if (mask & DIMM_ALT) {
+ modifiers |= Qt::AltModifier;
+ }
+ if (mask & DIMM_ALTGR) {
+ modifiers |= Qt::MetaModifier;
+ }
+ if (mask & DIMM_CONTROL) {
+ modifiers |= Qt::ControlModifier;
+ }
+ if (mask & DIMM_META) {
+ modifiers | Qt::MetaModifier;
+ }
+ return modifiers;
+}
+
QEvent::Type QDirectFbConvenience::eventType(DFBWindowEventType type)
{
switch(type) {
diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h
index 0ae141000d..2f5e10b42b 100644
--- a/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h
+++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbconvenience.h
@@ -23,6 +23,7 @@ public:
static IDirectFB *dfbInterface() { return dfb; }
static Qt::MouseButton mouseButton(DFBInputDeviceButtonIdentifier identifier);
static Qt::MouseButtons mouseButtons(DFBInputDeviceButtonMask mask);
+ static Qt::KeyboardModifiers keyboardModifiers(DFBInputDeviceModifierMask mask);
static QEvent::Type eventType(DFBWindowEventType type);
static QDirectFbKeyMap *keyMap();
diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp
index 7c8d3c2454..b6f0b65f1f 100644
--- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp
+++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp
@@ -71,6 +71,9 @@ void QDirectFbInput::handleEvents()
case DWET_KEYDOWN:
case DWET_KEYUP:
handleKeyEvents(event);
+ break;
+ default:
+ break;
}
} else
@@ -87,9 +90,30 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event)
QPoint globalPos = globalPoint(event);
Qt::MouseButton button = QDirectFbConvenience::mouseButton(event.window.button);
Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons);
+ QWidget *tlw = tlwMap.value(event.window.window_id);
+ if (event.window.type == DWET_BUTTONDOWN) {
+ static long prevTime = 0;
+ static QWidget *prevWindow;
+ static int prevX = -999;
+ static int prevY = -999;
+ long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
+ timestamp /= 1000;
+
+ if (tlw == prevWindow && timestamp - prevTime < QApplication::doubleClickInterval()
+ && qAbs(event.window.cx - prevX) < 5 && qAbs(event.window.cy - prevY) < 5) {
+ type = QEvent::MouseButtonDblClick;
+ prevTime = timestamp - QApplication::doubleClickInterval(); //no double click next time
+ } else {
+ prevTime = timestamp;
+ }
+ prevWindow = tlw;
+ prevX = event.window.cx;
+ prevY = event.window.cy;
+ }
+
+ //DFB doesn't give keyboardmodifiers on mouseevents
QMouseEvent mouseEvent(type,p,globalPos,button, buttons,(Qt::KeyboardModifiers)0);
- QWidget *tlw = tlwMap.value(event.window.window_id);
QApplicationPrivate::handleMouseEvent(tlw,mouseEvent);
}
@@ -97,8 +121,9 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event)
{
QEvent::Type type = QDirectFbConvenience::eventType(event.window.type);
Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol);
+ Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers);
- QKeyEvent keyEvent(type,key,0,QChar(event.window.key_symbol));//,"",true,0);
+ QKeyEvent keyEvent(type,key,modifiers,QChar(event.window.key_symbol));
QWidget *tlw = tlwMap.value(event.window.window_id);
QApplicationPrivate::handleKeyEvent(tlw,&keyEvent);
}