input: give a MultiTouchTracker reference pointer to KeyboardHelper
authorGiWoong Kim <giwoong.kim@samsung.com>
Sat, 9 May 2015 02:51:03 +0000 (11:51 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Sat, 9 May 2015 03:34:31 +0000 (12:34 +0900)
Change-Id: I3b26cc8bf36b2d8a3af77e36cdc49d04fe2286c0
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/ui/displaybase.cpp
tizen/src/ui/input/keyboardhelper.cpp
tizen/src/ui/input/keyboardhelper.h
tizen/src/ui/input/touchscreenhelper.cpp
tizen/src/ui/input/touchscreenhelper.h
tizen/src/ui/mainwindow.cpp
tizen/src/ui/mainwindow.h
tizen/src/ui/skinview.cpp
tizen/src/ui/skinview.h

index 1d9b827..0a72b7f 100644 (file)
@@ -43,7 +43,10 @@ DisplayBase::DisplayBase(DisplayType *displayForm, qreal scaleFactor,
     this->rotateAngle = displayForm->getAngle();
     this->scaleFactor = scaleFactor;
     this->isDragging = false;
+
     this->tsHelper = new TouchScreenHelper(this);
+    MainWindow *win = (MainWindow *)widget->parentWidget();
+    win->getSkinView()->getKbdHelper()->setMtTracker(tsHelper->getMtTracker());
 
     updateGeometry();
 }
index 731a064..420dc2f 100644 (file)
@@ -42,6 +42,7 @@ void virtio_keyboard_event(int keycode);
 KeyboardHelper::KeyboardHelper(QWidget *parent)
 {
     this->parent = parent;
+    this->mtTracker = NULL;
     this->numLockState = false;
     this->capsLockState = false;
 
@@ -207,18 +208,15 @@ void KeyboardHelper::createKeyMap()
     keyMap.insert(Qt::Key_F12, 88); /* f12 */
 }
 
-void KeyboardHelper::finishMtTracking()
+void KeyboardHelper::setMtTracker(MultiTouchTracker *mtTracker)
 {
-    DisplayBase *display = ((MainWindow *)parent->parentWidget())->getDisplay();
-    if (display != NULL) {
-        display->getTouchScreenHelper()->finishMtTracking();
-    }
+    this->mtTracker = mtTracker;
 }
 
 void KeyboardHelper::autoKeyRelease(void)
 {
     while (!keyCodeList.isEmpty()) {
-        qDebug() << "auto release scancode : " << keyCodeList.last();
+        qDebug() << "auto release scancode :" << keyCodeList.last();
 
         do_qt_keyboard_key_event(KEY_RELEASED, keyCodeList.last());
         keyCodeList.removeLast();
@@ -229,7 +227,7 @@ void KeyboardHelper::autoKeyRelease(void)
         qDebug() << "disable multi-touch";
 
         set_multi_touch_enable(MultiTouchTracker::MT_OFF);
-        finishMtTracking();
+        mtTracker->finishTracking();
     }
 }
 
@@ -258,7 +256,7 @@ int KeyboardHelper::keyCodeOperation(QKeyEvent *event, int keyCode)
     }
 
     if (keyMapIter == keyMap.end()) {
-        qWarning() << "unsupported keycode pressed : " << keyCode;
+        qWarning() << "unsupported keycode pressed :" << keyCode;
         return -1;
     }
 
@@ -321,7 +319,7 @@ void KeyboardHelper::pressFilterMtChecking(QKeyEvent *event)
             qDebug() << "disable multi-touch";
 
             set_multi_touch_enable(MultiTouchTracker::MT_OFF);
-            finishMtTracking();
+            mtTracker->finishTracking();
         }
 
         break;
@@ -335,7 +333,7 @@ void KeyboardHelper::keyPressed(QKeyEvent *event)
         event->nativeScanCode() << event->modifiers() << event->nativeModifiers();
 
     /* multi-touch checking */
-    if (get_emul_max_touch_point() > 1) {
+    if (mtTracker != NULL && get_emul_max_touch_point() > 1) {
         pressFilterMtChecking(event);
         /* fall through */
     }
@@ -442,7 +440,7 @@ void KeyboardHelper::releaseFilterMtChecking(QKeyEvent *event)
             qDebug() << "disable multi-touch";
 
             set_multi_touch_enable(MultiTouchTracker::MT_OFF);
-            finishMtTracking();
+            mtTracker->finishTracking();
         }
 
         break;
@@ -454,7 +452,7 @@ void KeyboardHelper::releaseFilterMtChecking(QKeyEvent *event)
             qDebug() << "disable multi-touch";
 
             set_multi_touch_enable(MultiTouchTracker::MT_OFF);
-            finishMtTracking();
+            mtTracker->finishTracking();
         }
 
         break;
@@ -466,7 +464,7 @@ void KeyboardHelper::releaseFilterMtChecking(QKeyEvent *event)
             qDebug() << "disable multi-touch";
 
             set_multi_touch_enable(MultiTouchTracker::MT_OFF);
-            finishMtTracking();
+            mtTracker->finishTracking();
         }
 
         break;
@@ -482,7 +480,7 @@ void KeyboardHelper::keyReleased(QKeyEvent *event)
         event->nativeScanCode() << event->modifiers() << event->nativeModifiers();
 
     /* multi-touch checking */
-    if (get_emul_max_touch_point() > 1) {
+    if (mtTracker != NULL && get_emul_max_touch_point() > 1) {
         releaseFilterMtChecking(event);
         /* fall through */
     }
@@ -541,7 +539,7 @@ void KeyboardHelper::keyReleased(QKeyEvent *event)
     }
 #endif
 
-    int ret = keyCodeOperation(event, keyCode);
+    const int ret = keyCodeOperation(event, keyCode);
     if (ret != -1) {
         do_qt_keyboard_key_event(KEY_RELEASED, ret);
         /* remove keycode from list */
index c4afca6..cc5f8fd 100644 (file)
@@ -32,6 +32,8 @@
 
 #include <QMap>
 
+#include "multitouchtracker.h"
+
 enum KbdLedState {
     OFF,
     ON
@@ -43,6 +45,7 @@ public:
     KeyboardHelper(QWidget *parent);
     ~KeyboardHelper();
 
+    void setMtTracker(MultiTouchTracker *mtTracker);
     void keyPressed(QKeyEvent *event);
     void keyReleased(QKeyEvent *event);
     void autoKeyRelease(void);
@@ -51,6 +54,8 @@ public:
 
 protected:
     QWidget *parent;
+    MultiTouchTracker *mtTracker;
+
     QList<int> keyCodeList;
     QMap<int, int> keyMap;
     QMap<int, int> keypadMap;
@@ -61,7 +66,6 @@ private:
     void createKeyMap();
     void createKeypadMap();
 
-    void finishMtTracking();
     void pressFilterMtChecking(QKeyEvent *event);
     void releaseFilterMtChecking(QKeyEvent *event);
 };
index f6f79cb..2415d8e 100644 (file)
@@ -50,6 +50,11 @@ void *TouchScreenHelper::getParent()
     return parent;
 }
 
+MultiTouchTracker *TouchScreenHelper::getMtTracker()
+{
+    return mtTracker;
+}
+
 void TouchScreenHelper::mousePressed(QMouseEvent *event, QPoint guestPos)
 {
     /* multi-touch processing */
@@ -84,11 +89,6 @@ void TouchScreenHelper::mouseMoved(QMouseEvent *event, QPoint guestPos)
     virtio_touchscreen_event(guestPos.x(), guestPos.y(), 0, 1);
 }
 
-void TouchScreenHelper::finishMtTracking()
-{
-    mtTracker->finishTracking();
-}
-
 TouchScreenHelper::~TouchScreenHelper()
 {
     qDebug("destroy touch screen helper");
index 286dfd7..bd33329 100644 (file)
@@ -39,12 +39,12 @@ public:
     ~TouchScreenHelper();
 
     void *getParent();
+    MultiTouchTracker *getMtTracker();
+
     void mousePressed(QMouseEvent *event, QPoint guestPos);
     void mouseReleased(QMouseEvent *event, QPoint guestPos);
     void mouseMoved(QMouseEvent *event, QPoint guestPos);
 
-    void finishMtTracking();
-
 private:
     void *parent;
     MultiTouchTracker *mtTracker;
index 7070b48..788467d 100644 (file)
@@ -232,6 +232,11 @@ UIState *MainWindow::getUIState()
     return &(uiInfo->uiState);
 }
 
+SkinView *MainWindow::getSkinView()
+{
+    return skinView;
+}
+
 ContextMenu *MainWindow::getPopupMenu()
 {
     return popupMenu;
index 8376cf5..db494f7 100644 (file)
@@ -75,6 +75,7 @@ public:
     ~MainWindow();
 
     UIState *getUIState(void);
+    SkinView *getSkinView();
     ContextMenu *getPopupMenu();
     DisplayBase *getDisplay();
     KeyboardShortcut *getKeyboardShortcut();
index 30ba666..d331ae5 100644 (file)
 SkinView::SkinView(QGraphicsScene *scene, QWidget *parent) :
     QGraphicsView(scene, parent)
 {
-    setStyleSheet("border-style: none");
+    this->win = ((MainWindow *)parent);
+    this->kbdHelper = new KeyboardHelper(this);
+    this->grabWinPos = QPoint(-1, -1);
+    this->grabPos = QPoint(-1, -1);
 
+    setStyleSheet("border-style: none");
     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     setAlignment(Qt::AlignLeft | Qt::AlignTop);
 
-    this->win = ((MainWindow *)parent);
-    this->grabWinPos = QPoint(-1, -1);
-    this->grabPos = QPoint(-1, -1);
-
     updateLayout();
-
-    kbd = new KeyboardHelper(this);
 }
 
 void SkinView::createItems(MainForm *form)
@@ -71,6 +69,11 @@ void SkinView::createItems(MainForm *form)
     }
 }
 
+KeyboardHelper *SkinView::getKbdHelper()
+{
+    return kbdHelper;
+}
+
 void SkinView::updateLayout()
 {
     scene()->clear();
@@ -82,6 +85,7 @@ void SkinView::updateLayout()
     createItems(win->uiInfo->getMainForm());
 }
 
+/* override */
 void SkinView::resizeEvent(QResizeEvent *event)
 {
     qDebug() << "resize skin view :" << size();
@@ -94,13 +98,12 @@ void SkinView::resizeEvent(QResizeEvent *event)
     QGraphicsView::resizeEvent(event);
 }
 
+/* override */
 void SkinView::mousePressEvent(QMouseEvent *event)
 {
     //qDebug("pressed %dx%d", event->x(), event->y());
 
     if (event->button() == Qt::LeftButton) {
-        //qDebug("grab");
-
         grabWinPos = parentWidget()->pos();
         grabPos = event->globalPos();
     }
@@ -108,19 +111,19 @@ void SkinView::mousePressEvent(QMouseEvent *event)
     QGraphicsView::mousePressEvent(event);
 }
 
+/* override */
 void SkinView::mouseReleaseEvent(QMouseEvent *event)
 {
     //qDebug("released %dx%d", event->x(), event->y());
 
     if (event->button() == Qt::LeftButton) {
-        //qDebug("unloose");
-
         grabPos = QPoint(-1, -1);
     }
 
     QGraphicsView::mouseReleaseEvent(event);
 }
 
+/* override */
 void SkinView::mouseMoveEvent(QMouseEvent *event)
 {
     if (grabPos != QPoint(-1, -1)) {
@@ -130,27 +133,30 @@ void SkinView::mouseMoveEvent(QMouseEvent *event)
     QGraphicsView::mouseMoveEvent(event);
 }
 
+/* override */
 void SkinView::focusOutEvent(QFocusEvent *event)
 {
     qDebug() << "focus out!";
-    kbd->autoKeyRelease();
+    kbdHelper->autoKeyRelease();
 }
 
+/* override */
 void SkinView::keyPressEvent(QKeyEvent *event)
 {
-    kbd->keyPressed(event);
+    kbdHelper->keyPressed(event);
 }
 
+/* override */
 void SkinView::keyReleaseEvent(QKeyEvent *event)
 {
-    kbd->keyReleased(event);
+    kbdHelper->keyReleased(event);
 }
 
 SkinView::~SkinView()
 {
     qDebug("destroy skin view");
 
-    if (kbd != NULL) {
-        delete kbd;
+    if (kbdHelper != NULL) {
+        delete kbdHelper;
     }
 }
index 7ef875b..7d9387d 100644 (file)
@@ -43,6 +43,7 @@ public:
     SkinView(QGraphicsScene *scene, QWidget *parent = 0);
     ~SkinView();
 
+    KeyboardHelper *getKbdHelper();
     void updateLayout();
 
 protected:
@@ -56,9 +57,10 @@ protected:
     void focusOutEvent(QFocusEvent *event);
 
     MainWindow *win;
+    KeyboardHelper *kbdHelper;
+
     QPoint grabWinPos;
     QPoint grabPos;
-    KeyboardHelper *kbd;
 
 private:
     void createItems(MainForm *form);