From: Sung-Jin Park Date: Fri, 14 Aug 2020 10:54:40 +0000 (+0900) Subject: DSWaylandTouch: implment send touchDown/Up/Move events to touch focus client X-Git-Tag: accepted/tizen/unified/20200820.213435~44 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cbcef546c0328e5e32390af6836422b0a5a6ebf9;p=platform%2Fcore%2Fuifw%2Flibds.git DSWaylandTouch: implment send touchDown/Up/Move events to touch focus client Change-Id: I7dab84ca478c3486702ba807c3790cf31920803a Signed-off-by: Sung-Jin Park --- diff --git a/src/DSWaylandServer/DSWaylandTouch.cpp b/src/DSWaylandServer/DSWaylandTouch.cpp index 0d31119..c2a3fa1 100644 --- a/src/DSWaylandServer/DSWaylandTouch.cpp +++ b/src/DSWaylandServer/DSWaylandTouch.cpp @@ -24,6 +24,9 @@ #include "DSWaylandTouch.h" #include "DSWaylandTouchPrivate.h" #include "DSWaylandClient.h" +#include "DSWaylandSeat.h" +#include "DSWaylandSurface.h" +#include "DSWaylandCompositor.h" namespace display_server { @@ -32,7 +35,9 @@ DSWaylandTouchPrivate::DSWaylandTouchPrivate(DSWaylandSeat *seat, DSWaylandTouch : DSObjectPrivate(touch), __p_ptr(touch), __seat(seat), - __waylandSurface(nullptr) + __compositor(seat->getCompositor()), + __waylandSurface(nullptr), + __wlTouchResource(nullptr) { wl_touch(); } @@ -41,6 +46,38 @@ DSWaylandTouchPrivate::~DSWaylandTouchPrivate() { } +void DSWaylandTouchPrivate::setFocus(DSWaylandSurface *waylandSurface) +{ + DSLOG_INF("DSWaylandTouchPrivate", "touch focus changed (%p -> %p)", __waylandSurface, waylandSurface); + + __waylandSurface = waylandSurface; + + if (!waylandSurface) + return; + + struct ::wl_resource *surface = waylandSurface->getWlResource(); + auto client = wl_resource_get_client(surface); + + std::multimap::iterator iter; + std::multimap resMap = resourceMap(); + + for (iter = resMap.begin(); iter != resMap.end(); iter++) + { + Resource *res = (*iter).second; + if (res->client() == client) + { + __wlTouchResource = res->handle; + break; + } + + } +} + +DSWaylandSurface *DSWaylandTouchPrivate::getFocus() +{ + return __waylandSurface; +} + void DSWaylandTouchPrivate::touch_bind_resource(Resource *resource) { DSLOG_INF("DSWaylandTouchPrivate",""); @@ -57,6 +94,36 @@ void DSWaylandTouchPrivate::touch_release(Resource *resource) wl_resource_destroy(resource->handle); } +void DSWaylandTouchPrivate::sendDown(int32_t id, int x, int y) +{ + if (!__waylandSurface) + { + DSLOG_INF("DSWaylandTouchPrivate", "no waylandSurface available !"); + return; + } + + wl_fixed_t x_fixed = wl_fixed_from_int(x); + wl_fixed_t y_fixed = wl_fixed_from_int(y); + + struct ::wl_resource *surface = __waylandSurface->getWlResource(); + DS_ASSERT(surface != nullptr); + + send_down(__wlTouchResource, __compositor->nextSerial(), __seat->getCurrentEventTime(), surface, id, x_fixed, y_fixed); +} + +void DSWaylandTouchPrivate::sendUp(int32_t id) +{ + send_up(__wlTouchResource, __compositor->nextSerial(), __seat->getCurrentEventTime(), id); +} + +void DSWaylandTouchPrivate::sendMotion(int32_t id, int x, int y) +{ + wl_fixed_t x_fixed = wl_fixed_from_int(x); + wl_fixed_t y_fixed = wl_fixed_from_int(y); + + send_motion(__wlTouchResource, __seat->getCurrentEventTime(), id, x_fixed, y_fixed); +} + /* Begin Public Class Implementation */ DSWaylandTouch::DSWaylandTouch(DSWaylandSeat *seat) : DSObject(), _d_ptr(std::make_unique(seat, this)) @@ -88,13 +155,31 @@ void DSWaylandTouch::addClient(DSWaylandClient *client, uint32_t id, int version void DSWaylandTouch::setFocus(DSWaylandSurface *waylandSurface) { DS_GET_PRIV(DSWaylandTouch); - priv->__waylandSurface = waylandSurface; + priv->setFocus(waylandSurface); } DSWaylandSurface *DSWaylandTouch::getFocus() { DS_GET_PRIV(DSWaylandTouch); - return priv->__waylandSurface; + return priv->getFocus(); +} + +void DSWaylandTouch::sendDown(int32_t id, int x, int y) +{ + DS_GET_PRIV(DSWaylandTouch); + priv->sendDown(id, x, y); +} + +void DSWaylandTouch::sendUp(int32_t id) +{ + DS_GET_PRIV(DSWaylandTouch); + priv->sendUp(id); +} + +void DSWaylandTouch::sendMotion(int32_t id, int x, int y) +{ + DS_GET_PRIV(DSWaylandTouch); + priv->sendMotion(id, x, y); } } diff --git a/src/DSWaylandServer/DSWaylandTouch.h b/src/DSWaylandServer/DSWaylandTouch.h index d787707..beef446 100644 --- a/src/DSWaylandServer/DSWaylandTouch.h +++ b/src/DSWaylandServer/DSWaylandTouch.h @@ -48,6 +48,10 @@ public: void setFocus(DSWaylandSurface *waylandSurface); DSWaylandSurface *getFocus(); + void sendDown(int32_t id, int x, int y); + void sendUp(int32_t id); + void sendMotion(int32_t id, int x, int y); + protected: private: diff --git a/src/DSWaylandServer/DSWaylandTouchPrivate.h b/src/DSWaylandServer/DSWaylandTouchPrivate.h index bf965d8..1556ce7 100644 --- a/src/DSWaylandServer/DSWaylandTouchPrivate.h +++ b/src/DSWaylandServer/DSWaylandTouchPrivate.h @@ -29,10 +29,15 @@ #include "DSCore.h" #include "DSObjectPrivate.h" +struct wl_resource; + namespace display_server { class DSWaylandSeat; +class DSWaylandCompositor; +class DSWaylandSurface; + class DS_DECL_EXPORT DSWaylandTouchPrivate : public DSObjectPrivate, public DSWaylandServer::wl_touch { DS_PIMPL_USE_PUBLIC(DSWaylandTouch); @@ -40,7 +45,8 @@ public: DSWaylandTouchPrivate(DSWaylandSeat *seat, DSWaylandTouch *touch); ~DSWaylandTouchPrivate() override; - //TODO + void setFocus(DSWaylandSurface *waylandSurface); + DSWaylandSurface *getFocus(); protected: //virtual Resource *touch_allocate(); @@ -49,14 +55,13 @@ protected: virtual void touch_release(Resource *resource); /* APIs must be provided */ + void sendDown(int32_t id, int x, int y); + void sendUp(int32_t id); + void sendMotion(int32_t id, int x, int y); /* - void sendDown(struct ::wl_client *client, uint32_t serial, uint32_t time, struct ::wl_resource *surface, int32_t id, wl_fixed_t x, wl_fixed_t y); - void sendUp(struct ::wl_client *client, uint32_t serial, uint32_t time, int32_t id); - void sendMotion(struct ::wl_client *client, uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y); - void sendFrame(struct ::wl_client *client); - void sendCancel(struct ::wl_client *client); + void sendFrame(struct ::wl_resource *surface); + void sendCancel(struct ::wl_resource *surface); */ - /* APIs don't need to provide */ /* void send_shape(struct ::wl_resource *resource, int32_t id, wl_fixed_t major, wl_fixed_t minor); @@ -65,7 +70,9 @@ protected: private: DSWaylandSeat *__seat; + DSWaylandCompositor *__compositor; DSWaylandSurface *__waylandSurface; + struct ::wl_resource *__wlTouchResource; }; }