From a8305d00c3ba27909aa8d2cfbad8ad329ecd001b Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 15:20:20 +0900 Subject: [PATCH 01/16] DSCompositor: initialize dsBufferManager @ constructor Change-Id: I4a48386e5c2aae294ec6501d58c68c2e59e5adf0 Signed-off-by: Sung-Jin Park --- src/DSCompositor/DSCompositor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DSCompositor/DSCompositor.cpp b/src/DSCompositor/DSCompositor.cpp index c86bba3..bda6f1d 100644 --- a/src/DSCompositor/DSCompositor.cpp +++ b/src/DSCompositor/DSCompositor.cpp @@ -71,6 +71,7 @@ DSCompositorPrivate::DSCompositorPrivate(DSCompositor *p_ptr) __p_ptr(p_ptr), __displayDevice(nullptr), __canvas(nullptr), + __dsBufferManager(nullptr), __dsAppinfoMgr(nullptr), __dsWindowMgr(nullptr) -- 2.7.4 From 73c88034beb8b97716b263d92a9fbd315f20d596 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 15:23:27 +0900 Subject: [PATCH 02/16] DSWaylandInputMethod: initialize member variable @ constructor Change-Id: I09193e3bded606217d67b7e2bd71dc4f7072a303 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandInputMethod.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandInputMethod.cpp b/src/DSWaylandServer/DSWaylandInputMethod.cpp index 316679c..96248dd 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.cpp +++ b/src/DSWaylandServer/DSWaylandInputMethod.cpp @@ -580,7 +580,8 @@ DSWaylandInputMethod::DSWaylandInputMethod(DSWaylandCompositor *compositor, DSTe : DSObject(), _d_ptr(std::make_unique(this, compositor)), __dsTextInputPrivate(dsTextInputPrivate), __compositor(compositor), - __activateContext(nullptr) + __activateContext(nullptr), + __candidateState(0) { __inputMethodContext = new DSWaylandInputMethodContext(compositor, this); } -- 2.7.4 From c6f2fdc6072b51a8104d82d6fad5c25ed235a205 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 15:25:54 +0900 Subject: [PATCH 03/16] DSWaylandInputPanel: disable unreachable code Change-Id: I1c1ee9e3dedee034969c769d6275e2bc428244d2 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandInputPanel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp index 8133842..75409c4 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ b/src/DSWaylandServer/DSWaylandInputPanel.cpp @@ -405,7 +405,6 @@ void DSWaylandInputPanelSurfacePrivate::setFloatingPosition(int x, int y) DS_GET_PUB(DSWaylandInputPanelSurface); DSWaylandInputPanelSurfaceData *floatingData = nullptr; DSWaylandInputPanelFloating *inputPanelFloating; - int curAngle = 0; for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) { @@ -421,6 +420,9 @@ void DSWaylandInputPanelSurfacePrivate::setFloatingPosition(int x, int y) if (!floatingData || !inputPanelFloating) return; +#if 0//Unreachable code ! Thus, disable temporarily. + int curAngle = 0; + /* TODO: * if (floatingData->showing) * curAngle = get ec angle @@ -449,6 +451,7 @@ void DSWaylandInputPanelSurfacePrivate::setFloatingPosition(int x, int y) if (floatingData->showing) pub->setPosition(nullptr, 0, 0); /* FIXME: set correct window and data */ +#endif } void DSWaylandInputPanelSurfacePrivate::input_panel_surface_destroy_resource(Resource *resource) -- 2.7.4 From 8a5a4ee5f0e5907d667ee00dae5f6817733f023c Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 15:26:55 +0900 Subject: [PATCH 04/16] DSBuffer: initialize member varable, add null ptr check @ constructor Change-Id: I9c3a940533041424c38d72611947f63347175c64 Signed-off-by: Sung-Jin Park --- src/DSBuffer/DSBufferManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/DSBuffer/DSBufferManager.cpp b/src/DSBuffer/DSBufferManager.cpp index 8c96912..3c3cc14 100644 --- a/src/DSBuffer/DSBufferManager.cpp +++ b/src/DSBuffer/DSBufferManager.cpp @@ -114,7 +114,8 @@ std::shared_ptr DSBufferManager::getDSBuffer(struct ::wl_resource *bu DSBufferManagerPrivate::DSBufferManagerPrivate(DSBufferManager *p_ptr) : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) + __p_ptr(p_ptr), + __wlTbmServer(nullptr) { tbm_bufmgr bufmgr = nullptr; @@ -133,7 +134,7 @@ DSBufferManagerPrivate::DSBufferManagerPrivate(DSBufferManager *p_ptr) DSLOG_ERR("DSBufferManagerPrivate", "fail to get tbm_bufmgr"); } - if (bufmgr) + if (__waylandCompositor && bufmgr) tbm_bufmgr_bind_native_display(bufmgr, __waylandCompositor->display()); } -- 2.7.4 From a50633f54cc146b4cd2a6329bd496e0e3f7fe8cf Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 19 Aug 2020 15:39:40 +0900 Subject: [PATCH 05/16] tests: add null ptr check on DSWaylandTizenInputDeviceManager-test Change-Id: Iaa26b683c3ed9e7798ad82dd9aedf0e73921b643 Signed-off-by: Sung-Jin Park --- tests/DSWaylandTizenInputDeviceManager-test.cpp | 36 +++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/tests/DSWaylandTizenInputDeviceManager-test.cpp b/tests/DSWaylandTizenInputDeviceManager-test.cpp index 8776e1c..aa437c7 100644 --- a/tests/DSWaylandTizenInputDeviceManager-test.cpp +++ b/tests/DSWaylandTizenInputDeviceManager-test.cpp @@ -38,18 +38,38 @@ public: TEST_F(DSWaylandTizenInputDeviceManagerTest, NewDSWaylandTizenInputDeviceManager) { DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSWaylandTizenInputDeviceManager *inputDeviceManager = new DSWaylandTizenInputDeviceManager(compositor); - delete inputDeviceManager; - DSWaylandCompositor::releaseInstance(); - EXPECT_TRUE(true); + EXPECT_TRUE(compositor != nullptr); + + if (compositor) + { + DSWaylandTizenInputDeviceManager *inputDeviceManager = new DSWaylandTizenInputDeviceManager(compositor); + EXPECT_TRUE(inputDeviceManager != nullptr); + + if (inputDeviceManager) + delete inputDeviceManager; + + DSWaylandCompositor::releaseInstance(); + } } TEST_F(DSWaylandTizenInputDeviceManagerTest, getTizenInputDevice) { DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSWaylandTizenInputDeviceManager *inputDeviceManager = new DSWaylandTizenInputDeviceManager(compositor); - EXPECT_TRUE(inputDeviceManager->getTizenInputDevice()); - delete inputDeviceManager; - DSWaylandCompositor::releaseInstance(); + EXPECT_TRUE(compositor != nullptr); + + if (compositor) + { + DSWaylandTizenInputDeviceManager *inputDeviceManager = new DSWaylandTizenInputDeviceManager(compositor); + EXPECT_TRUE(inputDeviceManager != nullptr); + + if (inputDeviceManager) + { + EXPECT_TRUE(inputDeviceManager->getTizenInputDevice()); + + delete inputDeviceManager; + } + + DSWaylandCompositor::releaseInstance(); + } } -- 2.7.4 From 4a58d1fdb0538ae11f059ad1f555f8d2673849a7 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Thu, 20 Aug 2020 09:55:19 +0900 Subject: [PATCH 06/16] add code to handle geometry - DSWindowManager / DSZone / DSWindowShell / DSWindow : add code to handle position/size - TizenPolicy : add list for tizen_position - TizenPosition : implement set function - ZxdgSurface : implement set_window_geometry function Change-Id: I464017642e31eca791a36b131dab6ff8688acf6f --- src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 10 ++-- src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h | 4 +- src/DSWaylandServer/DSWaylandTizenPosition.cpp | 9 +++- src/DSWaylandServer/DSWaylandTizenPosition.h | 1 + .../DSWaylandTizenPositionPrivate.h | 2 +- src/DSWaylandServer/DSWaylandZxdgShellV6.cpp | 6 +++ src/DSWindow/DSWindow.cpp | 20 ++++++-- src/DSWindow/DSWindowPrivate.h | 1 + src/DSWindowManager/DSWindowManager.cpp | 59 ++++++++++++++++++++++ src/DSWindowManager/DSWindowManager.h | 3 ++ src/DSWindowManager/DSWindowManagerPrivate.h | 3 ++ src/DSWindowShell/DSWindowShell.cpp | 11 +++- src/DSWindowShell/DSWindowShell.h | 4 +- src/DSWindowShell/DSWindowShellPrivate.cpp | 20 ++++++-- src/DSWindowShell/DSWindowShellPrivate.h | 6 ++- src/DSZone/DSZone.cpp | 57 ++++++++++++++++++++- src/DSZone/DSZone.h | 3 ++ 17 files changed, 200 insertions(+), 19 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index a83cb75..e589896 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -71,15 +71,17 @@ void DSWaylandTizenPolicyPrivate::tizen_policy_destroy_resource(Resource *resour void DSWaylandTizenPolicyPrivate::tizen_policy_get_visibility(Resource *resource, uint32_t id, struct ::wl_resource *surface) { - DSLOG_DBG("TizenPolicyPriv", ""); + DSLOG_DBG("TizenPolicyPriv", "get_visibility... resource:%p, id:%d", resource, id); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_position(Resource *resource, uint32_t id, struct ::wl_resource *surface) { - DSLOG_DBG("TizenPolicyPriv", ""); + DSLOG_DBG("TizenPolicyPriv", "get_position... resource:%p, id:%d", resource, id); + + std::shared_ptr tzPos = std::make_shared(resource->client(), id, TIZEN_POLICY_VERSION, surface); + __tzPosList.push_front(tzPos); - DSWaylandTizenPosition *tzPos = new DSWaylandTizenPosition(resource->client(), id, TIZEN_POLICY_VERSION, surface); - // DO something using tzPos + // TODO: we have to remove tzPos when it's resource is destroyed } void DSWaylandTizenPolicyPrivate::tizen_policy_activate(Resource *resource, struct ::wl_resource *surface) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h index 34a324a..3484097 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h +++ b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h @@ -30,6 +30,8 @@ namespace display_server { +class DSWaylandTizenPosition; + class DSWaylandTizenPolicyPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_policy { DS_PIMPL_USE_PUBLIC(DSWaylandTizenPolicy) @@ -88,7 +90,7 @@ protected: void tizen_policy_set_appid(Resource *resource, int32_t pid, const std::string &appid) override; private: - + std::list> __tzPosList; }; } diff --git a/src/DSWaylandServer/DSWaylandTizenPosition.cpp b/src/DSWaylandServer/DSWaylandTizenPosition.cpp index 892f582..7b0455a 100644 --- a/src/DSWaylandServer/DSWaylandTizenPosition.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPosition.cpp @@ -23,6 +23,7 @@ #include "DSWaylandTizenPosition.h" #include "DSWaylandTizenPositionPrivate.h" +#include "DSWindowManager.h" namespace display_server { @@ -48,7 +49,8 @@ void DSWaylandTizenPosition::init(struct ::wl_client *client, uint32_t id, int v DSWaylandTizenPositionPrivate::DSWaylandTizenPositionPrivate(DSWaylandTizenPosition *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), - __wlSurface(nullptr) + __wlSurface(nullptr), + __dswlSurface(nullptr) { } @@ -60,6 +62,7 @@ void DSWaylandTizenPositionPrivate::init(struct ::wl_client *client, uint32_t id { tizen_position::init(client, id, version); __wlSurface = surface; + __dswlSurface = DSWaylandSurface::fromWlResource(surface); } void DSWaylandTizenPositionPrivate::tizen_position_bind_resource(Resource *resource) @@ -80,6 +83,10 @@ void DSWaylandTizenPositionPrivate::tizen_position_destroy(Resource *resource) void DSWaylandTizenPositionPrivate::tizen_position_set(Resource *resource, int32_t x, int32_t y) { DSLOG_DBG("TIZEN_POSITION", "Requested pos(%d,%d)", x, y); + + DSWindowManager *wm = DSWindowManager::getInstance(); + wm->setWindowPosition(__dswlSurface, x, y); + DSWindowManager::releaseInstance(); } diff --git a/src/DSWaylandServer/DSWaylandTizenPosition.h b/src/DSWaylandServer/DSWaylandTizenPosition.h index 64a39df..f6a0396 100644 --- a/src/DSWaylandServer/DSWaylandTizenPosition.h +++ b/src/DSWaylandServer/DSWaylandTizenPosition.h @@ -26,6 +26,7 @@ #include "DSCore.h" #include "DSObject.h" +#include "DSWaylandSurface.h" #include namespace display_server diff --git a/src/DSWaylandServer/DSWaylandTizenPositionPrivate.h b/src/DSWaylandServer/DSWaylandTizenPositionPrivate.h index 93915a0..fa3b5de 100644 --- a/src/DSWaylandServer/DSWaylandTizenPositionPrivate.h +++ b/src/DSWaylandServer/DSWaylandTizenPositionPrivate.h @@ -51,7 +51,7 @@ protected: private: struct ::wl_resource *__wlSurface; - //DSWaylandSurface *__waylandSurface; + DSWaylandSurface *__dswlSurface; }; diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp index 70d122d..1e38eae 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp @@ -413,6 +413,12 @@ void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_set_window_geometry(zxdg_sur __w = width; __h = height; // TODO: needs codes for adjust geometry + + DSLOG_DBG("ZXDG_SURFACE", "Set Window geometry (%d,%d,%d,%d)", x, y, width, height); + + DSWindowManager *wm = DSWindowManager::getInstance(); + wm->setWindowGeometry(__dsSurface, __x, __y, __w, __h); + DSWindowManager::releaseInstance(); } void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_ack_configure(zxdg_surface_v6::Resource *resource, uint32_t serial) { diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 434d134..3306276 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -34,8 +34,8 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) __p_ptr(p_ptr), __x(0), __y(0), - __w(1), - __h(1), + __w(0), + __h(0), __committedW(0), __committedH(0), __created(false), @@ -43,6 +43,7 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) __waylandSurface(nullptr), __winShell(nullptr), __firstCommit(true), + __changedGeometry(false), __title("") { } @@ -147,11 +148,18 @@ void DSWindowPrivate::__onSurfaceCommitted(std::shared_ptr buffer = waylandSurfaceCommitInfo->getBuffer(); if (buffer) { // TODO: set the size of window with the size of commit information @@ -286,6 +294,8 @@ void DSWindow::setPosition(int x, int y) priv->__x = x; priv->__y = y; + + priv->__changedGeometry = true; } stPosition DSWindow::getPosition(void) @@ -316,6 +326,8 @@ void DSWindow::setSize(unsigned int w, unsigned int h) priv->__w = w; priv->__h = h; + + priv->__changedGeometry = true; } void DSWindow::setSize(stSize size) @@ -324,6 +336,8 @@ void DSWindow::setSize(stSize size) priv->__w = size.w; priv->__h = size.h; + + priv->__changedGeometry = true; } DSWaylandSurface *DSWindow::surface() diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index d532ad0..df18827 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -77,6 +77,7 @@ private: std::shared_ptr __waylandSurface; DSWindowShell *__winShell; bool __firstCommit; + bool __changedGeometry; std::string __title; }; diff --git a/src/DSWindowManager/DSWindowManager.cpp b/src/DSWindowManager/DSWindowManager.cpp index 4a5761c..acacdf2 100644 --- a/src/DSWindowManager/DSWindowManager.cpp +++ b/src/DSWindowManager/DSWindowManager.cpp @@ -216,6 +216,47 @@ void DSWindowManagerPrivate::setWindowTitle(DSWaylandSurface *dsSurface, const s } } +void DSWindowManagerPrivate::setWindowType(DSWaylandSurface *dsSurface, int type) +{ + // find dsSurface's window + DSZone *zone = __getZone(dsSurface); + if (zone) + { + zone->setWindowType(dsSurface, type); + } + else + { + // Do something if there is no zone + } +} + +void DSWindowManagerPrivate::setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h) +{ + // find dsSurface's window + DSZone *zone = __getZone(dsSurface); + if (zone) + { + zone->setWindowGeometry(dsSurface, x, y, w, h); + } + else + { + // Do something if there is no zone + } +} + +void DSWindowManagerPrivate::setWindowPosition(DSWaylandSurface *dsSurface, int x, int y) +{ + // find dsSurface's window + DSZone *zone = __getZone(dsSurface); + if (zone) + { + zone->setWindowPosition(dsSurface, x, y); + } + else + { + // Do something if there is no zone + } +} DSWindowManager::DSWindowManager(DSObject *parent) : DS_INIT_PRIVATE_PTR(DSWindowManager) @@ -321,5 +362,23 @@ void DSWindowManager::setWindowTitle(DSWaylandSurface *dsSurface, const std::str priv->setWindowTitle(dsSurface, title); } +void DSWindowManager::setWindowType(DSWaylandSurface *dsSurface, int type) +{ + DS_GET_PRIV(DSWindowManager); + priv->setWindowType(dsSurface, type); +} + +void DSWindowManager::setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h) +{ + DS_GET_PRIV(DSWindowManager); + priv->setWindowGeometry(dsSurface, x, y, w, h); +} + +void DSWindowManager::setWindowPosition(DSWaylandSurface *dsSurface, int x, int y) +{ + DS_GET_PRIV(DSWindowManager); + priv->setWindowPosition(dsSurface, x, y); +} + } // namespace display_server diff --git a/src/DSWindowManager/DSWindowManager.h b/src/DSWindowManager/DSWindowManager.h index 9ae0af6..08eb75d 100644 --- a/src/DSWindowManager/DSWindowManager.h +++ b/src/DSWindowManager/DSWindowManager.h @@ -56,6 +56,9 @@ public: DSZone *getZone(DSWaylandSurface *surface); 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); + void setWindowPosition(DSWaylandSurface *dsSurface, int x, int y); protected: diff --git a/src/DSWindowManager/DSWindowManagerPrivate.h b/src/DSWindowManager/DSWindowManagerPrivate.h index 9f6bed1..43acc3e 100644 --- a/src/DSWindowManager/DSWindowManagerPrivate.h +++ b/src/DSWindowManager/DSWindowManagerPrivate.h @@ -51,6 +51,9 @@ public: DSZone *getZone(DSWaylandSurface *surface); 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); + void setWindowPosition(DSWaylandSurface *dsSurface, int x, int y); private: DSZone *__getZone(DSWindow *window); diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp index c5a1d7b..d6291b5 100644 --- a/src/DSWindowShell/DSWindowShell.cpp +++ b/src/DSWindowShell/DSWindowShell.cpp @@ -67,10 +67,15 @@ IDSWaylandShellSurface *DSWindowShell::getShellSurface(void) return priv->getShellSurface(); } -bool DSWindowShell::setPosition(int x, int y) +bool DSWindowShell::setTitle(const std::string &title) { DS_GET_PRIV(DSWindowShell); + return priv->setTitle(title); +} +bool DSWindowShell::setPosition(int x, int y) +{ + DS_GET_PRIV(DSWindowShell); return priv->setPosition(x, y); } @@ -88,8 +93,10 @@ bool DSWindowShell::setSize(unsigned int w, unsigned int h) return priv->setSize(w, h); } -void DSWindowShell::setGeometry(int x, int y, unsigned int w, unsigned int h) +bool DSWindowShell::setGeometry(int x, int y, unsigned int w, unsigned int h) { + DSLOG_DBG("DSWindowShell", "Set Geometry (%d, %d, %d, %d)", x, y, w, h); + DS_GET_PRIV(DSWindowShell); return priv->setGeometry(x, y, w, h); } diff --git a/src/DSWindowShell/DSWindowShell.h b/src/DSWindowShell/DSWindowShell.h index 10e131e..d9ac09c 100644 --- a/src/DSWindowShell/DSWindowShell.h +++ b/src/DSWindowShell/DSWindowShell.h @@ -50,12 +50,14 @@ public: void setShellSurface(IDSWaylandShellSurface *zxdgSurface); IDSWaylandShellSurface *getShellSurface(void); + bool setTitle(const std::string &title); + bool setPosition(int x, int y); stPosition getPosition(void); bool setSize(unsigned int w, unsigned int h); - void setGeometry(int x, int y, unsigned int w, unsigned int h); + bool setGeometry(int x, int y, unsigned int w, unsigned int h); stGeometry getGeometry(void); bool show(void); diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index 2caa850..e4a1e2a 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -36,7 +36,9 @@ DSWindowShellPrivate::DSWindowShellPrivate(DSWindowShell *p_ptr, DSWindow *windo __window(window), __shellSurface(nullptr), __x(0), __y(0), - __w(1), __h(1) + __w(0), __h(0), + __reqX(0), __reqY(0), + __reqW(0), __reqH(0) { } @@ -84,6 +86,17 @@ IDSWaylandShellSurface *DSWindowShellPrivate::getShellSurface(void) return __shellSurface; } +bool DSWindowShellPrivate::setTitle(const std::string &title) +{ + if (__window) + { + __window->setTitle(title); + return true; + } + else + return false; +} + bool DSWindowShellPrivate::setPosition(int x, int y) { __x = x; @@ -116,7 +129,7 @@ bool DSWindowShellPrivate::setSize(unsigned int w, unsigned int h) return true; } -void DSWindowShellPrivate::setGeometry(int x, int y, unsigned int w, unsigned int h) +bool DSWindowShellPrivate::setGeometry(int x, int y, unsigned int w, unsigned int h) { __x = x; __y = y; @@ -128,6 +141,8 @@ void DSWindowShellPrivate::setGeometry(int x, int y, unsigned int w, unsigned in __window->setPosition(__x, __y); __window->setSize(__w, __h); } + + return true; } stGeometry DSWindowShellPrivate::getGeometry(void) @@ -140,7 +155,6 @@ stGeometry DSWindowShellPrivate::getGeometry(void) return geo; } - bool DSWindowShellPrivate::show(void) { return true; diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h index e16d3f0..809324a 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -46,12 +46,14 @@ public: void setShellSurface(IDSWaylandShellSurface *shellSurface); IDSWaylandShellSurface *getShellSurface(void); + bool setTitle(const std::string &title); + bool setPosition(int x, int y); stPosition getPosition(void); bool setSize(unsigned int w, unsigned int h); - void setGeometry(int x, int y, unsigned int w, unsigned int h); + bool setGeometry(int x, int y, unsigned int w, unsigned int h); stGeometry getGeometry(void); bool show(void); @@ -98,6 +100,8 @@ private: IDSWaylandShellSurface *__shellSurface; int __x, __y; unsigned int __w, __h; + int __reqX, __reqY; + unsigned int __reqW, __reqH; }; } diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index e127faa..4f7b5e4 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -238,8 +238,6 @@ std::shared_ptr DSZone::__createWindowShell(std::shared_ptrsurface(), shell.get())); - shell->setGeometry(__position.x, __position.y, __size.w, __size.h); - // emit a signal of the shell created __windowShellCreatedSignal.emit(shell); @@ -266,8 +264,63 @@ void DSZone::__destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface * bool DSZone::setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title) { + DSWindowShell *wShell = __findWindowShell(dswSurface); + if (!wShell) return false; + + return wShell->setTitle(title); + +/* std::shared_ptr window = __findWindow(dswSurface); + if (!window) return false; + return window->setTitle(title); +*/ +} + +bool DSZone::setWindowType(DSWaylandSurface *dswSurface, int type) +{ + DSWindowShell *wShell = __findWindowShell(dswSurface); + if (!wShell) return false; + + return wShell->setType(type); + +/* + std::shared_ptr window = __findWindow(dswSurface); + if (!window) return false; + + return window->setType(type); +*/ +} + +bool DSZone::setWindowGeometry(DSWaylandSurface *dswSurface, int x, int y, unsigned int w, unsigned h) +{ + DSWindowShell *wShell = __findWindowShell(dswSurface); + if (!wShell) return false; + + return wShell->setGeometry(x, y, w, h); + +/* + std::shared_ptr window = __findWindow(dswSurface); + if (!window) return false; + + return window->setGeometry(x, y, w, h); +*/ } +bool DSZone::setWindowPosition(DSWaylandSurface *dswSurface, int x, int y) +{ + DSWindowShell *wShell = __findWindowShell(dswSurface); + if (!wShell) return false; + + return wShell->setPosition(x, y); + +/* + std::shared_ptr window = __findWindow(dswSurface); + if (!window) return false; + + return window->setPosition(x, y); +*/ +} + + } // namespace display_server diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index f89893b..be3d78e 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -60,6 +60,9 @@ public: // for window property 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); + bool setWindowPosition(DSWaylandSurface *dswSurface, int x, int y); std::list> getWindowList(); std::list> getWindowShellList(); -- 2.7.4 From 61096a1d93f11c567861635cbb13894f35eebbcc Mon Sep 17 00:00:00 2001 From: jeon Date: Wed, 19 Aug 2020 21:59:20 +0900 Subject: [PATCH 07/16] DSWaylandTizenAppInfo: set Resource handle for event Change-Id: I186bcf883839386acba358986091961f8b8cbd82 --- src/DSWaylandServer/DSWaylandTizenAppinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp b/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp index 9bbd803..44d5416 100644 --- a/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp +++ b/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp @@ -88,7 +88,7 @@ void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_get_base_output_resoluti if (!result) { /* TODO: Read configured resolution values */ } - send_base_output_resolution_done(pid, res_w, res_h); + send_base_output_resolution_done(resource->handle, pid, res_w, res_h); DSLOG_DBG("TizenAppinfoPriv", "SEND base_output_resolution_done event with width(%d), height(%d)", res_w, res_h); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_register_appid(Resource *resource, const std::string &appid) -- 2.7.4 From d2491aec3a18af12ebfb2622704a15f9f700d5fb Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 14:58:40 +0900 Subject: [PATCH 08/16] DSDebug: fix to print 'domain' before the funtion name Change-Id: I1fcfdad9d29980c7017e02bd067dba32cd7b9fbe Signed-off-by: Sung-Jin Park --- src/DSDebug/DSDebugLog.cpp | 5 +++-- src/DSDebug/DSDebugLog.h | 10 +++++----- tests/DSDebugLog-test.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/DSDebug/DSDebugLog.cpp b/src/DSDebug/DSDebugLog.cpp index fd15355..2900668 100644 --- a/src/DSDebug/DSDebugLog.cpp +++ b/src/DSDebug/DSDebugLog.cpp @@ -53,7 +53,7 @@ DSDebugLog *DSDebugLog::GetInstance() return mInstance; } -void DSDebugLog::printLog(int logLevel, const char *funcName, int line, const char *fmt, ...) +void DSDebugLog::printLog(int logLevel, const char *domain, const char *funcName, int line, const char *fmt, ...) { //TODO: apply logLevel //TODO: use dlog or stdout @@ -65,7 +65,8 @@ void DSDebugLog::printLog(int logLevel, const char *funcName, int line, const ch va_start(arg, fmt); printf("%s", color[logLevel]); printf("[%s]", lvl_str[logLevel]); - printf(":[%s(%d)]", funcName, line); + printf("[%s]", domain); + printf(":[%s(%d)]:", funcName, line); vprintf(fmt, arg); printf("\n"); va_end(arg); diff --git a/src/DSDebug/DSDebugLog.h b/src/DSDebug/DSDebugLog.h index d9a3dad..12be42e 100644 --- a/src/DSDebug/DSDebugLog.h +++ b/src/DSDebug/DSDebugLog.h @@ -45,7 +45,7 @@ public: void operator=(const DSDebugLog &) = delete; // should not be assignable static DSDebugLog *GetInstance(); - void printLog(int logLevel, const char *funcName, int line, const char *fmt, ...); + void printLog(int logLevel, const char *domain, const char *funcName, int line, const char *fmt, ...); int getLogLevel(); private: @@ -60,28 +60,28 @@ private: #define DSLOG_DBG(domain, fmt, args...) \ do { \ DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, __LINE__, "[" domain "]: " fmt, \ + log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, domain, __func__, __LINE__, fmt, \ ##args); \ } while (0) #define DSLOG_INF(domain, fmt, args...) \ do { \ DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, __LINE__, "[" domain "]: " fmt, \ + log->printLog(DSDebugLog::LOG_LEVEL_INFO, domain, __func__, __LINE__, fmt, \ ##args); \ } while (0) #define DSLOG_WRN(domain, fmt, args...) \ do { \ DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, __LINE__, "[" domain "]: " fmt, \ + log->printLog(DSDebugLog::LOG_LEVEL_WARN, domain, __func__, __LINE__, fmt, \ ##args); \ } while (0) #define DSLOG_ERR(domain, fmt, args...) \ do { \ DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, __LINE__, "[" domain "]: " fmt, \ + log->printLog(DSDebugLog::LOG_LEVEL_ERR, domain, __func__, __LINE__, fmt, \ ##args); \ } while (0) } diff --git a/tests/DSDebugLog-test.cpp b/tests/DSDebugLog-test.cpp index 71265ed..78322b4 100644 --- a/tests/DSDebugLog-test.cpp +++ b/tests/DSDebugLog-test.cpp @@ -46,10 +46,10 @@ TEST_F(DSDebugLogTest, PrintLog) const char *str = "Hi world"; DSDebugLog *log = DSDebugLog::GetInstance(); - log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, __LINE__, "Hello world"); - log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, __LINE__, "%s", str); - log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, __LINE__, "Greeting world"); - log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, __LINE__, "Hey world"); + log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, "DSDebugLogTest", __func__, __LINE__, "Hello world"); + log->printLog(DSDebugLog::LOG_LEVEL_INFO, "DSDebugLogTest", __func__, __LINE__, "%s", str); + log->printLog(DSDebugLog::LOG_LEVEL_WARN, "DSDebugLogTest", __func__, __LINE__, "Greeting world"); + log->printLog(DSDebugLog::LOG_LEVEL_ERR, "DSDebugLogTest", __func__, __LINE__, "Hey world"); EXPECT_TRUE(true); } -- 2.7.4 From 616fd12f0e0f6331fe30dd39dd6013be0670f0f4 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 14:59:50 +0900 Subject: [PATCH 09/16] DSZone: add registerCallbackWindowDestroy() Change-Id: Ie2887d8700ce481bfd6f6c04cb4a5c9d443a3874 Signed-off-by: Sung-Jin Park --- src/DSZone/DSZone.cpp | 5 +++++ src/DSZone/DSZone.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index 4f7b5e4..f075601 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -102,6 +102,11 @@ void DSZone::registerCallbackWindowShellCreated(DSObject *slot, std::function)> func) +{ + __windowDestroySignal.connect(slot, func); +} + void DSZone::callCallbackWindowCreated() { __windowCreatedSignal.emit(nullptr); diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index be3d78e..7b37a6c 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -52,6 +52,7 @@ public: // Callback methods void registerCallbackWindowCreated(DSObject *slot, std::function)> func); + void registerCallbackWindowDestroy(DSObject *slot, std::function)> func); void registerCallbackWindowShellCreated(DSObject *slot, std::function)> func); // emit functions for testing -- 2.7.4 From e75ed7cf7a48a65eb51e488314650461de7dc7ea Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 15:01:01 +0900 Subject: [PATCH 10/16] DSWaylandKeyboard: add resetFocus() Change-Id: I4bb3fbb00fd297762daeed0671cf0b3200f2aed1 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandKeyboard.cpp | 7 +++++++ src/DSWaylandServer/DSWaylandKeyboard.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/DSWaylandServer/DSWaylandKeyboard.cpp b/src/DSWaylandServer/DSWaylandKeyboard.cpp index 48ce7f4..e920198 100644 --- a/src/DSWaylandServer/DSWaylandKeyboard.cpp +++ b/src/DSWaylandServer/DSWaylandKeyboard.cpp @@ -285,6 +285,13 @@ void DSWaylandKeyboard::setFocus(DSWaylandSurface *waylandSurface) } } +void DSWaylandKeyboard::resetFocus() +{ + DS_GET_PRIV(DSWaylandKeyboard); + priv->__focusSurface = nullptr; + priv->__focusClient = nullptr; +} + DSWaylandSurface *DSWaylandKeyboard::getFocus() { DS_GET_PRIV(DSWaylandKeyboard); diff --git a/src/DSWaylandServer/DSWaylandKeyboard.h b/src/DSWaylandServer/DSWaylandKeyboard.h index 0dd4722..1a577b9 100644 --- a/src/DSWaylandServer/DSWaylandKeyboard.h +++ b/src/DSWaylandServer/DSWaylandKeyboard.h @@ -51,6 +51,7 @@ public: void addClient(DSWaylandClient *client, uint32_t id, int version); void setFocus(DSWaylandSurface *waylandSurface); + void resetFocus(); DSWaylandSurface *getFocus(); void sendKeyDown(uint32_t keycode); -- 2.7.4 From dfedfbb5342aa34d1958c33357bc7ae36d9ff890 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 15:01:36 +0900 Subject: [PATCH 11/16] DSWaylandPointer: add resetFocus() Change-Id: I91ff2e65678b3c10a8e30fa3fa1c0cfe8b74a092 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandPointer.cpp | 7 +++++++ src/DSWaylandServer/DSWaylandPointer.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/DSWaylandServer/DSWaylandPointer.cpp b/src/DSWaylandServer/DSWaylandPointer.cpp index 4ae9813..186c5cd 100644 --- a/src/DSWaylandServer/DSWaylandPointer.cpp +++ b/src/DSWaylandServer/DSWaylandPointer.cpp @@ -182,6 +182,13 @@ void DSWaylandPointer::setFocus(DSWaylandSurface *waylandSurface) priv->setFocus(waylandSurface); } +void DSWaylandPointer::resetFocus() +{ + DS_GET_PRIV(DSWaylandPointer); + priv->__waylandSurface = nullptr; + priv->__wlPointerResource = nullptr; +} + DSWaylandSurface *DSWaylandPointer::getFocus() { DS_GET_PRIV(DSWaylandPointer); diff --git a/src/DSWaylandServer/DSWaylandPointer.h b/src/DSWaylandServer/DSWaylandPointer.h index 7a1f832..350ce60 100644 --- a/src/DSWaylandServer/DSWaylandPointer.h +++ b/src/DSWaylandServer/DSWaylandPointer.h @@ -45,6 +45,7 @@ public: DSWaylandSeat *seat(); void addClient(DSWaylandClient *client, uint32_t id, int version); + void resetFocus(); void setFocus(DSWaylandSurface *waylandSurface); DSWaylandSurface *getFocus(); -- 2.7.4 From 5453352bae89b4df37de3d0013f668233059b6d5 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 15:01:57 +0900 Subject: [PATCH 12/16] DSWaylandTouch: add resetFocus() Change-Id: Ief2ca9ead908778c2ec65e55efb022826e027c2b Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandTouch.cpp | 7 +++++++ src/DSWaylandServer/DSWaylandTouch.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/DSWaylandServer/DSWaylandTouch.cpp b/src/DSWaylandServer/DSWaylandTouch.cpp index 25a267b..2f011dc 100644 --- a/src/DSWaylandServer/DSWaylandTouch.cpp +++ b/src/DSWaylandServer/DSWaylandTouch.cpp @@ -162,6 +162,13 @@ void DSWaylandTouch::setFocus(DSWaylandSurface *waylandSurface) priv->setFocus(waylandSurface); } +void DSWaylandTouch::resetFocus() +{ + DS_GET_PRIV(DSWaylandTouch); + priv->__waylandSurface = nullptr; + priv->__wlTouchResource = nullptr; +} + DSWaylandSurface *DSWaylandTouch::getFocus() { DS_GET_PRIV(DSWaylandTouch); diff --git a/src/DSWaylandServer/DSWaylandTouch.h b/src/DSWaylandServer/DSWaylandTouch.h index beef446..8f251c1 100644 --- a/src/DSWaylandServer/DSWaylandTouch.h +++ b/src/DSWaylandServer/DSWaylandTouch.h @@ -46,6 +46,7 @@ public: void addClient(DSWaylandClient *client, uint32_t id, int version); void setFocus(DSWaylandSurface *waylandSurface); + void resetFocus(); DSWaylandSurface *getFocus(); void sendDown(int32_t id, int x, int y); -- 2.7.4 From 7301eaa00f51bc17f302f5152aba3abbb2b05100 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 15:03:57 +0900 Subject: [PATCH 13/16] DSKeyboard: add resetFocus(), fix setFocus() and log Change-Id: I5c76e29b4188a88ca88d89afd670322973de59da Signed-off-by: Sung-Jin Park --- src/DSSeat/DSKeyboard.cpp | 19 +++++++++++++++++-- src/DSSeat/DSKeyboard.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/DSSeat/DSKeyboard.cpp b/src/DSSeat/DSKeyboard.cpp index e9a8345..c97f7e7 100644 --- a/src/DSSeat/DSKeyboard.cpp +++ b/src/DSSeat/DSKeyboard.cpp @@ -117,6 +117,9 @@ void DSKeyboard::setFocus(std::shared_ptr window) if (!window) { DSLOG_ERR("DSKeyboard", "Given window is INVALID. (window : %p)", window); + __kbdFocus = window; + if (__dswlKeyboard) + __dswlKeyboard->setFocus(nullptr); return; } @@ -124,11 +127,11 @@ void DSKeyboard::setFocus(std::shared_ptr window) if (!waylandSurface) { - DSLOG_ERR("DSKeyboard", "Wayland surface of the given window is INVALID. (window : %p, surface : %p)", window, waylandSurface); + DSLOG_ERR("DSKeyboard", "Wayland surface of the given window is INVALID. (window : %p (%p), surface : %p)", window, window.get(), waylandSurface); return; } - DSLOG_INF("DSKeyboard", "focus window has been changed. (%p -> %p)", __kbdFocus, window); + DSLOG_INF("DSKeyboard", "focus window has been changed. (%p -> %p)", __kbdFocus ? __kbdFocus.get() : nullptr, window ? window.get() : nullptr); __kbdFocus = window; if (!__dswlKeyboard) @@ -141,6 +144,18 @@ void DSKeyboard::setFocus(std::shared_ptr window) } +void DSKeyboard::resetFocus() +{ + if (__kbdFocus) + { + __kbdFocus = nullptr; + DSLOG_INF("DSKeyboard", "kbdFocus has been reset."); + } + + if (__dswlKeyboard) + __dswlKeyboard->resetFocus(); +} + std::shared_ptr DSKeyboard::getFocus() { return __kbdFocus; diff --git a/src/DSSeat/DSKeyboard.h b/src/DSSeat/DSKeyboard.h index 45c844f..2e6e4dd 100644 --- a/src/DSSeat/DSKeyboard.h +++ b/src/DSSeat/DSKeyboard.h @@ -53,6 +53,7 @@ public: void setRepeatDelay(uint32_t delay); void setFocus(std::shared_ptr window); + void resetFocus(); std::shared_ptr getFocus(); private: -- 2.7.4 From 103e1c6593b57ad408c5e64c13d79d21289de620 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 15:04:25 +0900 Subject: [PATCH 14/16] DSPointer: add resetFocus() Change-Id: I6a7e8b1104f92367ba8cefc170b9255886204638 Signed-off-by: Sung-Jin Park --- src/DSSeat/DSPointer.cpp | 12 ++++++++++++ src/DSSeat/DSPointer.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/DSSeat/DSPointer.cpp b/src/DSSeat/DSPointer.cpp index 3f6375e..12f3c0c 100644 --- a/src/DSSeat/DSPointer.cpp +++ b/src/DSSeat/DSPointer.cpp @@ -169,6 +169,18 @@ void DSPointer::setFocus(std::shared_ptr window) __dswlPointer->setFocus(waylandSurface); } +void DSPointer::resetFocus() +{ + if (__ptrFocus) + { + __ptrFocus = nullptr; + DSLOG_INF("DSPointer", "ptrFocus has been reset."); + } + + if (__dswlPointer) + __dswlPointer->resetFocus(); +} + std::shared_ptr DSPointer::getFocus() { return __ptrFocus; diff --git a/src/DSSeat/DSPointer.h b/src/DSSeat/DSPointer.h index 5717c51..79dc209 100644 --- a/src/DSSeat/DSPointer.h +++ b/src/DSSeat/DSPointer.h @@ -51,6 +51,7 @@ public: void mouseIn(int x, int y); void mouseOut(); void setFocus(std::shared_ptr window); + void resetFocus(); std::shared_ptr getFocus(); private: -- 2.7.4 From 662e3f9617b3b3ddcd468b095e7ac5d70681e3ff Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 20 Aug 2020 15:05:01 +0900 Subject: [PATCH 15/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 16/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