From 0126aee89744108f47837896620f21fcb277f0e1 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 18 Aug 2020 16:25:56 +0900 Subject: [PATCH 01/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 02/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 03/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 04/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 05/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 06/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 07/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 08/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 09/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 10/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 From 7b31e3e0ca7df6f472e53eed98027762400530e7 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 13:09:23 +0900 Subject: [PATCH 11/16] DSWaylandSurface: initialize member variables @ constructor Change-Id: I30852908d86dabd6a7f038248ac393035e0c13fa Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandSurface.cpp | 11 +++++++++-- src/DSWaylandServer/DSWaylandSurfacePrivate.h | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp index 60d2f56..4e6e2d7 100644 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ b/src/DSWaylandServer/DSWaylandSurface.cpp @@ -30,8 +30,15 @@ namespace display_server /* DSWaylandSurfaceCommitInfoPrivate */ DSWaylandSurfaceCommitInfoPrivate::DSWaylandSurfaceCommitInfoPrivate(DSWaylandSurfaceCommitInfo *p_ptr) : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{} + __p_ptr(p_ptr), + bufferRef(nullptr), + attach({0, 0, nullptr}), + damageSurface({0, 0, 0, 0}), + transform(0), + scale(0), + damageBuffer({0,0,0,0}) +{ +} DSWaylandSurfaceCommitInfoPrivate::~DSWaylandSurfaceCommitInfoPrivate() {} diff --git a/src/DSWaylandServer/DSWaylandSurfacePrivate.h b/src/DSWaylandServer/DSWaylandSurfacePrivate.h index d1f65b1..121f034 100644 --- a/src/DSWaylandServer/DSWaylandSurfacePrivate.h +++ b/src/DSWaylandServer/DSWaylandSurfacePrivate.h @@ -49,13 +49,13 @@ public: std::shared_ptr getBuffer(); public: - struct attach { + struct _attach { int32_t x; int32_t y; struct ::wl_resource *buffer; }; std::unique_ptr bufferRef; - struct attach attach; + struct _attach attach; struct damageSurface { int32_t x; -- 2.7.4 From 338832dffc6adc660eb959952712359b02b56f6e Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 13:10:23 +0900 Subject: [PATCH 12/16] DSWaylandZxdg*: initialize member variables @ constructor Change-Id: Ic8f3026caa343df75042c4d967e2159f1a24f9f4 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandZxdgShellV6.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp index 76b3758..70d122d 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp @@ -490,7 +490,9 @@ void DSWaylandZxdgToplevelV6::sendConfigure(unsigned int w, unsigned int h) } DSWaylandZxdgToplevelV6Private::DSWaylandZxdgToplevelV6Private(DSWaylandZxdgToplevelV6 *p_ptr) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr), + __zxdgSurface(nullptr) { } @@ -613,7 +615,9 @@ void DSWaylandZxdgPopupV6::sendConfigure(int x, int y, unsigned int w, unsigned } DSWaylandZxdgPopupV6Private::DSWaylandZxdgPopupV6Private(DSWaylandZxdgPopupV6 *p_ptr) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr), + __zxdgSurface(nullptr) { } -- 2.7.4 From cbe3b60ad8086f7ed907b2b229976a0349084bec Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 13:12:05 +0900 Subject: [PATCH 13/16] tests: initialize member variables @ constuctor of TestZone class Change-Id: Ib2165f55d4e5a14b05c85fc7274831803fea1678 Signed-off-by: Sung-Jin Park --- tests/DSZone-test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/DSZone-test.cpp b/tests/DSZone-test.cpp index 510712b..e302e52 100644 --- a/tests/DSZone-test.cpp +++ b/tests/DSZone-test.cpp @@ -41,7 +41,8 @@ class TestZone : public DSObject { public: TestZone(std::shared_ptr zone) - : __boolOnWindowCreated(false) + : __boolOnWindowCreated(false), + __boolOnWindowShellCreated(false) { zone->registerCallbackWindowCreated(this, std::bind(&TestZone::onWindowCreated, this, std::placeholders::_1)); __zone = zone; -- 2.7.4 From 52835a5e021d81d5669fc29bcad04f8eb3b6bf02 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 13:12:56 +0900 Subject: [PATCH 14/16] libds-mock: initialize member variables and add exception code @ constructor of MockWaylandCompositor Change-Id: I7ac66ef93fce9a08b3e5bbacd48079c7b44e00f5 Signed-off-by: Sung-Jin Park --- tests/libds-mock.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/libds-mock.h b/tests/libds-mock.h index 6bd23ef..ac77287 100644 --- a/tests/libds-mock.h +++ b/tests/libds-mock.h @@ -40,13 +40,19 @@ class MockWaylandCompositor : public DSObject { public: MockWaylandCompositor() - : surfaceCreated(false) + : surfaceCreated(false), + surfaceCommitted(false), + __waylandSurface(nullptr) { __eventLoop = DSEventLoop::getInstance(); __waylandCompositor = DSWaylandCompositor::getInstance(); - __waylandCompositor->create(); - __waylandCompositor->registerCallbackSurfaceCreated(this, std::bind(&MockWaylandCompositor::onSurfaceCreated, this, std::placeholders::_1)); + + if (__waylandCompositor) + { + __waylandCompositor->create(); + __waylandCompositor->registerCallbackSurfaceCreated(this, std::bind(&MockWaylandCompositor::onSurfaceCreated, this, std::placeholders::_1)); + } } ~MockWaylandCompositor() -- 2.7.4 From 9f305872f515b63a49daeeedf5ebfe3af5bfd8da Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 14:54:02 +0900 Subject: [PATCH 15/16] DSZone: add null check for waylandCompositor variable Change-Id: I7883a7d0054a0aaf756b48b0d073071a56c24e96 Signed-off-by: Sung-Jin Park --- src/DSZone/DSZone.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index 0b0f043..e127faa 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -38,8 +38,11 @@ DSZone::DSZone() __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)); + 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) -- 2.7.4 From 90472012efd9a4b4a4d3a0cb4e7a0d2c42d746da Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 14:55:13 +0900 Subject: [PATCH 16/16] DSWaylandOutput: initialize member variables @ constructor Change-Id: Ic3bb02ea09a10a2aa6b40e2cf8624ec24f885f9e Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandOutput.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandOutput.cpp b/src/DSWaylandServer/DSWaylandOutput.cpp index 067f353..7216dbb 100644 --- a/src/DSWaylandServer/DSWaylandOutput.cpp +++ b/src/DSWaylandServer/DSWaylandOutput.cpp @@ -31,7 +31,14 @@ namespace display_server DSWaylandOutputPrivate::DSWaylandOutputPrivate(DSWaylandOutput *p_ptr, DSWaylandCompositor *compositor) : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) + __p_ptr(p_ptr), + __outputRect({0,0,0,0}), + __phyWidth(0), + __phyHeight(0), + __refresh(0), + __subpixel(0), + __transform(0), + __scale(1.0) { if (!compositor) return; -- 2.7.4