From 662e3f9617b3b3ddcd468b095e7ac5d70681e3ff Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 15:05:01 +0900 Subject: [PATCH 01/16] DSTouch: add resetFocus(), fix setFocus() Change-Id: Ie5885f765c44fc88bfbb2d781810729ed2696aa6 Signed-off-by: Sung-Jin Park --- src/DSSeat/DSTouch.cpp | 15 +++++++++++++++ src/DSSeat/DSTouch.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/DSSeat/DSTouch.cpp b/src/DSSeat/DSTouch.cpp index 00f8abc..c636dd7 100644 --- a/src/DSSeat/DSTouch.cpp +++ b/src/DSSeat/DSTouch.cpp @@ -108,6 +108,9 @@ void DSTouch::setFocus(std::shared_ptr window) if (!window) { DSLOG_ERR("DSTouch", "Given window is INVALID. (window : %p)", window); + __touchFocus = window; + if (__dswlTouch) + __dswlTouch->setFocus(nullptr); return; } @@ -131,6 +134,18 @@ void DSTouch::setFocus(std::shared_ptr window) __dswlTouch->setFocus(waylandSurface); } +void DSTouch::resetFocus() +{ + if (__touchFocus) + { + __touchFocus = nullptr; + DSLOG_INF("DSTouch", "touchFocus has been reset."); + } + + if (__dswlTouch) + __dswlTouch->resetFocus(); +} + std::shared_ptr DSTouch::getFocus() { return __touchFocus; diff --git a/src/DSSeat/DSTouch.h b/src/DSSeat/DSTouch.h index 99c8d7a..ef164d9 100644 --- a/src/DSSeat/DSTouch.h +++ b/src/DSSeat/DSTouch.h @@ -49,6 +49,7 @@ public: void touchUp(int32_t id); void touchMove(int32_t id, int x, int y); void setFocus(std::shared_ptr window); + void resetFocus(); std::shared_ptr getFocus(); private: -- 2.7.4 From 49af5030c67e16458cdcef6e3cc5900d96627968 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 15:07:37 +0900 Subject: [PATCH 02/16] DSSeat: renew focus window on window creation/destroy handlers Change-Id: I88d6a9460a56c847a4cf57983a179449ecaa2b2f Signed-off-by: Sung-Jin Park --- src/DSSeat/DSSeat.cpp | 70 +++++++++++++++++++++++++++++++++++---------------- src/DSSeat/DSSeat.h | 2 ++ 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index b98574d..86d3cc7 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -138,6 +138,7 @@ bool DSSeat::attachZone(std::shared_ptr zone) __zone = zone; __zone->registerCallbackWindowCreated(this, std::bind(&DSSeat::__onWindowCreated, this, std::placeholders::_1)); + __zone->registerCallbackWindowDestroy(this, std::bind(&DSSeat::__onWindowDestroy, this, std::placeholders::_1)); return true; } @@ -420,7 +421,8 @@ void DSSeat::__onPointerEvent(DSInputMouseEvent *ev) //TODO : emit MouseOut signal //set the window as pointer focus window - __pointer->setFocus(window); + if (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); @@ -445,8 +447,11 @@ void DSSeat::__onTouchEvent(DSInputTouchEvent *ev) //get window whose geometry has intersection with the touch coordinates auto window = getTopWindowOnPosition(ev->getX(), ev->getY()); + DSLOG_INF("DSSeat", "window=%p, window.get()=%p", window, window.get()); + //set the window as touch focus window - __touch->setFocus(window); + if (window) + __touch->setFocus(window); //TODO : emit touch focus changed signal } @@ -457,32 +462,40 @@ void DSSeat::__onTouchEvent(DSInputTouchEvent *ev) void DSSeat::__onWindowCreated(std::shared_ptr window) { - DSLOG_INF("DSSeat", "window created : %p", window); - - if (window == nullptr) - { - DSLOG_ERR("DSSeat", "Invalid window is given."); - return; - } + DSLOG_INF("DSSeat", "window created : %p (%p)", window, window.get()); - /* Set newly created window as focus window for keyboard/pointer/touch temporarily */ - /* FIXME when DSWindowShell and DSWMPolicy has been implmented properly */ + /* FIXME : get focus window for keyboard from DSWindowManager/DSWindowPolicy later */ if (__keyboard) { - DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", __focusWin, window); - __keyboard->setFocus(window); - } + std::shared_ptr focusWin = getTopWindow(__focusWin); + DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", __focusWin ? __focusWin.get() : nullptr, focusWin ? focusWin.get() : nullptr); - if (__pointer) - { - DSLOG_INF("DSSeat", "pointer focus : %p -> %p", __focusWin, window); - __pointer->setFocus(window); + if (focusWin) + __keyboard->setFocus(focusWin); } +} + +void DSSeat::__onWindowDestroy(std::shared_ptr window) +{ + DSLOG_INF("DSSeat", "window destroy : %p (%p)", window, window.get()); + + std::shared_ptr currentFocus = nullptr; + + if (__keyboard && (currentFocus = __keyboard->getFocus()) && (currentFocus.get() == window.get())) + __keyboard->resetFocus(); + if (__pointer && (currentFocus = __pointer->getFocus()) && (currentFocus.get() == window.get())) + __pointer->resetFocus(); + if (__touch && (currentFocus = __touch->getFocus()) && (currentFocus.get() == window.get())) + __touch->resetFocus(); - if (__touch) + /* FIXME : get focus window for keyboard from DSWindowManager/DSWindowPolicy later */ + if (__keyboard) { - DSLOG_INF("DSSeat", "touch focus : %p -> %p", __focusWin, window); - __touch->setFocus(window); + std::shared_ptr focusWin = getTopWindow(window); + DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", __focusWin ? __focusWin.get() : nullptr, focusWin ? focusWin.get() : nullptr); + + if (focusWin) + __keyboard->setFocus(focusWin); } } @@ -510,6 +523,21 @@ Eina_Bool DSSeat::inputEventHandlerTouch(void *data, int type, void *event) return EINA_TRUE; } +std::shared_ptr DSSeat::getTopWindow(std::shared_ptr winExcl) +{ + for (std::shared_ptr w : __zone->getWindowList()) + { + if (w && w.get() == winExcl.get()) + continue; + + /* We suppose that the window located at the top of the window stack is at the front of the list. */ + return w; + + } + + return nullptr; +} + std::shared_ptr DSSeat::getTopWindowOnPosition(int x, int y) { stPosition wPos; diff --git a/src/DSSeat/DSSeat.h b/src/DSSeat/DSSeat.h index 9363f6c..a599b50 100644 --- a/src/DSSeat/DSSeat.h +++ b/src/DSSeat/DSSeat.h @@ -72,6 +72,7 @@ public: void removeTouch(); DSXkb *getXkb(); + std::shared_ptr getTopWindow(std::shared_ptr winExcl); std::shared_ptr getTopWindowOnPosition(int x, int y); private: @@ -109,6 +110,7 @@ private: void __onPointerEvent(DSInputMouseEvent *ev); void __onTouchEvent(DSInputTouchEvent *ev); void __onWindowCreated(std::shared_ptr window); + void __onWindowDestroy(std::shared_ptr window); }; } -- 2.7.4 From cc314ed5856958ed7efcb50970c05251c8c7e733 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 16:00:43 +0900 Subject: [PATCH 03/16] DSWaylandInputPanel: comment on unreachable code Change-Id: I9ba546261d3317b04a82144296a7a8d5c8713e7e Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandInputPanel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp index 75409c4..c1f99b0 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ b/src/DSWaylandServer/DSWaylandInputPanel.cpp @@ -417,10 +417,11 @@ void DSWaylandInputPanelSurfacePrivate::setFloatingPosition(int x, int y) } inputPanelFloating = pub->__inputPanel->getFloatingData(); + (void) inputPanelFloating; +#if 0//Unreachable code ! Thus, disable temporarily. if (!floatingData || !inputPanelFloating) return; -#if 0//Unreachable code ! Thus, disable temporarily. int curAngle = 0; /* TODO: -- 2.7.4 From ddfe422e32da00649312944b9487960b72f824a1 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 16:02:12 +0900 Subject: [PATCH 04/16] DSZone: fix to use waylandCompositor when it's valid Change-Id: I7b995b018865b17ec9e73736b430a9539227e82b Signed-off-by: Sung-Jin Park --- src/DSZone/DSZone.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index f075601..fe5ab33 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -35,22 +35,23 @@ DSZone::DSZone() : __position{0, 0}, __size{0, 0}, __waylandCompositor(nullptr), - __wm(nullptr) + __wm(nullptr), + __waylandShell(nullptr) { __waylandCompositor = DSWaylandCompositor::getInstance(); if (__waylandCompositor) { __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); + __wm = DSWindowManager::getInstance(); + if (__wm) + __wm->registerZone(this); - __waylandShell = __waylandCompositor->getShell(); - if (__waylandShell) - __waylandShell->registerCallbackShellSurfaceCreated(this, std::bind(&DSZone::__onShellSurfaceCreated, this, std::placeholders::_1)); + __waylandShell = __waylandCompositor->getShell(); + if (__waylandShell) + __waylandShell->registerCallbackShellSurfaceCreated(this, std::bind(&DSZone::__onShellSurfaceCreated, this, std::placeholders::_1)); + } } DSZone::~DSZone() -- 2.7.4 From 0783ff8c8f8b7e87640f1ce58247d35dacedc111 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 16:02:43 +0900 Subject: [PATCH 05/16] tests: fix DSWaylandTizenInputDevice-test to use class instancec when it's valid Change-Id: I69a0cb2195b370895cae014fb5f5319a7acfa21e Signed-off-by: Sung-Jin Park --- tests/DSWaylandTizenInputDevice-test.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/DSWaylandTizenInputDevice-test.cpp b/tests/DSWaylandTizenInputDevice-test.cpp index 275f4e4..5ebd223 100644 --- a/tests/DSWaylandTizenInputDevice-test.cpp +++ b/tests/DSWaylandTizenInputDevice-test.cpp @@ -38,11 +38,23 @@ public: TEST_F(DSWaylandTizenInputDeviceTest, NewDSWaylandTizenInputDevice) { DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSWaylandTizenInputDeviceManager *inputDeviceManager = new DSWaylandTizenInputDeviceManager(compositor); - DSWaylandTizenInputDevice *inputDevice = new DSWaylandTizenInputDevice(inputDeviceManager); - delete inputDevice; - delete inputDeviceManager; - DSWaylandCompositor::releaseInstance(); - EXPECT_TRUE(true); + EXPECT_TRUE(compositor != nullptr); + + if (compositor) + { + DSWaylandTizenInputDeviceManager *inputDeviceManager = new DSWaylandTizenInputDeviceManager(compositor); + EXPECT_TRUE(inputDeviceManager != nullptr); + + if (inputDeviceManager) + { + DSWaylandTizenInputDevice *inputDevice = new DSWaylandTizenInputDevice(inputDeviceManager); + EXPECT_TRUE(inputDevice != nullptr); + + delete inputDevice; + delete inputDeviceManager; + } + + DSWaylandCompositor::releaseInstance(); + } } -- 2.7.4 From 8e62f56be11b90cf83035ff5a6d190da7a88c4cc Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Thu, 20 Aug 2020 18:56:37 +0900 Subject: [PATCH 06/16] DSZone/DSWaylandTizenPolicy/DSWindowManager: add code to handle window stack Change-Id: Ifa1c05f98050d3f117b9fdeae027feb53b49ef8f --- src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 24 +++++- src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h | 2 + src/DSWindowManager/DSWindowManager.cpp | 48 +++++++++++ src/DSWindowManager/DSWindowManager.h | 4 + src/DSWindowManager/DSWindowManagerPrivate.h | 4 + src/DSZone/DSZone.cpp | 98 +++++++++++++++++++++-- src/DSZone/DSZone.h | 16 +++- tests/DSZone-test.cpp | 66 ++++++++++++++- 8 files changed, 247 insertions(+), 15 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index e589896..52f19e3 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -39,11 +39,14 @@ DSWaylandTizenPolicyPrivate::DSWaylandTizenPolicyPrivate(DSWaylandTizenPolicy *p __p_ptr(p_ptr) { DSLOG_DBG("TizenPolicyPriv", ""); + __wm = DSWindowManager::getInstance(); } DSWaylandTizenPolicyPrivate::~DSWaylandTizenPolicyPrivate() { DSLOG_DBG("TizenPolicyPriv", ""); + if (__wm) + DSWindowManager::releaseInstance(); } void DSWaylandTizenPolicyPrivate::tizen_policy_initialize(DSWaylandCompositor *wlCompositor) @@ -86,7 +89,12 @@ void DSWaylandTizenPolicyPrivate::tizen_policy_get_position(Resource *resource, void DSWaylandTizenPolicyPrivate::tizen_policy_activate(Resource *resource, struct ::wl_resource *surface) { - DSLOG_DBG("TizenPolicyPriv", ""); + DSLOG_DBG("TizenPolicyPriv", "Request to activate. resource:%p, wl_surface:%p", resource, surface); + DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); + if (!dswlSurface) return; + if (!__wm) return; + + __wm->activateWindow(dswlSurface); } void DSWaylandTizenPolicyPrivate::tizen_policy_activate_below_by_res_id(Resource *resource, uint32_t res_id, uint32_t below_res_id) @@ -96,12 +104,22 @@ void DSWaylandTizenPolicyPrivate::tizen_policy_activate_below_by_res_id(Resource void DSWaylandTizenPolicyPrivate::tizen_policy_raise(Resource *resource, struct ::wl_resource *surface) { - DSLOG_DBG("TizenPolicyPriv", ""); + DSLOG_DBG("TizenPolicyPriv", "Request to raise. resource:%p, wl_surface:%p", resource, surface); + DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); + if (!dswlSurface) return; + if (!__wm) return; + + __wm->raiseWindow(dswlSurface); } void DSWaylandTizenPolicyPrivate::tizen_policy_lower(Resource *resource, struct ::wl_resource *surface) { - DSLOG_DBG("TizenPolicyPriv", ""); + DSLOG_DBG("TizenPolicyPriv", "Request to lower. resource:%p, wl_surface:%p", resource, surface); + DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); + if (!dswlSurface) return; + if (!__wm) return; + + __wm->lowerWindow(dswlSurface); } void DSWaylandTizenPolicyPrivate::tizen_policy_lower_by_res_id(Resource *resource, uint32_t res_id) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h index 3484097..af39461 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h +++ b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h @@ -25,6 +25,7 @@ #define _DS_WAYLAND_TIZEN_POLICY_PRIVATE_H_ #include "dswayland-server-tizen-extension.h" +#include "DSWindowManager.h" #include "DSWaylandTizenPolicy.h" namespace display_server @@ -90,6 +91,7 @@ protected: void tizen_policy_set_appid(Resource *resource, int32_t pid, const std::string &appid) override; private: + DSWindowManager *__wm; std::list> __tzPosList; }; diff --git a/src/DSWindowManager/DSWindowManager.cpp b/src/DSWindowManager/DSWindowManager.cpp index acacdf2..4137305 100644 --- a/src/DSWindowManager/DSWindowManager.cpp +++ b/src/DSWindowManager/DSWindowManager.cpp @@ -258,6 +258,36 @@ void DSWindowManagerPrivate::setWindowPosition(DSWaylandSurface *dsSurface, int } } +void DSWindowManagerPrivate::activateWindow(DSWaylandSurface *dswlSurface) +{ + // find dswlSurface's window + DSZone *zone = __getZone(dswlSurface); + if (zone) + { + zone->activateWindow(dswlSurface); + } +} + +void DSWindowManagerPrivate::raiseWindow(DSWaylandSurface *dswlSurface) +{ + // find dswlSurface's window + DSZone *zone = __getZone(dswlSurface); + if (zone) + { + zone->raiseWindow(dswlSurface); + } +} + +void DSWindowManagerPrivate::lowerWindow(DSWaylandSurface *dswlSurface) +{ + // find dswlSurface's window + DSZone *zone = __getZone(dswlSurface); + if (zone) + { + zone->lowerWindow(dswlSurface); + } +} + DSWindowManager::DSWindowManager(DSObject *parent) : DS_INIT_PRIVATE_PTR(DSWindowManager) { @@ -380,5 +410,23 @@ void DSWindowManager::setWindowPosition(DSWaylandSurface *dsSurface, int x, int priv->setWindowPosition(dsSurface, x, y); } +void DSWindowManager::activateWindow(DSWaylandSurface *dswlSurface) +{ + DS_GET_PRIV(DSWindowManager); + priv->activateWindow(dswlSurface); +} + +void DSWindowManager::raiseWindow(DSWaylandSurface *dswlSurface) +{ + DS_GET_PRIV(DSWindowManager); + priv->raiseWindow(dswlSurface); +} + +void DSWindowManager::lowerWindow(DSWaylandSurface *dswlSurface) +{ + DS_GET_PRIV(DSWindowManager); + priv->lowerWindow(dswlSurface); +} + } // namespace display_server diff --git a/src/DSWindowManager/DSWindowManager.h b/src/DSWindowManager/DSWindowManager.h index 08eb75d..6b6ce69 100644 --- a/src/DSWindowManager/DSWindowManager.h +++ b/src/DSWindowManager/DSWindowManager.h @@ -60,6 +60,10 @@ public: void setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h); void setWindowPosition(DSWaylandSurface *dsSurface, int x, int y); + void activateWindow(DSWaylandSurface *dswlSurface); + void raiseWindow(DSWaylandSurface *dswlSurface); + void lowerWindow(DSWaylandSurface *dswlSurface); + protected: private: diff --git a/src/DSWindowManager/DSWindowManagerPrivate.h b/src/DSWindowManager/DSWindowManagerPrivate.h index 43acc3e..b42ad84 100644 --- a/src/DSWindowManager/DSWindowManagerPrivate.h +++ b/src/DSWindowManager/DSWindowManagerPrivate.h @@ -55,6 +55,10 @@ public: void setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h); void setWindowPosition(DSWaylandSurface *dsSurface, int x, int y); + void activateWindow(DSWaylandSurface *dswlSurface); + void raiseWindow(DSWaylandSurface *dswlSurface); + void lowerWindow(DSWaylandSurface *dswlSurface); + private: DSZone *__getZone(DSWindow *window); DSZone *__getZone(DSWaylandSurface *surface); diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index fe5ab33..39ceafa 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -36,7 +36,9 @@ DSZone::DSZone() __size{0, 0}, __waylandCompositor(nullptr), __wm(nullptr), - __waylandShell(nullptr) + __eventLoop(nullptr), + __waylandShell(nullptr), + __stackChanged(false) { __waylandCompositor = DSWaylandCompositor::getInstance(); if (__waylandCompositor) @@ -48,6 +50,11 @@ DSZone::DSZone() if (__wm) __wm->registerZone(this); + __eventLoop = DSEventLoop::getInstance(); + if (__eventLoop) + __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSZone::__onEventIdleEnterer, this, std::placeholders::_1)); + + __waylandShell = __waylandCompositor->getShell(); if (__waylandShell) __waylandShell->registerCallbackShellSurfaceCreated(this, std::bind(&DSZone::__onShellSurfaceCreated, this, std::placeholders::_1)); @@ -58,9 +65,12 @@ DSZone::~DSZone() { if (__wm) __wm->unregisterZone(this); - - DSWindowManager::releaseInstance(); - DSWaylandCompositor::releaseInstance(); + if (__eventLoop) + DSEventLoop::releaseInstance(); + if (__wm) + DSWindowManager::releaseInstance(); + if (__waylandCompositor) + DSWaylandCompositor::releaseInstance(); } void DSZone::setPosition(stPosition &position) @@ -113,6 +123,17 @@ void DSZone::callCallbackWindowCreated() __windowCreatedSignal.emit(nullptr); } +void DSZone::__onEventIdleEnterer(void *data) +{ + if (__stackChanged) + { + DSLOG_DBG("DSZone", "Calculate Visibility..."); + + // calculate visibility? + __stackChanged = false; + } +} + void DSZone::__onSurfaceCreated(std::shared_ptr waylandSurface) { DSLOG_DBG("DSZone", "waylandSurface:(shared:%p, pure:%p)", waylandSurface, waylandSurface.get()); @@ -170,9 +191,17 @@ void DSZone::__onShellSurfaceCreated(IDSWaylandShellSurface *waylandShellSurface } // for Test -void DSZone::callCallbackWindowShellCreated() +void DSZone::callCallbackWindowShellCreated(std::shared_ptr winShell) +{ + __windowShellCreatedSignal.emit(winShell); +} + +bool DSZone::testCreateWindow(std::shared_ptr waylandSurface) { - __windowShellCreatedSignal.emit(nullptr); + std::shared_ptr window = __createWindow(waylandSurface); + if (!window) return false; + + return true; } std::list> DSZone::getWindowList() @@ -185,6 +214,22 @@ std::list> DSZone::getWindowShellList() return __windowShellList; } +void DSZone::__prependWindowList(std::shared_ptr window) +{ + __windowList.remove(window); + __windowList.push_front(window); + + __stackChanged = true; +} + +void DSZone::__appendWindowList(std::shared_ptr window) +{ + __windowList.remove(window); + __windowList.push_back(window); + + __stackChanged = true; +} + std::shared_ptr DSZone::__findWindow(DSWaylandSurface *dswlSurface) { std::list> wList = getWindowList(); @@ -221,7 +266,7 @@ DSWindowShell *DSZone::__findWindowShell(DSWaylandSurface *dswlSurface) std::shared_ptr DSZone::__createWindow(std::shared_ptr waylandSurface) { std::shared_ptr window = std::make_shared(waylandSurface); - __windowList.push_front(window); + __prependWindowList(window); // emit a signal of the surface committed __windowCreatedSignal.emit(window); @@ -328,5 +373,44 @@ bool DSZone::setWindowPosition(DSWaylandSurface *dswSurface, int x, int y) */ } +void DSZone::activateWindow(DSWaylandSurface *dswlSurface) +{ + if (!dswlSurface) return; + + std::shared_ptr window = __findWindow(dswlSurface); + __prependWindowList(window); + + DSWindowShell *wShell = __findWindowShell(dswlSurface); + if (!wShell) return; + + wShell->activate(); +} + +void DSZone::raiseWindow(DSWaylandSurface* dswlSurface) +{ + if (!dswlSurface) return; + + std::shared_ptr window = __findWindow(dswlSurface); + __prependWindowList(window); + + DSWindowShell *wShell = __findWindowShell(dswlSurface); + if (!wShell) return; + + wShell->raise(); +} + +void DSZone::lowerWindow(DSWaylandSurface* dswlSurface) +{ + if (!dswlSurface) return; + + std::shared_ptr window = __findWindow(dswlSurface); + __appendWindowList(window); + + DSWindowShell *wShell = __findWindowShell(dswlSurface); + if (!wShell) return; + + wShell->lower(); +} + } // namespace display_server diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index 7b37a6c..e115978 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -30,6 +30,7 @@ #include "DSWindowShell.h" #include "DSSignal.h" #include "DSStruct.h" +#include "DSEventLoop.h" namespace display_server { @@ -57,7 +58,9 @@ public: // emit functions for testing void callCallbackWindowCreated(); - void callCallbackWindowShellCreated(); + void callCallbackWindowShellCreated(std::shared_ptr winShell); + // for test + bool testCreateWindow(std::shared_ptr waylandSurface); // for window property bool setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title); @@ -65,10 +68,16 @@ public: bool setWindowGeometry(DSWaylandSurface *dswSurface, int x, int y, unsigned int w, unsigned h); bool setWindowPosition(DSWaylandSurface *dswSurface, int x, int y); + void activateWindow(DSWaylandSurface *dswlSurface); + void raiseWindow(DSWaylandSurface* dswlSurface); + void lowerWindow(DSWaylandSurface* dswlSurface); + std::list> getWindowList(); std::list> getWindowShellList(); private: + void __onEventIdleEnterer(void *data); + void __onSurfaceCreated(std::shared_ptr waylandSurface); void __onSurfaceDestroy(std::shared_ptr waylandSurface); @@ -80,6 +89,9 @@ private: std::shared_ptr __createWindowShell(std::shared_ptr window); void __destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface *surface); + void __prependWindowList(std::shared_ptr window); + void __appendWindowList(std::shared_ptr window); + std::shared_ptr __findWindow(DSWaylandSurface *dswlSurface); DSWindowShell* __findWindowShell(DSWaylandSurface *dswlSurface); @@ -89,7 +101,9 @@ private: std::list> __windowShellList; DSWaylandCompositor *__waylandCompositor; DSWindowManager *__wm; + DSEventLoop *__eventLoop; IDSWaylandShell *__waylandShell; + bool __stackChanged; std::map __windowShellMap; diff --git a/tests/DSZone-test.cpp b/tests/DSZone-test.cpp index e302e52..83a685b 100644 --- a/tests/DSZone-test.cpp +++ b/tests/DSZone-test.cpp @@ -23,6 +23,8 @@ #include "libds-tests.h" #include "DSZone.h" +#include "DSWaylandSurface.h" +#include "DSWindow.h" #include "DSPolicyArea.h" #include "DSPolicyAreaPrivate.h" @@ -45,7 +47,13 @@ public: __boolOnWindowShellCreated(false) { zone->registerCallbackWindowCreated(this, std::bind(&TestZone::onWindowCreated, this, std::placeholders::_1)); + zone->registerCallbackWindowShellCreated(this, std::bind(&TestZone::onWindowShellCreated, this, std::placeholders::_1)); __zone = zone; + + __countWindow = 0; + + for (int i=0; i<5; i++) + myWindow[i] = nullptr; } ~TestZone() @@ -61,24 +69,39 @@ public: void onWindowCreated(std::shared_ptr window) { __boolOnWindowCreated = true; + + myWindow[__countWindow] = window.get(); + __countWindow++; } - void callOnWindowShellCreated() { - __zone->callCallbackWindowShellCreated(); + void callOnWindowShellCreated(std::shared_ptr winShell) { + __zone->callCallbackWindowShellCreated(winShell); } bool getResultOnWindowShellCreated() { return __boolOnWindowShellCreated; } - void onWindowShellCreated(std::shared_ptr window) { + void onWindowShellCreated(std::shared_ptr windowShell) { __boolOnWindowShellCreated = true; } + std::list> getWindowList() { + return __zone->getWindowList(); + } + + int getWindowCount() { + return __countWindow; + } + +public: + DSWindow* myWindow[5]; + private: bool __boolOnWindowCreated; bool __boolOnWindowShellCreated; std::shared_ptr __zone; + int __countWindow; }; TEST_F(DSZoneTest, NewDSZone) @@ -136,8 +159,43 @@ TEST_F(DSZoneTest, registerCallbackWindowShellCreated) // before calling WindowShell created EXPECT_FALSE(testZone->getResultOnWindowShellCreated()); - testZone->callOnWindowShellCreated(); + testZone->callOnWindowShellCreated(nullptr); // after calling WindowShell created EXPECT_TRUE(testZone->getResultOnWindowShellCreated()); } + +TEST_F(DSZoneTest, stackChanged) +{ + int count; + + auto zone = std::make_shared(); + EXPECT_TRUE(zone != nullptr); + + auto testZone = std::make_shared(zone); + + EXPECT_TRUE(testZone != nullptr); + + auto dswlSurface1 = std::make_shared(); + EXPECT_TRUE(zone->testCreateWindow(dswlSurface1)); + + auto dswlSurface2 = std::make_shared(); + EXPECT_TRUE(zone->testCreateWindow(dswlSurface2)); + + count = testZone->getWindowCount(); + for (std::shared_ptr w : zone->getWindowList()) + { + EXPECT_TRUE(w.get() == testZone->myWindow[count-1]); + count--; + } + + zone->raiseWindow(dswlSurface1.get()); + + count = 0; + for (std::shared_ptr w : zone->getWindowList()) + { + EXPECT_TRUE(w.get() == testZone->myWindow[count]); + count++; + } +} + -- 2.7.4 From bcbd03934f49081790e63a7203b1282875efc545 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Thu, 20 Aug 2020 19:36:21 +0900 Subject: [PATCH 07/16] add code to handle focus_skip_set Change-Id: I9dfa518f7916681b13534be2d08152026e2fd637 --- src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 14 ++++++++++++-- src/DSWindow/DSWindow.cpp | 27 +++++++++++++++++++++++++++ src/DSWindow/DSWindow.h | 3 +++ src/DSWindow/DSWindowPrivate.h | 4 ++++ src/DSWindowManager/DSWindowManager.cpp | 17 +++++++++++++++++ src/DSWindowManager/DSWindowManager.h | 2 ++ src/DSWindowManager/DSWindowManagerPrivate.h | 2 ++ src/DSWindowShell/DSWindowShell.cpp | 6 ++++++ src/DSWindowShell/DSWindowShell.h | 2 ++ src/DSWindowShell/DSWindowShellPrivate.cpp | 11 +++++++++++ src/DSWindowShell/DSWindowShellPrivate.h | 2 ++ src/DSZone/DSZone.cpp | 7 +++++++ src/DSZone/DSZone.h | 2 ++ tests/DSWindow-test.cpp | 28 ++++++++++++++++++++++++++-- 14 files changed, 123 insertions(+), 4 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index 52f19e3..33e47b0 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -129,12 +129,22 @@ void DSWaylandTizenPolicyPrivate::tizen_policy_lower_by_res_id(Resource *resourc void DSWaylandTizenPolicyPrivate::tizen_policy_set_focus_skip(Resource *resource, struct ::wl_resource *surface) { - DSLOG_DBG("TizenPolicyPriv", ""); + DSLOG_DBG("TizenPolicyPriv", "Request to skip focus. resource:%p, wl_surface:%p", resource, surface); + DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); + if (!dswlSurface) return; + if (!__wm) return; + + __wm->setWindowSkipFocus(dswlSurface, true); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_focus_skip(Resource *resource, struct ::wl_resource *surface) { - DSLOG_DBG("TizenPolicyPriv", ""); + DSLOG_DBG("TizenPolicyPriv", "Request to unset skip_focus. resource:%p, wl_surface:%p", resource, surface); + DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); + if (!dswlSurface) return; + if (!__wm) return; + + __wm->setWindowSkipFocus(dswlSurface, false); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_role(Resource *resource, struct ::wl_resource *surface, const std::string &role) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 3306276..8c10913 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -44,6 +44,7 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) __winShell(nullptr), __firstCommit(true), __changedGeometry(false), + __acceptsFocus(true), __title("") { } @@ -92,6 +93,20 @@ const std::string DSWindowPrivate::getTitle(void) return __title; } +bool DSWindowPrivate::setSkipFocus(bool set) +{ + __acceptsFocus = !set; + return true; +} + +bool DSWindowPrivate::getSkipFocus(void) +{ + if (__acceptsFocus) + return false; + else + return true; +} + bool DSWindowPrivate::setLayer(int layer) { return true; @@ -253,6 +268,18 @@ const std::string DSWindow::getTitle(void) return priv->getTitle(); } +bool DSWindow::setSkipFocus(bool set) +{ + DS_GET_PRIV(DSWindow); + return priv->setSkipFocus(set); +} + +bool DSWindow::getSkipFocus(void) +{ + DS_GET_PRIV(DSWindow); + return priv->getSkipFocus(); +} + bool DSWindow::setLayer(int layer) { DS_GET_PRIV(DSWindow); diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index 04bfa9f..10fb3b8 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -56,6 +56,9 @@ public: bool setTitle(const std::string &title); const std::string getTitle(void); + bool setSkipFocus(bool set); + bool getSkipFocus(void); + bool setLayer(int layer); bool raise(void); bool lower(void); diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index df18827..b5a36f4 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -53,6 +53,9 @@ public: bool setTitle(const std::string &title); const std::string getTitle(void); + bool setSkipFocus(bool set); + bool getSkipFocus(void); + bool setLayer(int layer); bool raise(void); bool lower(void); @@ -78,6 +81,7 @@ private: DSWindowShell *__winShell; bool __firstCommit; bool __changedGeometry; + bool __acceptsFocus; std::string __title; }; diff --git a/src/DSWindowManager/DSWindowManager.cpp b/src/DSWindowManager/DSWindowManager.cpp index 4137305..818fd33 100644 --- a/src/DSWindowManager/DSWindowManager.cpp +++ b/src/DSWindowManager/DSWindowManager.cpp @@ -288,6 +288,17 @@ void DSWindowManagerPrivate::lowerWindow(DSWaylandSurface *dswlSurface) } } +void DSWindowManagerPrivate::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set) +{ + // find dswlSurface's window + DSZone *zone = __getZone(dswlSurface); + if (zone) + { + zone->setWindowSkipFocus(dswlSurface, set); + } +} + + DSWindowManager::DSWindowManager(DSObject *parent) : DS_INIT_PRIVATE_PTR(DSWindowManager) { @@ -428,5 +439,11 @@ void DSWindowManager::lowerWindow(DSWaylandSurface *dswlSurface) priv->lowerWindow(dswlSurface); } +void DSWindowManager::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set) +{ + DS_GET_PRIV(DSWindowManager); + priv->setWindowSkipFocus(dswlSurface, set); +} + } // namespace display_server diff --git a/src/DSWindowManager/DSWindowManager.h b/src/DSWindowManager/DSWindowManager.h index 6b6ce69..ed69080 100644 --- a/src/DSWindowManager/DSWindowManager.h +++ b/src/DSWindowManager/DSWindowManager.h @@ -64,6 +64,8 @@ public: void raiseWindow(DSWaylandSurface *dswlSurface); void lowerWindow(DSWaylandSurface *dswlSurface); + void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); + protected: private: diff --git a/src/DSWindowManager/DSWindowManagerPrivate.h b/src/DSWindowManager/DSWindowManagerPrivate.h index b42ad84..f1066a0 100644 --- a/src/DSWindowManager/DSWindowManagerPrivate.h +++ b/src/DSWindowManager/DSWindowManagerPrivate.h @@ -59,6 +59,8 @@ public: void raiseWindow(DSWaylandSurface *dswlSurface); void lowerWindow(DSWaylandSurface *dswlSurface); + void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); + private: DSZone *__getZone(DSWindow *window); DSZone *__getZone(DSWaylandSurface *surface); diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp index d6291b5..94029b0 100644 --- a/src/DSWindowShell/DSWindowShell.cpp +++ b/src/DSWindowShell/DSWindowShell.cpp @@ -73,6 +73,12 @@ bool DSWindowShell::setTitle(const std::string &title) return priv->setTitle(title); } +bool DSWindowShell::setSkipFocus(bool set) +{ + DS_GET_PRIV(DSWindowShell); + return priv->setSkipFocus(set); +} + bool DSWindowShell::setPosition(int x, int y) { DS_GET_PRIV(DSWindowShell); diff --git a/src/DSWindowShell/DSWindowShell.h b/src/DSWindowShell/DSWindowShell.h index d9ac09c..53d2bcb 100644 --- a/src/DSWindowShell/DSWindowShell.h +++ b/src/DSWindowShell/DSWindowShell.h @@ -52,6 +52,8 @@ public: bool setTitle(const std::string &title); + bool setSkipFocus(bool set); + bool setPosition(int x, int y); stPosition getPosition(void); diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index e4a1e2a..56eee9b 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -97,6 +97,17 @@ bool DSWindowShellPrivate::setTitle(const std::string &title) return false; } +bool DSWindowShellPrivate::setSkipFocus(bool set) +{ + if (__window) + { + __window->setSkipFocus(set); + return true; + } + else + return false; +} + bool DSWindowShellPrivate::setPosition(int x, int y) { __x = x; diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h index 809324a..8cebc66 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -48,6 +48,8 @@ public: bool setTitle(const std::string &title); + bool setSkipFocus(bool set); + bool setPosition(int x, int y); stPosition getPosition(void); diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index 39ceafa..7ce4399 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -412,5 +412,12 @@ void DSZone::lowerWindow(DSWaylandSurface* dswlSurface) wShell->lower(); } +void DSZone::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set) +{ + DSWindowShell *wShell = __findWindowShell(dswlSurface); + if (!wShell) return; + + wShell->setSkipFocus(set); +} } // namespace display_server diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index e115978..01a8c9b 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -72,6 +72,8 @@ public: void raiseWindow(DSWaylandSurface* dswlSurface); void lowerWindow(DSWaylandSurface* dswlSurface); + void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); + std::list> getWindowList(); std::list> getWindowShellList(); diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp index 7f33bd3..8ee7f19 100644 --- a/tests/DSWindow-test.cpp +++ b/tests/DSWindow-test.cpp @@ -76,8 +76,8 @@ TEST_F(DSWindowTest, SizeTest) EXPECT_TRUE(win != nullptr); stSize size = win->getSize(); - EXPECT_TRUE(size.w == 1); - EXPECT_TRUE(size.h == 1); + EXPECT_TRUE(size.w == 0); + EXPECT_TRUE(size.h == 0); win->setSize(1280, 720); size = win->getSize(); @@ -137,3 +137,27 @@ TEST_F(DSWindowTest, TitleTest) EXPECT_TRUE(title.compare("test title") == 0); } +TEST_F(DSWindowTest, SkipFocusTest) +{ + bool ret; + bool skip; + + auto win = std::make_shared(); + EXPECT_TRUE(win != nullptr); + + skip = win->getSkipFocus(); + EXPECT_TRUE(skip == false); + + ret = win->setSkipFocus(true); + EXPECT_TRUE(ret == true); + + skip = win->getSkipFocus(); + EXPECT_TRUE(skip == true); + + ret = win->setSkipFocus(false); + EXPECT_TRUE(ret == true); + + skip = win->getSkipFocus(); + EXPECT_TRUE(skip == false); +} + -- 2.7.4 From 77ae659ac0e02333539417efce54f7ef42d05728 Mon Sep 17 00:00:00 2001 From: jeon Date: Thu, 20 Aug 2020 18:35:17 +0900 Subject: [PATCH 08/16] DSWaylandRegion: add skeleton codes for create wl_region Change-Id: I7d1c55392df451612ea667f6b44ed80d234f0e73 --- src/DSWaylandServer/DSWaylandCompositor.cpp | 20 ++++- src/DSWaylandServer/DSWaylandCompositor.h | 3 + src/DSWaylandServer/DSWaylandRegion.cpp | 108 +++++++++++++++++++++++++++ src/DSWaylandServer/DSWaylandRegion.h | 57 ++++++++++++++ src/DSWaylandServer/DSWaylandRegionPrivate.h | 57 ++++++++++++++ src/meson.build | 3 + 6 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 src/DSWaylandServer/DSWaylandRegion.cpp create mode 100644 src/DSWaylandServer/DSWaylandRegion.h create mode 100644 src/DSWaylandServer/DSWaylandRegionPrivate.h diff --git a/src/DSWaylandServer/DSWaylandCompositor.cpp b/src/DSWaylandServer/DSWaylandCompositor.cpp index 233b8c5..9f823ee 100644 --- a/src/DSWaylandServer/DSWaylandCompositor.cpp +++ b/src/DSWaylandServer/DSWaylandCompositor.cpp @@ -27,6 +27,7 @@ #include "DSWaylandClient.h" #include "DSWaylandSeat.h" #include "DSWaylandSurface.h" +#include "DSWaylandRegion.h" #include "DSDebugLog.h" namespace display_server @@ -275,7 +276,12 @@ void DSWaylandCompositorPrivate::compositor_create_surface(wl_compositor::Resour void DSWaylandCompositorPrivate::compositor_create_region(wl_compositor::Resource *resource, uint32_t id) { - //TODO + DS_GET_PUB(DSWaylandCompositor); + + DSWaylandClient *waylandClient = DSWaylandClient::fromWlClient(resource->client()); + auto waylandRegion = std::make_shared(waylandClient, id); + + pub->__regionList.push_front(waylandRegion); } /* Begin Public Class Implementation */ @@ -508,6 +514,18 @@ void DSWaylandCompositor::sendSurfaceDestroy(DSWaylandSurface *dswSurface) } } +void DSWaylandCompositor::regionDestroy(DSWaylandRegion *dswRegion) +{ + for (auto s : __regionList) + { + if (s.get() == dswRegion) + { + __regionList.remove(s); + break; + } + } +} + void DSWaylandCompositor::registerCallbackSurfaceCreated(DSObject *slot, std::function)> func) { this->__surfaceCreatedSignal.connect(slot, func); diff --git a/src/DSWaylandServer/DSWaylandCompositor.h b/src/DSWaylandServer/DSWaylandCompositor.h index 4de11dc..c8ae82f 100644 --- a/src/DSWaylandServer/DSWaylandCompositor.h +++ b/src/DSWaylandServer/DSWaylandCompositor.h @@ -38,6 +38,7 @@ class DSWaylandClient; class DSWaylandSeat; class DSWaylandSurface; class IDSWaylandShell; +class DSWaylandRegion; class DSWaylandCompositorPrivate; @@ -67,6 +68,7 @@ public: IDSWaylandShell *getShell(void); void sendSurfaceDestroy(DSWaylandSurface *dswSurface); + void regionDestroy(DSWaylandRegion *dswRegion); // Callback methods void registerCallbackSurfaceCreated(DSObject *slot, std::function)> func); @@ -86,6 +88,7 @@ private: DSWaylandCompositor& operator=(const DSWaylandCompositor&) = delete; std::list> __surfaceList; + std::list> __regionList; // signals DSSignal> __surfaceCreatedSignal; diff --git a/src/DSWaylandServer/DSWaylandRegion.cpp b/src/DSWaylandServer/DSWaylandRegion.cpp new file mode 100644 index 0000000..19d3231 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandRegion.cpp @@ -0,0 +1,108 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "DSWaylandRegion.h" +#include "DSWaylandRegionPrivate.h" +#include "DSWaylandCompositor.h" + +namespace display_server +{ + +/* DSWaylandRegionPrivate */ +DSWaylandRegionPrivate::DSWaylandRegionPrivate(DSWaylandRegion *p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr) +{} + +DSWaylandRegionPrivate::DSWaylandRegionPrivate(DSWaylandRegion *p_ptr, DSWaylandClient *waylandClient, uint32_t id) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr) +{ + if (id > 0) + { + init(waylandClient->wlClient(), (int)id, 1); + } +} + +DSWaylandRegionPrivate::~DSWaylandRegionPrivate() +{} + +void DSWaylandRegionPrivate::region_bind_resource(Resource *resource) +{ +} + +void DSWaylandRegionPrivate::region_destroy_resource(Resource *resource) +{ + DS_GET_PUB(DSWaylandRegion); + + DSWaylandCompositor *dswCompositor = DSWaylandCompositor::getInstance(); + if (dswCompositor) + { + dswCompositor->regionDestroy(pub); + } + DSWaylandCompositor::releaseInstance(); +} + +void DSWaylandRegionPrivate::region_destroy(Resource *resource) +{ +} + +void DSWaylandRegionPrivate::region_add(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) +{ +} + +void DSWaylandRegionPrivate::region_subtract(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) +{ +} + +DS_WAYLAND_IMPL_FROM_RESOURCE(DSWaylandRegion); + + +DSWaylandRegion::DSWaylandRegion() + : DS_INIT_PRIVATE_PTR(DSWaylandRegion) +{} + +DSWaylandRegion::DSWaylandRegion(DSWaylandClient *waylandClient, uint32_t id) + : _d_ptr(std::make_unique(this, waylandClient, id)) +{} + +DSWaylandRegion::~DSWaylandRegion() +{} + +struct ::wl_resource *DSWaylandRegion::getWlResource() +{ + DS_GET_PRIV(DSWaylandRegion); + + return priv->resource()->handle; +} + +bool DSWaylandRegion::hasResource() +{ + DS_GET_PRIV(DSWaylandRegion); + + if (priv->resource()) + return true; + return false; +} + +} /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandRegion.h b/src/DSWaylandServer/DSWaylandRegion.h new file mode 100644 index 0000000..996b583 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandRegion.h @@ -0,0 +1,57 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __DS_WAYLAND_REGION_H__ +#define __DS_WAYLAND_REGION_H__ + +#include "DSCore.h" +#include "DSObject.h" +#include "DSStruct.h" +#include "DSWaylandClient.h" + +struct wl_resource; + +namespace display_server +{ + +class DSWaylandRegionPrivate; + +class DSWaylandRegion : public DSObject +{ + DS_PIMPL_USE_PRIVATE(DSWaylandRegion); + DS_WAYLAND_DEFINE_FROM_RESOURCE(DSWaylandRegion); +public: + DSWaylandRegion(); + DSWaylandRegion(DSWaylandClient *waylandClient, uint32_t id); + virtual ~DSWaylandRegion(); + + struct ::wl_resource *getWlResource(); + bool hasResource(); + +private: + +}; + +} /* namespace display_server */ + +#endif /* _DS_WAYLAND_REGION_H_ */ diff --git a/src/DSWaylandServer/DSWaylandRegionPrivate.h b/src/DSWaylandServer/DSWaylandRegionPrivate.h new file mode 100644 index 0000000..d2d6338 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandRegionPrivate.h @@ -0,0 +1,57 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __DS_WAYLAND_REGION_PRIVATE_H__ +#define __DS_WAYLAND_REGION_PRIVATE_H__ + +#include "dswayland-server-wayland.h" +#include "DSWaylandRegion.h" + +namespace display_server +{ + +class DSWaylandRegion; + +class DSWaylandRegionPrivate : public DSObjectPrivate, public DSWaylandServer::wl_region +{ +DS_PIMPL_USE_PUBLIC(DSWaylandRegion); +public: + DSWaylandRegionPrivate() = delete; + DSWaylandRegionPrivate(DSWaylandRegion *p_ptr); + DSWaylandRegionPrivate(DSWaylandRegion *p_ptr, DSWaylandClient *waylandClient, uint32_t id); + ~DSWaylandRegionPrivate() override; + +protected: + void region_bind_resource(Resource *resource); + void region_destroy_resource(Resource *resource); + + void region_destroy(Resource *resource); + void region_add(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); + void region_subtract(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); + +private: +}; + +} /*namespace display_server */ + +#endif /* _DS_WAYLAND_REGION_PRIVATE_H_ */ diff --git a/src/meson.build b/src/meson.build index 53a0f9e..61eaa73 100644 --- a/src/meson.build +++ b/src/meson.build @@ -104,6 +104,9 @@ libds_wayland_srcs = [ 'DSWaylandServer/DSWaylandSurface.cpp', 'DSWaylandServer/DSWaylandSurface.h', 'DSWaylandServer/DSWaylandSurfacePrivate.h', + 'DSWaylandServer/DSWaylandRegion.cpp', + 'DSWaylandServer/DSWaylandRegion.h', + 'DSWaylandServer/DSWaylandRegionPrivate.h', 'DSWaylandServer/DSWaylandTizenInputDevice.h', 'DSWaylandServer/DSWaylandTizenInputDevicePrivate.h', 'DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp', -- 2.7.4 From ce8e39625c874ece64d001fc3956f478efd0e00b Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 08:34:03 +0900 Subject: [PATCH 09/16] DSDisplayDeviceHWC: make event_fd and add it to fd handler. Make a event_fd in order to notify the acquirable buffer from buffer queue. The process needs to wake up when the buffer queue prepare the acquirable buffer. In order that, DSDisplayDeviceHWCWindowTDMTargetImpl create the event fd and track it to wake up the process. Change-Id: I8e650ed45583abda87e9f8ebd86a6ac2e0784628 --- .../DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 30 ++++++++++++++++++++-- .../DSDisplayDeviceHWCWindowTDMTargetImpl.h | 5 ++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index 7008623..11ddef6 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -23,15 +23,24 @@ #include "DSDisplayDeviceHWCWindowTDMTargetImpl.h" #include "DSDebugLog.h" +# include namespace display_server { + DSDisplayDeviceHWCWindowTDMTargetImpl::DSDisplayDeviceHWCWindowTDMTargetImpl(IDSDisplayDeviceHWC *deviceHWC, std::shared_ptr bufferQueue) : __deviceHWC(deviceHWC), - __bufferQueue(bufferQueue) -{} + __bufferQueue(bufferQueue), + __ecoreFdHandler(nullptr) +{ + __eventFd = eventfd(0, EFD_NONBLOCK); + __ecoreFdHandler = ecore_main_fd_handler_add(__eventFd, ECORE_FD_READ, __onFdHandler, this, NULL, NULL); +} + DSDisplayDeviceHWCWindowTDMTargetImpl::~DSDisplayDeviceHWCWindowTDMTargetImpl() { + ecore_main_fd_handler_del(__ecoreFdHandler); + close(__eventFd); } void DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame(bool &update) @@ -72,4 +81,21 @@ void DSDisplayDeviceHWCWindowTDMTargetImpl::onPresentFrameDone() __presentedBuffer = std::move(__presentBuffer); } +Eina_Bool DSDisplayDeviceHWCWindowTDMTargetImpl::__onFdHandler(void *data, Ecore_Fd_Handler *hdlr) +{ + int len; + int fd; + char buffer[64]; + + fd = ecore_main_fd_handler_fd_get(hdlr); + if (fd < 0) + return ECORE_CALLBACK_RENEW; + + len = read(fd, buffer, sizeof(buffer)); + if (len == -1) + DSLOG_WRN("DSDisplayDeviceHWCWindowTDMTargetImpl", "failed to read buffer from event fd:%m"); + + return ECORE_CALLBACK_RENEW; +} + } diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h index e5c08d0..46bdfe2 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h @@ -30,6 +30,7 @@ #include "DSWindow.h" #include "IDSBuffer.h" #include +#include namespace display_server { @@ -44,11 +45,15 @@ public: void onPresentFrameDone() override; private: + static Eina_Bool __onFdHandler(void *data, Ecore_Fd_Handler *hdlr); + IDSDisplayDeviceHWC *__deviceHWC; std::shared_ptr __bufferQueue; std::shared_ptr __buffer; std::shared_ptr __presentBuffer; std::shared_ptr __presentedBuffer; + int __eventFd; + Ecore_Fd_Handler *__ecoreFdHandler; }; } -- 2.7.4 From 96c3206506d9c552045933b811b7a64b4100f737 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 08:23:54 +0900 Subject: [PATCH 10/16] DSBuffer: add registerCallbackAcquirable function call a callback function when the DSBufferQueue can aquire Change-Id: I89672b5c7f6b160c1198b52c76e3c2013edcf803 --- src/DSBuffer/DSBufferQueueTBMImpl.cpp | 19 +++++++++++++++++-- src/DSBuffer/DSBufferQueueTBMImpl.h | 5 +++++ src/DSBuffer/IDSBufferQueue.h | 4 +++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/DSBuffer/DSBufferQueueTBMImpl.cpp b/src/DSBuffer/DSBufferQueueTBMImpl.cpp index eed20ff..4640d3a 100644 --- a/src/DSBuffer/DSBufferQueueTBMImpl.cpp +++ b/src/DSBuffer/DSBufferQueueTBMImpl.cpp @@ -29,6 +29,9 @@ namespace display_server { +// the static variables. +DSSignal DSBufferQueueTBMImpl::__aquirableSignal; + DSBufferQueueTBMImpl::DSBufferQueueTBMImpl(int slotSize, int bufferWidth, int bufferHeight, IDSBuffer::Format format) : __slotSize{slotSize}, __bufferWidth{bufferWidth}, @@ -39,6 +42,8 @@ DSBufferQueueTBMImpl::DSBufferQueueTBMImpl(int slotSize, int bufferWidth, int bu if (!__tqueue) { DSLOG_ERR("DSBufferTBM", "tbm_surface_queue_create fails."); } + + tbm_surface_queue_add_acquirable_cb(__tqueue, __onAquireable, this); } DSBufferQueueTBMImpl::DSBufferQueueTBMImpl(tbm_surface_queue_h tqueue) @@ -47,7 +52,9 @@ DSBufferQueueTBMImpl::DSBufferQueueTBMImpl(tbm_surface_queue_h tqueue) __bufferHeight{tbm_surface_queue_get_height(tqueue)}, __format{DSBufferTBMImpl::getBufferFormat(tbm_surface_queue_get_format(tqueue))}, __tqueue{tqueue} -{} +{ + tbm_surface_queue_add_acquirable_cb(__tqueue, __onAquireable, this); +} DSBufferQueueTBMImpl::~DSBufferQueueTBMImpl() { @@ -155,8 +162,16 @@ bool DSBufferQueueTBMImpl::canAcquireBuffer(bool wait) return false; return true; +} - return true; +void DSBufferQueueTBMImpl::registerCallbackAcquirable(DSObject *slot, std::function func) +{ + __aquirableSignal.connect(slot, func); +} + +void DSBufferQueueTBMImpl::__onAquireable(tbm_surface_queue_h surface_queue, void *data) +{ + __aquirableSignal.emit(data); } } diff --git a/src/DSBuffer/DSBufferQueueTBMImpl.h b/src/DSBuffer/DSBufferQueueTBMImpl.h index 27b8165..f74a94e 100644 --- a/src/DSBuffer/DSBufferQueueTBMImpl.h +++ b/src/DSBuffer/DSBufferQueueTBMImpl.h @@ -25,6 +25,7 @@ #define __DS_BUFFER_QUEUE_TBM_IMPL_H_ #include "IDSBufferQueue.h" +#include "DSSignal.h" #include #include @@ -48,6 +49,7 @@ public: bool releaseBuffer(std::shared_ptr buffer) override; bool canAcquireBuffer(bool wait) override; + void registerCallbackAcquirable(DSObject *slot, std::function func) override; private: int __slotSize; @@ -56,6 +58,9 @@ private: IDSBuffer::Format __format; tbm_surface_queue_h __tqueue; std::vector> __bufferVector; + + static void __onAquireable(tbm_surface_queue_h surface_queue, void *data); + static DSSignal __aquirableSignal; }; } diff --git a/src/DSBuffer/IDSBufferQueue.h b/src/DSBuffer/IDSBufferQueue.h index 5a8a4a0..80ade8b 100644 --- a/src/DSBuffer/IDSBufferQueue.h +++ b/src/DSBuffer/IDSBufferQueue.h @@ -25,11 +25,12 @@ #define __I_DS_BUFFER_QUEUE_H__ #include "IDSBuffer.h" +#include "DSObject.h" namespace display_server { -class IDSBufferQueue +class IDSBufferQueue : public DSObject { public: virtual ~IDSBufferQueue() = default; @@ -43,6 +44,7 @@ public: virtual bool releaseBuffer(std::shared_ptr ) = 0; virtual bool canAcquireBuffer(bool wait) = 0; + virtual void registerCallbackAcquirable(DSObject *slot, std::function func) = 0; }; } -- 2.7.4 From 21b323824ab4bbe550558eca9d8e68e381f82fab Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 08:39:07 +0900 Subject: [PATCH 11/16] DSDisplayDeviceHWC: register the acquirable buffer Register the acquirable buffer and write the value to event fd. Change-Id: I8bea0e945fbcfd7cea5ef110b154189f01b86346 --- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 11 +++++++++++ src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index 11ddef6..a4454e2 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -35,6 +35,7 @@ DSDisplayDeviceHWCWindowTDMTargetImpl::DSDisplayDeviceHWCWindowTDMTargetImpl(IDS { __eventFd = eventfd(0, EFD_NONBLOCK); __ecoreFdHandler = ecore_main_fd_handler_add(__eventFd, ECORE_FD_READ, __onFdHandler, this, NULL, NULL); + __bufferQueue->registerCallbackAcquirable(this, std::bind(&DSDisplayDeviceHWCWindowTDMTargetImpl::__onAcquirable, this, std::placeholders::_1)); } DSDisplayDeviceHWCWindowTDMTargetImpl::~DSDisplayDeviceHWCWindowTDMTargetImpl() @@ -98,4 +99,14 @@ Eina_Bool DSDisplayDeviceHWCWindowTDMTargetImpl::__onFdHandler(void *data, Ecore return ECORE_CALLBACK_RENEW; } +void DSDisplayDeviceHWCWindowTDMTargetImpl::__onAcquirable(void *data) +{ + uint64_t value = 1; + int ret; + + ret = write(__eventFd, &value, sizeof(value)); + if (ret == -1) + DSLOG_WRN("DSDisplayDeviceHWCWindowTDMTargetImpl", "failed to write a value on event fd:%m"); +} + } diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h index 46bdfe2..70997dc 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h @@ -34,7 +34,7 @@ namespace display_server { -class DSDisplayDeviceHWCWindowTDMTargetImpl : public IDSDisplayDeviceHWCWindow +class DSDisplayDeviceHWCWindowTDMTargetImpl : public IDSDisplayDeviceHWCWindow, public DSObject { public: DSDisplayDeviceHWCWindowTDMTargetImpl(IDSDisplayDeviceHWC *deviceHWC, std::shared_ptr __bufferQueue); @@ -46,6 +46,7 @@ public: private: static Eina_Bool __onFdHandler(void *data, Ecore_Fd_Handler *hdlr); + void __onAcquirable(void *data); IDSDisplayDeviceHWC *__deviceHWC; std::shared_ptr __bufferQueue; -- 2.7.4 From 5ce9659c6bcb4a55f02eb4f3ea35c79d7c99069b Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Thu, 20 Aug 2020 21:23:04 +0900 Subject: [PATCH 12/16] DSWaylandSurface: release BufferManager resource in destructor Change-Id: I88d69d74e9b2966142faf36815f86e63950c6762 --- src/DSWaylandServer/DSWaylandSurface.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp index 4e6e2d7..54996ba 100644 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ b/src/DSWaylandServer/DSWaylandSurface.cpp @@ -85,7 +85,10 @@ DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr, DSWayl } DSWaylandSurfacePrivate::~DSWaylandSurfacePrivate() -{} +{ + if (__bufferManager) + DSBufferManager::releaseInstance(); +} void DSWaylandSurfacePrivate::surface_bind_resource(Resource *resource) { -- 2.7.4 From 00290872a991adb8ea95abdd5ce7edad21275ba1 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:10:13 +0900 Subject: [PATCH 13/16] DSRenderView: add getWindow() methods Change-Id: I17c92e24c328c121c742089508955c7925bfa473 --- src/DSRender/DSRenderView.h | 1 + src/DSRender/DSRenderViewDaliImpl.cpp | 5 +++++ src/DSRender/DSRenderViewDaliImpl.h | 1 + src/DSRender/DSRenderViewEcoreEvasImpl.cpp | 5 +++++ src/DSRender/DSRenderViewEcoreEvasImpl.h | 1 + 5 files changed, 13 insertions(+) diff --git a/src/DSRender/DSRenderView.h b/src/DSRender/DSRenderView.h index 71f95b2..74a4a2c 100644 --- a/src/DSRender/DSRenderView.h +++ b/src/DSRender/DSRenderView.h @@ -37,6 +37,7 @@ public: virtual ~DSRenderView(); virtual bool setBuffer(std::shared_ptr buffer) = 0; + virtual std::shared_ptr getWindow() = 0; private: /* data */ diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp index 5c5d35a..5ec25c6 100644 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ b/src/DSRender/DSRenderViewDaliImpl.cpp @@ -129,6 +129,11 @@ bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) return true; } +std::shared_ptr DSRenderViewDaliImpl::getWindow() +{ + return __window; +} + void DSRenderViewDaliImpl::__onWindowBufferChanged(std::shared_ptr buffer) { std::shared_ptr bufferSize = buffer->getSize(); diff --git a/src/DSRender/DSRenderViewDaliImpl.h b/src/DSRender/DSRenderViewDaliImpl.h index 8d3a89a..1bb7698 100644 --- a/src/DSRender/DSRenderViewDaliImpl.h +++ b/src/DSRender/DSRenderViewDaliImpl.h @@ -41,6 +41,7 @@ public: ~DSRenderViewDaliImpl(); bool setBuffer(std::shared_ptr buffer) override; + std::shared_ptr getWindow() override; Dali::Geometry CreateTexturedQuad(); diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp index bac48e8..e66845c 100644 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp +++ b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp @@ -73,4 +73,9 @@ void DSRenderViewEcoreEvasImpl::__onWindowBufferChanged(std::shared_ptr DSRenderViewEcoreEvasImpl::getWindow() +{ + return __window; +} + } // namespace display_server diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.h b/src/DSRender/DSRenderViewEcoreEvasImpl.h index 53ed231..11ab261 100644 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.h +++ b/src/DSRender/DSRenderViewEcoreEvasImpl.h @@ -38,6 +38,7 @@ public: ~DSRenderViewEcoreEvasImpl(); bool setBuffer(std::shared_ptr buffer) override; + std::shared_ptr getWindow() override; private: void __onWindowBufferChanged(std::shared_ptr buffer); -- 2.7.4 From 5cef661294329a759fa13453cb90de078cb9ba50 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:14:07 +0900 Subject: [PATCH 14/16] DSDisplayDeviceHWCWindow: add getWindow() methods Change-Id: If0b794b2b078db36e03b56efa524bb0bc8cce738 --- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp | 5 +++++ src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h | 1 + src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 5 +++++ src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h | 1 + src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h | 3 +++ 5 files changed, 15 insertions(+) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp index a1671ec..cbb76e4 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp @@ -55,4 +55,9 @@ void DSDisplayDeviceHWCWindowTDMImpl::onPresentFrameDone() /* TODO:: */ } +std::shared_ptr DSDisplayDeviceHWCWindowTDMImpl::getWindow() +{ + return __window; +} + } diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h index 90ef3f5..99796be 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h @@ -41,6 +41,7 @@ public: void updateFrame(bool &update) override; void presentFrame() override; void onPresentFrameDone() override; + std::shared_ptr getWindow() override; private: std::shared_ptr __window; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index a4454e2..a840510 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -82,6 +82,11 @@ void DSDisplayDeviceHWCWindowTDMTargetImpl::onPresentFrameDone() __presentedBuffer = std::move(__presentBuffer); } +std::shared_ptr DSDisplayDeviceHWCWindowTDMTargetImpl::getWindow() +{ + return nullptr; +} + Eina_Bool DSDisplayDeviceHWCWindowTDMTargetImpl::__onFdHandler(void *data, Ecore_Fd_Handler *hdlr) { int len; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h index 70997dc..2dadf75 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h @@ -43,6 +43,7 @@ public: void updateFrame(bool &update) override; void presentFrame() override; void onPresentFrameDone() override; + std::shared_ptr getWindow() override; private: static Eina_Bool __onFdHandler(void *data, Ecore_Fd_Handler *hdlr); diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h index cd18a5b..3379243 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h @@ -24,6 +24,8 @@ #ifndef _I_DS_DISPLAY_DEVICE_HWC_WINDOW_H_ #define _I_DS_DISPLAY_DEVICE_HWC_WINDOW_H_ +#include "DSWindow.h" + namespace display_server { class IDSDisplayDeviceHWCWindow @@ -33,6 +35,7 @@ public: virtual void updateFrame(bool &update) = 0; virtual void presentFrame() = 0; virtual void onPresentFrameDone() = 0; + virtual std::shared_ptr getWindow() = 0; }; } -- 2.7.4 From 356198ae9a1a860ec340f23b1c2880311bfa1f77 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:14:57 +0900 Subject: [PATCH 15/16] DSDisplayArea: destory DSRenderView and DSDisplayDeviceHWCWindow Change-Id: Id79476dfabdbb4c6726783f47be648265fb8b0bc --- src/DSDisplayArea/DSDisplayArea.cpp | 24 ++++++++++++++++++++++++ src/DSDisplayArea/DSDisplayAreaPrivate.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index fdcadd4..ecfd519 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -130,16 +130,40 @@ bool DSDisplayAreaPrivate::addZone(std::shared_ptr zone) { __zone = zone; __zone->registerCallbackWindowCreated(this, std::bind(&DSDisplayAreaPrivate::__onWindowCreated, this, std::placeholders::_1)); + __zone->registerCallbackWindowDestroy(this, std::bind(&DSDisplayAreaPrivate::__onWindowDestroy, this, std::placeholders::_1)); return true; } void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) { + // TODO: think about using unordered_map __renderViewList.push_back(__renderEngine->makeRenderView(window)); __displayDeviceHWCWindowList.push_back(__displayDeviceHWC->makeHWCWindow(window)); } +void DSDisplayAreaPrivate::__onWindowDestroy(std::shared_ptr window) +{ + // TODO: think about using unordered_map + for (auto renderView : __renderViewList) { + auto tmpWindow = renderView->getWindow(); + if (tmpWindow.get() == window.get()) { + __renderViewList.remove(renderView); + renderView.reset(); + break; + } + } + + for (auto displayDeviceHWCWindow : __displayDeviceHWCWindowList) { + auto tmpHWCWindow = displayDeviceHWCWindow->getWindow(); + if (tmpHWCWindow.get() == window.get()) { + __displayDeviceHWCWindowList.remove(displayDeviceHWCWindow); + displayDeviceHWCWindow.reset(); + break; + } + } +} + void DSDisplayAreaPrivate::__onEventIdleEnterer(void *data) { DSLOG_INF("DSDisplayAreaPrivate", "__onEventIdleEnterer"); diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h index 1b92f99..cb16595 100644 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ b/src/DSDisplayArea/DSDisplayAreaPrivate.h @@ -54,6 +54,7 @@ public: private: void __onWindowCreated(std::shared_ptr window); + void __onWindowDestroy(std::shared_ptr window); void __onEventIdleEnterer(void *data); std::shared_ptr __output; -- 2.7.4 From 429cbf59a47c1e2bdedd565f67c551bf28ed928d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:19:01 +0900 Subject: [PATCH 16/16] DSDisplayDeviceHWC: make updateFrame return bool type. Change-Id: I1a75b0b6e4cbb5634e59cffca1b5d549ad825535 --- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp | 13 ++++++++----- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h | 2 +- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp | 4 ++-- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h | 2 +- .../DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 11 +++++++---- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h | 2 +- src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h | 2 +- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp index bb52d70..f26f02a 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp @@ -121,10 +121,9 @@ bool DSDisplayDeviceHWCTDMImpl::commit() { tdm_error terror; uint32_t numChanges; - bool frameUpdate = false; - if (!__updateFrameWindows(frameUpdate)) { - DSLOG_ERR("HWCTDM", "__updateTarget fails."); + if (!__updateFrameWindows()) { + DSLOG_INF("HWCTDM", "no update windows."); return false; } @@ -158,6 +157,8 @@ bool DSDisplayDeviceHWCTDMImpl::commit() return false; } + DSLOG_INF("HWCTDM", "HWC COMMIT COMMIT COMMIT ~#######"); + __presentFrameDoneWindows(); return true; @@ -248,9 +249,11 @@ bool DSDisplayDeviceHWCTDMImpl::__acceptValidation() return true; } -bool DSDisplayDeviceHWCTDMImpl::__updateFrameWindows(bool &frameUpdate) +bool DSDisplayDeviceHWCTDMImpl::__updateFrameWindows() { - __targetWindow->updateFrame(frameUpdate); + if (!__targetWindow->updateFrame()) { + return false; + } return true; } diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h index f852caf..abdfc70 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h @@ -55,7 +55,7 @@ private: bool __validate(uint32_t &numChanges); bool __updateChanges(uint32_t numChanges); bool __acceptValidation(); - bool __updateFrameWindows(bool &frameUpdate); + bool __updateFrameWindows(); bool __presentFrameWindows(); bool __presentFrameDoneWindows(); }; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp index cbb76e4..051cbd1 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp @@ -39,10 +39,10 @@ tdm_hwc_window *DSDisplayDeviceHWCWindowTDMImpl::getNativeHWCWindow() return __twindow; } -void DSDisplayDeviceHWCWindowTDMImpl::updateFrame(bool &update) +bool DSDisplayDeviceHWCWindowTDMImpl::updateFrame() { // temp always false update - update = false; + return false; } void DSDisplayDeviceHWCWindowTDMImpl::presentFrame() diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h index 99796be..1a6fc6a 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h @@ -38,7 +38,7 @@ public: ~DSDisplayDeviceHWCWindowTDMImpl(); tdm_hwc_window *getNativeHWCWindow(); - void updateFrame(bool &update) override; + bool updateFrame() override; void presentFrame() override; void onPresentFrameDone() override; std::shared_ptr getWindow() override; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index a840510..983f4fa 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -44,16 +44,19 @@ DSDisplayDeviceHWCWindowTDMTargetImpl::~DSDisplayDeviceHWCWindowTDMTargetImpl() close(__eventFd); } -void DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame(bool &update) +bool DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame() { std::shared_ptr dsBuffer; - if (!__bufferQueue->canAcquireBuffer(false)) return; + if (!__bufferQueue->canAcquireBuffer(false)) { + DSLOG_INF("TDM_HWC", "no acquirable buffer."); + return false; + } dsBuffer = __bufferQueue->acquireBuffer(); if (!dsBuffer) { DSLOG_ERR("TDM_HWC", "acquire buffer fails."); - return; + return false; } if (__buffer) { @@ -63,7 +66,7 @@ void DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame(bool &update) __buffer= dsBuffer; - update = true; + return true; } void DSDisplayDeviceHWCWindowTDMTargetImpl::presentFrame() diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h index 2dadf75..756b920 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h @@ -40,7 +40,7 @@ public: DSDisplayDeviceHWCWindowTDMTargetImpl(IDSDisplayDeviceHWC *deviceHWC, std::shared_ptr __bufferQueue); ~DSDisplayDeviceHWCWindowTDMTargetImpl(); - void updateFrame(bool &update) override; + bool updateFrame() override; void presentFrame() override; void onPresentFrameDone() override; std::shared_ptr getWindow() override; diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h index 3379243..e8eb85f 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h @@ -32,7 +32,7 @@ class IDSDisplayDeviceHWCWindow { public: virtual ~IDSDisplayDeviceHWCWindow() = default; - virtual void updateFrame(bool &update) = 0; + virtual bool updateFrame() = 0; virtual void presentFrame() = 0; virtual void onPresentFrameDone() = 0; virtual std::shared_ptr getWindow() = 0; -- 2.7.4