DSWindowShell: move wm policy functionalities from DSWindow to DSWindowShell 53/242753/1
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 28 Aug 2020 03:58:25 +0000 (12:58 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 1 Sep 2020 01:29:16 +0000 (10:29 +0900)
move firstCommit, visible and changedGeometry

Change-Id: I75a5805587a93091f274cbc99f7813ff70b695c1

src/DSWindow/DSWindow.cpp
src/DSWindow/DSWindowPrivate.h
src/DSWindowShell/DSWindowShellPrivate.cpp
src/DSWindowShell/DSWindowShellPrivate.h

index e4cf6f1..6267a96 100644 (file)
@@ -41,12 +41,9 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr)
          __committedW(0),
          __committedH(0),
          __created(false),
-         __visible(false),
          __hasFocus(false),
          __waylandSurface(nullptr),
          __winShell(nullptr),
-         __firstCommit(true),
-         __changedGeometry(false),
          __acceptsFocus(true),
          __allowUserGeometry(false),
          __title(""),
@@ -181,14 +178,6 @@ DSWindowShell *DSWindowPrivate::getWindowShell(void)
        return __winShell;
 }
 
-void DSWindowPrivate::sendConfigure(void)
-{
-       if (__winShell)
-       {
-               __winShell->sendConfigure();
-       }
-}
-
 bool DSWindowPrivate::setVkbdFloating(bool set)
 {
        __vkbd_floating = set;
@@ -204,34 +193,8 @@ void DSWindowPrivate::__onSurfaceCommitted(std::shared_ptr<DSWaylandSurfaceCommi
 {
        DS_GET_PUB(DSWindow);
 
-       if (__firstCommit)
-       {
-               DSLOG_DBG("DSWindow", "First Commit!!! ");
-               __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;
-       }
-
        if (waylandSurfaceCommitInfo->bufferChanged()) {
                std::shared_ptr<IDSBuffer> buffer = waylandSurfaceCommitInfo->getBuffer();
-               if (buffer)
-               {
-                       std::shared_ptr<stSize> bufferSize = buffer->getSize();
-                       __committedW = bufferSize->w;
-                       __committedH = bufferSize->h;
-
-                       if (!__visible)
-                               __visible = true;
-               }
-               else
-               {
-                       __visible = false;
-               }
 
                // emit a signal of the buffer changed
                pub->__bufferChangedSignal.emit(buffer);
@@ -411,8 +374,6 @@ void DSWindow::setPosition(int x, int y)
        priv->__x = x;
        priv->__y = y;
 
-       priv->__changedGeometry = true;
-
        __windowPositionChangedSignal.emit(nullptr);
 }
 
@@ -444,8 +405,6 @@ void DSWindow::setSize(unsigned int w, unsigned int h)
 
        priv->__w = w;
        priv->__h = h;
-
-       priv->__changedGeometry = true;
 }
 
 void DSWindow::setSize(stSize size)
@@ -454,8 +413,6 @@ void DSWindow::setSize(stSize size)
 
        priv->__w = size.w;
        priv->__h = size.h;
-
-       priv->__changedGeometry = true;
 }
 
 void DSWindow::setZOrder(unsigned int zOrder)
index 3109df7..a6a8200 100644 (file)
@@ -73,8 +73,6 @@ public:
        bool setWindowShell(DSWindowShell *winShell);
        DSWindowShell *getWindowShell(void);
 
-       void sendConfigure(void);
-
        bool setVkbdFloating(bool set);
        bool getVkbdFloating();
 
@@ -89,12 +87,9 @@ private:
        unsigned int __zOrder;
        unsigned int __committedW, __committedH;
        bool __created;
-       bool __visible;
        bool __hasFocus;
        std::shared_ptr<DSWaylandSurface> __waylandSurface;
        DSWindowShell *__winShell;
-       bool __firstCommit;
-       bool __changedGeometry;
        bool __acceptsFocus;
        bool __allowUserGeometry;
        std::string __title;
index 897f91c..65778c3 100644 (file)
@@ -70,8 +70,12 @@ DSWindowShellPrivate::DSWindowShellPrivate(DSWindowShell *p_ptr, DSWindow *windo
          __reqX(0), __reqY(0),
          __reqW(0), __reqH(0),
          __parent(nullptr),
-         __layer(0)
+         __layer(0),
+         __firstCommit(true),
+         __changedGeometry(false),
+         __visible(false)
 {
+       __window->registerCallbackBufferChanged(this, std::bind(&DSWindowShellPrivate::__onWindowBufferChanged, this, std::placeholders::_1));
 }
 
 DSWindowShellPrivate::~DSWindowShellPrivate()
@@ -172,6 +176,7 @@ bool DSWindowShellPrivate::__handleUserGeometryHint(bool setUserGeometry)
                __x = __y = __w = __h = 0;
                __window->setPosition(__x, __y);
                __window->setSize(__w, __h);
+               __changedGeometry = true;
        }
        else
        {
@@ -187,6 +192,7 @@ bool DSWindowShellPrivate::__handleUserGeometryHint(bool setUserGeometry)
 
                        __window->setPosition(__x, __y);
                        __window->setSize(__w, __h);
+                       __changedGeometry = true;
                }
        }
 
@@ -209,6 +215,7 @@ bool DSWindowShellPrivate::create(int x, int y, unsigned int w, unsigned int h,
        {
                __window->setPosition(__x, __y);
                __window->setSize(__w, __h);
+               __changedGeometry = true;
        }
 
        return true;
@@ -245,6 +252,7 @@ bool DSWindowShellPrivate::setZone(DSZone *zone)
 
                                __window->setPosition(__x, __y);
                                __window->setSize(__w, __h);
+                               __changedGeometry = true;
                        }
                }
                else
@@ -336,6 +344,7 @@ bool DSWindowShellPrivate::setPosition(int x, int y)
                        __x = x;
                        __y = y;
                        __window->setPosition(__x, __y);
+                       __changedGeometry = true;
                }
        }
        else
@@ -397,6 +406,7 @@ bool DSWindowShellPrivate::setGeometry(int x, int y, unsigned int w, unsigned in
                        __h = h;
                        __window->setPosition(__x, __y);
                        __window->setSize(__w, __h);
+                       __changedGeometry = true;
                }
        }
        else
@@ -645,4 +655,28 @@ void DSWindowShellPrivate::sendConfigure(void)
        }
 }
 
+void DSWindowShellPrivate::__onWindowBufferChanged(std::shared_ptr<IDSBuffer> buffer)
+{
+       if (__firstCommit)
+       {
+               DSLOG_DBG("DSWindow", "First Commit!!! ");
+               __firstCommit = false;
+       }
+
+       if (__changedGeometry)
+       {
+               std::shared_ptr<stSize> bufferSize = buffer->getSize();
+               DSLOG_DBG("DSWindow", "Geometry Changed!!! Send Configure... geo(%d,%d,%d,%d) commit(%d,%d)", __x, __y, __w, __h, bufferSize->w, bufferSize->h);
+               sendConfigure();
+               __changedGeometry = false;
+       }
+
+       if (buffer) {
+               __visible = true;
+       } else {
+               __visible = false;
+       }
+
+}
+
 } // namespace display_server
index 25e27ae..5057859 100644 (file)
@@ -38,7 +38,7 @@ struct stWindowAuxHint
        bool deleted;
 };
 
-class DSWindowShellPrivate
+class DSWindowShellPrivate : public DSObject
 {
 DS_PIMPL_USE_PUBLIC(DSWindowShell)
 
@@ -126,6 +126,7 @@ 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);
+       void __onWindowBufferChanged(std::shared_ptr<IDSBuffer> buffer);
 
        struct stWindowAuxHint* __findAuxHint(int32_t id);
        void __handleAuxHint(stWindowAuxHint *hint);
@@ -141,6 +142,9 @@ private:
        unsigned int __reqW, __reqH; // requested size by client
        DSWindowShell *__parent;
        int __layer;
+       bool __firstCommit;
+       bool __changedGeometry;
+       bool __visible;
        std::list<DSWindowShell*> __childList;
        std::list<stWindowAuxHint*> __auxHintsList;
 };