From a1caa73dad5dfacb1aeee0c3f9e387fdffbd181d Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 14 Aug 2020 20:51:50 +0900 Subject: [PATCH 01/16] DSWaylandPointer: add set/getFocus(), send event APIs Change-Id: I056f8ab50aa47cd173850dad47218579e99c2ab5 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandPointer.cpp | 121 +++++++++++++++++++++++++- src/DSWaylandServer/DSWaylandPointer.h | 6 ++ src/DSWaylandServer/DSWaylandPointerPrivate.h | 21 +++-- 3 files changed, 138 insertions(+), 10 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandPointer.cpp b/src/DSWaylandServer/DSWaylandPointer.cpp index 6a04cfa..dea562f 100644 --- a/src/DSWaylandServer/DSWaylandPointer.cpp +++ b/src/DSWaylandServer/DSWaylandPointer.cpp @@ -24,6 +24,9 @@ #include "DSWaylandPointer.h" #include "DSWaylandPointerPrivate.h" #include "DSWaylandClient.h" +#include "DSWaylandSeat.h" +#include "DSWaylandSurface.h" +#include "DSWaylandCompositor.h" namespace display_server { @@ -33,7 +36,9 @@ DSWaylandPointerPrivate::DSWaylandPointerPrivate(DSWaylandSeat *seat, DSWaylandP : DSObjectPrivate(pointer), __p_ptr(pointer), __seat(seat), - __waylandSurface(nullptr) + __compositor(seat->getCompositor()), + __waylandSurface(nullptr), + __wlPointerResource(nullptr) { wl_pointer(); } @@ -42,6 +47,60 @@ DSWaylandPointerPrivate::~DSWaylandPointerPrivate() { } +void DSWaylandPointerPrivate::setFocus(DSWaylandSurface *waylandSurface) +{ + DSLOG_INF("DSWaylandPointerPrivate", "pointer focus changed (%p -> %p)", __waylandSurface, waylandSurface); + +#if 0 + if (__waylandSurface) + { + DSLOG_INF("DSWaylandPointerPrivate", "send leave to %p", __waylandSurface); + send_leave(__wlPointerResource, __waylandSurface->getWlResource()); + } +#endif + + __waylandSurface = waylandSurface; + + if (!waylandSurface) + { + __wlPointerResource = nullptr; + DSLOG_INF("DSWaylandPointerPrivate", "wlPointerResource has been set to null."); + 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) + { + __wlPointerResource = res->handle; + break; + } + + } + + if (!__wlPointerResource) + { + DSLOG_INF("DSWaylandPointerPrivate", "no wlPointerResource available"); + return; + } +#if 0 + DSLOG_INF("DSWaylandPointerPrivate", "send enter to %p", __waylandSurface); + sendEnter(__wlPointerResource, __waylandSurface->getWlResource(), surface_x, surface_y); +#endif +} + +DSWaylandSurface *DSWaylandPointerPrivate::getFocus() +{ + return __waylandSurface; +} + void DSWaylandPointerPrivate::pointer_bind_resource(Resource *resource) { DSLOG_INF("DSWaylandPointerPrivate",""); @@ -63,6 +122,32 @@ void DSWaylandPointerPrivate::pointer_release(Resource *resource) wl_resource_destroy(resource->handle); } +void DSWaylandPointerPrivate::sendEnter(struct ::wl_resource *wlResource, struct ::wl_resource *surface, int surface_x, int surface_y) +{ + wl_fixed_t surface_x_fixed = wl_fixed_from_int(surface_x); + wl_fixed_t surface_y_fixed = wl_fixed_from_int(surface_y); + + send_enter(__wlPointerResource, __compositor->nextSerial(), surface, surface_x_fixed, surface_y_fixed); +} + +void DSWaylandPointerPrivate::sendLeave(struct ::wl_resource *wlResource, struct ::wl_resource *surface) +{ + send_leave(__wlPointerResource, __compositor->nextSerial(), surface); +} + +void DSWaylandPointerPrivate::sendMotion(int surface_x, int surface_y) +{ + wl_fixed_t surface_x_fixed = wl_fixed_from_int(surface_x); + wl_fixed_t surface_y_fixed = wl_fixed_from_int(surface_y); + + send_motion(__wlPointerResource, __seat->getCurrentEventTime(), surface_x_fixed, surface_y_fixed); +} + +void DSWaylandPointerPrivate::sendButton(uint32_t button, uint32_t state) +{ + send_button(__wlPointerResource, __compositor->nextSerial(), __seat->getCurrentEventTime(), button, state); +} + /* Begin Public Class Implementation */ DSWaylandPointer::DSWaylandPointer(DSWaylandSeat *seat) : DSObject(), _d_ptr(std::make_unique(seat, this)) @@ -94,13 +179,43 @@ void DSWaylandPointer::addClient(DSWaylandClient *client, uint32_t id, int versi void DSWaylandPointer::setFocus(DSWaylandSurface *waylandSurface) { DS_GET_PRIV(DSWaylandPointer); - priv->__waylandSurface = waylandSurface; + priv->setFocus(waylandSurface); } DSWaylandSurface *DSWaylandPointer::getFocus() { DS_GET_PRIV(DSWaylandPointer); - return priv->__waylandSurface; + return priv->getFocus(); +} + +void DSWaylandPointer::sendEnter(int surface_x, int surface_y) +{ + DS_GET_PRIV(DSWaylandPointer); + priv->sendEnter(priv->__wlPointerResource, priv->__waylandSurface->getWlResource(), surface_x, surface_y); +} + +void DSWaylandPointer::sendLeave() +{ + DS_GET_PRIV(DSWaylandPointer); + priv->sendLeave(priv->__wlPointerResource, priv->__waylandSurface->getWlResource()); +} + +void DSWaylandPointer::sendMotion(int surface_x, int surface_y) +{ + DS_GET_PRIV(DSWaylandPointer); + priv->sendMotion(surface_x, surface_y); +} + +void DSWaylandPointer::sendButtonDown(uint32_t button) +{ + DS_GET_PRIV(DSWaylandPointer); + priv->sendButton(button, WL_POINTER_BUTTON_STATE_PRESSED); +} + +void DSWaylandPointer::sendButtonUp(uint32_t button) +{ + DS_GET_PRIV(DSWaylandPointer); + priv->sendButton(button, WL_POINTER_BUTTON_STATE_RELEASED); } } diff --git a/src/DSWaylandServer/DSWaylandPointer.h b/src/DSWaylandServer/DSWaylandPointer.h index d2f468a..7a1f832 100644 --- a/src/DSWaylandServer/DSWaylandPointer.h +++ b/src/DSWaylandServer/DSWaylandPointer.h @@ -48,6 +48,12 @@ public: void setFocus(DSWaylandSurface *waylandSurface); DSWaylandSurface *getFocus(); + void sendEnter(int surface_x, int surface_y); + void sendLeave(void); + void sendMotion(int surface_x, int surface_y); + void sendButtonDown(uint32_t button); + void sendButtonUp(uint32_t button); + protected: private: diff --git a/src/DSWaylandServer/DSWaylandPointerPrivate.h b/src/DSWaylandServer/DSWaylandPointerPrivate.h index a53bece..aa0809a 100644 --- a/src/DSWaylandServer/DSWaylandPointerPrivate.h +++ b/src/DSWaylandServer/DSWaylandPointerPrivate.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 DSWaylandPointerPrivate : public DSObjectPrivate, public DSWaylandServer::wl_pointer { DS_PIMPL_USE_PUBLIC(DSWaylandPointer); @@ -40,6 +45,9 @@ public: DSWaylandPointerPrivate(DSWaylandSeat *seat, DSWaylandPointer *pointer); ~DSWaylandPointerPrivate() override; + void setFocus(DSWaylandSurface *waylandSurface); + DSWaylandSurface *getFocus(); + protected: //virtual Resource *pointer_allocate(); void pointer_bind_resource(Resource *resource) override; @@ -48,13 +56,10 @@ protected: void pointer_release(Resource *resource) override; /* APIs must be provided */ - /* - void sendEnter(struct ::wl_client *client, uint32_t serial, struct ::wl_resource *surface, wl_fixed_t surface_x, wl_fixed_t surface_y); - void sendLeave(struct ::wl_client *client, uint32_t serial, struct ::wl_resource *surface); - void sendMotion(struct ::wl_client *client, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y); - void sendButton(struct ::wl_client *client, uint32_t serial, uint32_t time, uint32_t button, uint32_t state); - */ - + void sendEnter(struct ::wl_resource *wlResource, struct ::wl_resource *surface, int surface_x, int surface_y); + void sendLeave(struct ::wl_resource *wlResource, struct ::wl_resource *surface); + void sendMotion(int surface_x, int surface_y); + void sendButton(uint32_t button, uint32_t state); /* APIs don't need to provide */ /* void sendAxis(struct ::wl_resource *resource, uint32_t time, uint32_t axis, wl_fixed_t value); @@ -66,7 +71,9 @@ protected: private: DSWaylandSeat *__seat; + DSWaylandCompositor *__compositor; DSWaylandSurface *__waylandSurface; + struct ::wl_resource *__wlPointerResource; }; } -- 2.7.4 From 42d205471f4f5124f6e1372157553cbe8335a665 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Sat, 15 Aug 2020 15:38:42 +0900 Subject: [PATCH 02/16] DSPointer: implement mouseDown/Move/Up/In/Out event handler Change-Id: I8221adc5b1357ca97e75a0f29776aa13e022a7ae Signed-off-by: Sung-Jin Park --- src/DSSeat/DSPointer.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++- src/DSSeat/DSPointer.h | 5 +++ 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/src/DSSeat/DSPointer.cpp b/src/DSSeat/DSPointer.cpp index ce2781d..3f6375e 100644 --- a/src/DSSeat/DSPointer.cpp +++ b/src/DSSeat/DSPointer.cpp @@ -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 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; } diff --git a/src/DSSeat/DSPointer.h b/src/DSSeat/DSPointer.h index d0dbdc7..5717c51 100644 --- a/src/DSSeat/DSPointer.h +++ b/src/DSSeat/DSPointer.h @@ -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 window); std::shared_ptr getFocus(); -- 2.7.4 From b7505031563bdae29e885e001ed68ab5e77e0cf8 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Sat, 15 Aug 2020 15:40:03 +0900 Subject: [PATCH 03/16] DSSeat: get Top Window on x, y coordinates and set it as a focus window for touch/pointer Change-Id: I45e4bdae90b3f7cd9a50b50f69853aab7765a62a Signed-off-by: Sung-Jin Park --- src/DSSeat/DSSeat.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/DSSeat/DSSeat.h | 1 + 2 files changed, 58 insertions(+) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index 69ca1d2..d8aab6c 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -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(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(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 DSSeat::getTopWindowOnPosition(int x, int y) +{ + stPosition wPos; + stSize wSize; + + std::list> 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 diff --git a/src/DSSeat/DSSeat.h b/src/DSSeat/DSSeat.h index 25f84c4..9363f6c 100644 --- a/src/DSSeat/DSSeat.h +++ b/src/DSSeat/DSSeat.h @@ -72,6 +72,7 @@ public: void removeTouch(); DSXkb *getXkb(); + std::shared_ptr getTopWindowOnPosition(int x, int y); private: DSInput *__input; -- 2.7.4 From 85dcbdc07fe71ebc5c4413456f1474d380dd250f Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 18 Aug 2020 14:24:23 +0900 Subject: [PATCH 04/16] DSRenderEngineDaliImpl: set default value of __needToRender to 'true' Change-Id: I9078b360b1308fe39145f0d509456209550c6e0c Signed-off-by: Joonbum Ko --- src/DSRender/DSRenderEngineDaliImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp index a716b55..1ab9f6c 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -36,7 +36,7 @@ namespace display_server DSRenderEngineDaliImpl::DSRenderEngineDaliImpl(std::shared_ptr bufferQueue) : __bufferQueue(bufferQueue), - __needToRender(false) + __needToRender(true) { tbm_surface_queue_h nativeBufferQueue = (tbm_surface_queue_h)bufferQueue->getNativeBufferQueue(); __offscreenApplication = OffscreenApplication::New(nativeBufferQueue, true, OffscreenApplication::RenderMode::MANUAL); -- 2.7.4 From e974efe18ea2ea299ad4fddeaefa8bd0cae57604 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 18 Aug 2020 14:32:46 +0900 Subject: [PATCH 05/16] DSWaylandKeyboard: fix to initialze member variable properly, add exception handling on setFocus() Change-Id: I20211a9be278d73bd21baacb230704f347711040 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandKeyboard.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandKeyboard.cpp b/src/DSWaylandServer/DSWaylandKeyboard.cpp index 85fa455..48ce7f4 100644 --- a/src/DSWaylandServer/DSWaylandKeyboard.cpp +++ b/src/DSWaylandServer/DSWaylandKeyboard.cpp @@ -39,8 +39,8 @@ DSWaylandKeyboardPrivate::DSWaylandKeyboardPrivate(DSWaylandSeat *seat, DSWaylan : DSObjectPrivate(keyboard), __p_ptr(keyboard), __seat(seat), - __xkb(seat->getXkb()), - __compositor(seat->getCompositor()), + __xkb(seat ? (seat->getXkb()) : nullptr), + __compositor(seat ? (seat->getCompositor()) : nullptr), __focusSurface(nullptr), __focusClient(nullptr), __repeatRate(0), @@ -267,18 +267,21 @@ void DSWaylandKeyboard::setFocus(DSWaylandSurface *waylandSurface) if (priv->__focusSurface != waylandSurface) { - if (priv->__focusSurface) + if (priv->__focusSurface && priv->__focusSurface->hasResource()) { struct ::wl_resource *surfaceToLeave = priv->__focusSurface->getWlResource(); priv->sendModifiers(surfaceToLeave); priv->sendLeave(surfaceToLeave); } - struct ::wl_resource *surfaceToEnter = waylandSurface->getWlResource(); - priv->sendEnter(surfaceToEnter); + if (waylandSurface && waylandSurface->hasResource()) + { + struct ::wl_resource *surfaceToEnter = waylandSurface->getWlResource(); + priv->sendEnter(surfaceToEnter); - priv->__focusSurface = waylandSurface; - priv->__focusClient = wl_resource_get_client(waylandSurface->getWlResource()); + priv->__focusSurface = waylandSurface; + priv->__focusClient = wl_resource_get_client(waylandSurface->getWlResource()); + } } } -- 2.7.4 From c9bfc8f68a41ee0c081f0bb48ec550465075c1ec Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 18 Aug 2020 14:35:22 +0900 Subject: [PATCH 06/16] DSWaylandSurface: add hasResource() to check validity of a DSWaylandSurface instance Change-Id: I2131ca2f173a2e2a6e43f1ad1560d94cb3920b50 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandSurface.cpp | 9 +++++++++ src/DSWaylandServer/DSWaylandSurface.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp index 9896f38..60d2f56 100644 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ b/src/DSWaylandServer/DSWaylandSurface.cpp @@ -211,4 +211,13 @@ struct ::wl_resource *DSWaylandSurface::getWlResource() return priv->resource()->handle; } +bool DSWaylandSurface::hasResource() +{ + DS_GET_PRIV(DSWaylandSurface); + + if (priv->resource()) + return true; + return false; +} + } /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandSurface.h b/src/DSWaylandServer/DSWaylandSurface.h index c7519dc..7cc360b 100644 --- a/src/DSWaylandServer/DSWaylandSurface.h +++ b/src/DSWaylandServer/DSWaylandSurface.h @@ -63,6 +63,7 @@ public: void registerCallbackSurfaceCommitted(DSObject *slot, std::function commitInfo)> func); struct ::wl_resource *getWlResource(); + bool hasResource(); private: // signals -- 2.7.4 From 0126aee89744108f47837896620f21fcb277f0e1 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 18 Aug 2020 16:25:56 +0900 Subject: [PATCH 07/16] DSWaylandPointer: fix crash at the constructor and setFocus() Change-Id: Iaa6352dc3e4f391fa2135085dc3552afc981678e Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandPointer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandPointer.cpp b/src/DSWaylandServer/DSWaylandPointer.cpp index dea562f..4ae9813 100644 --- a/src/DSWaylandServer/DSWaylandPointer.cpp +++ b/src/DSWaylandServer/DSWaylandPointer.cpp @@ -36,7 +36,7 @@ DSWaylandPointerPrivate::DSWaylandPointerPrivate(DSWaylandSeat *seat, DSWaylandP : DSObjectPrivate(pointer), __p_ptr(pointer), __seat(seat), - __compositor(seat->getCompositor()), + __compositor(seat ? (seat->getCompositor()) : nullptr), __waylandSurface(nullptr), __wlPointerResource(nullptr) { @@ -61,7 +61,7 @@ void DSWaylandPointerPrivate::setFocus(DSWaylandSurface *waylandSurface) __waylandSurface = waylandSurface; - if (!waylandSurface) + if (!waylandSurface || !waylandSurface->hasResource()) { __wlPointerResource = nullptr; DSLOG_INF("DSWaylandPointerPrivate", "wlPointerResource has been set to null."); -- 2.7.4 From 3a7e72fe0377bcc69ee3d77d4a56a9cee06a516c Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 18 Aug 2020 16:28:56 +0900 Subject: [PATCH 08/16] DSWaylandTouch: fix crash at the constructor and setFocus() Change-Id: I6406ab69856a7c21467ee11888edf122f27e9f7a Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandTouch.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandTouch.cpp b/src/DSWaylandServer/DSWaylandTouch.cpp index c2a3fa1..25a267b 100644 --- a/src/DSWaylandServer/DSWaylandTouch.cpp +++ b/src/DSWaylandServer/DSWaylandTouch.cpp @@ -35,7 +35,7 @@ DSWaylandTouchPrivate::DSWaylandTouchPrivate(DSWaylandSeat *seat, DSWaylandTouch : DSObjectPrivate(touch), __p_ptr(touch), __seat(seat), - __compositor(seat->getCompositor()), + __compositor(seat ? (seat->getCompositor()) : nullptr), __waylandSurface(nullptr), __wlTouchResource(nullptr) { @@ -52,8 +52,12 @@ void DSWaylandTouchPrivate::setFocus(DSWaylandSurface *waylandSurface) __waylandSurface = waylandSurface; - if (!waylandSurface) + if (!waylandSurface || !waylandSurface->hasResource()) + { + __wlTouchResource = nullptr; + DSLOG_INF("DSWaylandTouchPrivate", "wlTouchResource has been set to null."); return; + } struct ::wl_resource *surface = waylandSurface->getWlResource(); auto client = wl_resource_get_client(surface); -- 2.7.4 From 272d3d729fa85b799f907d3185730ca4af9f2072 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Tue, 18 Aug 2020 16:31:35 +0900 Subject: [PATCH 09/16] DSWindowManager: add register/unregister zone/surface Change-Id: I0993c30c11572ece50df11c620974f1cb51e8352 --- src/DSWindowManager/DSWindowManager.cpp | 212 ++++++++++++++++++++++++++- src/DSWindowManager/DSWindowManager.h | 15 ++ src/DSWindowManager/DSWindowManagerPrivate.h | 32 +++- src/DSZone/DSZone.cpp | 17 ++- src/DSZone/DSZone.h | 2 + tests/DSWindowManager-test.cpp | 72 ++++++++- 6 files changed, 343 insertions(+), 7 deletions(-) diff --git a/src/DSWindowManager/DSWindowManager.cpp b/src/DSWindowManager/DSWindowManager.cpp index 10dc622..5eaa293 100644 --- a/src/DSWindowManager/DSWindowManager.cpp +++ b/src/DSWindowManager/DSWindowManager.cpp @@ -23,6 +23,9 @@ #include "DSWindowManager.h" #include "DSWindowManagerPrivate.h" +#include "DSZone.h" +#include "DSWindow.h" +#include "DSWaylandSurface.h" #include "DSDebugLog.h" namespace display_server @@ -43,6 +46,163 @@ DSWindowManagerPrivate::~DSWindowManagerPrivate() { } +DSZone *DSWindowManagerPrivate::__getZone(DSWindow *window) +{ + auto it = __zoneWinMap.find(window); + if (it != __zoneWinMap.end()) + return it->second; + + return nullptr; +} + +DSZone *DSWindowManagerPrivate::__getZone(DSWaylandSurface *surface) +{ + auto it = __zoneSurfaceMap.find(surface); + if (it != __zoneSurfaceMap.end()) + return it->second; + + return nullptr; +} + +bool DSWindowManagerPrivate::__checkZone(DSZone *zone) +{ + std::list zList = __zoneList; + for (DSZone *z : zList) + { + if (z == zone) + { + return true; + } + } + + return false; +} + +void DSWindowManagerPrivate::__registerZone(DSZone *zone) +{ + __zoneList.push_front(zone); +} + +bool DSWindowManagerPrivate::registerZone(DSZone *zone) +{ + // find zone in zone List + if (__checkZone(zone)) + { + // Error... Already exist!!! + return false; + } + + DSLOG_DBG("WindowManager", "Register Zone:%p", zone); + // add zone to list + __registerZone(zone); + return true; +} + +void DSWindowManagerPrivate::__unregisterZone(DSZone *zone) +{ + __zoneList.remove(zone); +} + +void DSWindowManagerPrivate::unregisterZone(DSZone *zone) +{ + // find zone in zone list + if (!__checkZone(zone)) return; + + DSLOG_DBG("WindowManager", "Unregister Zone:%p", zone); + // remove zone from list + __unregisterZone(zone); +} + +void DSWindowManagerPrivate::__registerWindow(DSZone *zone, DSWindow *window) +{ + __zoneWinMap.insert(std::make_pair(window, zone)); +} + +bool DSWindowManagerPrivate::registerWindow(DSZone *zone, DSWindow *window) +{ + // find zone in zone list + if (!__checkZone(zone)) + { + // Error.. Zone is not exist + return false; + } + + // map window to zone + __registerWindow(zone, window); + return true; +} + +void DSWindowManagerPrivate::__unregisterWindow(DSWindow *window) +{ + __zoneWinMap.erase(window); +} + +void DSWindowManagerPrivate::unregisterWindow(DSZone *zone, DSWindow *window) +{ + // find zone in zone list + if (!__checkZone(zone)) + { + // Error.. Zone is not exist + return; + } + + // unmap window from zone + __unregisterWindow(window); +} + +DSZone *DSWindowManagerPrivate::getZone(DSWindow *window) +{ + return __getZone(window); +} + +void DSWindowManagerPrivate::__registerSurface(DSZone *zone, DSWaylandSurface *surface) +{ + __zoneSurfaceMap.insert(std::make_pair(surface, zone)); +} + +bool DSWindowManagerPrivate::registerSurface(DSZone *zone, DSWaylandSurface *surface) +{ + // find zone in zone list + if (!__checkZone(zone)) + { + // Error.. Zone is not exist + return false; + } + + DSLOG_DBG("WindowManager", "Register Surface:%p to Zone:%p", surface, zone); + + // map window to zone + __registerSurface(zone, surface); + return true; +} + +void DSWindowManagerPrivate::__unregisterSurface(DSWaylandSurface *surface) +{ + __zoneSurfaceMap.erase(surface); +} + +void DSWindowManagerPrivate::unregisterSurface(DSZone *zone, DSWaylandSurface *surface) +{ + // find zone in zone list + if (!__checkZone(zone)) + { + // Error.. Zone is not exist + return; + } + + DSLOG_DBG("WindowManager", "Unregister Surface:%p from Zone:%p", surface, zone); + + // unmap window from zone + __unregisterSurface(surface); +} + +DSZone *DSWindowManagerPrivate::getZone(DSWaylandSurface *surface) +{ + return __getZone(surface); +} + + + DSWindowManager::DSWindowManager(DSObject *parent) : DS_INIT_PRIVATE_PTR(DSWindowManager) { @@ -53,6 +213,7 @@ DSWindowManager::~DSWindowManager() } /* getInstance for DSWindowManager singleton */ +//static DSWindowManager *DSWindowManager::getInstance() { std::lock_guard tLock(__mutex); @@ -72,6 +233,7 @@ DSWindowManager *DSWindowManager::getInstance() } /* releaseInstance for DSWindowManager singleton */ +// static void DSWindowManager::releaseInstance() { std::lock_guard tLock(__mutex); @@ -91,5 +253,53 @@ void DSWindowManager::releaseInstance() } } +bool DSWindowManager::registerZone(DSZone *zone) +{ + DS_GET_PRIV(DSWindowManager); + return priv->registerZone(zone); +} + +void DSWindowManager::unregisterZone(DSZone *zone) +{ + DS_GET_PRIV(DSWindowManager); + priv->unregisterZone(zone); +} + +bool DSWindowManager::registerWindow(DSZone *zone, DSWindow *window) +{ + DS_GET_PRIV(DSWindowManager); + return priv->registerWindow(zone, window); +} + +void DSWindowManager::unregisterWindow(DSZone *zone, DSWindow *window) +{ + DS_GET_PRIV(DSWindowManager); + priv->unregisterWindow(zone, window); +} + +DSZone *DSWindowManager::getZone(DSWindow *window) +{ + DS_GET_PRIV(DSWindowManager); + return priv->getZone(window); +} + +bool DSWindowManager::registerSurface(DSZone *zone, DSWaylandSurface *surface) +{ + DS_GET_PRIV(DSWindowManager); + return priv->registerSurface(zone, surface); +} + +void DSWindowManager::unregisterSurface(DSZone *zone, DSWaylandSurface *surface) +{ + DS_GET_PRIV(DSWindowManager); + priv->unregisterSurface(zone, surface); +} + +DSZone *DSWindowManager::getZone(DSWaylandSurface *surface) +{ + DS_GET_PRIV(DSWindowManager); + return priv->getZone(surface); +} + -} // namespace display_server \ No newline at end of file +} // namespace display_server diff --git a/src/DSWindowManager/DSWindowManager.h b/src/DSWindowManager/DSWindowManager.h index 0dd3252..7ad2f0d 100644 --- a/src/DSWindowManager/DSWindowManager.h +++ b/src/DSWindowManager/DSWindowManager.h @@ -31,6 +31,9 @@ namespace display_server { class DSWindowManagerPrivate; +class DSZone; +class DSWindow; +class DSWaylandSurface; class DSWindowManager : public DSObject { @@ -40,6 +43,18 @@ public: static DSWindowManager *getInstance(); static void releaseInstance(); + // APIs for DSZone related + bool registerZone(DSZone *zone); + void unregisterZone(DSZone *zone); + + bool registerWindow(DSZone *zone, DSWindow *window); + void unregisterWindow(DSZone *zone, DSWindow *window); + DSZone *getZone(DSWindow *window); + + bool registerSurface(DSZone *zone, DSWaylandSurface *surface); + void unregisterSurface(DSZone *zone, DSWaylandSurface *surface); + DSZone *getZone(DSWaylandSurface *surface); + protected: private: diff --git a/src/DSWindowManager/DSWindowManagerPrivate.h b/src/DSWindowManager/DSWindowManagerPrivate.h index 8538009..f92b0d7 100644 --- a/src/DSWindowManager/DSWindowManagerPrivate.h +++ b/src/DSWindowManager/DSWindowManagerPrivate.h @@ -24,6 +24,7 @@ #ifndef __DS_WINDOW_MANAGER_PRIVATE__ #define __DS_WINDOW_MANAGER_PRIVATE__ +#include #include "DSWindowManager.h" namespace display_server @@ -38,9 +39,38 @@ public: DSWindowManagerPrivate(DSWindowManager *p_ptr); ~DSWindowManagerPrivate(); + bool registerZone(DSZone *zone); + void unregisterZone(DSZone *zone); + + bool registerWindow(DSZone *zone, DSWindow *window); + void unregisterWindow(DSZone *zone, DSWindow *window); + DSZone *getZone(DSWindow *window); + + bool registerSurface(DSZone *zone, DSWaylandSurface *surface); + void unregisterSurface(DSZone *zone, DSWaylandSurface *surface); + DSZone *getZone(DSWaylandSurface *surface); + +private: + DSZone *__getZone(DSWindow *window); + DSZone *__getZone(DSWaylandSurface *surface); + bool __checkZone(DSZone *zone); + + void __registerZone(DSZone *zone); + void __unregisterZone(DSZone *zone); + + void __registerWindow(DSZone *zone, DSWindow *window); + void __unregisterWindow(DSWindow *window); + + void __registerSurface(DSZone *zone, DSWaylandSurface *surface); + void __unregisterSurface(DSWaylandSurface *surface); + + private: + std::list __zoneList; + std::unordered_map __zoneWinMap; + std::unordered_map __zoneSurfaceMap; }; } // namespace display_server -#endif \ No newline at end of file +#endif diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index c1844c3..a838a28 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -34,12 +34,17 @@ namespace display_server DSZone::DSZone() : __position{0, 0}, __size{0, 0}, - __waylandCompositor(nullptr) + __waylandCompositor(nullptr), + __wm(nullptr) { __waylandCompositor = DSWaylandCompositor::getInstance(); __waylandCompositor->registerCallbackSurfaceCreated(this, std::bind(&DSZone::__onSurfaceCreated, this, std::placeholders::_1)); __waylandCompositor->registerCallbackSurfaceDestroy(this, std::bind(&DSZone::__onSurfaceDestroy, this, std::placeholders::_1)); + __wm = DSWindowManager::getInstance(); + if (__wm) + __wm->registerZone(this); + __waylandShell = __waylandCompositor->getShell(); if (__waylandShell) __waylandShell->registerCallbackShellSurfaceCreated(this, std::bind(&DSZone::__onShellSurfaceCreated, this, std::placeholders::_1)); @@ -47,6 +52,10 @@ DSZone::DSZone() DSZone::~DSZone() { + if (__wm) + __wm->unregisterZone(this); + + DSWindowManager::releaseInstance(); DSWaylandCompositor::releaseInstance(); } @@ -99,6 +108,9 @@ void DSZone::__onSurfaceCreated(std::shared_ptr waylandSurface { DSLOG_DBG("DSZone", "waylandSurface:(shared:%p, pure:%p)", waylandSurface, waylandSurface.get()); + if (__wm) + __wm->registerSurface(this, waylandSurface.get()); + // create DSWindow std::shared_ptr window = __createWindow(waylandSurface); @@ -113,6 +125,9 @@ void DSZone::__onSurfaceDestroy(std::shared_ptr waylandSurface { DSWaylandSurface *dswSurfacePtr = waylandSurface.get(); + if (__wm) + __wm->unregisterSurface(this, dswSurfacePtr); + DSWindowShell *shell = __findWindowShell(dswSurfacePtr); __destroyWindowShell(shell, dswSurfacePtr); diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index e464e31..5bbf38f 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -25,6 +25,7 @@ #define __DS_ZONE_H__ #include +#include "DSWindowManager.h" #include "DSWindow.h" #include "DSWindowShell.h" #include "DSSignal.h" @@ -80,6 +81,7 @@ private: std::list> __windowList; std::list> __windowShellList; DSWaylandCompositor *__waylandCompositor; + DSWindowManager *__wm; IDSWaylandShell *__waylandShell; std::map __windowShellMap; diff --git a/tests/DSWindowManager-test.cpp b/tests/DSWindowManager-test.cpp index 918651e..319d418 100644 --- a/tests/DSWindowManager-test.cpp +++ b/tests/DSWindowManager-test.cpp @@ -24,24 +24,88 @@ #include "libds-tests.h" #include "DSWaylandCompositor.h" #include "DSWindowManager.h" +#include "DSZone.h" +#include "DSWindow.h" +#include "DSWaylandSurface.h" + using namespace display_server; +DSWindowManager* g_winMgr = nullptr; + class DSWindowManagerTest : public ::testing::Test { public: void SetUp(void) override { - setenv("XDG_RUNTIME_DIR", "/run", 1); + g_winMgr = DSWindowManager::getInstance(); } void TearDown(void) override { - unsetenv("XDG_RUNTIME_DIR"); + DSWindowManager::releaseInstance(); + g_winMgr = nullptr; } }; TEST_F(DSWindowManagerTest, GetWindowManager) { - DSWindowManager* winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); + EXPECT_TRUE(g_winMgr != nullptr); +} + +TEST_F(DSWindowManagerTest, RegisterWindow) +{ + bool ret = false; + DSZone *foundZone = nullptr; + + EXPECT_TRUE(g_winMgr != nullptr); + + auto zone = std::make_shared(); + EXPECT_TRUE(zone != nullptr); + + auto window = std::make_shared(); + EXPECT_TRUE(window != nullptr); + + foundZone = g_winMgr->getZone(window.get()); + EXPECT_TRUE(foundZone == nullptr); + + ret = g_winMgr->registerWindow(zone.get(), window.get()); + EXPECT_TRUE(ret == true); + + foundZone = g_winMgr->getZone(window.get()); + EXPECT_TRUE(foundZone == zone.get()); + + g_winMgr->unregisterWindow(zone.get(), window.get()); + + foundZone = g_winMgr->getZone(window.get()); + EXPECT_TRUE(foundZone == nullptr); +} + +TEST_F(DSWindowManagerTest, RegisterSurface) +{ + bool ret = false; + DSZone *foundZone = nullptr; + + EXPECT_TRUE(g_winMgr != nullptr); + + auto zone = std::make_shared(); + EXPECT_TRUE(zone != nullptr); + + auto surface = std::make_shared(); + EXPECT_TRUE(surface != nullptr); + + foundZone = g_winMgr->getZone(surface.get()); + EXPECT_TRUE(foundZone == nullptr); + + ret = g_winMgr->registerSurface(zone.get(), surface.get()); + EXPECT_TRUE(ret == true); + + foundZone = g_winMgr->getZone(surface.get()); + EXPECT_TRUE(foundZone == zone.get()); + + g_winMgr->unregisterSurface(zone.get(), surface.get()); + + foundZone = g_winMgr->getZone(surface.get()); + EXPECT_TRUE(foundZone == nullptr); } + + -- 2.7.4 From 861cc59d3c9fef41cfd91ddc66243822265cded7 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Tue, 18 Aug 2020 16:36:24 +0900 Subject: [PATCH 10/16] add sample code to handle request (set title) Change-Id: I6e95c415675585ea4188df166644610413d6298d --- src/DSWaylandServer/DSWaylandZxdgShellV6.cpp | 6 +++++- src/DSWindow/DSWindow.cpp | 27 ++++++++++++++++++++++- src/DSWindow/DSWindow.h | 3 +++ src/DSWindow/DSWindowPrivate.h | 4 ++++ src/DSWindowManager/DSWindowManager.cpp | 20 +++++++++++++++++ src/DSWindowManager/DSWindowManager.h | 2 ++ src/DSWindowManager/DSWindowManagerPrivate.h | 2 ++ src/DSZone/DSZone.cpp | 6 ++++++ src/DSZone/DSZone.h | 3 +++ tests/DSWindow-test.cpp | 32 ++++++++++++++++++++-------- 10 files changed, 94 insertions(+), 11 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp index 47d3b0d..76b3758 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp @@ -21,6 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ +#include "DSWindowManager.h" #include "DSWaylandZxdgShellV6.h" #include "DSWaylandZxdgShellV6Private.h" #include "DSWaylandCompositor.h" @@ -420,8 +421,11 @@ void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_ack_configure(zxdg_surface_v void DSWaylandZxdgSurfaceV6Private::setWindowTitle(const std::string &title) { // TODO: needs DSWindow title set method - //__window->setTitle(title); __title = title; + + DSWindowManager *wm = DSWindowManager::getInstance(); + wm->setWindowTitle(__dsSurface, __title); + DSWindowManager::releaseInstance(); } void DSWaylandZxdgSurfaceV6Private::setAppID(const std::string &appId) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index d210e16..434d134 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -42,7 +42,8 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) __hasFocus(false), __waylandSurface(nullptr), __winShell(nullptr), - __firstCommit(true) + __firstCommit(true), + __title("") { } @@ -79,6 +80,17 @@ int DSWindowPrivate::showState(void) return 0; } +bool DSWindowPrivate::setTitle(const std::string &title) +{ + __title.replace(__title.begin(), __title.end(), title); + return true; +} + +const std::string DSWindowPrivate::getTitle(void) +{ + return __title; +} + bool DSWindowPrivate::setLayer(int layer) { return true; @@ -219,6 +231,19 @@ int DSWindow::showState(void) return priv->showState(); } +bool DSWindow::setTitle(const std::string &title) +{ + DSLOG_DBG("DSWindow", "title:%s", title.c_str()); + + DS_GET_PRIV(DSWindow); + return priv->setTitle(title); +} + +const std::string DSWindow::getTitle(void) +{ + DS_GET_PRIV(DSWindow); + return priv->getTitle(); +} bool DSWindow::setLayer(int layer) { diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index ec94e12..04bfa9f 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -53,6 +53,9 @@ public: bool hide(bool autoFocus = true); int showState(void); + bool setTitle(const std::string &title); + const std::string getTitle(void); + bool setLayer(int layer); bool raise(void); bool lower(void); diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index 249c5b0..d532ad0 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -50,6 +50,9 @@ public: bool hide(bool autoFocus); int showState(void); + bool setTitle(const std::string &title); + const std::string getTitle(void); + bool setLayer(int layer); bool raise(void); bool lower(void); @@ -74,6 +77,7 @@ private: std::shared_ptr __waylandSurface; DSWindowShell *__winShell; bool __firstCommit; + std::string __title; }; } diff --git a/src/DSWindowManager/DSWindowManager.cpp b/src/DSWindowManager/DSWindowManager.cpp index 5eaa293..4a5761c 100644 --- a/src/DSWindowManager/DSWindowManager.cpp +++ b/src/DSWindowManager/DSWindowManager.cpp @@ -202,6 +202,20 @@ DSZone *DSWindowManagerPrivate::getZone(DSWaylandSurface *surface) } +void DSWindowManagerPrivate::setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title) +{ + // find dsSurface's window + DSZone *zone = __getZone(dsSurface); + if (zone) + { + zone->setWindowTitle(dsSurface, title); + } + else + { + // Do something if there is no zone + } +} + DSWindowManager::DSWindowManager(DSObject *parent) : DS_INIT_PRIVATE_PTR(DSWindowManager) @@ -301,5 +315,11 @@ DSZone *DSWindowManager::getZone(DSWaylandSurface *surface) return priv->getZone(surface); } +void DSWindowManager::setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title) +{ + DS_GET_PRIV(DSWindowManager); + priv->setWindowTitle(dsSurface, title); +} + } // namespace display_server diff --git a/src/DSWindowManager/DSWindowManager.h b/src/DSWindowManager/DSWindowManager.h index 7ad2f0d..9ae0af6 100644 --- a/src/DSWindowManager/DSWindowManager.h +++ b/src/DSWindowManager/DSWindowManager.h @@ -55,6 +55,8 @@ public: void unregisterSurface(DSZone *zone, DSWaylandSurface *surface); DSZone *getZone(DSWaylandSurface *surface); + void setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title); + protected: private: diff --git a/src/DSWindowManager/DSWindowManagerPrivate.h b/src/DSWindowManager/DSWindowManagerPrivate.h index f92b0d7..9f6bed1 100644 --- a/src/DSWindowManager/DSWindowManagerPrivate.h +++ b/src/DSWindowManager/DSWindowManagerPrivate.h @@ -50,6 +50,8 @@ public: void unregisterSurface(DSZone *zone, DSWaylandSurface *surface); DSZone *getZone(DSWaylandSurface *surface); + void setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title); + private: DSZone *__getZone(DSWindow *window); DSZone *__getZone(DSWaylandSurface *surface); diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index a838a28..0b0f043 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -261,4 +261,10 @@ void DSZone::__destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface * } } +bool DSZone::setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title) +{ + std::shared_ptr window = __findWindow(dswSurface); + return window->setTitle(title); +} + } // namespace display_server diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index 5bbf38f..f89893b 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -58,6 +58,9 @@ public: void callCallbackWindowCreated(); void callCallbackWindowShellCreated(); + // for window property + bool setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title); + std::list> getWindowList(); std::list> getWindowShellList(); diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp index e10385e..7f33bd3 100644 --- a/tests/DSWindow-test.cpp +++ b/tests/DSWindow-test.cpp @@ -40,7 +40,7 @@ public: TEST_F(DSWindowTest, NewDSWindow) { - DSWindow *win = new DSWindow(); + auto win = std::make_shared(); EXPECT_TRUE(win != nullptr); } @@ -54,7 +54,7 @@ TEST_F(DSWindowTest, NewDSWindowWithDSWaylandSurface) TEST_F(DSWindowTest, BasicMethods) { - auto win = new DSWindow(); + auto win = std::make_shared(); EXPECT_TRUE(win != nullptr); EXPECT_TRUE(win->show() == true); @@ -66,13 +66,13 @@ TEST_F(DSWindowTest, BasicMethods) EXPECT_TRUE(win->raise() == true); EXPECT_TRUE(win->lower() == true); + EXPECT_TRUE(win->hasFocus() == false); EXPECT_TRUE(win->setFocus() == true); - EXPECT_TRUE(win->hasFocus() == true); } TEST_F(DSWindowTest, SizeTest) { - auto win = new DSWindow(); + auto win = std::make_shared(); EXPECT_TRUE(win != nullptr); stSize size = win->getSize(); @@ -96,7 +96,7 @@ TEST_F(DSWindowTest, SizeTest) TEST_F(DSWindowTest, PositionTest) { - auto win = new DSWindow(); + auto win = std::make_shared(); EXPECT_TRUE(win != nullptr); stPosition pos = win->getPosition(); @@ -111,15 +111,29 @@ TEST_F(DSWindowTest, PositionTest) TEST_F(DSWindowTest, WindowShellTest) { - auto win = new DSWindow(); + auto win = std::make_shared(); EXPECT_TRUE(win != nullptr); - auto winShell = new DSWindowShell(win); + auto winShell = std::make_shared(win.get()); EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(win->setWindowShell(winShell) == true); + EXPECT_TRUE(win->setWindowShell(winShell.get()) == true); DSWindowShell *getWinShell = nullptr; getWinShell = win->getWindowShell(); - EXPECT_TRUE(winShell == getWinShell); + EXPECT_TRUE(winShell.get() == getWinShell); } + +TEST_F(DSWindowTest, TitleTest) +{ + auto win = std::make_shared(); + EXPECT_TRUE(win != nullptr); + + bool ret = false; + ret = win->setTitle("test title"); + EXPECT_TRUE(ret == true); + + std::string title = win->getTitle(); + EXPECT_TRUE(title.compare("test title") == 0); +} + -- 2.7.4 From c8bb7b09d3017547d7f98a4c9ad654270b953bc1 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 14 Aug 2020 13:48:14 +0900 Subject: [PATCH 11/16] DSDisplayArea: Change the default renderer to DaliRenderEngine. Change-Id: Ibf93fb8ea83cfebb3580bbfb479b5efe35be629e Signed-off-by: Joonbum Ko --- src/DSDisplayArea/DSDisplayArea.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index 00804e0..fdcadd4 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -25,6 +25,7 @@ #include "DSDisplayAreaPrivate.h" #include "DSOutputImpl.h" #include "DSRenderEngineEcoreEvasImpl.h" +#include "DSRenderEngineDaliImpl.h" namespace display_server { @@ -85,7 +86,7 @@ DSDisplayAreaPrivate::DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr if (!bufferQueue) DSLOG_ERR("DSDisplayAreaPrivate", "bufferQueue is null."); - __renderEngine = std::make_shared(bufferQueue); + __renderEngine = std::make_shared(bufferQueue); if (!__renderEngine) DSLOG_ERR("DSCanvasPrivate", "__RenderEngine is null."); -- 2.7.4 From 0f4f3401761c83faa611aec5b4a65637ff5bef3c Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 19 Aug 2020 12:49:22 +0900 Subject: [PATCH 12/16] samples: change the comments on exampleCompositor Change-Id: I82dfa3b0fd5f59d2c2bc01f05680bd19cc45ca3f --- samples/exampleCompositor.cpp | 46 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/samples/exampleCompositor.cpp b/samples/exampleCompositor.cpp index 601658b..a544023 100644 --- a/samples/exampleCompositor.cpp +++ b/samples/exampleCompositor.cpp @@ -32,38 +32,7 @@ using namespace display_server; -/* - 1. MyCompositor and DSCompositor are created. - 2. DSCompositor probes the InputDevice and the OutputDevice at the creation time. - 3. DSCompositor sends the InputAdd/Remove signals and the OutputAdd/Remove signal. - 4. MyCompositor gets those signals and set up outputs and inputs. - 5. MyCompositor configures the canvases with zones and outputs. - 6. MyCompositor configures the the seats with zones. -*/ - -// DSCompositor () -// initialization/deinitialize TDM -// initialization/deinitialize libinput -// initialization/deinitialize wl_server -// initialization event_loop -// call the output callbacks ( OutputAdd, OutputRemove, OutputResolutionSet) -// call the output callbacks ( InputAdd, InputRemove ) -// plugins loading??? - -// policyArea or screenArea ? -// policyRegion or screenRegion ? -// policyZone or screenZone ? -// displayArea or outputArea ? -// displayRegion or outputRegion ? -// displayZone or outputZone ? - -// DSCompositor listen signals. OutputAdd/Remove/ResolutionSet and InputAdd/Remove. -// compositor->connectSignal(DSOuptut::ADD_SIGNAL, DSCompositor::OutputAdd); -// compositor->connectSignal(IDSOutput::REMOVE_SIGNAL, DSCompositor::OutputRemove); -// compositor->connectSignal(IDSOutput::RESOLUTION_SET_SIGNAL, DSCompositor::OutputResolutionSet); -// compositor->connectSignal(DSInput::ADD_SIGNAL, DSCompositor::InputAdd); -// compositor->connectSignal(DSInput::REMOVE_SIGNAL, DSCompositor::InputRemove); - +// MyCompositor has to inherit DSCompositor. class MyCompositor : public DSCompositor { public: @@ -77,6 +46,9 @@ public: virtual ~MyCompositor() {} + // The _onInitialized is called when the DSCompositor is ready to run. + // Make a seat and a policy area. Attach the seat to the policy area. + // Attach the policy area and the display area to canvas and return it. std::shared_ptr _onInitialized() override { int width = __displayArea->getWidth(); @@ -98,6 +70,7 @@ public: return __canvas; } + // The _onOutputAdded is called when the IDSOutput is added. void _onOutputAdded(std::shared_ptr output) override { // set the resolution. @@ -107,18 +80,19 @@ public: __displayArea = std::make_shared(output); } + // The _onOutputAdded is called when the IDSOutput is removed. void _onOutputRemoved(std::shared_ptr output) override { __displayArea.reset(); // delete shared_ptr } + // TODO: void _onInputAdded(std::shared_ptr input) override - { - } + {} + // TODO: void _onInputRemoved(std::shared_ptr input) override - { - } + {} private: std::shared_ptr __canvas; -- 2.7.4 From 84a20bf09fa47ba73eba1e1b6cc70c6cb9690b8a Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 19 Aug 2020 12:59:24 +0900 Subject: [PATCH 13/16] tests: fix the build warning Change-Id: I58d14fad2ed0ef346e79705f0df239c19c577a79 --- tests/DSRenderEngineDaliImpl-test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index 8cc94d0..b1d342f 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -82,7 +82,7 @@ public: for (int j = 0; j < h; j++) { - for (int i = 0; i < stride/4; i++) + for (int i = 0; i < (int)stride/4; i++) { if (i < w) { ptr[0] = b; -- 2.7.4 From ed872441095643fd6754fa33a2ee5393dbd669e7 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 19 Aug 2020 13:18:51 +0900 Subject: [PATCH 14/16] add gcov option for checking code coverage Change-Id: Id3eebafe701c46bb08ec11949c00a79ee0330640 Signed-off-by: Junkyeong Kim --- packaging/libds.spec | 6 ++++++ tests/libds-tests.cpp | 7 +++++++ tests/libds-tests.h | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/packaging/libds.spec b/packaging/libds.spec index 488d26c..81ef44d 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -1,3 +1,5 @@ +%define USE_GCOV 0 + Name: libds Version: 0.0.1 Release: 0 @@ -65,6 +67,10 @@ Test module for testing libtbm APIs cp %{SOURCE1001} . %build +%if "%{USE_GCOV}" == "1" +CXXFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV" +LDFLAGS+=" -lgcov" +%endif meson setup \ --prefix /usr \ --libdir %{_libdir} \ diff --git a/tests/libds-tests.cpp b/tests/libds-tests.cpp index 6ac27a3..4a9ed5a 100644 --- a/tests/libds-tests.cpp +++ b/tests/libds-tests.cpp @@ -29,6 +29,10 @@ int main(int argc, char **argv) { auto AllTestSuccess = false; +#ifdef TIZEN_TEST_GCOV + setenv("GCOV_PREFIX", "/tmp", 1); +#endif + try { ::testing::InitGoogleMock(&argc, argv); ::testing::FLAGS_gtest_death_test_style = "fast"; @@ -45,5 +49,8 @@ int main(int argc, char **argv) std::cout << "\n"; } +#ifdef TIZEN_TEST_GCOV + __gcov_flush(); +#endif return AllTestSuccess; } diff --git a/tests/libds-tests.h b/tests/libds-tests.h index dfb2119..312a732 100644 --- a/tests/libds-tests.h +++ b/tests/libds-tests.h @@ -39,6 +39,10 @@ #include "libds-mock.h" +#ifdef TIZEN_TEST_GCOV +extern "C" void __gcov_flush(void); +#endif + using ::testing::TestWithParam; using ::testing::Bool; using ::testing::Values; -- 2.7.4 From f7af387d3d651bf907da8f5d4203ba22ee8e8b1d Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 12:58:28 +0900 Subject: [PATCH 15/16] DSSeat: fix build warning, getTopWindowOnPosition() to return value properly Change-Id: I8b8c9072f8a7e6c7eb91968f58f5e5744e58b36f Signed-off-by: Sung-Jin Park --- src/DSSeat/DSSeat.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index d8aab6c..b98574d 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -21,7 +21,6 @@ * DEALINGS IN THE SOFTWARE. */ -#include "DSCore.h" #include "DSSeat.h" #include "DSInput.h" #include "DSCompositor.h" @@ -30,6 +29,7 @@ #include "DSInputEvent.h" #include "DSXkb.h" #include "DSZone.h" +#include "DSWindow.h" #include "DSPointer.h" #include "DSKeyboard.h" @@ -515,8 +515,7 @@ std::shared_ptr DSSeat::getTopWindowOnPosition(int x, int y) stPosition wPos; stSize wSize; - std::list> wList = __zone->getWindowList(); - for (auto w : wList) + for (std::shared_ptr w : __zone->getWindowList()) { wSize = w->getSize(); wPos = w->getPosition(); @@ -527,6 +526,8 @@ std::shared_ptr DSSeat::getTopWindowOnPosition(int x, int y) return w; } } + + return nullptr; } } // namespace display_server -- 2.7.4 From 455e4faadd6f0ae96075a9e7bbe40d26b9f294b3 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 13:08:07 +0900 Subject: [PATCH 16/16] DSBuffer: intialize member variable @ DSBufferTBMImpl() Change-Id: Id3ca531f9d32ab049058744a35b255605fe7e1ca Signed-off-by: Sung-Jin Park --- src/DSBuffer/DSBufferTBMImpl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/DSBuffer/DSBufferTBMImpl.cpp b/src/DSBuffer/DSBufferTBMImpl.cpp index faa906a..6cfcc3b 100644 --- a/src/DSBuffer/DSBufferTBMImpl.cpp +++ b/src/DSBuffer/DSBufferTBMImpl.cpp @@ -33,6 +33,7 @@ DSBufferTBMImpl::DSBufferTBMImpl(int width, int height, IDSBuffer::Format format __height{height}, __format{format}, __refCount(0), + __resource(nullptr), __type(DSBufferTBMImpl::Type::SERVER) { @@ -48,6 +49,7 @@ DSBufferTBMImpl::DSBufferTBMImpl(int width, int height, IDSBuffer::Format format __format{format}, __refCount(0), __tsurface(tsurface), + __resource(nullptr), __type(DSBufferTBMImpl::Type::SERVER) {} -- 2.7.4