display: minor cleanup for input
authorGiWoong Kim <giwoong.kim@samsung.com>
Fri, 8 Jan 2016 05:31:00 +0000 (14:31 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 13 Jan 2016 01:21:10 +0000 (10:21 +0900)
move each duplicated code to its parent class

Change-Id: I7eeb29892bd23264eb688a72d6583fc9d4460755
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
(cherry picked from commit 9ca2ddeccd7c8e00beffe1e4fc044314e5ae8701)

tizen/src/ui/displaybase.cpp
tizen/src/ui/displaybase.h
tizen/src/ui/displayglwidget.cpp
tizen/src/ui/displayglwidget.h
tizen/src/ui/displayswwidget.cpp
tizen/src/ui/displayswwidget.h

index 4dfa9329e43782a073f2c85ceda22347cf297369..6eb3c3367ae133b4c778045ffdd5128df6195347 100644 (file)
@@ -5,7 +5,8 @@
  *
  * Contact:
  * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
  * Stanislav Vorobiov
  *
  * This program is free software; you can redistribute it and/or
@@ -53,17 +54,27 @@ DisplayBase::DisplayBase(DisplayType *displayForm, QSize resolution, qreal scale
     this->scaleFactor = scaleFactor;
     this->isDragging = false;
 
+    this->tsHelper = NULL;
+    this->mouseHelper = NULL;
+
     this->offGuide = NULL;
     this->offGuideShown = false;
 
     this->isTsEnabled = is_touchscreen_enabled();
-
-    /* touch screen */
-    this->tsHelper = new TouchScreenHelper(this);
-    win->getMainView()->getKbdHelper()->setMtTracker(tsHelper->getMtTracker());
-
-    /* mouse */
-    this->mouseHelper = new MouseHelper(this, resolution);
+    if (isTsEnabled == true) {
+        qDebug("touch screen device was enabled");
+
+        /* touch screen */
+        tsHelper = new TouchScreenHelper(this);
+        win->getMainView()->getKbdHelper()->setMtTracker(tsHelper->getMtTracker());
+    } else {
+        qDebug("touch screen device was not enabled");
+
+        /* mouse */
+        mouseHelper = new MouseHelper(this, resolution);
+        widget->setCursor(Qt::BlankCursor);
+        widget->setMouseTracking(true);
+    }
 
     loadOffGuideImg();
 
@@ -228,7 +239,9 @@ QPoint DisplayBase::getGuestPos(QPoint hostPos)
         guestPos.setY(guestPosX);
         break;
     case 0:
+        break;
     default:
+        qWarning() << "unsupported coordinate system:" << rotateAngle;
         break;
     }
 
@@ -250,9 +263,10 @@ void DisplayBase::handleMousePress(QMouseEvent *event)
     if (event->button() == Qt::LeftButton) {
         isDragging = true;
 
-        if (isTsEnabled == true) {
+        if (tsHelper != NULL) {
             tsHelper->mousePressed(event, getGuestPos(event->pos()));
-        } else {
+        }
+        if (mouseHelper != NULL) {
             mouseHelper->mousePressed(event);
         }
     }
@@ -265,9 +279,10 @@ void DisplayBase::handleMouseRelease(QMouseEvent *event)
             isDragging = false;
         }
 
-        if (isTsEnabled == true) {
+        if (tsHelper != NULL) {
             tsHelper->mouseReleased(event, getGuestPos(event->pos()));
-        } else {
+        }
+        if (mouseHelper != NULL) {
             mouseHelper->mouseReleased(event);
         }
     }
@@ -275,7 +290,8 @@ void DisplayBase::handleMouseRelease(QMouseEvent *event)
 
 void DisplayBase::handleMouseMove(QMouseEvent *event)
 {
-    if (isTsEnabled == true) { /* touch device */
+    /* touch screen device */
+    if (tsHelper != NULL) {
         if (isDragging == true) {
             int hostPosX = event->x();
             int hostPosY = event->y();
@@ -307,7 +323,10 @@ void DisplayBase::handleMouseMove(QMouseEvent *event)
                 tsHelper->mouseMoved(event, getGuestPos(event->pos()));
             }
         }
-    } else { /* mouse device */
+    }
+
+    /* mouse device */
+    if (mouseHelper != NULL) {
         const int hostPosX = event->x();
         const int hostPosY = event->y();
 
@@ -329,14 +348,14 @@ void DisplayBase::handleMouseMove(QMouseEvent *event)
 
 void DisplayBase::handleMouseEnter(QEvent *event)
 {
-    if (isTsEnabled == false) {
+    if (mouseHelper != NULL) {
         mouseHelper->mouseEnter(event);
     }
 }
 
 void DisplayBase::handleMouseLeave(QEvent *event)
 {
-    if (isTsEnabled == false) {
+    if (mouseHelper != NULL) {
         mouseHelper->mouseLeave(event);
     }
 }
index fdaa8d3e5bfa7961c112d7f9bfef5f4746658695..de83c7613a350d7e03f925fcc829f7a0574dbbd1 100644 (file)
@@ -5,7 +5,8 @@
  *
  * Contact:
  * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
  * Stanislav Vorobiov
  *
  * This program is free software; you can redistribute it and/or
@@ -78,12 +79,12 @@ protected:
     int rotateAngle;
     qreal scaleFactor;
     bool isDragging;
+    bool isTsEnabled;
 
 private:
     void loadOffGuideImg();
 
     QSize resolution;
-    bool isTsEnabled;
 
     MainWindow *win;
     QWidget *widget; /* child */
index 65841bee0e820af8639db1c879e5b2cc58c40f5d..84f173dc024d7f60733471ce914ab4e7866ab0f5 100644 (file)
@@ -5,7 +5,8 @@
  *
  * Contact:
  * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
  * Stanislav Vorobiov
  *
  * This program is free software; you can redistribute it and/or
@@ -39,12 +40,6 @@ DisplayGLWidget::DisplayGLWidget(QWidget *parent, QGLContext *context,
     QGLWidget(context, parent), DisplayBase(displayForm, resolution, scaleFactor, this)
 {
     setAutoBufferSwap(false);
-    isTouch = is_touchscreen_enabled();
-    /* mouse mode */
-    if (!isTouch) {
-        setCursor(Qt::BlankCursor);
-        setMouseTracking(true);
-    }
 }
 
 /* override */
index 170c8011592b9e00c29af8e8e833deb72e1e5d37..378fd6377d90dde7fee6810935e8872fed8fc840 100644 (file)
@@ -5,7 +5,8 @@
  *
  * Contact:
  * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
  * Stanislav Vorobiov
  *
  * This program is free software; you can redistribute it and/or
@@ -57,8 +58,6 @@ protected:
 
     void enterEvent(QEvent *event);
     void leaveEvent(QEvent *event);
-private:
-    bool isTouch;
 };
 
 #endif // DISPLAYGLWIDGET_H
index a973a8c0a00c98d838d5306c4fdf33f9c579c501..831c8ec430ece1d56cfa9e0bc005c2c863996842 100644 (file)
@@ -5,7 +5,8 @@
  *
  * Contact:
  * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
  * Stanislav Vorobiov
  *
  * This program is free software; you can redistribute it and/or
@@ -47,13 +48,6 @@ DisplaySWWidget::DisplaySWWidget(QWidget *parent,
         displayForm->getRect().height() * scaleFactor);
     initImage.fill(Qt::black);
     setPixmap(initImage);
-
-    isTouch = is_touchscreen_enabled();
-    /* mouse mode */
-    if (!isTouch) {
-        setCursor(Qt::BlankCursor);
-        setMouseTracking(true);
-    }
 }
 
 /* override */
index 5c3d27ec32b46b6514aff6ba47edeb7cb0c92cec..26de5d9b009dc7e6ff331e14a71b7e62386b5fec 100644 (file)
@@ -5,7 +5,8 @@
  *
  * Contact:
  * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
  * Stanislav Vorobiov
  *
  * This program is free software; you can redistribute it and/or
@@ -55,9 +56,9 @@ protected:
 
     void enterEvent(QEvent *event);
     void leaveEvent(QEvent *event);
+
 private:
     MultiTouchTracker *mtTracker;
-    bool isTouch;
 };
 
 #endif // DISPLAYSWWIDGET_H