From b080475d6d50184c63ee63faaeee6e24bed60b22 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Sun, 2 Aug 2020 20:55:05 +0900 Subject: [PATCH] DSWindow : add onSurfaceCommitted callback funtion Change-Id: I964779023645b047e271a807ca47dc98b114476a --- src/DSWindow/DSWindow.cpp | 25 +++++++++++++++++++++++++ src/DSWindow/DSWindow.h | 6 +++++- src/DSWindow/DSWindowPrivate.h | 6 ++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 188c2a9..365d0f0 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -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 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 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 buffer = waylandSurfaceCommitInfo->getBuffer(); + std::shared_ptr 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)> func) +{ + __sizeChangedSignal.connect(slot, func); +} + } // namespace display_server \ No newline at end of file diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index f7e330a..a8d2a7c 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -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)> func); + protected: //virtual bool _onFocus(void); //virtual bool _onShowStateChange(void); private: - + // signals + DSSignal> __sizeChangedSignal; }; } diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index 28eeeea..f098f2a 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -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 waylandSurfaceCommitInfo); + int __x; int __y; unsigned int __w; -- 2.7.4