add code to handle geometry 62/241862/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Thu, 20 Aug 2020 00:55:19 +0000 (09:55 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:12:20 +0000 (19:12 +0900)
- 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

17 files changed:
src/DSWaylandServer/DSWaylandTizenPolicy.cpp
src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h
src/DSWaylandServer/DSWaylandTizenPosition.cpp
src/DSWaylandServer/DSWaylandTizenPosition.h
src/DSWaylandServer/DSWaylandTizenPositionPrivate.h
src/DSWaylandServer/DSWaylandZxdgShellV6.cpp
src/DSWindow/DSWindow.cpp
src/DSWindow/DSWindowPrivate.h
src/DSWindowManager/DSWindowManager.cpp
src/DSWindowManager/DSWindowManager.h
src/DSWindowManager/DSWindowManagerPrivate.h
src/DSWindowShell/DSWindowShell.cpp
src/DSWindowShell/DSWindowShell.h
src/DSWindowShell/DSWindowShellPrivate.cpp
src/DSWindowShell/DSWindowShellPrivate.h
src/DSZone/DSZone.cpp
src/DSZone/DSZone.h

index a83cb75..e589896 100644 (file)
@@ -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<DSWaylandTizenPosition> tzPos = std::make_shared<DSWaylandTizenPosition>(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)
index 34a324a..3484097 100644 (file)
@@ -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<std::shared_ptr<DSWaylandTizenPosition>> __tzPosList;
 };
 
 }
index 892f582..7b0455a 100644 (file)
@@ -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();
 }
 
 
index 64a39df..f6a0396 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "DSCore.h"
 #include "DSObject.h"
+#include "DSWaylandSurface.h"
 #include <wayland-server-core.h>
 
 namespace display_server
index 93915a0..fa3b5de 100644 (file)
@@ -51,7 +51,7 @@ protected:
 
 private:
        struct ::wl_resource *__wlSurface;
-       //DSWaylandSurface *__waylandSurface;
+       DSWaylandSurface *__dswlSurface;
 
 };
 
index 70d122d..1e38eae 100644 (file)
@@ -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)
 {
index 434d134..3306276 100644 (file)
@@ -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<DSWaylandSurfaceCommi
 
        if (__firstCommit)
        {
-               DSLOG_DBG("DSWindow", "First Commit!!! Send Configure...");
+               DSLOG_DBG("DSWindow", "First Commit!!! Send Configure... geo(%d,%d,%d,%d)", __x, __y, __w, __h);
                sendConfigure();
                __firstCommit = false;
        }
 
+       if (__changedGeometry)
+       {
+               DSLOG_DBG("DSWindow", "Geometry Changed!!! Send Configure... geo(%d,%d,%d,%d) commit(%d,%d)", __x, __y, __w, __h, __committedW, __committedH);
+               sendConfigure();
+               __changedGeometry = false;
+       }
+
        std::shared_ptr<IDSBuffer> 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()
index d532ad0..df18827 100644 (file)
@@ -77,6 +77,7 @@ private:
        std::shared_ptr<DSWaylandSurface> __waylandSurface;
        DSWindowShell *__winShell;
        bool __firstCommit;
+       bool __changedGeometry;
        std::string __title;
 };
 
index 4a5761c..acacdf2 100644 (file)
@@ -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
index 9ae0af6..08eb75d 100644 (file)
@@ -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:
 
index 9f6bed1..43acc3e 100644 (file)
@@ -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);
index c5a1d7b..d6291b5 100644 (file)
@@ -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);
 }
index 10e131e..d9ac09c 100644 (file)
@@ -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);
index 2caa850..e4a1e2a 100644 (file)
@@ -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;
index e16d3f0..809324a 100644 (file)
@@ -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;
 };
 
 }
index e127faa..4f7b5e4 100644 (file)
@@ -238,8 +238,6 @@ std::shared_ptr<DSWindowShell> DSZone::__createWindowShell(std::shared_ptr<DSWin
 
        __windowShellMap.insert(std::make_pair(ptrWindow->surface(), 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<DSWindow> 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<DSWindow> 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<DSWindow> 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<DSWindow> window = __findWindow(dswSurface);
+       if (!window) return false;
+
+       return window->setPosition(x, y);
+*/
+}
+
+
 } //  namespace display_server
index f89893b..be3d78e 100644 (file)
@@ -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<std::shared_ptr<DSWindow>> getWindowList();
        std::list<std::shared_ptr<DSWindowShell>> getWindowShellList();