From 01b698ec8aa794bc8c33f75a3d416bce45040f4a Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Sat, 22 Aug 2020 16:44:55 +0900 Subject: [PATCH 01/16] DSWaylandCompositor/DSWaylandSurface: add API to get surface by resource ID Change-Id: I1946ac7b360cce6b22693c547cbf97aec3cab29a --- src/DSWaylandServer/DSWaylandCompositor.cpp | 13 +++++++++++++ src/DSWaylandServer/DSWaylandCompositor.h | 2 ++ src/DSWaylandServer/DSWaylandSurface.cpp | 19 +++++++++++++++++-- src/DSWaylandServer/DSWaylandSurface.h | 2 ++ src/DSWaylandServer/DSWaylandSurfacePrivate.h | 3 +++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandCompositor.cpp b/src/DSWaylandServer/DSWaylandCompositor.cpp index 1570727..f09ef05 100644 --- a/src/DSWaylandServer/DSWaylandCompositor.cpp +++ b/src/DSWaylandServer/DSWaylandCompositor.cpp @@ -506,6 +506,19 @@ IDSWaylandShell *DSWaylandCompositor::getShell(void) return priv->getShell(); } +DSWaylandSurface *DSWaylandCompositor::getSurface(uint32_t id) +{ + for (auto s : __surfaceList) + { + if (s->getResourceId() == id) + { + return s.get(); + } + } + + return nullptr; +} + void DSWaylandCompositor::sendSurfaceDestroy(DSWaylandSurface *dswSurface) { for (auto s : __surfaceList) diff --git a/src/DSWaylandServer/DSWaylandCompositor.h b/src/DSWaylandServer/DSWaylandCompositor.h index c8ae82f..b350f48 100644 --- a/src/DSWaylandServer/DSWaylandCompositor.h +++ b/src/DSWaylandServer/DSWaylandCompositor.h @@ -67,6 +67,8 @@ public: bool setShell(IDSWaylandShell *shell); IDSWaylandShell *getShell(void); + DSWaylandSurface *getSurface(uint32_t id); + void sendSurfaceDestroy(DSWaylandSurface *dswSurface); void regionDestroy(DSWaylandRegion *dswRegion); diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp index 54996ba..473e3a0 100644 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ b/src/DSWaylandServer/DSWaylandSurface.cpp @@ -69,7 +69,8 @@ DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr) __p_ptr(p_ptr), __commitInfoPending{std::make_unique()}, __commitInfo{std::make_shared()}, - __bufferManager{DSBufferManager::getInstance()} + __bufferManager{DSBufferManager::getInstance()}, + __resId(0) {} DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr, DSWaylandClient *waylandClient, uint32_t id) @@ -77,10 +78,12 @@ DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr, DSWayl __p_ptr(p_ptr), __commitInfoPending{std::make_unique()}, __commitInfo{std::make_shared()}, - __bufferManager{DSBufferManager::getInstance()} + __bufferManager{DSBufferManager::getInstance()}, + __resId(0) { if (id > 0) { wl_surface::init(waylandClient->wlClient(), (int)id, 4); + __resId = id; } } @@ -90,6 +93,11 @@ DSWaylandSurfacePrivate::~DSWaylandSurfacePrivate() DSBufferManager::releaseInstance(); } +uint32_t DSWaylandSurfacePrivate::getResourceId() +{ + return __resId; +} + void DSWaylandSurfacePrivate::surface_bind_resource(Resource *resource) { } @@ -230,4 +238,11 @@ bool DSWaylandSurface::hasResource() return false; } +uint32_t DSWaylandSurface::getResourceId() +{ + DS_GET_PRIV(DSWaylandSurface); + + return priv->getResourceId(); +} + } /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandSurface.h b/src/DSWaylandServer/DSWaylandSurface.h index 7cc360b..41d1ccb 100644 --- a/src/DSWaylandServer/DSWaylandSurface.h +++ b/src/DSWaylandServer/DSWaylandSurface.h @@ -65,6 +65,8 @@ public: struct ::wl_resource *getWlResource(); bool hasResource(); + uint32_t getResourceId(); + private: // signals DSSignal> __surfaceCommittedSignal; diff --git a/src/DSWaylandServer/DSWaylandSurfacePrivate.h b/src/DSWaylandServer/DSWaylandSurfacePrivate.h index 121f034..abff9c2 100644 --- a/src/DSWaylandServer/DSWaylandSurfacePrivate.h +++ b/src/DSWaylandServer/DSWaylandSurfacePrivate.h @@ -90,6 +90,8 @@ public: DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr, DSWaylandClient *waylandClient, uint32_t id); ~DSWaylandSurfacePrivate() override; + uint32_t getResourceId(); + protected: void surface_bind_resource(Resource *resource) override; void surface_destroy_resource(Resource *resource) override; @@ -109,6 +111,7 @@ private: std::unique_ptr __commitInfoPending; std::shared_ptr __commitInfo; DSBufferManager *__bufferManager; + uint32_t __resId; }; } /*namespace display_server */ -- 2.7.4 From 7a8caf602617d92bc5f4c08bee10a5fa50ebc763 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Sat, 22 Aug 2020 16:49:29 +0900 Subject: [PATCH 02/16] DSWindowShell/DSWindow : handle set/get Parent Change-Id: I99f21cf923b640213e48fc8c9c186f9fa213ddc6 --- src/DSWindow/DSWindow.cpp | 25 +++++++++ src/DSWindow/DSWindow.h | 3 ++ src/DSWindow/DSWindowPrivate.h | 5 ++ src/DSWindowShell/DSWindowShell.cpp | 36 ++++++++++++- src/DSWindowShell/DSWindowShell.h | 8 +++ src/DSWindowShell/DSWindowShellPrivate.cpp | 82 +++++++++++++++++++++++++++++- src/DSWindowShell/DSWindowShellPrivate.h | 13 +++++ tests/DSWindow-test.cpp | 20 ++++++++ tests/DSWindowShell-test.cpp | 25 +++++++++ 9 files changed, 214 insertions(+), 3 deletions(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 4f063fc..1657a07 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -32,6 +32,7 @@ namespace display_server DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), + __parent(nullptr), __x(0), __y(0), __w(0), @@ -68,6 +69,16 @@ void DSWindowPrivate::destroy(void) { } +void DSWindowPrivate::setParent(DSWindow *parent) +{ + __parent = parent; +} + +DSWindow *DSWindowPrivate::getParent(void) +{ + return __parent; +} + bool DSWindowPrivate::show(void) { return true; @@ -252,6 +263,20 @@ void DSWindow::destroy(void) priv->destroy(); } +void DSWindow::setParent(DSWindow *parent) +{ + if (parent == this) return; + + DS_GET_PRIV(DSWindow); + priv->setParent(parent); +} + +DSWindow *DSWindow::getParent(void) +{ + DS_GET_PRIV(DSWindow); + return priv->getParent(); +} + bool DSWindow::show(void) { DS_GET_PRIV(DSWindow); diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index 9024dbc..2907456 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -49,6 +49,9 @@ public: bool create(std::shared_ptr waylandSurface); void destroy(void); + void setParent(DSWindow *parent); + DSWindow *getParent(void); + bool show(void); bool hide(bool autoFocus = true); int showState(void); diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index 8b429e6..b8be9ee 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -46,6 +46,9 @@ public: bool create(std::shared_ptr waylandSurface); void destroy(void); + void setParent(DSWindow *parent); + DSWindow *getParent(void); + bool show(void); bool hide(bool autoFocus); int showState(void); @@ -75,6 +78,8 @@ public: private: void __onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo); + DSWindow *__parent; + std::list __childList; int __x, __y; unsigned int __w; unsigned int __h; diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp index 357f5d1..c6a0e7c 100644 --- a/src/DSWindowShell/DSWindowShell.cpp +++ b/src/DSWindowShell/DSWindowShell.cpp @@ -67,6 +67,39 @@ IDSWaylandShellSurface *DSWindowShell::getShellSurface(void) return priv->getShellSurface(); } +DSWindow *DSWindowShell::getWindow(void) +{ + DS_GET_PRIV(DSWindowShell); + return priv->getWindow(); +} + +bool DSWindowShell::setParent(DSWindowShell *parentWinShell) +{ + if (parentWinShell == this) + return false; + + DS_GET_PRIV(DSWindowShell); + return priv->setParent(parentWinShell); +} + +DSWindowShell *DSWindowShell::getParent(void) +{ + DS_GET_PRIV(DSWindowShell); + return priv->getParent(); +} + +bool DSWindowShell::addChild(DSWindowShell *childWinShell) +{ + DS_GET_PRIV(DSWindowShell); + return priv->addChild(childWinShell); +} + +void DSWindowShell::removeChild(DSWindowShell *childWinShell) +{ + DS_GET_PRIV(DSWindowShell); + priv->removeChild(childWinShell); +} + bool DSWindowShell::setTitle(const std::string &title) { DS_GET_PRIV(DSWindowShell); @@ -137,7 +170,8 @@ int DSWindowShell::showState(void) bool DSWindowShell::setLayer(int layer) { - return true; + DS_GET_PRIV(DSWindowShell); + return priv->setLayer(layer); } int DSWindowShell::getLayer(void) diff --git a/src/DSWindowShell/DSWindowShell.h b/src/DSWindowShell/DSWindowShell.h index c0aa944..0fe1f6d 100644 --- a/src/DSWindowShell/DSWindowShell.h +++ b/src/DSWindowShell/DSWindowShell.h @@ -50,6 +50,14 @@ public: void setShellSurface(IDSWaylandShellSurface *zxdgSurface); IDSWaylandShellSurface *getShellSurface(void); + DSWindow *getWindow(void); + + bool setParent(DSWindowShell *parentWinShell); + DSWindowShell *getParent(void); + + bool addChild(DSWindowShell *childWinShell); + void removeChild(DSWindowShell *childWinShell); + bool setTitle(const std::string &title); bool setSkipFocus(bool set); diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index 62dcd98..1b766c9 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -38,7 +38,8 @@ DSWindowShellPrivate::DSWindowShellPrivate(DSWindowShell *p_ptr, DSWindow *windo __x(0), __y(0), __w(0), __h(0), __reqX(0), __reqY(0), - __reqW(0), __reqH(0) + __reqW(0), __reqH(0), + __parent(nullptr) { } @@ -47,6 +48,56 @@ DSWindowShellPrivate::~DSWindowShellPrivate() } +bool DSWindowShellPrivate::__findInChildList(DSWindowShell *parentWinShell) +{ + for (auto ws : __childList) + { + if (ws == parentWinShell) + return true; + } + + return false; +} + +bool DSWindowShellPrivate::__setParent(DSWindowShell *parentWinShell) +{ + DS_GET_PUB(DSWindowShell); + + if (__parent == parentWinShell) + return true; + + if (__findInChildList(parentWinShell)) + { + DSLOG_ERR("DSWindowShell", "Fatal error. Set parent each other. winShell:%p, parentWinShell:%p", pub, parentWinShell); + return false; + } + + if (__parent) + { + // remove this from old parent's child list + __parent->removeChild(pub); + } + + __parent = parentWinShell; + if (__parent) + { + __parent->addChild(pub); + } + + if (__window) + { + if (__parent) + { + DSWindow *parentWin = __parent->getWindow(); + __window->setParent(parentWin); + } + else + __window->setParent(nullptr); + } + + return true; +} + bool DSWindowShellPrivate::create(DSWindowShell *pParent) { @@ -86,6 +137,32 @@ IDSWaylandShellSurface *DSWindowShellPrivate::getShellSurface(void) return __shellSurface; } +DSWindow *DSWindowShellPrivate::getWindow(void) +{ + return __window; +} + +bool DSWindowShellPrivate::setParent(DSWindowShell *parentWinShell) +{ + return __setParent(parentWinShell); +} + +DSWindowShell *DSWindowShellPrivate::getParent(void) +{ + return __parent; +} + +bool DSWindowShellPrivate::addChild(DSWindowShell *childWinShell) +{ + __childList.push_back(childWinShell); + return true; +} + +void DSWindowShellPrivate::removeChild(DSWindowShell *childWinShell) +{ + __childList.remove(childWinShell); +} + bool DSWindowShellPrivate::setTitle(const std::string &title) { if (__window) @@ -184,12 +261,13 @@ int DSWindowShellPrivate::showState(void) bool DSWindowShellPrivate::setLayer(int layer) { + __layer = layer; return true; } int DSWindowShellPrivate::getLayer(void) { - return 0; + return __layer; } diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h index 77582d1..3340a31 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -46,6 +46,14 @@ public: void setShellSurface(IDSWaylandShellSurface *shellSurface); IDSWaylandShellSurface *getShellSurface(void); + DSWindow *getWindow(void); + + bool setParent(DSWindowShell *parentWinShell); + DSWindowShell *getParent(void); + + bool addChild(DSWindowShell *childWinShell); + void removeChild(DSWindowShell *childWinShell); + bool setTitle(const std::string &title); bool setSkipFocus(bool set); @@ -100,14 +108,19 @@ public: private: bool __create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pWin, DSWindowShell *pParent); + bool __findInChildList(DSWindowShell *parentWinShell); + bool __setParent(DSWindowShell *parentWinShell); private: DSWindow *__window; IDSWaylandShellSurface *__shellSurface; int __x, __y; unsigned int __w, __h; + int __layer; int __reqX, __reqY; unsigned int __reqW, __reqH; + DSWindowShell *__parent; + std::list __childList; }; } diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp index c037f6d..d591563 100644 --- a/tests/DSWindow-test.cpp +++ b/tests/DSWindow-test.cpp @@ -164,3 +164,23 @@ TEST_F(DSWindowTest, SkipFocusTest) EXPECT_TRUE(skip == false); } +TEST_F(DSWindowTest, ParentTest) +{ + auto parent = std::make_shared(); + EXPECT_TRUE(parent != nullptr); + EXPECT_TRUE(parent->getParent() == nullptr); + + auto child = std::make_shared(); + EXPECT_TRUE(child != nullptr); + EXPECT_TRUE(child->getParent() == nullptr); + + child->setParent(parent.get()); + EXPECT_TRUE(child->getParent() == parent.get()); + + child->setParent(nullptr); + EXPECT_TRUE(child->getParent() == nullptr); + + child->setParent(child.get()); + EXPECT_TRUE(child->getParent() == nullptr); +} + diff --git a/tests/DSWindowShell-test.cpp b/tests/DSWindowShell-test.cpp index 73af28c..01fba49 100644 --- a/tests/DSWindowShell-test.cpp +++ b/tests/DSWindowShell-test.cpp @@ -62,6 +62,31 @@ TEST_F(DSWindowShellTest, create_P2) EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); } +TEST_F(DSWindowShellTest, parent_P1) +{ + auto window = std::make_shared(); + std::unique_ptr shell = std::make_unique(window.get()); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->getParent() == nullptr); + + auto childWindow = std::make_shared(); + std::unique_ptr childShell = std::make_unique(childWindow.get()); + EXPECT_TRUE(childShell != nullptr); + + EXPECT_TRUE(childShell->setParent(shell.get()) == true); + EXPECT_TRUE(childShell->getParent() == shell.get()); + + // test for set parent each other + EXPECT_TRUE(shell->setParent(childShell.get()) == false); + + // test for set parent itself + EXPECT_TRUE(childShell->setParent(childShell.get()) == false); + + EXPECT_TRUE(childShell->setParent(nullptr) == true); + EXPECT_TRUE(childShell->getParent() == nullptr); +} + TEST_F(DSWindowShellTest, setPosition_P1) { auto window = std::make_shared(); -- 2.7.4 From d2c200d15b4d69a45b453ed21583a76c6e668ebe Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Sat, 22 Aug 2020 17:10:25 +0900 Subject: [PATCH 03/16] DSZone: add setWindowParent API Change-Id: I595e7cc1c33f8f0a6a5055caa58360e03b3038ca --- src/DSZone/DSZone.cpp | 10 ++++++++++ src/DSZone/DSZone.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index 52c55f9..4823aac 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -313,6 +313,16 @@ void DSZone::__destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface * } } +bool DSZone::setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface) +{ + DSWindowShell *wShell = __findWindowShell(dswlSurface); + if (!wShell) return false; + + DSWindowShell *pwShell = __findWindowShell(dswlParentSurface); + + return wShell->setParent(pwShell); +} + bool DSZone::setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title) { DSWindowShell *wShell = __findWindowShell(dswSurface); diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index 9d5083b..f7266fc 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -63,6 +63,7 @@ public: bool testCreateWindow(std::shared_ptr waylandSurface); // for window property + bool setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface); bool setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title); bool setWindowType(DSWaylandSurface *dswSurface, int type); bool setWindowGeometry(DSWaylandSurface *dswSurface, int x, int y, unsigned int w, unsigned h); -- 2.7.4 From 3486ed8d722fd40838c74607b222f698ae82f787 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Sat, 22 Aug 2020 17:11:24 +0900 Subject: [PATCH 04/16] DSWindowManager: add API for setting parent window Change-Id: I87e6d1550ce89eede32ec2b2a421332126469e9d --- src/DSWindowManager/DSWindowManager.cpp | 17 +++++++++++++++++ src/DSWindowManager/DSWindowManager.h | 1 + src/DSWindowManager/DSWindowManagerPrivate.h | 1 + 3 files changed, 19 insertions(+) diff --git a/src/DSWindowManager/DSWindowManager.cpp b/src/DSWindowManager/DSWindowManager.cpp index ecb0420..3fc3e44 100644 --- a/src/DSWindowManager/DSWindowManager.cpp +++ b/src/DSWindowManager/DSWindowManager.cpp @@ -201,6 +201,17 @@ DSZone *DSWindowManagerPrivate::getZone(DSWaylandSurface *surface) return __getZone(surface); } +bool DSWindowManagerPrivate::setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface) +{ + // find dsSurface's window + DSZone *zone = __getZone(dswlSurface); + if (!zone) return false; + + DSZone *pZone = __getZone(dswlParentSurface); + if (zone != pZone) return false; + + return zone->setWindowParent(dswlSurface, dswlParentSurface); +} void DSWindowManagerPrivate::setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title) { @@ -421,6 +432,12 @@ DSZone *DSWindowManager::getZone(DSWaylandSurface *surface) return priv->getZone(surface); } +bool DSWindowManager::setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface) +{ + DS_GET_PRIV(DSWindowManager); + return priv->setWindowParent(dswlSurface, dswlParentSurface); +} + void DSWindowManager::setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title) { DS_GET_PRIV(DSWindowManager); diff --git a/src/DSWindowManager/DSWindowManager.h b/src/DSWindowManager/DSWindowManager.h index e7a135b..c11a495 100644 --- a/src/DSWindowManager/DSWindowManager.h +++ b/src/DSWindowManager/DSWindowManager.h @@ -55,6 +55,7 @@ public: void unregisterSurface(DSZone *zone, DSWaylandSurface *surface); DSZone *getZone(DSWaylandSurface *surface); + bool setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface); void setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title); void setWindowType(DSWaylandSurface *dsSurface, int type); void setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h); diff --git a/src/DSWindowManager/DSWindowManagerPrivate.h b/src/DSWindowManager/DSWindowManagerPrivate.h index be3610c..28f6ec2 100644 --- a/src/DSWindowManager/DSWindowManagerPrivate.h +++ b/src/DSWindowManager/DSWindowManagerPrivate.h @@ -50,6 +50,7 @@ public: void unregisterSurface(DSZone *zone, DSWaylandSurface *surface); DSZone *getZone(DSWaylandSurface *surface); + bool setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface); void setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title); void setWindowType(DSWaylandSurface *dsSurface, int type); void setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h); -- 2.7.4 From d12c320aba12635b0c7854c15626f8bee4161811 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Sat, 22 Aug 2020 17:12:09 +0900 Subject: [PATCH 05/16] implement tizen_policy_set_transient_for Change-Id: I072c7aad76e60f95da68680c4ec40fd871af38d8 --- src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index 2a28cb5..2ccef52 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -185,7 +185,16 @@ void DSWaylandTizenPolicyPrivate::tizen_policy_set_notification_level(Resource * void DSWaylandTizenPolicyPrivate::tizen_policy_set_transient_for(Resource *resource, uint32_t child_id, uint32_t parent_id) { - DSLOG_DBG("TizenPolicyPriv", ""); + DSLOG_DBG("TizenPolicyPriv", "Set Transient_for (parent_id:%d, child_id:%d)", parent_id, child_id); + DS_GET_PUB(DSWaylandTizenPolicy); + DSWaylandCompositor *wlComp = pub->getWlCompositor(); + if (!wlComp) return; + if (!__wm) return; + + DSWaylandSurface *childSurface = wlComp->getSurface(child_id); + DSWaylandSurface *parentSurface = wlComp->getSurface(parent_id); + + __wm->setWindowParent(childSurface, parentSurface); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_transient_for(Resource *resource, uint32_t child_id) -- 2.7.4 From 5030f47e19168d1e03f8c33a95aa02b1f9f55741 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Mon, 24 Aug 2020 08:46:56 +0900 Subject: [PATCH 06/16] DSWaylandZxdgToplevel: implement set_parent Change-Id: If4e310ceea19cae12bad463d09913d87b85a7086 --- src/DSWaylandServer/DSWaylandZxdgShellV6.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp index 1e38eae..f72a1e7 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp @@ -544,9 +544,24 @@ void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_destroy_resource(zxdg_topl void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_destroy(zxdg_toplevel_v6::Resource *resource) { } + void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_set_parent(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *parent) { + DSLOG_DBG("XDG_TopLevel", "Set Parent (parent:%p)", parent); + + DSWaylandSurface *surface = __zxdgSurface->getSurface(); + if (!surface) return; + + DSWaylandSurface *parentSurface = DSWaylandSurface::fromWlResource(parent); + + DSWindowManager *wm = DSWindowManager::getInstance(); + if (wm) + { + wm->setWindowParent(surface, parentSurface); + DSWindowManager::releaseInstance(); + } } + void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_set_title(zxdg_toplevel_v6::Resource *resource, const std::string &title) { __zxdgSurface->setWindowTitle(title); -- 2.7.4 From c35e683050abf5b3aeabef9017bf7befb27c77ff Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Mon, 24 Aug 2020 09:05:45 +0900 Subject: [PATCH 07/16] DSWindowShellPrivate: initialize __layer value Change-Id: I834fbb839c74ca732600922353cbb271dc58db6d --- src/DSWindowShell/DSWindowShellPrivate.cpp | 3 ++- src/DSWindowShell/DSWindowShellPrivate.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index 1b766c9..5119f90 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -39,7 +39,8 @@ DSWindowShellPrivate::DSWindowShellPrivate(DSWindowShell *p_ptr, DSWindow *windo __w(0), __h(0), __reqX(0), __reqY(0), __reqW(0), __reqH(0), - __parent(nullptr) + __parent(nullptr), + __layer(0) { } diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h index 3340a31..454f23d 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -116,10 +116,10 @@ private: IDSWaylandShellSurface *__shellSurface; int __x, __y; unsigned int __w, __h; - int __layer; int __reqX, __reqY; unsigned int __reqW, __reqH; DSWindowShell *__parent; + int __layer; std::list __childList; }; -- 2.7.4 From e4bacf2c3a3791a84aaa2e94aae6ae947a50bf2d Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 24 Aug 2020 14:32:26 +0900 Subject: [PATCH 08/16] DSWindow: add setZOrder/getZOrder API Change-Id: I4345dbc9de85e18545138cfd7b619f191bb8cf67 Signed-off-by: Sung-Jin Park --- src/DSWindow/DSWindow.cpp | 14 ++++++++++++++ src/DSWindow/DSWindow.h | 3 +++ src/DSWindow/DSWindowPrivate.h | 1 + 3 files changed, 18 insertions(+) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 1657a07..8673000 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -37,6 +37,7 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) __y(0), __w(0), __h(0), + __zOrder(0), __committedW(0), __committedH(0), __created(false), @@ -418,6 +419,19 @@ void DSWindow::setSize(stSize size) priv->__changedGeometry = true; } +void DSWindow::setZOrder(unsigned int zOrder) +{ + DS_GET_PRIV(DSWindow); + + priv->__zOrder = zOrder; +} + +unsigned int DSWindow::getZOrder() +{ + DS_GET_PRIV(DSWindow); + + return priv->__zOrder; +} bool DSWindow::setVkbdFloating(bool set) { diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index 2907456..4f1922a 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -77,6 +77,9 @@ public: void setSize(unsigned int w, unsigned int h); void setSize(stSize size); + void setZOrder(unsigned int zOrder); + unsigned int getZOrder(); + bool setVkbdFloating(bool set); bool getVkbdFloating(); diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index b8be9ee..f250484 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -83,6 +83,7 @@ private: int __x, __y; unsigned int __w; unsigned int __h; + unsigned int __zOrder; unsigned int __committedW, __committedH; bool __created; bool __hasFocus; -- 2.7.4 From 88ec1669113f1e6e4bc39fc09c92a29a9f871fee Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 24 Aug 2020 14:47:23 +0900 Subject: [PATCH 09/16] DSZone: emit windowStackChanged signal when the stack has been changed Change-Id: I9755c327797fcebc22eac7accab49cd9ba22b331 Signed-off-by: Sung-Jin Park --- src/DSZone/DSZone.cpp | 30 ++++++++++++++++++++++++++++++ src/DSZone/DSZone.h | 3 +++ 2 files changed, 33 insertions(+) diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index 4823aac..bf2700f 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -113,6 +113,11 @@ void DSZone::registerCallbackWindowShellCreated(DSObject *slot, std::function)> func) +{ + __windowStackChangedSignal.connect(slot, func); +} + void DSZone::registerCallbackWindowDestroy(DSObject *slot, std::function)> func) { __windowDestroySignal.connect(slot, func); @@ -220,6 +225,10 @@ void DSZone::__prependWindowList(std::shared_ptr window) __windowList.push_front(window); __stackChanged = true; + __updateWindowOrder(); + + std::shared_ptr wTop(__windowList.front()); + __windowStackChangedSignal.emit(wTop); } void DSZone::__appendWindowList(std::shared_ptr window) @@ -228,6 +237,10 @@ void DSZone::__appendWindowList(std::shared_ptr window) __windowList.push_back(window); __stackChanged = true; + __updateWindowOrder(); + + std::shared_ptr wTop(__windowList.front()); + __windowStackChangedSignal.emit(wTop); } std::shared_ptr DSZone::__findWindow(DSWaylandSurface *dswlSurface) @@ -278,6 +291,23 @@ void DSZone::__destroyWindow(std::shared_ptr window) { __windowDestroySignal.emit(window); __windowList.remove(window); + + __stackChanged = true; + __updateWindowOrder(); + + std::shared_ptr wTop(__windowList.front()); + __windowStackChangedSignal.emit(wTop); +} + +void DSZone::__updateWindowOrder(void) +{ + uint32_t zOrder = 0; + std::list> wList = getWindowList(); + for (auto w : wList) + { + /* TODO : check if the w is in its visible state */ + w->setZOrder(zOrder++); + } } std::shared_ptr DSZone::__createWindowShell(std::shared_ptr window) diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index f7266fc..acb3a61 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -55,6 +55,7 @@ public: void registerCallbackWindowCreated(DSObject *slot, std::function)> func); void registerCallbackWindowDestroy(DSObject *slot, std::function)> func); void registerCallbackWindowShellCreated(DSObject *slot, std::function)> func); + void registerCallbackWindowStackChanged(DSObject *slot, std::function)> func); // emit functions for testing void callCallbackWindowCreated(); @@ -91,6 +92,7 @@ private: std::shared_ptr __createWindow(std::shared_ptr waylandSurface); void __destroyWindow(std::shared_ptr window); + void __updateWindowOrder(void); std::shared_ptr __createWindowShell(std::shared_ptr window); void __destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface *surface); @@ -116,6 +118,7 @@ private: // signals DSSignal> __windowCreatedSignal; DSSignal> __windowDestroySignal; + DSSignal> __windowStackChangedSignal; DSSignal> __windowShellCreatedSignal; DSSignal> __windowShellDestroySignal; }; -- 2.7.4 From 84ee6ac1d505a60634a3cd7807385e1f93ed9006 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 24 Aug 2020 14:48:05 +0900 Subject: [PATCH 10/16] DSSeat: add/register slot for windowStackChanged signal Change-Id: Ida868f529c5c9a766b08414da5a269caee525506 Signed-off-by: Sung-Jin Park --- src/DSSeat/DSSeat.cpp | 12 ++++++++++-- src/DSSeat/DSSeat.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index 645b45f..0030478 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -58,7 +58,8 @@ DSSeat::DSSeat() __numPointer(0), __numKeyboard(0), __numTouch(0), - __focusWin(nullptr) + __focusWin(nullptr), + __stackChanged(false) { } @@ -75,7 +76,8 @@ DSSeat::DSSeat(DSCompositor *compositor, std::string name) __numPointer(0), __numKeyboard(0), __numTouch(0), - __focusWin(nullptr) + __focusWin(nullptr), + __stackChanged(false) { if (!compositor) return; @@ -138,6 +140,7 @@ bool DSSeat::attachZone(std::shared_ptr zone) __zone = zone; __zone->registerCallbackWindowCreated(this, std::bind(&DSSeat::__onWindowCreated, this, std::placeholders::_1)); + __zone->registerCallbackWindowStackChanged(this, std::bind(&DSSeat::__onWindowStackChanged, this, std::placeholders::_1)); __zone->registerCallbackWindowDestroy(this, std::bind(&DSSeat::__onWindowDestroy, this, std::placeholders::_1)); return true; @@ -460,6 +463,11 @@ void DSSeat::__onTouchEvent(DSInputTouchEvent *ev) __touch->processEvent(ev, nullptr); } +void DSSeat::__onWindowStackChanged(std::shared_ptr topWindow) +{ + __stackChanged = true; +} + void DSSeat::__onWindowCreated(std::shared_ptr window) { DSLOG_INF("DSSeat", "window created : %p (%p)", window, window.get()); diff --git a/src/DSSeat/DSSeat.h b/src/DSSeat/DSSeat.h index a599b50..6b7cc01 100644 --- a/src/DSSeat/DSSeat.h +++ b/src/DSSeat/DSSeat.h @@ -91,6 +91,7 @@ private: uint32_t __numTouch; std::shared_ptr __focusWin; + bool __stackChanged; void __initSlots(); void __initEventHandlers(); @@ -109,6 +110,7 @@ private: void __onKeyEvent(DSInputKeyboardEvent *ev); void __onPointerEvent(DSInputMouseEvent *ev); void __onTouchEvent(DSInputTouchEvent *ev); + void __onWindowStackChanged(std::shared_ptr topWindow); void __onWindowCreated(std::shared_ptr window); void __onWindowDestroy(std::shared_ptr window); }; -- 2.7.4 From 7010f8e37eb145fc10fdabe110cb8f2d9fd32cb4 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 24 Aug 2020 16:55:50 +0900 Subject: [PATCH 11/16] DSWaylandSurface: add bufferChanged method allow to check if buffer is attached. wayland client can attach null buffer resource. Change-Id: I284b186e150e4fa577eb7b451d81f1a14d9e68ea --- src/DSWaylandServer/DSWaylandSurface.cpp | 14 +++++++++++++- src/DSWaylandServer/DSWaylandSurface.h | 1 + src/DSWaylandServer/DSWaylandSurfacePrivate.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp index 473e3a0..7e98b10 100644 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ b/src/DSWaylandServer/DSWaylandSurface.cpp @@ -63,6 +63,13 @@ std::shared_ptr DSWaylandSurfaceCommitInfo::getBuffer() return priv->getBuffer(); } +bool DSWaylandSurfaceCommitInfo::bufferChanged() +{ + DS_GET_PRIV(DSWaylandSurfaceCommitInfo); + + return priv->bufferChanged; +} + /* DSWaylandSurfacePrivate */ DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr) : DSObjectPrivate(p_ptr), @@ -131,8 +138,11 @@ void DSWaylandSurfacePrivate::surface_attach(Resource *resource, struct ::wl_res if (buffer) { dsBuffer = __bufferManager->getDSBuffer(buffer); commitInfoPendingPriv->bufferRef = std::make_unique(dsBuffer); - + } else { + commitInfoPendingPriv->bufferRef = nullptr; } + + commitInfoPendingPriv->bufferChanged = true; } void DSWaylandSurfacePrivate::surface_damage(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) @@ -174,6 +184,8 @@ void DSWaylandSurfacePrivate::surface_commit(Resource *resource) commitInfoPriv->scale = commitInfoPendingPriv->scale; commitInfoPriv->damageBuffer = commitInfoPendingPriv->damageBuffer; commitInfoPriv->bufferRef = std::move(commitInfoPendingPriv->bufferRef); + commitInfoPriv->bufferChanged = commitInfoPendingPriv->bufferChanged; + commitInfoPendingPriv->bufferChanged = false; // reset value // emit a signal of the surface committed pub->__surfaceCommittedSignal.emit(__commitInfo); diff --git a/src/DSWaylandServer/DSWaylandSurface.h b/src/DSWaylandServer/DSWaylandSurface.h index 41d1ccb..d9cac4a 100644 --- a/src/DSWaylandServer/DSWaylandSurface.h +++ b/src/DSWaylandServer/DSWaylandSurface.h @@ -48,6 +48,7 @@ public: //TODO: add getter functions. std::shared_ptr getBuffer(); + bool bufferChanged(); }; class DSWaylandSurface : public DSObject diff --git a/src/DSWaylandServer/DSWaylandSurfacePrivate.h b/src/DSWaylandServer/DSWaylandSurfacePrivate.h index abff9c2..4b37613 100644 --- a/src/DSWaylandServer/DSWaylandSurfacePrivate.h +++ b/src/DSWaylandServer/DSWaylandSurfacePrivate.h @@ -56,6 +56,7 @@ public: }; std::unique_ptr bufferRef; struct _attach attach; + bool bufferChanged; struct damageSurface { int32_t x; -- 2.7.4 From 7b1b82bfa9d99b4074733ad112bc23a5d53755b6 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 24 Aug 2020 16:57:29 +0900 Subject: [PATCH 12/16] DSWindow: client can commit null buffer. Change-Id: I6a7b98d9151f70f68aec0b0ccbb9fd95ab437691 --- src/DSWindow/DSWindow.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 8673000..acf1e07 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -206,22 +206,8 @@ void DSWindowPrivate::__onSurfaceCommitted(std::shared_ptr buffer = waylandSurfaceCommitInfo->getBuffer(); - if (buffer) { - // TODO: set the size of window with the size of commit information - // It could be changed by DSWindowShell policy later.. - std::shared_ptr bufferSize = buffer->getSize(); - __committedW = bufferSize->w; - __committedH = bufferSize->h; - -#if 0 // temporary code - we have to use policy to decide window's size. - if ((__committedW != __w) || - (__committedH != __h)) - { - DSLOG_ERR("DSWindow", "Committed size (%d,%d) is not same to requested size(%d,%d)", bufferSize->w, bufferSize->h, __w, __h); - return; - } -#endif + if (waylandSurfaceCommitInfo->bufferChanged()) { + std::shared_ptr buffer = waylandSurfaceCommitInfo->getBuffer(); // emit a signal of the buffer changed pub->__bufferChangedSignal.emit(buffer); -- 2.7.4 From 6228bb3eacea64ec0493a74295ed55e3154c5ff7 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 24 Aug 2020 16:59:21 +0900 Subject: [PATCH 13/16] DSRenderViewDaliImpl: change the visibility of the dali actor. when buffer exist, set visible. when buffer is null, set unvisible. Change-Id: I944f99582bde658a7aac9ce6fe602b5f3a9761b4 --- src/DSRender/DSRenderViewDaliImpl.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp index b76a004..1b64d5b 100644 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ b/src/DSRender/DSRenderViewDaliImpl.cpp @@ -115,19 +115,28 @@ DSRenderViewDaliImpl::~DSRenderViewDaliImpl() bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) { - tbm_surface_h nativeBuffer = (tbm_surface_h)buffer->getNativeBuffer(); - std::shared_ptr bufferSize = buffer->getSize(); + if (buffer) { + DSLOG_INF("DSRenderViewDaliImpl", "buffer set."); - __textureViewActor.SetProperty(Actor::Property::SIZE, Vector2(bufferSize->w, bufferSize->h)); + __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); - NativeImageSourcePtr nativeImageSource = NativeImageSource::New(Any(nativeBuffer)); + tbm_surface_h nativeBuffer = (tbm_surface_h)buffer->getNativeBuffer(); + std::shared_ptr bufferSize = buffer->getSize(); - Texture nativeTexture = Texture::New(*nativeImageSource); + __textureViewActor.SetProperty(Actor::Property::SIZE, Vector2(bufferSize->w, bufferSize->h)); - TextureSet textureSet = TextureSet::New(); - textureSet.SetTexture(0u, nativeTexture); + NativeImageSourcePtr nativeImageSource = NativeImageSource::New(Any(nativeBuffer)); - __renderer.SetTextures(textureSet); + Texture nativeTexture = Texture::New(*nativeImageSource); + + TextureSet textureSet = TextureSet::New(); + textureSet.SetTexture(0u, nativeTexture); + + __renderer.SetTextures(textureSet); + } else { + DSLOG_INF("DSRenderViewDaliImpl", "buffer NULL."); + __textureViewActor.SetProperty(Actor::Property::VISIBLE, false); + } return true; } @@ -139,9 +148,12 @@ std::shared_ptr DSRenderViewDaliImpl::getWindow() void DSRenderViewDaliImpl::__onWindowBufferChanged(std::shared_ptr buffer) { - std::shared_ptr bufferSize = buffer->getSize(); - - DSLOG_INF("DSRenderViewDaliImpl", "Window Buffer changed. buffer(%p) size(%d, %d)", buffer.get(), bufferSize->w, bufferSize->h); + if (buffer) { + std::shared_ptr bufferSize = buffer->getSize(); + DSLOG_INF("DSRenderViewDaliImpl", "Window Buffer changed. buffer(%p) size(%d, %d)", buffer.get(), bufferSize->w, bufferSize->h); + } else { + DSLOG_INF("DSRenderViewDaliImpl", "Window Buffer changed. buffer(nullptr)"); + } if (!setBuffer(buffer)) { DSLOG_ERR("DSRenderViewDaliImpl", "setBuffer fails."); -- 2.7.4 From 81ff4150eb6f6ebe958117a1aa1c5cad5e53edeb Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 24 Aug 2020 19:24:40 +0900 Subject: [PATCH 14/16] DSWaylandSurfaceCommitInfo: initialize bufferChanged to false Change-Id: Iba5d6da7e04512640d8e98ae28cc3da624884418 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandSurface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp index 7e98b10..26afa18 100644 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ b/src/DSWaylandServer/DSWaylandSurface.cpp @@ -33,6 +33,7 @@ DSWaylandSurfaceCommitInfoPrivate::DSWaylandSurfaceCommitInfoPrivate(DSWaylandSu __p_ptr(p_ptr), bufferRef(nullptr), attach({0, 0, nullptr}), + bufferChanged(false), damageSurface({0, 0, 0, 0}), transform(0), scale(0), -- 2.7.4 From fb0ebc19682c5ac2685ef3de133824ec0e48d101 Mon Sep 17 00:00:00 2001 From: jeon Date: Mon, 24 Aug 2020 20:41:59 +0900 Subject: [PATCH 15/16] DSDebug: check environment to use dlog Change-Id: I3d98a8723c33ca96b80bb503a40d21c88b3c12c4 --- src/DSDebug/DSDebugLog.cpp | 51 +++++++++++++++++++++++++++++++++++----------- src/DSDebug/DSDebugLog.h | 1 + 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/DSDebug/DSDebugLog.cpp b/src/DSDebug/DSDebugLog.cpp index 2900668..3966335 100644 --- a/src/DSDebug/DSDebugLog.cpp +++ b/src/DSDebug/DSDebugLog.cpp @@ -24,6 +24,7 @@ #include #include #include "DSDebugLog.h" +#include #define COLOR_RED "\x1b[31m" /* for error */ #define COLOR_YELLOW "\x1b[33m" /* for warning */ @@ -33,7 +34,18 @@ namespace display_server { DSDebugLog::DSDebugLog() : mLogLevel(LOG_LEVEL_DEBUG) -{} +{ + char *tmp = getenv("DSLOG_DLOG_ENABLE"); + char *env = strdup(tmp); + int value = atoi(env); + + free(env); + + if (value == 1) + __enableDlog = true; + else + __enableDlog = false; +} DSDebugLog::~DSDebugLog() {} @@ -59,17 +71,32 @@ void DSDebugLog::printLog(int logLevel, const char *domain, const char *funcName //TODO: use dlog or stdout //TODO: use dlog filters va_list arg; - const char *lvl_str[] = { "DS_DBG", "DS_INF", "DS_WRN", "DS_ERR" }; - const char *color[] = { COLOR_RESET, COLOR_GREEN, COLOR_YELLOW, COLOR_RED }; - - va_start(arg, fmt); - printf("%s", color[logLevel]); - printf("[%s]", lvl_str[logLevel]); - printf("[%s]", domain); - printf(":[%s(%d)]:", funcName, line); - vprintf(fmt, arg); - printf("\n"); - va_end(arg); + + if (__enableDlog) + { + const log_priority dlogLevel[] = { DLOG_DEBUG, DLOG_INFO, DLOG_WARN, DLOG_ERROR }; + char buf[512] = {0,}; + + va_start(arg, fmt); + vsnprintf((char *)buf, sizeof(buf), fmt, arg); + va_end(arg); + + dlog_print(dlogLevel[logLevel], "LIBDS", "[%s][%s:%d] %s", domain, funcName, line, buf); + } + else + { + const char *lvl_str[] = { "DS_DBG", "DS_INF", "DS_WRN", "DS_ERR" }; + const char *color[] = { COLOR_RESET, COLOR_GREEN, COLOR_YELLOW, COLOR_RED }; + + va_start(arg, fmt); + printf( "%s", color[logLevel]); + printf( "[%s]", lvl_str[logLevel]); + printf( "[%s]", domain); + printf( ":[%s(%d)]:", funcName, line); + vprintf( fmt, arg); + printf( "\n"); + va_end(arg); + } } int DSDebugLog::getLogLevel() diff --git a/src/DSDebug/DSDebugLog.h b/src/DSDebug/DSDebugLog.h index 12be42e..a1e8dfd 100644 --- a/src/DSDebug/DSDebugLog.h +++ b/src/DSDebug/DSDebugLog.h @@ -55,6 +55,7 @@ private: static DSDebugLog *mInstance; // singleton instance static std::mutex mMutex; // mutex int mLogLevel; // current log level + bool __enableDlog; }; #define DSLOG_DBG(domain, fmt, args...) \ -- 2.7.4 From f14da1c5d987e3abc1081b4604bb02e9c8fb48bf Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 24 Aug 2020 20:03:39 +0900 Subject: [PATCH 16/16] DSWaylandKeyboard: sendEnter when the focused client binds to wl_keyboard Change-Id: Idd975376e71f7d465152022b7dc02fcb7c6bfe91 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandKeyboard.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/DSWaylandServer/DSWaylandKeyboard.cpp b/src/DSWaylandServer/DSWaylandKeyboard.cpp index e920198..3ca2388 100644 --- a/src/DSWaylandServer/DSWaylandKeyboard.cpp +++ b/src/DSWaylandServer/DSWaylandKeyboard.cpp @@ -89,6 +89,12 @@ void DSWaylandKeyboardPrivate::keyboard_bind_resource(Resource *resource) sendKeymap(resource); sendRepeatInfo(resource); + + if (__focusSurface && __focusSurface->hasResource()) + { + DSLOG_INF("DSWaylandKeyboardPrivate", "Send enter to focusSurface(%p)", __focusSurface); + sendEnter(__focusSurface->getWlResource()); + } } void DSWaylandKeyboardPrivate::keyboard_destroy_resource(Resource *resource) -- 2.7.4