From: Doyoun Kang Date: Thu, 13 Aug 2020 04:12:58 +0000 (+0900) Subject: Add code send configure event X-Git-Tag: accepted/tizen/unified/20200820.213435~69 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2248ad3bb491439f80e7ad9d815b9317572cf5ea;p=platform%2Fcore%2Fuifw%2Flibds.git Add code send configure event Change-Id: I9447aa24c642d683fce41ab75c555b564abd4136 --- diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp index ba2e9ff..47d3b0d 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp @@ -274,6 +274,12 @@ DSWaylandSurface *DSWaylandZxdgSurfaceV6::getSurface(void) return priv->getSurface(); } +void DSWaylandZxdgSurfaceV6::sendConfigure(int x, int y, unsigned int w, unsigned int h) +{ + DS_GET_PRIV(DSWaylandZxdgSurfaceV6); + priv->sendConfigure(x, y, w, h); +} + void DSWaylandZxdgSurfaceV6::setWindowTitle(const std::string &title) { DS_GET_PRIV(DSWaylandZxdgSurfaceV6); @@ -317,8 +323,11 @@ std::string DSWaylandZxdgSurfaceV6::getAppID() DSWaylandZxdgSurfaceV6Private::DSWaylandZxdgSurfaceV6Private(DSWaylandZxdgSurfaceV6 *p_ptr) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), __x(0), __y(0), __w(0), __h(0), - __wlSurface(nullptr), __dsSurface(nullptr) + : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), + __wlSurface(nullptr), __dsSurface(nullptr), + __toplevel(nullptr), __popup(nullptr), __role(DSWaylandZxdgSurfaceV6::DS_XDG_SURFACE_ROLE_NONE), + __x(0), __y(0), __w(0), __h(0), + __title(""), __appId("") { } @@ -346,6 +355,28 @@ DSWaylandSurface *DSWaylandZxdgSurfaceV6Private::getSurface(void) return __dsSurface; } +void DSWaylandZxdgSurfaceV6Private::sendConfigure(int x, int y, unsigned int w, unsigned int h) +{ + DSWaylandCompositor *wlCompositor = DSWaylandCompositor::getInstance(); + if (wlCompositor == nullptr) return; + + uint32_t serial = wlCompositor->nextSerial(); + + DSLOG_DBG("ZXDG_SURFACE", "Role:%d, Toplevel:%p, Popup:%p", __role, __toplevel, __popup); + + // TODO: Do we check role (toplevel or popup) + if (__toplevel) + __toplevel->sendConfigure(w, h); + + if (__popup) + __popup->sendConfigure(x, y, w, h); + + DSLOG_DBG("ZXDG_SURFACE", "Send configure... serial:%d", serial); + send_configure(serial); + + DSWaylandCompositor::releaseInstance(); +} + void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_bind_resource(zxdg_surface_v6::Resource *resource) { } @@ -362,6 +393,8 @@ void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_get_toplevel(zxdg_surface_v6 DSWaylandZxdgToplevelV6 *zxdgToplevel = new DSWaylandZxdgToplevelV6(pub, resource->client(), id, ZXDG_TOPLEVEL_V6_VERSION); __toplevel = zxdgToplevel; __role = DSWaylandZxdgSurfaceV6::DS_XDG_SURFACE_ROLE_TOPLEVEL; + + DSLOG_DBG("ZXDG_SURFACE", "Get Toplevel. DSWaylandZxdgToplevel:%p", __toplevel); } void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_get_popup(zxdg_surface_v6::Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner) { @@ -369,6 +402,8 @@ void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_get_popup(zxdg_surface_v6::R DSWaylandZxdgPopupV6 *zxdgPopup = new DSWaylandZxdgPopupV6(pub, resource->client(), id, ZXDG_TOPLEVEL_V6_VERSION); __popup = zxdgPopup; __role = DSWaylandZxdgSurfaceV6::DS_XDG_SURFACE_ROLE_POPUP; + + DSLOG_DBG("ZXDG_SURFACE", "Get Popup. DSWaylandZxdgPopup:%p", __popup); } void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_set_window_geometry(zxdg_surface_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { @@ -444,6 +479,11 @@ void DSWaylandZxdgToplevelV6::init(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct : priv->__zxdgSurface = zxdgSurface; } +void DSWaylandZxdgToplevelV6::sendConfigure(unsigned int w, unsigned int h) +{ + DS_GET_PRIV(DSWaylandZxdgToplevelV6); + priv->sendConfigure(w, h); +} DSWaylandZxdgToplevelV6Private::DSWaylandZxdgToplevelV6Private(DSWaylandZxdgToplevelV6 *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) @@ -454,6 +494,34 @@ DSWaylandZxdgToplevelV6Private::~DSWaylandZxdgToplevelV6Private() { } +void DSWaylandZxdgToplevelV6Private::sendConfigure(unsigned int w, unsigned int h) +{ + struct ::wl_array states; + wl_array_init(&states); + +/* + uint32_t *s; + + // if maximized + s = wl_array_add(&states, sizeof(uint32_t)); + if (s) + { + *s = ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED; + } + + // if fullscreen + s = wl_array_add(&states, sizeof(uint32_t)); + if (s) + { + *s = ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN; + } +*/ + + send_configure((int32_t)w, (int32_t)h, &states); + + wl_array_release(&states); +} + void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_bind_resource(zxdg_toplevel_v6::Resource *resource) { } @@ -534,6 +602,11 @@ void DSWaylandZxdgPopupV6::init(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl priv->__zxdgSurface = zxdgSurface; } +void DSWaylandZxdgPopupV6::sendConfigure(int x, int y, unsigned int w, unsigned int h) +{ + DS_GET_PRIV(DSWaylandZxdgPopupV6); + priv->send_configure(x, y, w, h); +} DSWaylandZxdgPopupV6Private::DSWaylandZxdgPopupV6Private(DSWaylandZxdgPopupV6 *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) @@ -544,6 +617,11 @@ DSWaylandZxdgPopupV6Private::~DSWaylandZxdgPopupV6Private() { } +void DSWaylandZxdgPopupV6Private::sendConfigure(int x, int y, unsigned int w, unsigned int h) +{ + send_configure(x, y, w, h); +} + void DSWaylandZxdgPopupV6Private::zxdg_popup_v6_bind_resource(zxdg_popup_v6::Resource *resource) { } diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.h b/src/DSWaylandServer/DSWaylandZxdgShellV6.h index 84ec284..e6a190e 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.h +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6.h @@ -105,6 +105,8 @@ public: void setSurface(DSWaylandSurface *surface) override; DSWaylandSurface *getSurface(void) override; + void sendConfigure(int x, int y, unsigned int w, unsigned int h) override; + void setWindowTitle(const std::string &title); void setAppID(const std::string &appId); @@ -123,6 +125,7 @@ public: virtual ~DSWaylandZxdgToplevelV6(); void init(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl_client *client, int id, int ver); + void sendConfigure(unsigned int w, unsigned int h); }; class DSWaylandZxdgPopupV6 : public DSObject @@ -135,6 +138,7 @@ public: virtual ~DSWaylandZxdgPopupV6(); void init(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl_client *client, int id, int ver); + void sendConfigure(int x, int y, unsigned int w, unsigned int h); }; diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6Private.h b/src/DSWaylandServer/DSWaylandZxdgShellV6Private.h index 6e85d1b..b76956b 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6Private.h +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6Private.h @@ -96,6 +96,8 @@ public: void setSurface(DSWaylandSurface *surface); DSWaylandSurface *getSurface(void); + void sendConfigure(int x, int y, unsigned int w, unsigned int h); + protected: void zxdg_surface_v6_bind_resource(zxdg_surface_v6::Resource *resource) override; void zxdg_surface_v6_destroy_resource(zxdg_surface_v6::Resource *resource) override; @@ -120,7 +122,8 @@ private: DSWaylandZxdgPopupV6 *__popup; DSWaylandZxdgSurfaceV6::Xdg_Surface_Role __role; - int __x, __y, __w, __h; + int __x, __y; + unsigned int __w, __h; std::string __title, __appId; }; @@ -133,6 +136,8 @@ public: DSWaylandZxdgToplevelV6Private(DSWaylandZxdgToplevelV6 *p_ptr); ~DSWaylandZxdgToplevelV6Private() override; + void sendConfigure(unsigned int w, unsigned int h); + protected: void zxdg_toplevel_v6_bind_resource(zxdg_toplevel_v6::Resource *resource) override; void zxdg_toplevel_v6_destroy_resource(zxdg_toplevel_v6::Resource *resource) override; @@ -165,6 +170,8 @@ public: DSWaylandZxdgPopupV6Private(DSWaylandZxdgPopupV6 *p_ptr); ~DSWaylandZxdgPopupV6Private() override; + void sendConfigure(int x, int y, unsigned int w, unsigned int h); + protected: void zxdg_popup_v6_bind_resource(zxdg_popup_v6::Resource *resource) override; void zxdg_popup_v6_destroy_resource(zxdg_popup_v6::Resource *resource) override; diff --git a/src/DSWaylandServer/IDSWaylandShell.h b/src/DSWaylandServer/IDSWaylandShell.h index 6983971..290efe0 100644 --- a/src/DSWaylandServer/IDSWaylandShell.h +++ b/src/DSWaylandServer/IDSWaylandShell.h @@ -55,6 +55,8 @@ public: virtual void setSurface(DSWaylandSurface *surface) = 0; virtual DSWaylandSurface *getSurface(void) = 0; + + virtual void sendConfigure(int x, int y, unsigned int w, unsigned int h) = 0; }; diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 4ae3746..ac75535 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -34,10 +34,13 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) __p_ptr(p_ptr), __w(1), __h(1), + __committedW(0), + __committedH(0), __created(false), __hasFocus(false), __waylandSurface(nullptr), - __winShell(nullptr) + __winShell(nullptr), + __firstCommit(true) { } @@ -116,17 +119,41 @@ DSWindowShell *DSWindowPrivate::getWindowShell(void) return __winShell; } +void DSWindowPrivate::sendConfigure(void) +{ + if (__winShell) + { + __winShell->sendConfigure(); + } +} + void DSWindowPrivate::__onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo) { DS_GET_PUB(DSWindow); + if (__firstCommit) + { + DSLOG_DBG("DSWindow", "First Commit!!! Send Configure..."); + sendConfigure(); + __firstCommit = false; + } + std::shared_ptr buffer = waylandSurfaceCommitInfo->getBuffer(); if (buffer) { // TODO: set the size of window with the size of commit information // It could be changed by DSWindowShell policy later.. std::shared_ptr bufferSize = buffer->getSize(); - __w = bufferSize->w; - __h = bufferSize->h; + __committedW = bufferSize->w; + __committedH = bufferSize->h; + +#if 1 // temporary code - we have to use policy to decide window's size. + if ((__committedW != __w) || + (__committedH != __h)) + { + DSLOG_ERR("DSWindow", "Committed size (%d,%d) is not same to requested size(%d,%d)", bufferSize->w, bufferSize->h, __w, __h); + return; + } +#endif // emit a signal of the buffer changed pub->__bufferChangedSignal.emit(buffer); diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index c19592f..1650248 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -60,15 +60,19 @@ public: bool setWindowShell(DSWindowShell *winShell); DSWindowShell *getWindowShell(void); + void sendConfigure(void); + private: void __onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo); unsigned int __w; unsigned int __h; + unsigned int __committedW, __committedH; bool __created; bool __hasFocus; std::shared_ptr __waylandSurface; DSWindowShell *__winShell; + bool __firstCommit; }; } diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp index 2f80857..c5a1d7b 100644 --- a/src/DSWindowShell/DSWindowShell.cpp +++ b/src/DSWindowShell/DSWindowShell.cpp @@ -275,5 +275,12 @@ const char* DSWindowShell::getRole(void) return priv->getRole(); } +void DSWindowShell::sendConfigure(void) +{ + DS_GET_PRIV(DSWindowShell); + + priv->sendConfigure(); +} + } // namespace display_server diff --git a/src/DSWindowShell/DSWindowShell.h b/src/DSWindowShell/DSWindowShell.h index ee4aa1e..10e131e 100644 --- a/src/DSWindowShell/DSWindowShell.h +++ b/src/DSWindowShell/DSWindowShell.h @@ -92,6 +92,8 @@ public: bool setRole(const char *role); const char* getRole(void); + void sendConfigure(void); + protected: private: diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index 07746d4..d4d5ab7 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -261,5 +261,12 @@ const char* DSWindowShellPrivate::getRole(void) return nullptr; } +void DSWindowShellPrivate::sendConfigure(void) +{ + if (__shellSurface) + { + __shellSurface->sendConfigure(__x, __y, __w, __h); + } +} } // namespace display_server diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h index 9a2e7ba..e16d3f0 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -88,6 +88,8 @@ public: bool setRole(const char *role); const char* getRole(void); + void sendConfigure(void); + private: bool __create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pWin, DSWindowShell *pParent);