DSSeat: get Top Window on x, y coordinates and set it as a focus window for touch... 36/241836/1
authorSung-Jin Park <sj76.park@samsung.com>
Sat, 15 Aug 2020 06:40:03 +0000 (15:40 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:11:55 +0000 (19:11 +0900)
Change-Id: I45e4bdae90b3f7cd9a50b50f69853aab7765a62a
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/DSSeat/DSSeat.cpp
src/DSSeat/DSSeat.h

index 69ca1d2..d8aab6c 100644 (file)
@@ -402,6 +402,33 @@ void DSSeat::__onPointerEvent(DSInputMouseEvent *ev)
        }
 
        __dswlSeat->setCurrentEventTime(ev->getTimestamp());
+
+       if (ev->getType() == DSInputEvent::MouseMoveEvent)
+       {
+               //get window whose geometry has intersection with the mouse coordinates
+               auto window = getTopWindowOnPosition(ev->getX(), ev->getY());
+
+               //check if the window is equal to the current pointer focus window
+               auto currentPointerFocus = __pointer->getFocus();
+
+               //if equal, no need to set focus / pointer enter/leave activities
+               if (window.get() != currentPointerFocus.get())
+               {
+                       //if not equal, send pointer leave to the current pointer focus window
+                       std::shared_ptr evMouseOut = std::make_shared<DSInputMouseEvent>(ev->getDevice(), DSInputEvent::MouseOutEvent, ev->getTimestamp(), ev->getButton(), ev->getX(), ev->getY(), 0);
+                       __pointer->processEvent(evMouseOut.get(), nullptr);
+                       //TODO : emit MouseOut signal
+
+                       //set the window as pointer focus window
+                       __pointer->setFocus(window);
+
+                       //send pointer enter to the new pointer focus window
+                       std::shared_ptr evMouseIn = std::make_shared<DSInputMouseEvent>(ev->getDevice(), DSInputEvent::MouseInEvent, ev->getTimestamp(), ev->getButton(), 0, 0, 0);
+                       __pointer->processEvent(evMouseIn.get(), nullptr);
+                       //TODO : emit MouseIn signal
+               }
+       }
+
        __pointer->processEvent(ev, nullptr);
 }
 
@@ -413,6 +440,17 @@ void DSSeat::__onTouchEvent(DSInputTouchEvent *ev)
                return;
        }
 
+       if (ev->getType() == DSInputEvent::TouchDownEvent)
+       {
+               //get window whose geometry has intersection with the touch coordinates
+               auto window = getTopWindowOnPosition(ev->getX(), ev->getY());
+
+               //set the window as touch focus window
+               __touch->setFocus(window);
+
+               //TODO : emit touch focus changed signal
+       }
+
        __dswlSeat->setCurrentEventTime(ev->getTimestamp());
        __touch->processEvent(ev, nullptr);
 }
@@ -472,5 +510,24 @@ Eina_Bool DSSeat::inputEventHandlerTouch(void *data, int type, void *event)
        return EINA_TRUE;
 }
 
+std::shared_ptr<DSWindow> DSSeat::getTopWindowOnPosition(int x, int y)
+{
+       stPosition wPos;
+       stSize wSize;
+
+       std::list<std::shared_ptr<DSWindow>> wList = __zone->getWindowList();
+       for (auto w : wList)
+       {
+               wSize = w->getSize();
+               wPos = w->getPosition();
+
+               if (x >= wPos.x && y >= wPos.y && x <= (int)(wPos.x+wSize.w) && y <= (int)(wPos.y+wSize.h))
+               {
+                       DSLOG_INF("DSSeat", "window(%p, x:%d, y:%d, w:%u, h:%u) contains (x:%d, y:%d)", w.get(), wPos.x, wPos.y, wSize.w, wSize.h, x, y);
+                       return w;
+               }
+       }
+}
+
 } // namespace display_server
 
index 25f84c4..9363f6c 100644 (file)
@@ -72,6 +72,7 @@ public:
        void removeTouch();
 
        DSXkb *getXkb();
+       std::shared_ptr<DSWindow> getTopWindowOnPosition(int x, int y);
 
 private:
        DSInput *__input;