DSPointer: implement mouseDown/Move/Up/In/Out event handler 35/241835/1
authorSung-Jin Park <sj76.park@samsung.com>
Sat, 15 Aug 2020 06:38:42 +0000 (15:38 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:11:54 +0000 (19:11 +0900)
Change-Id: I8221adc5b1357ca97e75a0f29776aa13e022a7ae
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/DSSeat/DSPointer.cpp
src/DSSeat/DSPointer.h

index ce2781d..3f6375e 100644 (file)
@@ -27,6 +27,7 @@
 #include "DSInputEvent.h"
 #include "DSWaylandPointer.h"
 #include "DSWaylandSurface.h"
+#include "DSStruct.h"
 
 namespace display_server
 {
@@ -59,13 +60,92 @@ void DSPointer::processEvent(DSInputMouseEvent *ev, void *data)
                DSLOG_ERR("DSPointer", "No ptrFocus available.");
                return;
        }
+
+       if (ev->getType() == DSInputEvent::MouseInEvent)
+       {
+               DSLOG_DBG("DSTouch", "[mouseIn] devicename: %s, timestamp: %u\n",
+                                       ev->getDevice()->getName().c_str(), ev->getTimestamp());
+               mouseIn(ev->getX(), ev->getY());
+       }
+       else if (ev->getType() == DSInputEvent::MouseOutEvent)
+       {
+               DSLOG_DBG("DSTouch", "[mouseOut] devicename: %s, timestamp: %u\n",
+                                       ev->getDevice()->getName().c_str(), ev->getTimestamp());
+               mouseOut();
+       }
+       else if (ev->getType() == DSInputEvent::MouseDownEvent)
+       {
+               DSLOG_DBG("DSTouch", "[MouseDown] devicename: %s, timestamp: %u\n",
+                                       ev->getDevice()->getName().c_str(), ev->getTimestamp());
+               mouseDown(ev->getButton());
+       }
+       else if (ev->getType() == DSInputEvent::MouseMoveEvent)
+       {
+               DSLOG_DBG("DSTouch", "[mouseMove] devicename: %s, timestamp: %u\n",
+                                       ev->getDevice()->getName().c_str(), ev->getTimestamp());
+               mouseMove(ev->getX(), ev->getY());
+       }
+       else if (ev->getType() == DSInputEvent::MouseUpEvent)
+       {
+               DSLOG_DBG("DSTouch", "[mouseUp] devicename: %s, timestamp: %u\n",
+                                       ev->getDevice()->getName().c_str(), ev->getTimestamp());
+               mouseUp(ev->getButton());
+       }
+       else
+       {
+               DSLOG_INF("DSPointer", "Event type %d won't be handled right now.", ev->getType());
+               return;
+       }
+}
+
+void DSPointer::mouseDown(uint32_t button)
+{
+       if (__dswlPointer)
+       {
+               __dswlPointer->sendButtonDown(button);
+       }
+}
+
+void DSPointer::mouseUp(uint32_t button)
+{
+       if (__dswlPointer)
+       {
+               __dswlPointer->sendButtonUp(button);
+       }
+}
+
+void DSPointer::mouseMove(int x, int y)
+{
+       if (__dswlPointer)
+       {
+               __dswlPointer->sendMotion(x, y);
+       }
+}
+
+void DSPointer::mouseIn(int x, int y)
+{
+       if (__dswlPointer)
+       {
+               __dswlPointer->sendEnter(x, y);
+       }
+}
+
+void DSPointer::mouseOut()
+{
+       if (__dswlPointer)
+       {
+               __dswlPointer->sendLeave();
+       }
 }
 
 void DSPointer::setFocus(std::shared_ptr<DSWindow> window)
 {
        if (!window)
        {
-               DSLOG_ERR("DSPointer", "Given window is INVALID. (window : %p)", window);
+               DSLOG_ERR("DSPointer", "__ptrFocus has been changed (%p -> %p)", __ptrFocus, window);
+               __ptrFocus = window;
+               if (__dswlPointer)
+                       __dswlPointer->setFocus(nullptr);
                return;
        }
 
index d0dbdc7..5717c51 100644 (file)
@@ -45,6 +45,11 @@ public:
        virtual ~DSPointer();
 
        void processEvent(DSInputMouseEvent *ev, void *data);
+       void mouseDown(uint32_t button);
+       void mouseUp(uint32_t button);
+       void mouseMove(int x, int y);
+       void mouseIn(int x, int y);
+       void mouseOut();
        void setFocus(std::shared_ptr<DSWindow> window);
        std::shared_ptr<DSWindow> getFocus();