From: GiWoong Kim Date: Sat, 9 May 2015 02:51:03 +0000 (+0900) Subject: input: give a MultiTouchTracker reference pointer to KeyboardHelper X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~457 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c29977299757685eb6eb9662a80b9e38bcdb6e5b;p=sdk%2Femulator%2Fqemu.git input: give a MultiTouchTracker reference pointer to KeyboardHelper Change-Id: I3b26cc8bf36b2d8a3af77e36cdc49d04fe2286c0 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/displaybase.cpp b/tizen/src/ui/displaybase.cpp index 1d9b8274af..0a72b7f33b 100644 --- a/tizen/src/ui/displaybase.cpp +++ b/tizen/src/ui/displaybase.cpp @@ -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(); } diff --git a/tizen/src/ui/input/keyboardhelper.cpp b/tizen/src/ui/input/keyboardhelper.cpp index 731a064343..420dc2f9b0 100644 --- a/tizen/src/ui/input/keyboardhelper.cpp +++ b/tizen/src/ui/input/keyboardhelper.cpp @@ -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 */ diff --git a/tizen/src/ui/input/keyboardhelper.h b/tizen/src/ui/input/keyboardhelper.h index c4afca6fd9..cc5f8fd523 100644 --- a/tizen/src/ui/input/keyboardhelper.h +++ b/tizen/src/ui/input/keyboardhelper.h @@ -32,6 +32,8 @@ #include +#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 keyCodeList; QMap keyMap; QMap keypadMap; @@ -61,7 +66,6 @@ private: void createKeyMap(); void createKeypadMap(); - void finishMtTracking(); void pressFilterMtChecking(QKeyEvent *event); void releaseFilterMtChecking(QKeyEvent *event); }; diff --git a/tizen/src/ui/input/touchscreenhelper.cpp b/tizen/src/ui/input/touchscreenhelper.cpp index f6f79cbb53..2415d8e1be 100644 --- a/tizen/src/ui/input/touchscreenhelper.cpp +++ b/tizen/src/ui/input/touchscreenhelper.cpp @@ -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"); diff --git a/tizen/src/ui/input/touchscreenhelper.h b/tizen/src/ui/input/touchscreenhelper.h index 286dfd70d3..bd33329d8c 100644 --- a/tizen/src/ui/input/touchscreenhelper.h +++ b/tizen/src/ui/input/touchscreenhelper.h @@ -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; diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index 7070b482e8..788467d81c 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -232,6 +232,11 @@ UIState *MainWindow::getUIState() return &(uiInfo->uiState); } +SkinView *MainWindow::getSkinView() +{ + return skinView; +} + ContextMenu *MainWindow::getPopupMenu() { return popupMenu; diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index 8376cf5a03..db494f743f 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -75,6 +75,7 @@ public: ~MainWindow(); UIState *getUIState(void); + SkinView *getSkinView(); ContextMenu *getPopupMenu(); DisplayBase *getDisplay(); KeyboardShortcut *getKeyboardShortcut(); diff --git a/tizen/src/ui/skinview.cpp b/tizen/src/ui/skinview.cpp index 30ba666a29..d331ae5828 100644 --- a/tizen/src/ui/skinview.cpp +++ b/tizen/src/ui/skinview.cpp @@ -36,19 +36,17 @@ 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; } } diff --git a/tizen/src/ui/skinview.h b/tizen/src/ui/skinview.h index 7ef875ba8d..7d9387dc06 100644 --- a/tizen/src/ui/skinview.h +++ b/tizen/src/ui/skinview.h @@ -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);