From 96c3206506d9c552045933b811b7a64b4100f737 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 08:23:54 +0900 Subject: [PATCH 01/16] DSBuffer: add registerCallbackAcquirable function call a callback function when the DSBufferQueue can aquire Change-Id: I89672b5c7f6b160c1198b52c76e3c2013edcf803 --- src/DSBuffer/DSBufferQueueTBMImpl.cpp | 19 +++++++++++++++++-- src/DSBuffer/DSBufferQueueTBMImpl.h | 5 +++++ src/DSBuffer/IDSBufferQueue.h | 4 +++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/DSBuffer/DSBufferQueueTBMImpl.cpp b/src/DSBuffer/DSBufferQueueTBMImpl.cpp index eed20ff..4640d3a 100644 --- a/src/DSBuffer/DSBufferQueueTBMImpl.cpp +++ b/src/DSBuffer/DSBufferQueueTBMImpl.cpp @@ -29,6 +29,9 @@ namespace display_server { +// the static variables. +DSSignal DSBufferQueueTBMImpl::__aquirableSignal; + DSBufferQueueTBMImpl::DSBufferQueueTBMImpl(int slotSize, int bufferWidth, int bufferHeight, IDSBuffer::Format format) : __slotSize{slotSize}, __bufferWidth{bufferWidth}, @@ -39,6 +42,8 @@ DSBufferQueueTBMImpl::DSBufferQueueTBMImpl(int slotSize, int bufferWidth, int bu if (!__tqueue) { DSLOG_ERR("DSBufferTBM", "tbm_surface_queue_create fails."); } + + tbm_surface_queue_add_acquirable_cb(__tqueue, __onAquireable, this); } DSBufferQueueTBMImpl::DSBufferQueueTBMImpl(tbm_surface_queue_h tqueue) @@ -47,7 +52,9 @@ DSBufferQueueTBMImpl::DSBufferQueueTBMImpl(tbm_surface_queue_h tqueue) __bufferHeight{tbm_surface_queue_get_height(tqueue)}, __format{DSBufferTBMImpl::getBufferFormat(tbm_surface_queue_get_format(tqueue))}, __tqueue{tqueue} -{} +{ + tbm_surface_queue_add_acquirable_cb(__tqueue, __onAquireable, this); +} DSBufferQueueTBMImpl::~DSBufferQueueTBMImpl() { @@ -155,8 +162,16 @@ bool DSBufferQueueTBMImpl::canAcquireBuffer(bool wait) return false; return true; +} - return true; +void DSBufferQueueTBMImpl::registerCallbackAcquirable(DSObject *slot, std::function func) +{ + __aquirableSignal.connect(slot, func); +} + +void DSBufferQueueTBMImpl::__onAquireable(tbm_surface_queue_h surface_queue, void *data) +{ + __aquirableSignal.emit(data); } } diff --git a/src/DSBuffer/DSBufferQueueTBMImpl.h b/src/DSBuffer/DSBufferQueueTBMImpl.h index 27b8165..f74a94e 100644 --- a/src/DSBuffer/DSBufferQueueTBMImpl.h +++ b/src/DSBuffer/DSBufferQueueTBMImpl.h @@ -25,6 +25,7 @@ #define __DS_BUFFER_QUEUE_TBM_IMPL_H_ #include "IDSBufferQueue.h" +#include "DSSignal.h" #include #include @@ -48,6 +49,7 @@ public: bool releaseBuffer(std::shared_ptr buffer) override; bool canAcquireBuffer(bool wait) override; + void registerCallbackAcquirable(DSObject *slot, std::function func) override; private: int __slotSize; @@ -56,6 +58,9 @@ private: IDSBuffer::Format __format; tbm_surface_queue_h __tqueue; std::vector> __bufferVector; + + static void __onAquireable(tbm_surface_queue_h surface_queue, void *data); + static DSSignal __aquirableSignal; }; } diff --git a/src/DSBuffer/IDSBufferQueue.h b/src/DSBuffer/IDSBufferQueue.h index 5a8a4a0..80ade8b 100644 --- a/src/DSBuffer/IDSBufferQueue.h +++ b/src/DSBuffer/IDSBufferQueue.h @@ -25,11 +25,12 @@ #define __I_DS_BUFFER_QUEUE_H__ #include "IDSBuffer.h" +#include "DSObject.h" namespace display_server { -class IDSBufferQueue +class IDSBufferQueue : public DSObject { public: virtual ~IDSBufferQueue() = default; @@ -43,6 +44,7 @@ public: virtual bool releaseBuffer(std::shared_ptr ) = 0; virtual bool canAcquireBuffer(bool wait) = 0; + virtual void registerCallbackAcquirable(DSObject *slot, std::function func) = 0; }; } -- 2.7.4 From 21b323824ab4bbe550558eca9d8e68e381f82fab Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 08:39:07 +0900 Subject: [PATCH 02/16] DSDisplayDeviceHWC: register the acquirable buffer Register the acquirable buffer and write the value to event fd. Change-Id: I8bea0e945fbcfd7cea5ef110b154189f01b86346 --- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 11 +++++++++++ src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index 11ddef6..a4454e2 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -35,6 +35,7 @@ DSDisplayDeviceHWCWindowTDMTargetImpl::DSDisplayDeviceHWCWindowTDMTargetImpl(IDS { __eventFd = eventfd(0, EFD_NONBLOCK); __ecoreFdHandler = ecore_main_fd_handler_add(__eventFd, ECORE_FD_READ, __onFdHandler, this, NULL, NULL); + __bufferQueue->registerCallbackAcquirable(this, std::bind(&DSDisplayDeviceHWCWindowTDMTargetImpl::__onAcquirable, this, std::placeholders::_1)); } DSDisplayDeviceHWCWindowTDMTargetImpl::~DSDisplayDeviceHWCWindowTDMTargetImpl() @@ -98,4 +99,14 @@ Eina_Bool DSDisplayDeviceHWCWindowTDMTargetImpl::__onFdHandler(void *data, Ecore return ECORE_CALLBACK_RENEW; } +void DSDisplayDeviceHWCWindowTDMTargetImpl::__onAcquirable(void *data) +{ + uint64_t value = 1; + int ret; + + ret = write(__eventFd, &value, sizeof(value)); + if (ret == -1) + DSLOG_WRN("DSDisplayDeviceHWCWindowTDMTargetImpl", "failed to write a value on event fd:%m"); +} + } diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h index 46bdfe2..70997dc 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h @@ -34,7 +34,7 @@ namespace display_server { -class DSDisplayDeviceHWCWindowTDMTargetImpl : public IDSDisplayDeviceHWCWindow +class DSDisplayDeviceHWCWindowTDMTargetImpl : public IDSDisplayDeviceHWCWindow, public DSObject { public: DSDisplayDeviceHWCWindowTDMTargetImpl(IDSDisplayDeviceHWC *deviceHWC, std::shared_ptr __bufferQueue); @@ -46,6 +46,7 @@ public: private: static Eina_Bool __onFdHandler(void *data, Ecore_Fd_Handler *hdlr); + void __onAcquirable(void *data); IDSDisplayDeviceHWC *__deviceHWC; std::shared_ptr __bufferQueue; -- 2.7.4 From 5ce9659c6bcb4a55f02eb4f3ea35c79d7c99069b Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Thu, 20 Aug 2020 21:23:04 +0900 Subject: [PATCH 03/16] DSWaylandSurface: release BufferManager resource in destructor Change-Id: I88d69d74e9b2966142faf36815f86e63950c6762 --- src/DSWaylandServer/DSWaylandSurface.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp index 4e6e2d7..54996ba 100644 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ b/src/DSWaylandServer/DSWaylandSurface.cpp @@ -85,7 +85,10 @@ DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr, DSWayl } DSWaylandSurfacePrivate::~DSWaylandSurfacePrivate() -{} +{ + if (__bufferManager) + DSBufferManager::releaseInstance(); +} void DSWaylandSurfacePrivate::surface_bind_resource(Resource *resource) { -- 2.7.4 From 00290872a991adb8ea95abdd5ce7edad21275ba1 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:10:13 +0900 Subject: [PATCH 04/16] DSRenderView: add getWindow() methods Change-Id: I17c92e24c328c121c742089508955c7925bfa473 --- src/DSRender/DSRenderView.h | 1 + src/DSRender/DSRenderViewDaliImpl.cpp | 5 +++++ src/DSRender/DSRenderViewDaliImpl.h | 1 + src/DSRender/DSRenderViewEcoreEvasImpl.cpp | 5 +++++ src/DSRender/DSRenderViewEcoreEvasImpl.h | 1 + 5 files changed, 13 insertions(+) diff --git a/src/DSRender/DSRenderView.h b/src/DSRender/DSRenderView.h index 71f95b2..74a4a2c 100644 --- a/src/DSRender/DSRenderView.h +++ b/src/DSRender/DSRenderView.h @@ -37,6 +37,7 @@ public: virtual ~DSRenderView(); virtual bool setBuffer(std::shared_ptr buffer) = 0; + virtual std::shared_ptr getWindow() = 0; private: /* data */ diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp index 5c5d35a..5ec25c6 100644 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ b/src/DSRender/DSRenderViewDaliImpl.cpp @@ -129,6 +129,11 @@ bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) return true; } +std::shared_ptr DSRenderViewDaliImpl::getWindow() +{ + return __window; +} + void DSRenderViewDaliImpl::__onWindowBufferChanged(std::shared_ptr buffer) { std::shared_ptr bufferSize = buffer->getSize(); diff --git a/src/DSRender/DSRenderViewDaliImpl.h b/src/DSRender/DSRenderViewDaliImpl.h index 8d3a89a..1bb7698 100644 --- a/src/DSRender/DSRenderViewDaliImpl.h +++ b/src/DSRender/DSRenderViewDaliImpl.h @@ -41,6 +41,7 @@ public: ~DSRenderViewDaliImpl(); bool setBuffer(std::shared_ptr buffer) override; + std::shared_ptr getWindow() override; Dali::Geometry CreateTexturedQuad(); diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp index bac48e8..e66845c 100644 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp +++ b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp @@ -73,4 +73,9 @@ void DSRenderViewEcoreEvasImpl::__onWindowBufferChanged(std::shared_ptr DSRenderViewEcoreEvasImpl::getWindow() +{ + return __window; +} + } // namespace display_server diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.h b/src/DSRender/DSRenderViewEcoreEvasImpl.h index 53ed231..11ab261 100644 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.h +++ b/src/DSRender/DSRenderViewEcoreEvasImpl.h @@ -38,6 +38,7 @@ public: ~DSRenderViewEcoreEvasImpl(); bool setBuffer(std::shared_ptr buffer) override; + std::shared_ptr getWindow() override; private: void __onWindowBufferChanged(std::shared_ptr buffer); -- 2.7.4 From 5cef661294329a759fa13453cb90de078cb9ba50 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:14:07 +0900 Subject: [PATCH 05/16] DSDisplayDeviceHWCWindow: add getWindow() methods Change-Id: If0b794b2b078db36e03b56efa524bb0bc8cce738 --- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp | 5 +++++ src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h | 1 + src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 5 +++++ src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h | 1 + src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h | 3 +++ 5 files changed, 15 insertions(+) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp index a1671ec..cbb76e4 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp @@ -55,4 +55,9 @@ void DSDisplayDeviceHWCWindowTDMImpl::onPresentFrameDone() /* TODO:: */ } +std::shared_ptr DSDisplayDeviceHWCWindowTDMImpl::getWindow() +{ + return __window; +} + } diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h index 90ef3f5..99796be 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h @@ -41,6 +41,7 @@ public: void updateFrame(bool &update) override; void presentFrame() override; void onPresentFrameDone() override; + std::shared_ptr getWindow() override; private: std::shared_ptr __window; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index a4454e2..a840510 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -82,6 +82,11 @@ void DSDisplayDeviceHWCWindowTDMTargetImpl::onPresentFrameDone() __presentedBuffer = std::move(__presentBuffer); } +std::shared_ptr DSDisplayDeviceHWCWindowTDMTargetImpl::getWindow() +{ + return nullptr; +} + Eina_Bool DSDisplayDeviceHWCWindowTDMTargetImpl::__onFdHandler(void *data, Ecore_Fd_Handler *hdlr) { int len; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h index 70997dc..2dadf75 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h @@ -43,6 +43,7 @@ public: void updateFrame(bool &update) override; void presentFrame() override; void onPresentFrameDone() override; + std::shared_ptr getWindow() override; private: static Eina_Bool __onFdHandler(void *data, Ecore_Fd_Handler *hdlr); diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h index cd18a5b..3379243 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h @@ -24,6 +24,8 @@ #ifndef _I_DS_DISPLAY_DEVICE_HWC_WINDOW_H_ #define _I_DS_DISPLAY_DEVICE_HWC_WINDOW_H_ +#include "DSWindow.h" + namespace display_server { class IDSDisplayDeviceHWCWindow @@ -33,6 +35,7 @@ public: virtual void updateFrame(bool &update) = 0; virtual void presentFrame() = 0; virtual void onPresentFrameDone() = 0; + virtual std::shared_ptr getWindow() = 0; }; } -- 2.7.4 From 356198ae9a1a860ec340f23b1c2880311bfa1f77 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:14:57 +0900 Subject: [PATCH 06/16] DSDisplayArea: destory DSRenderView and DSDisplayDeviceHWCWindow Change-Id: Id79476dfabdbb4c6726783f47be648265fb8b0bc --- src/DSDisplayArea/DSDisplayArea.cpp | 24 ++++++++++++++++++++++++ src/DSDisplayArea/DSDisplayAreaPrivate.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index fdcadd4..ecfd519 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -130,16 +130,40 @@ bool DSDisplayAreaPrivate::addZone(std::shared_ptr zone) { __zone = zone; __zone->registerCallbackWindowCreated(this, std::bind(&DSDisplayAreaPrivate::__onWindowCreated, this, std::placeholders::_1)); + __zone->registerCallbackWindowDestroy(this, std::bind(&DSDisplayAreaPrivate::__onWindowDestroy, this, std::placeholders::_1)); return true; } void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) { + // TODO: think about using unordered_map __renderViewList.push_back(__renderEngine->makeRenderView(window)); __displayDeviceHWCWindowList.push_back(__displayDeviceHWC->makeHWCWindow(window)); } +void DSDisplayAreaPrivate::__onWindowDestroy(std::shared_ptr window) +{ + // TODO: think about using unordered_map + for (auto renderView : __renderViewList) { + auto tmpWindow = renderView->getWindow(); + if (tmpWindow.get() == window.get()) { + __renderViewList.remove(renderView); + renderView.reset(); + break; + } + } + + for (auto displayDeviceHWCWindow : __displayDeviceHWCWindowList) { + auto tmpHWCWindow = displayDeviceHWCWindow->getWindow(); + if (tmpHWCWindow.get() == window.get()) { + __displayDeviceHWCWindowList.remove(displayDeviceHWCWindow); + displayDeviceHWCWindow.reset(); + break; + } + } +} + void DSDisplayAreaPrivate::__onEventIdleEnterer(void *data) { DSLOG_INF("DSDisplayAreaPrivate", "__onEventIdleEnterer"); diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h index 1b92f99..cb16595 100644 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ b/src/DSDisplayArea/DSDisplayAreaPrivate.h @@ -54,6 +54,7 @@ public: private: void __onWindowCreated(std::shared_ptr window); + void __onWindowDestroy(std::shared_ptr window); void __onEventIdleEnterer(void *data); std::shared_ptr __output; -- 2.7.4 From 429cbf59a47c1e2bdedd565f67c551bf28ed928d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:19:01 +0900 Subject: [PATCH 07/16] DSDisplayDeviceHWC: make updateFrame return bool type. Change-Id: I1a75b0b6e4cbb5634e59cffca1b5d549ad825535 --- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp | 13 ++++++++----- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h | 2 +- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp | 4 ++-- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h | 2 +- .../DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 11 +++++++---- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h | 2 +- src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h | 2 +- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp index bb52d70..f26f02a 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp @@ -121,10 +121,9 @@ bool DSDisplayDeviceHWCTDMImpl::commit() { tdm_error terror; uint32_t numChanges; - bool frameUpdate = false; - if (!__updateFrameWindows(frameUpdate)) { - DSLOG_ERR("HWCTDM", "__updateTarget fails."); + if (!__updateFrameWindows()) { + DSLOG_INF("HWCTDM", "no update windows."); return false; } @@ -158,6 +157,8 @@ bool DSDisplayDeviceHWCTDMImpl::commit() return false; } + DSLOG_INF("HWCTDM", "HWC COMMIT COMMIT COMMIT ~#######"); + __presentFrameDoneWindows(); return true; @@ -248,9 +249,11 @@ bool DSDisplayDeviceHWCTDMImpl::__acceptValidation() return true; } -bool DSDisplayDeviceHWCTDMImpl::__updateFrameWindows(bool &frameUpdate) +bool DSDisplayDeviceHWCTDMImpl::__updateFrameWindows() { - __targetWindow->updateFrame(frameUpdate); + if (!__targetWindow->updateFrame()) { + return false; + } return true; } diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h index f852caf..abdfc70 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h @@ -55,7 +55,7 @@ private: bool __validate(uint32_t &numChanges); bool __updateChanges(uint32_t numChanges); bool __acceptValidation(); - bool __updateFrameWindows(bool &frameUpdate); + bool __updateFrameWindows(); bool __presentFrameWindows(); bool __presentFrameDoneWindows(); }; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp index cbb76e4..051cbd1 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp @@ -39,10 +39,10 @@ tdm_hwc_window *DSDisplayDeviceHWCWindowTDMImpl::getNativeHWCWindow() return __twindow; } -void DSDisplayDeviceHWCWindowTDMImpl::updateFrame(bool &update) +bool DSDisplayDeviceHWCWindowTDMImpl::updateFrame() { // temp always false update - update = false; + return false; } void DSDisplayDeviceHWCWindowTDMImpl::presentFrame() diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h index 99796be..1a6fc6a 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h @@ -38,7 +38,7 @@ public: ~DSDisplayDeviceHWCWindowTDMImpl(); tdm_hwc_window *getNativeHWCWindow(); - void updateFrame(bool &update) override; + bool updateFrame() override; void presentFrame() override; void onPresentFrameDone() override; std::shared_ptr getWindow() override; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index a840510..983f4fa 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -44,16 +44,19 @@ DSDisplayDeviceHWCWindowTDMTargetImpl::~DSDisplayDeviceHWCWindowTDMTargetImpl() close(__eventFd); } -void DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame(bool &update) +bool DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame() { std::shared_ptr dsBuffer; - if (!__bufferQueue->canAcquireBuffer(false)) return; + if (!__bufferQueue->canAcquireBuffer(false)) { + DSLOG_INF("TDM_HWC", "no acquirable buffer."); + return false; + } dsBuffer = __bufferQueue->acquireBuffer(); if (!dsBuffer) { DSLOG_ERR("TDM_HWC", "acquire buffer fails."); - return; + return false; } if (__buffer) { @@ -63,7 +66,7 @@ void DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame(bool &update) __buffer= dsBuffer; - update = true; + return true; } void DSDisplayDeviceHWCWindowTDMTargetImpl::presentFrame() diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h index 2dadf75..756b920 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h @@ -40,7 +40,7 @@ public: DSDisplayDeviceHWCWindowTDMTargetImpl(IDSDisplayDeviceHWC *deviceHWC, std::shared_ptr __bufferQueue); ~DSDisplayDeviceHWCWindowTDMTargetImpl(); - void updateFrame(bool &update) override; + bool updateFrame() override; void presentFrame() override; void onPresentFrameDone() override; std::shared_ptr getWindow() override; diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h index 3379243..e8eb85f 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h @@ -32,7 +32,7 @@ class IDSDisplayDeviceHWCWindow { public: virtual ~IDSDisplayDeviceHWCWindow() = default; - virtual void updateFrame(bool &update) = 0; + virtual bool updateFrame() = 0; virtual void presentFrame() = 0; virtual void onPresentFrameDone() = 0; virtual std::shared_ptr getWindow() = 0; -- 2.7.4 From fef4a14554b1d4ff9c35b938ad02ff8e2378ee7c Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:22:34 +0900 Subject: [PATCH 08/16] DSWindow: make registerCallbackWindowDestroyed method Change-Id: I5c2ef80a43b83956808bc9142221dfb949ffa992 --- src/DSWindow/DSWindow.cpp | 7 ++++++- src/DSWindow/DSWindow.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 8c10913..2b31ec1 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -211,7 +211,7 @@ DSWindow::DSWindow(std::shared_ptr waylandSurface) DSWindow::~DSWindow() { - + this->__windowDestroySignal.emit(nullptr); } bool DSWindow::create(std::shared_ptr waylandSurface) @@ -397,4 +397,9 @@ void DSWindow::registerCallbackBufferChanged(DSObject *slot, std::function func) +{ + __windowDestroySignal.connect(slot, func); +} + } // namespace display_server diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index 10fb3b8..eeb4a04 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -80,6 +80,7 @@ public: void registerCallbackSizeChanged(DSObject *slot, std::function)> func); void registerCallbackBufferChanged(DSObject *slot, std::function)> func); + void registerCallbackWindowDestroyed(DSObject *slot, std::function func); protected: //virtual bool _onFocus(void); @@ -89,6 +90,7 @@ private: // signals DSSignal> __sizeChangedSignal; DSSignal> __bufferChangedSignal; + DSSignal __windowDestroySignal; }; } -- 2.7.4 From 0742373162b5525cbb5c19f302bb47b768755a87 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:28:34 +0900 Subject: [PATCH 09/16] DSRenderEngineDaliImpl: register WindowDestroyed callback of window object need to kick the Dali Renderer when the window is destroyed. Change-Id: I4547baf37dda4863780f1f3d1490641376ba4a76 --- src/DSRender/DSRenderEngineDaliImpl.cpp | 18 +++++++++++++++++- src/DSRender/DSRenderEngineDaliImpl.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp index 1ab9f6c..082e815 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -62,16 +62,20 @@ std::shared_ptr DSRenderEngineDaliImpl::makeRenderView(std::shared // callbacks window->registerCallbackBufferChanged(this, std::bind(&DSRenderEngineDaliImpl::__onWindowUpdated, this, std::placeholders::_1)); + window->registerCallbackWindowDestroyed(this, std::bind(&DSRenderEngineDaliImpl::__onWindowDestroyed, this, std::placeholders::_1)); return renderView; } bool DSRenderEngineDaliImpl::renderFrame() { - if (__needToRender) + if (__needToRender) { Adaptor::Get().RenderOnce(); + DSLOG_DBG("DSRenderEngineDaliImpl", "RENDER RENDER RENDER~!!!!"); + } __needToRender = false; + return true; } @@ -83,4 +87,16 @@ void DSRenderEngineDaliImpl::__onWindowUpdated(std::shared_ptr buffer } } +void DSRenderEngineDaliImpl::__onWindowDestroyed(void *data) +{ + if (!__needToRender) { + DSLOG_DBG("DSRenderEngineDaliImpl", "Window destroyed!!"); + // TODO: update twice, at this time and at idle handler. + // do not update a frame only once.. + // NEED to check why dali does not update a frame at this time by execute one RenderOnce call. + Adaptor::Get().RenderOnce(); + __needToRender = true; + } +} + } // namespace display_server diff --git a/src/DSRender/DSRenderEngineDaliImpl.h b/src/DSRender/DSRenderEngineDaliImpl.h index d9244f7..2cbdc7b 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.h +++ b/src/DSRender/DSRenderEngineDaliImpl.h @@ -48,6 +48,7 @@ public: private: void __onWindowUpdated(std::shared_ptr buffer); + void __onWindowDestroyed(void *data); std::shared_ptr __bufferQueue; Dali::OffscreenApplication __offscreenApplication; -- 2.7.4 From 7e89d279d0b141ead1804f2a7d0075887a2fbdb4 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:30:38 +0900 Subject: [PATCH 10/16] DSRenderViewDaliImpl: remove actor from offscreen at destructor Change-Id: I967d9f5961f9f62b109f2321729114a2f3585d1f --- src/DSRender/DSRenderViewDaliImpl.cpp | 5 ++++- src/DSRender/DSRenderViewDaliImpl.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp index 5ec25c6..b76a004 100644 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ b/src/DSRender/DSRenderViewDaliImpl.cpp @@ -83,7 +83,8 @@ Geometry DSRenderViewDaliImpl::CreateTexturedQuad() } DSRenderViewDaliImpl::DSRenderViewDaliImpl(std::shared_ptr window, Dali::OffscreenWindow offscreenWindow) - : __window(window) + : __window(window), + __offscreenWindow(offscreenWindow) { std::string fragmentShader = "#extension GL_OES_EGL_image_external:require\n"; fragmentShader += FRAGMENT_SHADER; @@ -108,6 +109,8 @@ DSRenderViewDaliImpl::DSRenderViewDaliImpl(std::shared_ptr window, Dal DSRenderViewDaliImpl::~DSRenderViewDaliImpl() { + __textureViewActor.RemoveRenderer(__renderer); + __offscreenWindow.Remove(__textureViewActor); } bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) diff --git a/src/DSRender/DSRenderViewDaliImpl.h b/src/DSRender/DSRenderViewDaliImpl.h index 1bb7698..47c72ff 100644 --- a/src/DSRender/DSRenderViewDaliImpl.h +++ b/src/DSRender/DSRenderViewDaliImpl.h @@ -49,6 +49,7 @@ private: void __onWindowBufferChanged(std::shared_ptr buffer); std::shared_ptr __window; + Dali::OffscreenWindow __offscreenWindow; Dali::Renderer __renderer; Dali::Actor __textureViewActor; }; -- 2.7.4 From 3a7ad8d9d7553980ff37a99f93a28bcd13872782 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:40:47 +0900 Subject: [PATCH 11/16] DSDisplayDeviceHWCWindowTDMTargetImpl: add ecore_init()/ecore_shutdown() Change-Id: Ie9e232c347602db60b43ef4238bd9c0fa7bde988 --- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index 983f4fa..5377c3b 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -33,6 +33,10 @@ DSDisplayDeviceHWCWindowTDMTargetImpl::DSDisplayDeviceHWCWindowTDMTargetImpl(IDS __bufferQueue(bufferQueue), __ecoreFdHandler(nullptr) { + if (!ecore_init()) { + DSLOG_ERR("EventLoop", "ecore_init() fails."); + } + __eventFd = eventfd(0, EFD_NONBLOCK); __ecoreFdHandler = ecore_main_fd_handler_add(__eventFd, ECORE_FD_READ, __onFdHandler, this, NULL, NULL); __bufferQueue->registerCallbackAcquirable(this, std::bind(&DSDisplayDeviceHWCWindowTDMTargetImpl::__onAcquirable, this, std::placeholders::_1)); @@ -42,6 +46,8 @@ DSDisplayDeviceHWCWindowTDMTargetImpl::~DSDisplayDeviceHWCWindowTDMTargetImpl() { ecore_main_fd_handler_del(__ecoreFdHandler); close(__eventFd); + + ecore_shutdown(); } bool DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame() -- 2.7.4 From f3d7bdebdd4b2e0e01fbb33098ac5556673c99f8 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 15:36:20 +0900 Subject: [PATCH 12/16] test: free waylandSurface before releasing DSWaylandCompositor Change-Id: I106f6860270dc9ad89eb05f1a4507de5f18c1542 Signed-off-by: SooChan Lim --- tests/libds-mock.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/libds-mock.h b/tests/libds-mock.h index ac77287..b473762 100644 --- a/tests/libds-mock.h +++ b/tests/libds-mock.h @@ -57,6 +57,7 @@ public: ~MockWaylandCompositor() { + __waylandSurface.reset(); DSWaylandCompositor::releaseInstance(); DSEventLoop::releaseInstance(); } -- 2.7.4 From 69c467710143b4e50c7ab9b84531a081d9c101d0 Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 15:00:46 +0900 Subject: [PATCH 13/16] protocols: update wayland protocols Change-Id: Ic1d34e543022fbbccdd7f194cc7b9fc865255588 --- .../dswayland-server-input-method.cpp | 20 ++++++++++++++++++++ src/DSWaylandServer/dswayland-server-input-method.h | 2 ++ src/DSWaylandServer/dswayland-server-text.cpp | 19 ++++++++++++++++++- src/DSWaylandServer/dswayland-server-text.h | 5 +++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/dswayland-server-input-method.cpp b/src/DSWaylandServer/dswayland-server-input-method.cpp index 3fcce7a..68351db 100644 --- a/src/DSWaylandServer/dswayland-server-input-method.cpp +++ b/src/DSWaylandServer/dswayland-server-input-method.cpp @@ -1090,6 +1090,26 @@ namespace DSWaylandServer { } + void wl_input_method_context::send_input_panel_enabled(uint32_t enabled) + { + DS_ASSERT_X(m_resource, "wl_input_method_context::input_panel_enabled", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wl_input_method_context::input_panel_enabled as it's not initialised"); + return; + } + send_input_panel_enabled( + m_resource->handle, + enabled); + } + + void wl_input_method_context::send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled) + { + wl_input_method_context_send_input_panel_enabled( + resource, + enabled); + } + + wl_input_method::wl_input_method(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) diff --git a/src/DSWaylandServer/dswayland-server-input-method.h b/src/DSWaylandServer/dswayland-server-input-method.h index 3d2b501..1f800ec 100644 --- a/src/DSWaylandServer/dswayland-server-input-method.h +++ b/src/DSWaylandServer/dswayland-server-input-method.h @@ -102,6 +102,8 @@ namespace DSWaylandServer { void send_finalized_content(struct ::wl_resource *resource, const std::string &text, uint32_t cursor_position); void send_prediction_hint_data(const std::string &key, const std::string &value); void send_prediction_hint_data(struct ::wl_resource *resource, const std::string &key, const std::string &value); + void send_input_panel_enabled(uint32_t enabled); + void send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled); protected: virtual Resource *input_method_context_allocate(); diff --git a/src/DSWaylandServer/dswayland-server-text.cpp b/src/DSWaylandServer/dswayland-server-text.cpp index a5e4d3c..e4bed15 100644 --- a/src/DSWaylandServer/dswayland-server-text.cpp +++ b/src/DSWaylandServer/dswayland-server-text.cpp @@ -204,7 +204,8 @@ namespace DSWaylandServer { wl_text_input::handle_set_mime_type, wl_text_input::handle_set_input_panel_position, wl_text_input::handle_finalize_content, - wl_text_input::handle_prediction_hint_data + wl_text_input::handle_prediction_hint_data, + wl_text_input::handle_input_panel_enabled }; void wl_text_input::text_input_destroy(Resource *) @@ -307,6 +308,10 @@ namespace DSWaylandServer { { } + void wl_text_input::text_input_input_panel_enabled(Resource *, uint32_t ) + { + } + void wl_text_input::handle_destroy( ::wl_client *client, @@ -638,6 +643,18 @@ namespace DSWaylandServer { std::string(value)); } + void wl_text_input::handle_input_panel_enabled( + ::wl_client *client, + struct wl_resource *resource, + uint32_t enabled) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->text_input_object)->text_input_input_panel_enabled( + r, + enabled); + } + void wl_text_input::send_enter(struct ::wl_resource *surface) { DS_ASSERT_X(m_resource, "wl_text_input::enter", "Uninitialised resource"); diff --git a/src/DSWaylandServer/dswayland-server-text.h b/src/DSWaylandServer/dswayland-server-text.h index eb437ef..622f5d6 100644 --- a/src/DSWaylandServer/dswayland-server-text.h +++ b/src/DSWaylandServer/dswayland-server-text.h @@ -244,6 +244,7 @@ namespace DSWaylandServer { virtual void text_input_set_input_panel_position(Resource *resource, uint32_t x, uint32_t y); virtual void text_input_finalize_content(Resource *resource, const std::string &text, uint32_t cursor_position); virtual void text_input_prediction_hint_data(Resource *resource, const std::string &key, const std::string &value); + virtual void text_input_input_panel_enabled(Resource *resource, uint32_t enabled); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -370,6 +371,10 @@ namespace DSWaylandServer { struct wl_resource *resource, const char *key, const char *value); + static void handle_input_panel_enabled( + ::wl_client *client, + struct wl_resource *resource, + uint32_t enabled); std::multimap m_resource_map; Resource *m_resource; -- 2.7.4 From 6c18252d00e2605d67bc12e98a78e4dfe55af808 Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 15:01:10 +0900 Subject: [PATCH 14/16] DSWaylandTextInput: add skeleton codes for input_panel_enabled request Change-Id: I595bf67198084fb8ba7756d878f2795050df4821 --- src/DSWaylandServer/DSWaylandTextInput.cpp | 5 +++++ src/DSWaylandServer/DSWaylandTextInputPrivate.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp index 5de2744..a865654 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ b/src/DSWaylandServer/DSWaylandTextInput.cpp @@ -606,6 +606,11 @@ void DSWaylandTextInputPrivate::text_input_prediction_hint_data(Resource *resour pub->__dsTextInputPrivate->predictionHintData(key, value); } +void DSWaylandTextInputPrivate::text_input_input_panel_enabled(Resource *resource, uint32_t enabled) +{ +} + + void DSWaylandTextInputPrivate::sendCommitString(unsigned int serial, std::string text) { if (!__activatedResource) diff --git a/src/DSWaylandServer/DSWaylandTextInputPrivate.h b/src/DSWaylandServer/DSWaylandTextInputPrivate.h index 12268f2..7d98454 100644 --- a/src/DSWaylandServer/DSWaylandTextInputPrivate.h +++ b/src/DSWaylandServer/DSWaylandTextInputPrivate.h @@ -92,6 +92,7 @@ protected: void text_input_set_input_panel_position(Resource *resource, uint32_t x, uint32_t y); void text_input_finalize_content(Resource *resource, const std::string &text, uint32_t cursor_position); void text_input_prediction_hint_data(Resource *resource, const std::string &key, const std::string &value); + void text_input_input_panel_enabled(Resource *resource, uint32_t enabled); private: DSWaylandCompositor *__compositor; -- 2.7.4 From 3a09e8f6900f54314dbca882d4cccf76129f753c Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 14:13:06 +0900 Subject: [PATCH 15/16] DSWaylandTextInput: fix error and invalid methods to prevent crash Change-Id: I4e5f2d2a07e70bfde455417090564644f4aa9ea9 --- src/DSWaylandServer/DSWaylandInputMethod.cpp | 38 ++++++++++++++--------- src/DSWaylandServer/DSWaylandInputMethodPrivate.h | 12 ++++--- src/DSWaylandServer/DSWaylandInputPanel.cpp | 1 + src/DSWaylandServer/DSWaylandTextInput.cpp | 14 ++++----- src/DSWaylandServer/DSWaylandTextInput.h | 2 +- src/DSWaylandServer/DSWaylandTextInputManager.h | 2 +- src/DSWaylandServer/DSWaylandTextInputPrivate.h | 2 +- 7 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandInputMethod.cpp b/src/DSWaylandServer/DSWaylandInputMethod.cpp index 96248dd..fc79bf1 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.cpp +++ b/src/DSWaylandServer/DSWaylandInputMethod.cpp @@ -495,11 +495,11 @@ DSWaylandInputMethodPrivate::~DSWaylandInputMethodPrivate() { } -int DSWaylandInputMethodPrivate::getResourceId(Resource *resource) +int DSWaylandInputMethodPrivate::getResourceId(DSWaylandInputMethodContextPrivate::Resource *resource) { int id = -1; - std::multimap::iterator it; + std::multimap::iterator it; for (it = __contextMap.begin(); it != __contextMap.end(); it++) { if (resource == (*it).first) @@ -512,11 +512,12 @@ int DSWaylandInputMethodPrivate::getResourceId(Resource *resource) return id; } -DSWaylandServer::wl_input_method::Resource* DSWaylandInputMethodPrivate::getResource(int id) +DSWaylandInputMethodContextPrivate::Resource* DSWaylandInputMethodPrivate::getResource(int id) { - Resource *resource = nullptr; + DSWaylandInputMethodContextPrivate::Resource *resource = nullptr; - std::multimap::iterator it; + + std::multimap::iterator it; for (it = __contextMap.begin(); it != __contextMap.end(); it++) { if (id == (*it).second) @@ -531,26 +532,28 @@ DSWaylandServer::wl_input_method::Resource* DSWaylandInputMethodPrivate::getReso void DSWaylandInputMethodPrivate::sendActivate(void *contextResource, int textInputId, bool focusInEvent) { - Resource *resource = Resource::fromResource((struct ::wl_resource *)contextResource); - __contextMap.insert(std::pair(resource, textInputId)); + DSWaylandInputMethodContextPrivate::Resource *resource = DSWaylandInputMethodContextPrivate::Resource::fromResource((struct ::wl_resource *)contextResource); + __contextMap.insert(std::pair(resource, textInputId)); send_activate(__resource->handle, (struct ::wl_resource *)contextResource, textInputId, focusInEvent); } void DSWaylandInputMethodPrivate::sendDeactivate(void *contextResource, bool focusInEvent) { - Resource *resource = Resource::fromResource((struct ::wl_resource *)contextResource); + DSWaylandInputMethodContextPrivate::Resource *resource = DSWaylandInputMethodContextPrivate::Resource::fromResource((struct ::wl_resource *)contextResource); __contextMap.erase(resource); send_deactivate(__resource->handle, (struct ::wl_resource *)contextResource, focusInEvent); } -void DSWaylandInputMethodPrivate::showInputPanel(void *contextResource) +void DSWaylandInputMethodPrivate::showInputPanel(void *contextResource, int textInputId) { - send_show_input_panel((struct ::wl_resource *)contextResource); + //Resource *resource = getResource(textInputId); + send_show_input_panel(__resource->handle, (struct ::wl_resource *)contextResource); } -void DSWaylandInputMethodPrivate::hideInputPanel(void *contextResource) +void DSWaylandInputMethodPrivate::hideInputPanel(void *contextResource, int textInputId) { - send_hide_input_panel((struct ::wl_resource *)contextResource); + //Resource *resource = getResource(textInputId); + send_hide_input_panel(__resource->handle, (struct ::wl_resource *)contextResource); } void DSWaylandInputMethodPrivate::input_method_bind_resource(Resource *resource) @@ -631,15 +634,20 @@ void DSWaylandInputMethod::showInputPanel(int textInputId) DS_GET_PRIV(DSWaylandInputMethod); if (__activateContext) - priv->showInputPanel(__activateContext); + priv->showInputPanel(__activateContext, textInputId); } void DSWaylandInputMethod::hideInputPanel(int textInputId) { DS_GET_PRIV(DSWaylandInputMethod); + if (textInputId < 0) + { + textInputId = priv->getResourceId(DSWaylandInputMethodContextPrivate::Resource::fromResource((struct ::wl_resource *)__activateContext)); + } + if (__activateContext) - priv->hideInputPanel(__activateContext); + priv->hideInputPanel(__activateContext, textInputId); } void DSWaylandInputMethod::resetTextInput() @@ -814,7 +822,7 @@ void DSWaylandInputMethod::contextHideInputPanel(unsigned int serial) if (__activateContext) { - priv->hideInputPanel(__activateContext); + priv->hideInputPanel(__activateContext, -1); } } diff --git a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h index 1b9cf3d..49a86cf 100644 --- a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h +++ b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h @@ -33,6 +33,8 @@ namespace display_server { +class DSWaylandInputMethodContextPrivate; + class DS_DECL_EXPORT DSWaylandInputMethodPrivate : public DSObjectPrivate, public DSWaylandServer::wl_input_method { DS_PIMPL_USE_PUBLIC(DSWaylandInputMethod); @@ -42,10 +44,10 @@ public: void sendActivate(void *contextResource, int textInputId, bool focusInEvent); void sendDeactivate(void *contextResource, bool focusInEvent); - void showInputPanel(void *contextResource); - void hideInputPanel(void *contextResource); - int getResourceId(Resource *resource); - Resource* getResource(int id); + void showInputPanel(void *contextResource, int textInputId); + void hideInputPanel(void *contextResource, int textInputId); + int getResourceId(DSWaylandInputMethodContextPrivate::Resource *resource); + DSWaylandInputMethodContextPrivate::Resource* getResource(int id); protected: void input_method_bind_resource(Resource *resource); @@ -54,7 +56,7 @@ protected: private: DSWaylandCompositor *__compositor; Resource *__resource; - std::multimap __contextMap; + std::multimap __contextMap; }; } diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp index c1f99b0..dc35b73 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ b/src/DSWaylandServer/DSWaylandInputPanel.cpp @@ -418,6 +418,7 @@ void DSWaylandInputPanelSurfacePrivate::setFloatingPosition(int x, int y) inputPanelFloating = pub->__inputPanel->getFloatingData(); (void) inputPanelFloating; + (void) floatingData; #if 0//Unreachable code ! Thus, disable temporarily. if (!floatingData || !inputPanelFloating) return; diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp index a865654..fdfc2dd 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ b/src/DSWaylandServer/DSWaylandTextInput.cpp @@ -47,7 +47,7 @@ void DSWaylandTextInputManagerPrivate::text_input_manager_create_text_input(Reso { DS_GET_PUB(DSWaylandTextInputManager); - pub->createTextInput((void *)(resource->client())); + pub->createTextInput((void *)(resource->client()), id); } @@ -73,9 +73,9 @@ DSWaylandTextInputManager::~DSWaylandTextInputManager() { } -void DSWaylandTextInputManager::createTextInput(void *client) +void DSWaylandTextInputManager::createTextInput(void *client, unsigned int managerId) { - __textInput->createGlobal(client, allocTextInputId()); + __textInput->createGlobal(client, managerId, allocTextInputId()); } int DSWaylandTextInputManager::allocTextInputId() @@ -208,9 +208,9 @@ DSWaylandTextInputPrivate::~DSWaylandTextInputPrivate() { } -void DSWaylandTextInputPrivate::createGlobal(void *client, int id) +void DSWaylandTextInputPrivate::createGlobal(void *client, unsigned int managerId, int id) { - Resource *resource = add((struct ::wl_client *)client, 1); + Resource *resource = add((struct ::wl_client *)client, managerId, 1); __resourceIdMap.insert(std::pair(resource, id)); } @@ -860,11 +860,11 @@ DSWaylandTextInput::~DSWaylandTextInput() { } -void DSWaylandTextInput::createGlobal(void *client, int id) +void DSWaylandTextInput::createGlobal(void *client, unsigned int managerId, int id) { DS_GET_PRIV(DSWaylandTextInput); - priv->createGlobal(client, id); + priv->createGlobal(client, managerId, id); } void DSWaylandTextInput::showInputPanel() diff --git a/src/DSWaylandServer/DSWaylandTextInput.h b/src/DSWaylandServer/DSWaylandTextInput.h index c40c922..7648814 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.h +++ b/src/DSWaylandServer/DSWaylandTextInput.h @@ -42,7 +42,7 @@ public: DSWaylandTextInput(DSWaylandCompositor *compositor, DSWaylandTextInputManager *textInputManager, DSTextInputPrivate *dsTextInputPrivate); ~DSWaylandTextInput() override; - void createGlobal(void *client, int id); + void createGlobal(void *client, unsigned int managerId, int id); void showInputPanel(); void hideInputPanel(); diff --git a/src/DSWaylandServer/DSWaylandTextInputManager.h b/src/DSWaylandServer/DSWaylandTextInputManager.h index 7a314e5..da94210 100644 --- a/src/DSWaylandServer/DSWaylandTextInputManager.h +++ b/src/DSWaylandServer/DSWaylandTextInputManager.h @@ -43,7 +43,7 @@ public: DSWaylandTextInputManager(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate); ~DSWaylandTextInputManager() override; - void createTextInput(void *client); + void createTextInput(void *client, unsigned int managerId); int allocTextInputId(); void contextCommitString(unsigned int serial, std::string text); diff --git a/src/DSWaylandServer/DSWaylandTextInputPrivate.h b/src/DSWaylandServer/DSWaylandTextInputPrivate.h index 7d98454..2d168d6 100644 --- a/src/DSWaylandServer/DSWaylandTextInputPrivate.h +++ b/src/DSWaylandServer/DSWaylandTextInputPrivate.h @@ -40,7 +40,7 @@ public: DSWaylandTextInputPrivate(DSWaylandTextInput *p_ptr, DSWaylandCompositor *compositor); ~DSWaylandTextInputPrivate() override; - void createGlobal(void *client, int id); + void createGlobal(void *client, unsigned int managerId, int id); int getResourceId(Resource *resource); void showInputPanel(void *resource); void hideInputPanel(Resource *resource, bool forceHide); -- 2.7.4 From 00d075005c103f8139093d4ebce0bdee6b0db88d Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 14:13:32 +0900 Subject: [PATCH 16/16] exampleCompositor: enable a DSTextInput Change-Id: I79bda1490aba4bcfa20dca54ea62fb1b19e41ec0 --- samples/exampleCompositor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/exampleCompositor.cpp b/samples/exampleCompositor.cpp index a544023..27787f5 100644 --- a/samples/exampleCompositor.cpp +++ b/samples/exampleCompositor.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "DSDebugLog.h" using namespace display_server; @@ -67,6 +68,8 @@ public: __canvas->attachPolicyArea(__policyArea); __canvas->attachDisplayArea(__displayArea); + __textInput = std::make_shared(); + return __canvas; } @@ -99,6 +102,7 @@ private: std::shared_ptr __seat; std::shared_ptr __policyArea; std::shared_ptr __displayArea; + std::shared_ptr __textInput; }; int main() { -- 2.7.4