From: Doyoun Kang Date: Thu, 20 Aug 2020 00:55:19 +0000 (+0900) Subject: add code to handle geometry X-Git-Tag: accepted/tizen/unified/20200820.213435~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a58d1fdb0538ae11f059ad1f555f8d2673849a7;p=platform%2Fcore%2Fuifw%2Flibds.git 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 --- 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();