DSWindow : add onSurfaceCommitted callback funtion 14/241714/1
authorSooChan Lim <sc1.lim@samsung.com>
Sun, 2 Aug 2020 11:55:05 +0000 (20:55 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:05:13 +0000 (19:05 +0900)
Change-Id: I964779023645b047e271a807ca47dc98b114476a

src/DSWindow/DSWindow.cpp
src/DSWindow/DSWindow.h
src/DSWindow/DSWindowPrivate.h

index 188c2a9..365d0f0 100644 (file)
@@ -1,6 +1,7 @@
 #include "DSWindow.h"
 #include "DSWindowPrivate.h"
 #include "DSWaylandSurface.h"
+#include "IDSBuffer.h"
 
 namespace display_server
 {
@@ -27,6 +28,8 @@ bool DSWindowPrivate::create(std::shared_ptr<DSWaylandSurface> waylandSurface)
        __waylandSurface = waylandSurface;
        __created = true;
 
+       __waylandSurface->registerCallbackSurfaceCommitted(this, std::bind(&DSWindowPrivate::__onSurfaceCommitted, this, std::placeholders::_1));
+
        return true;
 }
 
@@ -74,6 +77,23 @@ bool DSWindowPrivate::isCreated()
        return __created;
 }
 
+void DSWindowPrivate::__onSurfaceCommitted(std::shared_ptr<DSWaylandSurfaceCommitInfo> waylandSurfaceCommitInfo)
+{
+       DS_GET_PUB(DSWindow);
+
+       // set the size of window with the size of commit infomation
+       // TODO: It could be changed by DSWindowShell policy later..
+       std::shared_ptr<IDSBuffer> buffer = waylandSurfaceCommitInfo->getBuffer();
+       std::shared_ptr<stSize> bufferSize = buffer->getSize();
+       __w = bufferSize->w;
+       __h = bufferSize->h;
+
+       // emit a signal of the size changed
+       pub->__sizeChangedSignal.emit(bufferSize);
+
+       // TODO: get more information from waylandSurfaceCommitInfo. ex) damageSurface, damageBuffer, transform, scale and so on
+}
+
 DSWindow::DSWindow()
        : DS_INIT_PRIVATE_PTR(DSWindow)
 {}
@@ -205,4 +225,9 @@ DSWaylandSurface *DSWindow::surface()
        return priv->__waylandSurface.get();
 }
 
+void DSWindow::registerCallbackSizeChanged(DSObject *slot, std::function<void(std::shared_ptr<stSize>)> func)
+{
+       __sizeChangedSignal.connect(slot, func);
+}
+
 } //  namespace display_server
\ No newline at end of file
index f7e330a..a8d2a7c 100644 (file)
@@ -4,6 +4,7 @@
 #include "DSCore.h"
 #include "DSStruct.h"
 #include "DSObject.h"
+#include "DSSignal.h"
 
 namespace display_server
 {
@@ -40,12 +41,15 @@ public:
 
        DSWaylandSurface *surface();
 
+       void registerCallbackSizeChanged(DSObject *slot, std::function<void(std::shared_ptr<stSize>)> func);
+
 protected:
        //virtual bool _onFocus(void);
        //virtual bool _onShowStateChange(void);
 
 private:
-
+       // signals
+       DSSignal<std::shared_ptr<stSize>> __sizeChangedSignal;
 };
 
 }
index 28eeeea..f098f2a 100644 (file)
@@ -3,14 +3,14 @@
 
 #include "DSCore.h"
 #include "DSObjectPrivate.h"
+#include "DSWaylandSurface.h"
 
 namespace display_server
 {
 
 class DSWindow;
-class DSWindowWaylandSurface;
 
-class DSWindowPrivate : public DSObjectPrivate
+class DSWindowPrivate : public DSObjectPrivate, public DSObject
 {
        DS_PIMPL_USE_PUBLIC(DSWindow)
 
@@ -34,6 +34,8 @@ public:
        bool isCreated();
 
 private:
+       void __onSurfaceCommitted(std::shared_ptr<DSWaylandSurfaceCommitInfo> waylandSurfaceCommitInfo);
+
        int __x;
        int __y;
        unsigned int __w;