From 63ce11bb090d2eee5a3d80018bf4e7460f6c2679 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 30 Jul 2020 17:12:05 +0900 Subject: [PATCH 01/16] DSBuffer: add canAquireBuffer method in DSBufferQueue Change-Id: Ic7aab2ea2843725a5d85c6a30c257294069f8b67 --- src/DSBuffer/DSBufferQueueTBMImpl.cpp | 10 ++++++++++ src/DSBuffer/DSBufferQueueTBMImpl.h | 2 ++ src/DSBuffer/IDSBufferQueue.h | 2 ++ tests/DSBufferTBMImpl-test.cpp | 13 ++++++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/DSBuffer/DSBufferQueueTBMImpl.cpp b/src/DSBuffer/DSBufferQueueTBMImpl.cpp index 08eb77e..c73e199 100644 --- a/src/DSBuffer/DSBufferQueueTBMImpl.cpp +++ b/src/DSBuffer/DSBufferQueueTBMImpl.cpp @@ -124,4 +124,14 @@ bool DSBufferQueueTBMImpl::releaseBuffer(std::shared_ptr buffer) return true; } +bool DSBufferQueueTBMImpl::canAcquireBuffer(bool wait) +{ + if (!tbm_surface_queue_can_acquire(__tqueue, wait)) { + DSLOG_ERR("BuffeQueueTBM", "tbm_surface_queue_can_acquire fails."); + return false; + } + + return true; +} + } diff --git a/src/DSBuffer/DSBufferQueueTBMImpl.h b/src/DSBuffer/DSBufferQueueTBMImpl.h index a4e06e3..f5919b3 100644 --- a/src/DSBuffer/DSBufferQueueTBMImpl.h +++ b/src/DSBuffer/DSBufferQueueTBMImpl.h @@ -24,6 +24,8 @@ public: std::shared_ptr acquireBuffer() override; bool releaseBuffer(std::shared_ptr buffer) override; + bool canAcquireBuffer(bool wait) override; + private: int __slotSize; int __bufferWidth; diff --git a/src/DSBuffer/IDSBufferQueue.h b/src/DSBuffer/IDSBufferQueue.h index a3e719d..4750374 100644 --- a/src/DSBuffer/IDSBufferQueue.h +++ b/src/DSBuffer/IDSBufferQueue.h @@ -19,6 +19,8 @@ public: virtual bool enqueueBuffer(std::shared_ptr ) = 0; virtual std::shared_ptr acquireBuffer() = 0; virtual bool releaseBuffer(std::shared_ptr ) = 0; + + virtual bool canAcquireBuffer(bool wait) = 0; }; } diff --git a/tests/DSBufferTBMImpl-test.cpp b/tests/DSBufferTBMImpl-test.cpp index f2758e8..6a96113 100644 --- a/tests/DSBufferTBMImpl-test.cpp +++ b/tests/DSBufferTBMImpl-test.cpp @@ -103,4 +103,15 @@ TEST_F(DSBufferTBMImplTest, DequeueBuffer_4Times) EXPECT_TRUE(bufferQueue->releaseBuffer(buffer4)); EXPECT_TRUE(bufferQueue->releaseBuffer(buffer5)); EXPECT_TRUE(bufferQueue->releaseBuffer(buffer6)); -} \ No newline at end of file +} + +TEST_F(DSBufferTBMImplTest, CanAcquireBuffer) +{ + auto bufferQueue = std::make_unique(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); + EXPECT_TRUE(bufferQueue.get() != nullptr); + + auto buffer1 = bufferQueue->dequeueBuffer(); + EXPECT_TRUE(buffer1 != nullptr); + EXPECT_TRUE(bufferQueue->enqueueBuffer(buffer1)); + EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); +} -- 2.7.4 From 17447dc9dc477bde7c3faddfe3aee367ac8a9e75 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 30 Jul 2020 15:41:13 +0900 Subject: [PATCH 02/16] DSWindow : create DSWindow with DSWaylandSurface DSWindow is associated with DSWaylandSurface. Change-Id: Ibbeb53b74c8ff0904e0bf2f96f182b0a6dc14b35 --- src/DSWindow/DSWindow.cpp | 82 ++++++++---------------------------------- src/DSWindow/DSWindow.h | 13 +++---- src/DSWindow/DSWindowPrivate.h | 8 ++--- src/DSZone/DSZone.cpp | 7 +--- tests/DSWindow-test.cpp | 41 ++++++--------------- 5 files changed, 32 insertions(+), 119 deletions(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 52d6eba..a64c771 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -1,5 +1,6 @@ #include "DSWindow.h" #include "DSWindowPrivate.h" +#include "DSWaylandSurface.h" namespace display_server { @@ -12,7 +13,8 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) __w(1), __h(1), __created(false), - __hasFocus(false) + __hasFocus(false), + __waylandSurface(nullptr) { } @@ -20,20 +22,12 @@ DSWindowPrivate::~DSWindowPrivate() { } -bool DSWindowPrivate::create(DSWindow *pParent) +bool DSWindowPrivate::create(std::shared_ptr waylandSurface) { - // get screen position (x, y) + __waylandSurface = waylandSurface; + __created = true; - // get screen width (w, h) - - __created = __create(__x, __y, __w, __h, pParent); - return __created; -} - -bool DSWindowPrivate::create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent) -{ - __created = __create(x, y, w, h, pParent); - return __created; + return true; } void DSWindowPrivate::destroy(void) @@ -75,44 +69,19 @@ bool DSWindowPrivate::setFocus(void) return true; } -bool DSWindowPrivate::__create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent) -{ - DS_GET_PUB(DSWindow); - - __x = x; - __y = y; - __w = w; - __h = h; - pub->__parentWindow = pParent; - - // Do something - - return true; -} - bool DSWindowPrivate::isCreated() { return __created; } DSWindow::DSWindow() - : DS_INIT_PRIVATE_PTR(DSWindow), - __parentWindow(nullptr) -{ -} + : DS_INIT_PRIVATE_PTR(DSWindow) +{} -DSWindow::DSWindow(DSWindow *pParent) - : DS_INIT_PRIVATE_PTR(DSWindow), - __parentWindow(pParent) +DSWindow::DSWindow(std::shared_ptr waylandSurface) + : DS_INIT_PRIVATE_PTR(DSWindow) { - create(pParent); -} - -DSWindow::DSWindow(DSWindow *pParent, int x, int y, unsigned int w, unsigned h) - : DS_INIT_PRIVATE_PTR(DSWindow), - __parentWindow(pParent) -{ - create(x, y, w, h, pParent); + create(waylandSurface); } DSWindow::~DSWindow() @@ -120,25 +89,13 @@ DSWindow::~DSWindow() } -bool DSWindow::create(DSWindow *pParent) +bool DSWindow::create(std::shared_ptr waylandSurface) { DS_GET_PRIV(DSWindow); if (!priv->isCreated()) { - return priv->create(pParent); - } - - return true; -} - -bool DSWindow::create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent) -{ - DS_GET_PRIV(DSWindow); - - if (!priv->isCreated()) - { - return priv->create(x, y, w, h, pParent); + return priv->create(waylandSurface); } return true; @@ -208,17 +165,6 @@ bool DSWindow::hasFocus(void) return priv->__hasFocus; } -DSWindow *DSWindow::getParent() -{ - return __parentWindow; -} - -void DSWindow::setParent(DSWindow *pParent) -{ - DSLOG_INF("DSWindow", "Parent window has been changed. (%p -> %p)", __parentWindow, pParent); - __parentWindow = pParent; -} - stGeometry DSWindow::getGeometry() { DS_GET_PRIV(DSWindow); diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index fca506b..45181ee 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -9,6 +9,7 @@ namespace display_server { class DSWindowPrivate; +class DSWaylandSurface; class DSWindow : public DSObject { @@ -16,13 +17,10 @@ class DSWindow : public DSObject public: explicit DSWindow(); - DSWindow(DSWindow *pParent); - DSWindow(DSWindow *pParent, int x, int y, unsigned int w, unsigned h); + DSWindow(std::shared_ptr waylandSurface); virtual ~DSWindow(); - bool create(DSWindow *pParent); - bool create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent); - + bool create(std::shared_ptr waylandSurface); void destroy(void); bool show(void); @@ -36,9 +34,6 @@ public: bool setFocus(void); bool hasFocus(void); - DSWindow *getParent(); - void setParent(DSWindow *pParent); - stGeometry getGeometry(); protected: @@ -46,7 +41,7 @@ protected: //virtual bool _onShowStateChange(void); private: - DSWindow *__parentWindow; + std::shared_ptr __waylandSurface; }; } diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index 44f284b..28eeeea 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -8,6 +8,7 @@ namespace display_server { class DSWindow; +class DSWindowWaylandSurface; class DSWindowPrivate : public DSObjectPrivate { @@ -18,9 +19,7 @@ public: DSWindowPrivate(DSWindow *p_ptr); ~DSWindowPrivate(); - bool create(DSWindow *pParent); - bool create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent); - + bool create(std::shared_ptr waylandSurface); void destroy(void); bool show(void); @@ -35,14 +34,13 @@ public: bool isCreated(); private: - bool __create(int x, int y, unsigned int w, unsigned int h, DSWindow *pParent); - int __x; int __y; unsigned int __w; unsigned int __h; bool __created; bool __hasFocus; + std::shared_ptr __waylandSurface; }; } diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index d26892e..3970f49 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -62,14 +62,9 @@ void DSZone::callCallbackWindowCreated() void DSZone::onSurfaceCreated(std::shared_ptr waylandSurface) { // create DSWindow - std::shared_ptr window = std::make_shared(); + std::shared_ptr window = std::make_shared(waylandSurface); __windowList.push_front(window); - //TODO: fix the vaules of (x, y, w, h) - // DSWindow does not need to provide the interface to set the (x, y, w, h). - // Those values have to be determined by the window manager policy (DSWindowShell). - window->create(0, 0, 720, 1280, NULL); - // emit a signal of the surface committed __windowCreatedSignal.emit(window); } diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp index 9838ca8..3f11ba4 100644 --- a/tests/DSWindow-test.cpp +++ b/tests/DSWindow-test.cpp @@ -20,45 +20,24 @@ TEST_F(DSWindowTest, NewDSWindow) EXPECT_TRUE(win != nullptr); } -TEST_F(DSWindowTest, NewDSWindowWithParent) +TEST_F(DSWindowTest, NewDSWindowWithDSWaylandSurface) { - DSWindow *wParent = new DSWindow(); - EXPECT_TRUE(wParent != nullptr); - - DSWindow *wChild = new DSWindow(wParent); - EXPECT_TRUE(wChild != nullptr); -} - -TEST_F(DSWindowTest, NewDSWindowWithGeometry) -{ - int x = 100; - int y = 100; - unsigned int w = 500; - unsigned int h = 500; - - DSWindow *win = new DSWindow(nullptr, x, y, w, h); - EXPECT_TRUE(win != nullptr); - - stGeometry geom = win->getGeometry(); - EXPECT_TRUE(geom.x == x); - EXPECT_TRUE(geom.y == y); - EXPECT_TRUE(geom.w == w); - EXPECT_TRUE(geom.h == h); + auto waylandSurface = std::make_shared(); + EXPECT_TRUE(waylandSurface != nullptr); + auto window = std::make_shared(waylandSurface); + EXPECT_TRUE(window != nullptr); } TEST_F(DSWindowTest, BasicMethods) { - bool hasFocus = false; - - DSWindow *win = new DSWindow(); + auto win = new DSWindow(); EXPECT_TRUE(win != nullptr); - EXPECT_TRUE(win->create(0, 0, 720, 1280, nullptr) == true); stGeometry geom = win->getGeometry(); EXPECT_TRUE(geom.x == 0); EXPECT_TRUE(geom.y == 0); - EXPECT_TRUE(geom.w == 720); - EXPECT_TRUE(geom.h == 1280); + EXPECT_TRUE(geom.w == 1); + EXPECT_TRUE(geom.h == 1); EXPECT_TRUE(win->show() == true); EXPECT_TRUE(win->hide(true) == true); @@ -69,6 +48,6 @@ TEST_F(DSWindowTest, BasicMethods) EXPECT_TRUE(win->raise() == true); EXPECT_TRUE(win->lower() == true); - hasFocus = win->setFocus(); - EXPECT_TRUE(hasFocus == win->hasFocus()); + EXPECT_TRUE(win->setFocus() == true); + EXPECT_TRUE(win->hasFocus() == true); } \ No newline at end of file -- 2.7.4 From b7fcf497a1b82f4ca6f19fe83a568d84a8f48545 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 30 Jul 2020 16:02:41 +0900 Subject: [PATCH 03/16] DSCanvas : fix the test fail Check the __policyArea at attachPolicyArea method Change-Id: I6bfc8f46528b1b9de21dc9047f92c93ad7687c70 --- src/DSCanvas/DSCanvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSCanvas/DSCanvas.cpp b/src/DSCanvas/DSCanvas.cpp index 959facc..a1fc99e 100644 --- a/src/DSCanvas/DSCanvas.cpp +++ b/src/DSCanvas/DSCanvas.cpp @@ -46,7 +46,7 @@ DSCanvasPrivate::~DSCanvasPrivate() bool DSCanvasPrivate::attachPolicyArea(std::shared_ptr policyArea) { - if (policyArea) { + if (__policyArea) { DSLOG_ERR("DSCanvasPrivate", "canvas has already policyArea(%p).", __policyArea); return false; } -- 2.7.4 From b6ee1101e71b492fae501b972cbcb4f0c94948bd Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 30 Jul 2020 17:56:40 +0900 Subject: [PATCH 04/16] DSDisplayArea: store DSZone Change-Id: I7927fcd662ab8174560ad4cf977ac4d888bbb44e --- src/DSDisplayArea/DSDisplayArea.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index a716dbf..ca65a8e 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -117,6 +117,7 @@ std::shared_ptr DSDisplayAreaPrivate::getOutput() bool DSDisplayAreaPrivate::addZone(std::shared_ptr zone) { + __zone = zone; __zone->registerCallbackWindowCreated(this, std::bind(&DSDisplayAreaPrivate::__onWindowCreated, this, std::placeholders::_1)); return true; -- 2.7.4 From cfeacd2e3eb1a77d637780954e0365c9435b9569 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 30 Jul 2020 19:14:57 +0900 Subject: [PATCH 05/16] DSOutput: add getDisplayDeviceOutput method Change-Id: Ia9731d22897c2d9addfde2c083b8906a226b8a03 --- src/DSOutput/DSOutputImpl.cpp | 5 +++++ src/DSOutput/DSOutputImpl.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/DSOutput/DSOutputImpl.cpp b/src/DSOutput/DSOutputImpl.cpp index ac43483..b97d6d4 100644 --- a/src/DSOutput/DSOutputImpl.cpp +++ b/src/DSOutput/DSOutputImpl.cpp @@ -50,6 +50,11 @@ bool DSOutputImpl::applyResolutionAuto() return true; } +std::shared_ptr DSOutputImpl::getDisplayDeviceOutput() +{ + return __displayDeviceOutput; +} + std::shared_ptr DSOutputImpl::getDisplayBufferQueue() { std::shared_ptr displayDeviceHWC = __displayDeviceOutput->getHWC(); diff --git a/src/DSOutput/DSOutputImpl.h b/src/DSOutput/DSOutputImpl.h index a16c546..b0792ff 100644 --- a/src/DSOutput/DSOutputImpl.h +++ b/src/DSOutput/DSOutputImpl.h @@ -17,6 +17,7 @@ public: int getResolutionHeight() override; bool applyResolutionAuto() override; + std::shared_ptr getDisplayDeviceOutput(); std::shared_ptr getDisplayBufferQueue(); private: -- 2.7.4 From 995da2a3ddef88d18076ec3ee8da6bc4a7109a07 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 30 Jul 2020 19:15:47 +0900 Subject: [PATCH 06/16] DSDisplayArea: get the IDisplayDeviceOutput DSDisplayAreaPrivate gets - IDSDisplayDeviceOutput from DSOutputImpl - IDSDisplayDeivceHWC from IDSDisplayDeviceOutput - IDSBufferQueue from IDSDisplayDeivceHWC Change-Id: Ifb2b7576d425a7639e0441fc52ac110e3a4b4eb6 --- src/DSDisplayArea/DSDisplayArea.cpp | 13 ++++++++++++- src/DSDisplayArea/DSDisplayAreaPrivate.h | 4 ++++ src/DSOutput/DSOutputImpl.cpp | 11 ----------- src/DSOutput/DSOutputImpl.h | 1 - 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index ca65a8e..29e0e42 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -58,6 +58,8 @@ DSDisplayAreaPrivate::DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), __output(output), + __displayDeviceOutput(nullptr), + __displayDeviceHWC(nullptr), __zone(nullptr), __renderEngine(nullptr), __x(0), @@ -66,7 +68,16 @@ DSDisplayAreaPrivate::DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr __height(0) { auto outputImpl = std::dynamic_pointer_cast(output); // down-casting of std::shared_ptr - auto bufferQueue = outputImpl->getDisplayBufferQueue(); + + __displayDeviceOutput = outputImpl->getDisplayDeviceOutput(); + if (!__displayDeviceOutput) + DSLOG_ERR("DSCanvasPrivate", "__displayDeviceOutput is null."); + + __displayDeviceHWC = __displayDeviceOutput->getHWC(); + if (!__displayDeviceHWC) + DSLOG_ERR("DSCanvasPrivate", "__displayDeviceHWC is null."); + + auto bufferQueue = __displayDeviceHWC->getTargetBufferQueue(); if (!bufferQueue) DSLOG_ERR("DSDisplayAreaPrivate", "bufferQueue is null."); diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h index b112f03..c19910c 100644 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ b/src/DSDisplayArea/DSDisplayAreaPrivate.h @@ -6,6 +6,8 @@ #include "DSZone.h" #include "IDSRenderEngine.h" #include +#include "IDSDisplayDeviceOutput.h" +#include "IDSDisplayDeviceHWC.h" #include namespace display_server @@ -33,6 +35,8 @@ private: void __onWindowCreated(std::shared_ptr window); std::shared_ptr __output; + std::shared_ptr __displayDeviceOutput; + std::shared_ptr __displayDeviceHWC; std::shared_ptr __zone; std::shared_ptr __renderEngine; int __x, __y; diff --git a/src/DSOutput/DSOutputImpl.cpp b/src/DSOutput/DSOutputImpl.cpp index b97d6d4..b51dbd4 100644 --- a/src/DSOutput/DSOutputImpl.cpp +++ b/src/DSOutput/DSOutputImpl.cpp @@ -55,15 +55,4 @@ std::shared_ptr DSOutputImpl::getDisplayDeviceOutput() return __displayDeviceOutput; } -std::shared_ptr DSOutputImpl::getDisplayBufferQueue() -{ - std::shared_ptr displayDeviceHWC = __displayDeviceOutput->getHWC(); - if (!displayDeviceHWC) { - DSLOG_ERR("DSOutputImpl", "displayDeviceHWC is NULL."); - return nullptr; - } - - return displayDeviceHWC->getTargetBufferQueue(); -} - } // namespace display_server diff --git a/src/DSOutput/DSOutputImpl.h b/src/DSOutput/DSOutputImpl.h index b0792ff..de0eb85 100644 --- a/src/DSOutput/DSOutputImpl.h +++ b/src/DSOutput/DSOutputImpl.h @@ -18,7 +18,6 @@ public: bool applyResolutionAuto() override; std::shared_ptr getDisplayDeviceOutput(); - std::shared_ptr getDisplayBufferQueue(); private: int __resolutionWidth; -- 2.7.4 From 1768dde8e92fca9f916fa1de5d20a99308300318 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 30 Jul 2020 19:24:48 +0900 Subject: [PATCH 07/16] DSDisplayArea: add DSRenderView to the list Change-Id: I5c64fdcc32b2dab36d15afc00dcaa7989fe74917 --- src/DSDisplayArea/DSDisplayArea.cpp | 2 +- src/DSDisplayArea/DSDisplayAreaPrivate.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index 29e0e42..39b31da 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -136,7 +136,7 @@ bool DSDisplayAreaPrivate::addZone(std::shared_ptr zone) void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) { - std::shared_ptr renderView = __renderEngine->makeRenderView(window); + __renderViewList.push_back(__renderEngine->makeRenderView(window)); } } // namespace display_server diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h index c19910c..9d85994 100644 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ b/src/DSDisplayArea/DSDisplayAreaPrivate.h @@ -41,6 +41,7 @@ private: std::shared_ptr __renderEngine; int __x, __y; int __width, __height; + std::list> __renderViewList; }; } -- 2.7.4 From 8f73f6748a274d904ea3f2e82e0c775318261ed4 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 30 Jul 2020 19:34:20 +0900 Subject: [PATCH 08/16] DSDisplayDevice: DSDisplayDeviceHWCWindow has DSWindow DSDisplayDeviceHWCWindow can get the window information from DSWindow Change-Id: I1b6f28b1dec4a6f76e4e004ff44deb966bdb3ace --- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp | 4 ++-- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h | 2 +- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp | 5 +++-- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h | 6 ++++-- src/DSDisplayDevice/IDSDisplayDeviceHWC.h | 4 +++- tests/DSDisplayDeviceTDMImpl-test.cpp | 5 +++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp index fea17fd..89ab367 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp @@ -52,7 +52,7 @@ bool DSDisplayDeviceHWCTDMImpl::setTargetBuffer(std::shared_ptr buffe return true; } -std::shared_ptr DSDisplayDeviceHWCTDMImpl::makeHWCWindow() +std::shared_ptr DSDisplayDeviceHWCTDMImpl::makeHWCWindow(std::shared_ptr window) { std::shared_ptr deviceHWCWindow; tdm_error terror; @@ -64,7 +64,7 @@ std::shared_ptr DSDisplayDeviceHWCTDMImpl::makeHWCWin return nullptr; } - deviceHWCWindow = std::make_shared(twindow); + deviceHWCWindow = std::make_shared(window, twindow); if (!deviceHWCWindow) { DSLOG_ERR("HWCTDM", "new DSDisplayDeviceHWCWindowTDMImpl fails."); return nullptr; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h index ba1daaf..e08b913 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h @@ -16,7 +16,7 @@ public: std::shared_ptr getTargetBufferQueue() override; bool setTargetBuffer(std::shared_ptr buffer) override; - std::shared_ptr makeHWCWindow() override; + std::shared_ptr makeHWCWindow(std::shared_ptr window) override; bool addVisibleHWCWindow(std::shared_ptr deviceHWCWindow) override; bool removeVisibleHWCWindow(std::shared_ptr deviceHWCWindow) override; void clearVisibleHWCWindows() override; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp index 3fde0ef..f1f8d42 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp @@ -4,8 +4,9 @@ namespace display_server { -DSDisplayDeviceHWCWindowTDMImpl::DSDisplayDeviceHWCWindowTDMImpl(tdm_hwc_window *twindow) - : __twindow(twindow) +DSDisplayDeviceHWCWindowTDMImpl::DSDisplayDeviceHWCWindowTDMImpl(std::shared_ptr window, tdm_hwc_window *twindow) + : __window(window), + __twindow(twindow) {} DSDisplayDeviceHWCWindowTDMImpl::~DSDisplayDeviceHWCWindowTDMImpl() { diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h index d4d9bbf..2efda71 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h @@ -2,6 +2,7 @@ #define _I_DS_DISPLAY_DEVICE_HWC_WINDOW_TDM_IMPL_H_ #include "IDSDisplayDeviceHWCWindow.h" +#include "DSWindow.h" #include namespace display_server @@ -9,11 +10,12 @@ namespace display_server class DSDisplayDeviceHWCWindowTDMImpl : public IDSDisplayDeviceHWCWindow { public: - DSDisplayDeviceHWCWindowTDMImpl(tdm_hwc_window *twindow); + DSDisplayDeviceHWCWindowTDMImpl(std::shared_ptr window, tdm_hwc_window *twindow); ~DSDisplayDeviceHWCWindowTDMImpl(); tdm_hwc_window *getNativeHWCWindow(); private: - tdm_hwc_window* __twindow; + std::shared_ptr __window; + tdm_hwc_window *__twindow; }; } diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWC.h b/src/DSDisplayDevice/IDSDisplayDeviceHWC.h index 154b4d7..8d6c77c 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWC.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceHWC.h @@ -8,6 +8,8 @@ namespace display_server { +class DSWindow; + class IDSDisplayDeviceHWC { public: @@ -15,7 +17,7 @@ public: virtual std::shared_ptr getTargetBufferQueue() = 0; virtual bool setTargetBuffer(std::shared_ptr buffer) = 0; - virtual std::shared_ptr makeHWCWindow() = 0; + virtual std::shared_ptr makeHWCWindow(std::shared_ptr window) = 0; virtual bool addVisibleHWCWindow(std::shared_ptr deviceHWCWindow) = 0; virtual bool removeVisibleHWCWindow(std::shared_ptr deviceHWCWindow) = 0; virtual void clearVisibleHWCWindows() = 0; diff --git a/tests/DSDisplayDeviceTDMImpl-test.cpp b/tests/DSDisplayDeviceTDMImpl-test.cpp index b9a3b89..640d5fb 100644 --- a/tests/DSDisplayDeviceTDMImpl-test.cpp +++ b/tests/DSDisplayDeviceTDMImpl-test.cpp @@ -1,4 +1,5 @@ #include "libds-tests.h" +#include "DSWindow.h" #include "DSDisplayDeviceTDMImpl.h" #include "DSDisplayDeviceOutputTDMImpl.h" @@ -231,7 +232,7 @@ TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_makeHWCWindow) deviceHWC = output->getHWC(); EXPECT_TRUE(deviceHWC != nullptr); - deviceHWCWindow = deviceHWC->makeHWCWindow(); + deviceHWCWindow = deviceHWC->makeHWCWindow(std::make_shared()); EXPECT_TRUE(deviceHWC != nullptr); } } @@ -265,7 +266,7 @@ TEST_F(DSDisplayDeviceTDMImplTest, DeviceHWC_commit) auto bufferQueue = deviceHWC->getTargetBufferQueue(); EXPECT_TRUE(deviceHWC != nullptr); - deviceHWCWindow = deviceHWC->makeHWCWindow(); + deviceHWCWindow = deviceHWC->makeHWCWindow(std::make_shared()); EXPECT_TRUE(deviceHWC != nullptr); EXPECT_TRUE(deviceHWC->addVisibleHWCWindow(deviceHWCWindow)); -- 2.7.4 From 6e5df43970e2bac639c7eb57cd9373561d913d37 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 30 Jul 2020 20:36:16 +0900 Subject: [PATCH 09/16] Test: add test for DSOutputImpl::getDisplayDeviceOutput Change-Id: I3fadb8f3fbf19bec4b14e137a29cc7779779053f --- tests/DSOutputImpl-test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/DSOutputImpl-test.cpp b/tests/DSOutputImpl-test.cpp index 6e49d3f..1b983f8 100644 --- a/tests/DSOutputImpl-test.cpp +++ b/tests/DSOutputImpl-test.cpp @@ -33,4 +33,5 @@ TEST_F(DSOutputTest, BasicMethods) EXPECT_TRUE(output->getResolutionWidth() != 0); EXPECT_TRUE(output->getResolutionHeight() != 0); EXPECT_TRUE(output->applyResolutionAuto() == true); + EXPECT_TRUE(output->getDisplayDeviceOutput() == displayDeviceOutput); } -- 2.7.4 From 6d99964eb86008b92281b7c0c4dbba888d574f8b Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 30 Jul 2020 20:50:57 +0900 Subject: [PATCH 10/16] DSDisplayArea: make IDSDisplayDeviceHWCWindow Change-Id: Ieeb7f8b122d8aadae69bb7baeb5c1bd9c90e78ca --- src/DSDisplayArea/DSDisplayArea.cpp | 1 + src/DSDisplayArea/DSDisplayAreaPrivate.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index 39b31da..a67494d 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -137,6 +137,7 @@ bool DSDisplayAreaPrivate::addZone(std::shared_ptr zone) void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) { __renderViewList.push_back(__renderEngine->makeRenderView(window)); + __displayDeviceHWCWindowList.push_back(__displayDeviceHWC->makeHWCWindow(window)); } } // namespace display_server diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h index 9d85994..32d7c70 100644 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ b/src/DSDisplayArea/DSDisplayAreaPrivate.h @@ -42,6 +42,7 @@ private: int __x, __y; int __width, __height; std::list> __renderViewList; + std::list> __displayDeviceHWCWindowList; }; } -- 2.7.4 From 4a3aa8d4420f7fc402d6c5d8e3e1b8166e4bf325 Mon Sep 17 00:00:00 2001 From: jeon Date: Thu, 30 Jul 2020 19:46:28 +0900 Subject: [PATCH 11/16] DSXkb: Imply xkb to get keyname and update modifiers Change-Id: I8f4064428691e949e9447e3894616571eae00900 --- src/DSInput/DSInput.cpp | 37 +++++++++++- src/DSInput/DSInput.h | 3 + src/DSInput/DSInputEvent.h | 1 + src/DSSeat/DSSeat.cpp | 5 +- src/DSSeat/DSSeat.h | 2 + src/DSXkb/DSXkb.cpp | 140 ++++++++++++++++++++++++++++++++++++++++++++- src/DSXkb/DSXkb.h | 4 +- src/DSXkb/DSXkbPrivate.h | 13 ++++- tests/DSXkb-test.cpp | 82 ++++++++++++++++++++++++++ 9 files changed, 279 insertions(+), 8 deletions(-) diff --git a/src/DSInput/DSInput.cpp b/src/DSInput/DSInput.cpp index a1bf408..817755a 100644 --- a/src/DSInput/DSInput.cpp +++ b/src/DSInput/DSInput.cpp @@ -2,6 +2,7 @@ #include "DSInputPrivate.h" #include "DSSeat.h" #include "DSInputEvent.h" +#include "DSXkb.h" namespace display_server { @@ -104,14 +105,16 @@ void DSInput::__initiaiize_ecore_event_types() DSInput::DSInput() : DS_INIT_PRIVATE_PTR(DSInput), - __seat(nullptr) + __seat(nullptr), + __xkb(nullptr) { __initiaiize_ecore_event_types(); } DSInput::DSInput(DSSeat *seat) : DS_INIT_PRIVATE_PTR(DSInput), - __seat(seat) + __seat(seat), + __xkb(nullptr) { if (seat == nullptr) { @@ -122,6 +125,21 @@ DSInput::DSInput(DSSeat *seat) __initiaiize_ecore_event_types(); } +DSInput::DSInput(DSSeat *seat, DSXkb *xkb) + : DS_INIT_PRIVATE_PTR(DSInput), + __seat(seat), + __xkb(xkb) +{ + if (seat == nullptr) + { + DSLOG_ERR("DSInput", "DSSeat ptr is required."); + return; + } + + __initiaiize_ecore_event_types(); +} + + DSInput::~DSInput() { for (auto eventHandler : __eventHandlerList) @@ -192,6 +210,11 @@ void DSInput::keyDown(int keycode, std::string devIdentifier, DSInput::DeviceCla DSLOG_DBG("DSInput", "[keyDown] keycode: %d, identifier: %d\n", keycode, devIdentifier); DSInputDevice *device = findDevice(devIdentifier, devClass); DSInputKeyboardEvent *ev = new DSInputKeyboardEvent(std::make_shared(*device), DSInputEvent::KeyDownEvent, 0, keycode); + if (__xkb) + { + __xkb->updateModifier(keycode, true); + ev->setKeyname(__xkb->getKeyname(keycode)); + } ecore_event_add(DS_INPUT_EVENT_KEY_DOWN, (void *)ev, nullptr, nullptr); } @@ -200,6 +223,11 @@ void DSInput::keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass DSLOG_DBG("DSInput", "[keyUp] keycode: %d, identifier: %d\n", keycode, devIdentifier); DSInputDevice *device = findDevice(devIdentifier, devClass); DSInputKeyboardEvent *ev = new DSInputKeyboardEvent(std::make_shared(*device), DSInputEvent::KeyUpEvent, 0, keycode); + if (__xkb) + { + __xkb->updateModifier(keycode, false); + ev->setKeyname(__xkb->getKeyname(keycode)); + } ecore_event_add(DS_INPUT_EVENT_KEY_UP, (void *)ev, nullptr, nullptr); } @@ -446,6 +474,11 @@ const std::string DSInputKeyboardEvent::getKeyname() return __keyname; } +void DSInputKeyboardEvent::setKeyname(std::string name) +{ + __keyname = name; +} + DSInputMouseEvent::DSInputMouseEvent() : DSInputEvent(nullptr, NoneEvent, 0), diff --git a/src/DSInput/DSInput.h b/src/DSInput/DSInput.h index 6f53993..3555256 100644 --- a/src/DSInput/DSInput.h +++ b/src/DSInput/DSInput.h @@ -17,6 +17,7 @@ namespace display_server class DSSeat; class DSInputPrivate; class DSInputDevice; +class DSXkb; class DSInput : public DSObject { @@ -34,6 +35,7 @@ public: public: DSInput(); DSInput(DSSeat *seat); + DSInput(DSSeat *seat, DSXkb *xkb); ~DSInput() override; void init(); @@ -64,6 +66,7 @@ public: private: DSSeat* __seat; + DSXkb* __xkb; std::list devList; DSSignal> __deviceAddSignal; diff --git a/src/DSInput/DSInputEvent.h b/src/DSInput/DSInputEvent.h index 7a8f75e..b737289 100644 --- a/src/DSInput/DSInputEvent.h +++ b/src/DSInput/DSInputEvent.h @@ -55,6 +55,7 @@ public: const int getKeycode(); const std::string getKeyname(); + void setKeyname(std::string name); protected: int __keycode; diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index b911c17..2a49039 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -5,6 +5,7 @@ #include "DSWaylandSeat.h" #include "DSWaylandCompositor.h" #include "DSInputEvent.h" +#include "DSXkb.h" namespace display_server { @@ -18,6 +19,7 @@ DSSeat::DSSeat() __dswlSeat(nullptr), __dswlComp(nullptr), __compositor(nullptr), + __xkb(nullptr), __numPointer(0), __numKeyboard(0), __numTouch(0) @@ -32,6 +34,7 @@ DSSeat::DSSeat(DSCompositor *compositor, std::string name) __dswlSeat(nullptr), __dswlComp(nullptr), __compositor(compositor), + __xkb(new DSXkb(this)), __numPointer(0), __numKeyboard(0), __numTouch(0) @@ -48,7 +51,7 @@ DSSeat::DSSeat(DSCompositor *compositor, std::string name) if (!name.empty()) __dswlSeat->setName(name); - __input = new DSInput(this); + __input = new DSInput(this, __xkb); DS_ASSERT(__input != nullptr); __input->registerCallbackDeviceAdd(this, std::bind(&DSSeat::slotDeviceAdd, this, std::placeholders::_1)); diff --git a/src/DSSeat/DSSeat.h b/src/DSSeat/DSSeat.h index a7347a0..5842428 100644 --- a/src/DSSeat/DSSeat.h +++ b/src/DSSeat/DSSeat.h @@ -15,6 +15,7 @@ class DSInputDevice; class DSCompositor; class DSWaylandSeat; class DSWaylandCompositor; +class DSXkb; class DSSeat : public DSObject { @@ -34,6 +35,7 @@ private: DSWaylandSeat *__dswlSeat; DSWaylandCompositor *__dswlComp; DSCompositor *__compositor; + DSXkb *__xkb; uint32_t __numPointer; uint32_t __numKeyboard; diff --git a/src/DSXkb/DSXkb.cpp b/src/DSXkb/DSXkb.cpp index cb8fb70..8a80669 100644 --- a/src/DSXkb/DSXkb.cpp +++ b/src/DSXkb/DSXkb.cpp @@ -1,12 +1,16 @@ #include "DSXkb.h" #include "DSXkbPrivate.h" +#include +#include + namespace display_server { DSXkbPrivate::DSXkbPrivate(DSXkb *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), __xkb_state(nullptr), __xkb_keymap(nullptr), __xkb_context(nullptr), + __keymap_fd(-1), __keymap_size(0), __keymap_area(nullptr), __depressed(0), __latched(0), __locked(0), __group(0) { } @@ -51,6 +55,52 @@ bool DSXkbPrivate::makeKeymap() return true; } +void DSXkbPrivate::mmapKeymap() +{ + char *tmp; + + if (__keymap_area) + { + munmap(__keymap_area, __keymap_size); + } + if (__keymap_fd >= 0) + { + close(__keymap_fd); + __keymap_fd = -1; + } + __keymap_size = 0; + + if (!(tmp = xkb_map_get_as_string(__xkb_keymap))) + { + DSLOG_ERR("DSXkb", "Could not get keymap string"); + return; + } + + __keymap_size = strlen(tmp) + 1; + __keymap_fd = __getKeymapFd(__keymap_size); + if (__keymap_fd < 0) + { + DSLOG_ERR("DSXkb", "Could not create keymap file"); + free(tmp); + __keymap_size = 0; + return; + } + + __keymap_area = (char *)mmap(nullptr, __keymap_size, (PROT_READ | PROT_WRITE), MAP_SHARED, __keymap_fd, 0); + if (__keymap_area == MAP_FAILED) + { + DSLOG_ERR("DSXkb", "Failed to mmap keymap area: %m"); + free(tmp); + __keymap_size = 0; + close(__keymap_fd); + __keymap_fd = -1; + return; + } + + strncpy(__keymap_area, tmp, __keymap_size); + free(tmp); +} + void DSXkbPrivate::updateModifier(int keycode, bool pressed) { enum xkb_key_direction direction; @@ -68,7 +118,7 @@ void DSXkbPrivate::updateModifier(int keycode, bool pressed) __group = xkb_state_serialize_mods(__xkb_state, XKB_STATE_LAYOUT_EFFECTIVE); } -uint32_t DSXkbPrivate::getModifierDePressed() +uint32_t DSXkbPrivate::getModifierDepressed() { return __depressed; } @@ -88,6 +138,16 @@ uint32_t DSXkbPrivate::getModifierGroup() return __group; } +int DSXkbPrivate::getKeymapFd() +{ + return __keymap_fd; +} + +int DSXkbPrivate::getKeymapSize() +{ + return __keymap_size; +} + std::string DSXkbPrivate::getKeyname(int keycode) { int nsyms; @@ -166,6 +226,64 @@ int DSXkbPrivate::getKeycode(std::string keyname) return keycode; } +int DSXkbPrivate::__getKeymapFd(off_t size) +{ + int fd = 0, blen = 0, len = 0; + char *path; + char tmp[PATH_MAX] = {0, }; + long flags; + mode_t old_umask; + + blen = sizeof(tmp) - 20; + + path = getenv("XDG_RUNTIME_DIR"); + if (!path) return -1; + + len = strlen(path) + 19; + if (len < blen) + { + strncpy(tmp, path, PATH_MAX - 20); + strncat(tmp, "/e-wl-keymap-XXXXXX", 19); + free(path); + } + else + { + free(path); + return -1; + } + + old_umask = umask(S_IRWXG|S_IRWXO); + fd = mkstemp(tmp); + umask(old_umask); + + if (fd < 0) + { + return -1; + } + + flags = fcntl(fd, F_GETFD); + if (flags < 0) + { + close(fd); + return -1; + } + + if (fcntl(fd, F_SETFD, (flags | FD_CLOEXEC)) == -1) + { + close(fd); + return -1; + } + + if (ftruncate(fd, size) < 0) + { + close(fd); + return -1; + } + + unlink(tmp); + return fd; +} + DSXkb::DSXkb(DSSeat *seat) : DS_INIT_PRIVATE_PTR(DSXkb), @@ -175,6 +293,7 @@ DSXkb::DSXkb(DSSeat *seat) DS_GET_PRIV(DSXkb); priv->makeKeymap(); + priv->mmapKeymap(); } DSXkb::DSXkb(DSSeat *seat, std::string rules, std::string model, std::string layout, std::string variant, std::string options) @@ -185,6 +304,7 @@ DSXkb::DSXkb(DSSeat *seat, std::string rules, std::string model, std::string lay DS_GET_PRIV(DSXkb); priv->makeKeymap(); + priv->mmapKeymap(); } DSXkb::~DSXkb() @@ -198,11 +318,11 @@ void DSXkb::updateModifier(int keycode, bool pressed) priv->updateModifier(keycode, pressed); } -uint32_t DSXkb::getModifierDePressed() +uint32_t DSXkb::getModifierDepressed() { DS_GET_PRIV(DSXkb); - return priv->getModifierDePressed(); + return priv->getModifierDepressed(); } uint32_t DSXkb::getModifierLatched() @@ -226,6 +346,20 @@ uint32_t DSXkb::getModifierGroup() return priv->getModifierGroup(); } +int DSXkb::getKeymapFd() +{ + DS_GET_PRIV(DSXkb); + + return priv->getKeymapFd(); +} + +int DSXkb::getKeymapSize() +{ + DS_GET_PRIV(DSXkb); + + return priv->getKeymapSize(); +} + std::string DSXkb::getKeyname(int keycode) { DS_GET_PRIV(DSXkb); diff --git a/src/DSXkb/DSXkb.h b/src/DSXkb/DSXkb.h index 7dd0c5d..a1e32ab 100644 --- a/src/DSXkb/DSXkb.h +++ b/src/DSXkb/DSXkb.h @@ -18,10 +18,12 @@ public: ~DSXkb() override; void updateModifier(int keycode, bool pressed); - uint32_t getModifierDePressed(); + uint32_t getModifierDepressed(); uint32_t getModifierLatched(); uint32_t getModifierLocked(); uint32_t getModifierGroup(); + int getKeymapFd(); + int getKeymapSize(); std::string getKeyname(int keycode); int getKeycode(std::string keyname); diff --git a/src/DSXkb/DSXkbPrivate.h b/src/DSXkb/DSXkbPrivate.h index 0a27934..d1f89d6 100644 --- a/src/DSXkb/DSXkbPrivate.h +++ b/src/DSXkb/DSXkbPrivate.h @@ -20,23 +20,34 @@ public: bool makeKeymap(); void updateModifier(int keycode, bool pressed); - xkb_mod_mask_t getModifierDePressed(); + xkb_mod_mask_t getModifierDepressed(); xkb_mod_mask_t getModifierLatched(); xkb_mod_mask_t getModifierLocked(); xkb_mod_mask_t getModifierGroup(); + int getKeymapFd(); + int getKeymapSize(); std::string getKeyname(int keycode); int getKeycode(std::string keyname); +protected: + void mmapKeymap(); + private: struct ::xkb_state *__xkb_state; struct ::xkb_keymap *__xkb_keymap; struct ::xkb_context *__xkb_context; + int __keymap_fd; + size_t __keymap_size; + char *__keymap_area; + xkb_mod_mask_t __depressed; xkb_mod_mask_t __latched; xkb_mod_mask_t __locked; xkb_mod_mask_t __group; + + int __getKeymapFd(off_t size); }; } diff --git a/tests/DSXkb-test.cpp b/tests/DSXkb-test.cpp index 83b2a54..832363c 100644 --- a/tests/DSXkb-test.cpp +++ b/tests/DSXkb-test.cpp @@ -49,3 +49,85 @@ TEST_F(DSXkbTest, GetKeycode) delete xkb; delete seat; } + +TEST_F(DSXkbTest, GetModifierDepressed) +{ + DSSeat *seat = new DSSeat; + DSXkb *xkb = new DSXkb(seat); + uint32_t depressed = xkb->getModifierDepressed(); + int keycode = xkb->getKeycode("Shift_L"); + + xkb->updateModifier(keycode, true); + + EXPECT_TRUE(depressed != xkb->getModifierDepressed()); + xkb->updateModifier(keycode, false); + + delete xkb; + delete seat; +} + +TEST_F(DSXkbTest, GetModifierLatched) +{ + DSSeat *seat = new DSSeat; + DSXkb *xkb = new DSXkb(seat); + + (void)xkb->getModifierLatched(); + + delete xkb; + delete seat; +} + +TEST_F(DSXkbTest, GetModifierLocked) +{ + DSSeat *seat = new DSSeat; + DSXkb *xkb = new DSXkb(seat); + uint32_t locked = xkb->getModifierLocked(); + int keycode = xkb->getKeycode("Caps_Lock"); + + xkb->updateModifier(keycode, true); + xkb->updateModifier(keycode, false); + + EXPECT_TRUE(locked != xkb->getModifierLocked()); + + xkb->updateModifier(keycode, true); + xkb->updateModifier(keycode, false); + + delete xkb; + delete seat; +} + +TEST_F(DSXkbTest, GetModifierGroup) +{ + DSSeat *seat = new DSSeat; + DSXkb *xkb = new DSXkb(seat); + + (void)xkb->getModifierGroup(); + + delete xkb; + delete seat; +} + +TEST_F(DSXkbTest, GetKeymapFd) +{ + DSSeat *seat = new DSSeat; + DSXkb *xkb = new DSXkb(seat); + int fd = xkb->getKeymapFd(); + + EXPECT_TRUE(fd >= 0); + + delete xkb; + delete seat; +} + +TEST_F(DSXkbTest, GetKeymapSize) +{ + DSSeat *seat = new DSSeat; + DSXkb *xkb = new DSXkb(seat); + int size = xkb->getKeymapSize(); + + EXPECT_TRUE(size > 0); + + delete xkb; + delete seat; +} + -- 2.7.4 From 21c3eb15ffd1c491911fde5bf8cca57c857b33f7 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 31 Jul 2020 12:38:05 +0900 Subject: [PATCH 12/16] DSEventLoop: add addIdleEnterer method addIdleEnterer is static method in order to use this method anywhere. Change-Id: Ic82c62caed004c813c6c68913af74f15b644de88 --- src/DSEventLoop/DSEventLoop.cpp | 13 ++++++++++++- src/DSEventLoop/DSEventLoop.h | 8 ++++++++ tests/DSEventLoop-test.cpp | 29 ++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/DSEventLoop/DSEventLoop.cpp b/src/DSEventLoop/DSEventLoop.cpp index 6cbf6aa..7977f16 100644 --- a/src/DSEventLoop/DSEventLoop.cpp +++ b/src/DSEventLoop/DSEventLoop.cpp @@ -5,6 +5,8 @@ namespace display_server { +static std::list __ecoreIdleEntererList; + DSEventLoop::DSEventLoop() : __running(false) { @@ -15,6 +17,10 @@ DSEventLoop::DSEventLoop() DSEventLoop::~DSEventLoop() { + for (auto ecoreIdleEnterer : __ecoreIdleEntererList) + ecore_idle_enterer_del(ecoreIdleEnterer); + __ecoreIdleEntererList.clear(); + ecore_shutdown(); } @@ -46,4 +52,9 @@ bool DSEventLoop::quit() return true; } -} // namespace display_server \ No newline at end of file +void DSEventLoop::addIdleEnterer(DSObject *slot, Ecore_Task_Cb func) +{ + __ecoreIdleEntererList.push_back(ecore_idle_enterer_add(func, slot)); +} + +} // namespace display_server diff --git a/src/DSEventLoop/DSEventLoop.h b/src/DSEventLoop/DSEventLoop.h index d343371..76a8c7a 100644 --- a/src/DSEventLoop/DSEventLoop.h +++ b/src/DSEventLoop/DSEventLoop.h @@ -1,6 +1,9 @@ #ifndef __DS_EVENT_LOOP_H__ #define __DS_EVENT_LOOP_H__ +#include "DSObject.h" +#include + namespace display_server { @@ -15,6 +18,11 @@ public: bool isRunning(); + // add Ecore_Idle_Enterer + // TODO: make generalization, hiding Ecore_Idle_Enterer, Ecore_Task_Cb + // TODO: need + static void addIdleEnterer(DSObject *slot, Ecore_Task_Cb func); + private: bool __running; }; diff --git a/tests/DSEventLoop-test.cpp b/tests/DSEventLoop-test.cpp index 773d890..31d11ea 100644 --- a/tests/DSEventLoop-test.cpp +++ b/tests/DSEventLoop-test.cpp @@ -38,4 +38,31 @@ TEST_F(DSEventLoopTest, RunAndQuit) if (timer != nullptr) { EXPECT_TRUE(eventLoop.run() == true); } -} \ No newline at end of file +} + +TEST_F(DSEventLoopTest, addIdleEnterer) +{ + DSEventLoop eventLoop; + + Ecore_Timer *timer = nullptr; + double delayInSecond = 1.0; + auto timerCb = [](void *data) -> Eina_Bool { + DSEventLoop *loop = (DSEventLoop *)data; + EXPECT_TRUE(loop->quit() == true); + return EINA_FALSE; + }; + + auto idleCb = [](void *data) -> Eina_Bool { + EXPECT_TRUE(true); + return EINA_TRUE; + }; + + timer = ecore_timer_loop_add(delayInSecond, timerCb, &eventLoop); + EXPECT_TRUE(timer != nullptr); + + DSEventLoop::addIdleEnterer(nullptr, idleCb); + + if (timer != nullptr) { + EXPECT_TRUE(eventLoop.run() == true); + } +} -- 2.7.4 From 39bc74c591308bef2b815f5a5db142fcd05c0640 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 31 Jul 2020 12:39:14 +0900 Subject: [PATCH 13/16] DSDisplayArea: add __onEventIdleEnterer method __onEventIdleEnterer method is called at the idle enterer in DSEventLoop Change-Id: I204dc463e6b747d28d9ce74a549b3e2e6d459deb --- src/DSDisplayArea/DSDisplayArea.cpp | 10 ++++++++++ src/DSDisplayArea/DSDisplayAreaPrivate.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index a67494d..c97da10 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -84,6 +84,9 @@ DSDisplayAreaPrivate::DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr __renderEngine = std::make_shared(bufferQueue); if (!__renderEngine) DSLOG_ERR("DSCanvasPrivate", "__RenderEngine is null."); + + // add idle enterer event on __onEventIdleEnterer for rendereing and displaying + DSEventLoop::addIdleEnterer(this, __onEventIdleEnterer); } DSDisplayAreaPrivate::~DSDisplayAreaPrivate() @@ -140,4 +143,11 @@ void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) __displayDeviceHWCWindowList.push_back(__displayDeviceHWC->makeHWCWindow(window)); } +Eina_Bool DSDisplayAreaPrivate::__onEventIdleEnterer(void *data) +{ + // TODO:: __displayDeviceHWC->commit(); + // TODO:: __renderEngine->renderFrame(); + return true; +} + } // namespace display_server diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h index 32d7c70..8022219 100644 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ b/src/DSDisplayArea/DSDisplayAreaPrivate.h @@ -8,6 +8,7 @@ #include #include "IDSDisplayDeviceOutput.h" #include "IDSDisplayDeviceHWC.h" +#include "DSEventLoop.h" #include namespace display_server @@ -33,6 +34,7 @@ public: private: void __onWindowCreated(std::shared_ptr window); + static Eina_Bool __onEventIdleEnterer(void *data); std::shared_ptr __output; std::shared_ptr __displayDeviceOutput; -- 2.7.4 From d6ea3e1874b6b9f0ebd66ed53f2f6779d95933de Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 31 Jul 2020 13:55:09 +0900 Subject: [PATCH 14/16] DSDisplayArea: remove setPosition and setSize These methods do not support at this time. The size and position of the DisplayArea is determined by DSOutput. Change-Id: Ic69ce8fa1e9f593a29e23ce9647450e6d76ec486 --- samples/exampleCompositor.cpp | 2 -- src/DSDisplayArea/DSDisplayArea.cpp | 40 ++++---------------------------- src/DSDisplayArea/DSDisplayArea.h | 2 -- src/DSDisplayArea/DSDisplayAreaPrivate.h | 2 -- tests/DSDisplayArea-test.cpp | 8 +++---- 5 files changed, 8 insertions(+), 46 deletions(-) diff --git a/samples/exampleCompositor.cpp b/samples/exampleCompositor.cpp index 5833c2b..438c642 100644 --- a/samples/exampleCompositor.cpp +++ b/samples/exampleCompositor.cpp @@ -82,8 +82,6 @@ public: // make a display area. __displayArea = std::make_shared(output); - __displayArea->setPosition(0, 0); - __displayArea->setSize(output->getResolutionWidth(), output->getResolutionHeight()); } void _onOutputRemoved(std::shared_ptr output) override diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index c97da10..1bef4c2 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -13,26 +13,6 @@ DSDisplayArea::DSDisplayArea(std::shared_ptr output) DSDisplayArea::~DSDisplayArea() {} -bool DSDisplayArea::setPosition(int x, int y) -{ - DS_GET_PRIV(DSDisplayArea); - - if (!priv->setPosition(x, y)) - return false; - - return true; -} - -bool DSDisplayArea::setSize(int width, int height) -{ - DS_GET_PRIV(DSDisplayArea); - - if (!priv->setSize(width, height)) - return false; - - return true; -} - int DSDisplayArea::getWidth() { DS_GET_PRIV(DSDisplayArea); @@ -87,27 +67,15 @@ DSDisplayAreaPrivate::DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr // add idle enterer event on __onEventIdleEnterer for rendereing and displaying DSEventLoop::addIdleEnterer(this, __onEventIdleEnterer); + + // The size of DSDisplayArea is the one of DSOutput + __width = outputImpl->getResolutionWidth(); + __height = outputImpl->getResolutionWidth(); } DSDisplayAreaPrivate::~DSDisplayAreaPrivate() {} -bool DSDisplayAreaPrivate::setPosition(int x, int y) -{ - __x = x; - __y = y; - - return true; -} - -bool DSDisplayAreaPrivate::setSize(int width, int height) -{ - __width = width; - __height = height; - - return true; -} - int DSDisplayAreaPrivate::getWidth() { if (__output == nullptr) diff --git a/src/DSDisplayArea/DSDisplayArea.h b/src/DSDisplayArea/DSDisplayArea.h index 84543c4..d644cdc 100644 --- a/src/DSDisplayArea/DSDisplayArea.h +++ b/src/DSDisplayArea/DSDisplayArea.h @@ -17,8 +17,6 @@ public: explicit DSDisplayArea(std::shared_ptr output); virtual ~DSDisplayArea(); - bool setPosition(int x, int y); - bool setSize(int width, int height); int getWidth(); int getHeight(); std::shared_ptr getOutput(); diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h index 8022219..b062987 100644 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ b/src/DSDisplayArea/DSDisplayAreaPrivate.h @@ -23,8 +23,6 @@ public: virtual ~DSDisplayAreaPrivate(); static DSDisplayAreaPrivate *getPrivate(DSDisplayArea *q) { return q->__d_func(); } - bool setPosition(int x, int y); - bool setSize(int width, int height); int getWidth(); int getHeight(); diff --git a/tests/DSDisplayArea-test.cpp b/tests/DSDisplayArea-test.cpp index 7fda1a5..da2ba5e 100644 --- a/tests/DSDisplayArea-test.cpp +++ b/tests/DSDisplayArea-test.cpp @@ -29,6 +29,7 @@ TEST_F(DSDisplayAreaTest, NewDSDisplayArea) auto output = std::make_shared(displayDeviceOutput); EXPECT_TRUE(output != nullptr); EXPECT_TRUE(output->applyResolutionAuto() == true); + auto displayArea = std::make_shared(output); } } @@ -41,10 +42,9 @@ TEST_F(DSDisplayAreaTest, BasicMethods) auto output = std::make_shared(displayDeviceOutput); EXPECT_TRUE(output != nullptr); EXPECT_TRUE(output->applyResolutionAuto() == true); + auto displayArea = std::make_shared(output); - EXPECT_TRUE(displayArea->setPosition(0, 0) != 0); - EXPECT_TRUE(displayArea->setSize(100, 100) != 0); - EXPECT_TRUE(displayArea->getHeight() != 0); - EXPECT_TRUE(displayArea->getWidth() != 0); + EXPECT_TRUE(displayArea->getHeight() == output->getResolutionWidth()); + EXPECT_TRUE(displayArea->getWidth() == output->getResolutionHeight()); } } -- 2.7.4 From eccb1ad7484eef9b588a430618071740dcd6fa20 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 31 Jul 2020 14:39:44 +0900 Subject: [PATCH 15/16] DSWindow: add setGeometry() func(s) Change-Id: I4c6df59415aa10ad8953ff5eef5c1742baf24256 Signed-off-by: Sung-Jin Park --- src/DSWindow/DSWindow.cpp | 20 ++++++++++++++++++++ src/DSWindow/DSWindow.h | 2 ++ tests/DSWindow-test.cpp | 22 +++++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index a64c771..7c7fd88 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -178,4 +178,24 @@ stGeometry DSWindow::getGeometry() return geom; } +void DSWindow::setGeometry(int x, int y, unsigned int w, unsigned int h) +{ + DS_GET_PRIV(DSWindow); + + priv->__x = x; + priv->__y = y; + priv->__w = w; + priv->__h = h; +} + +void DSWindow::setGeometry(stGeometry geom) +{ + DS_GET_PRIV(DSWindow); + + priv->__x = geom.x; + priv->__y = geom.y; + priv->__w = geom.w; + priv->__h = geom.h; +} + } // namespace display_server \ No newline at end of file diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index 45181ee..ae8b222 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -35,6 +35,8 @@ public: bool hasFocus(void); stGeometry getGeometry(); + void setGeometry(int x, int y, unsigned int w, unsigned int h); + void setGeometry(stGeometry geom); protected: //virtual bool _onFocus(void); diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp index 3f11ba4..99622e5 100644 --- a/tests/DSWindow-test.cpp +++ b/tests/DSWindow-test.cpp @@ -39,6 +39,26 @@ TEST_F(DSWindowTest, BasicMethods) EXPECT_TRUE(geom.w == 1); EXPECT_TRUE(geom.h == 1); + win->setGeometry(100, 100, 1280, 720); + geom = win->getGeometry(); + EXPECT_TRUE(geom.x == 100); + EXPECT_TRUE(geom.y == 100); + EXPECT_TRUE(geom.w == 1280); + EXPECT_TRUE(geom.h == 720); + + stGeometry sGeom; + sGeom.x = 50; + sGeom.y = 50; + sGeom.w = 700; + sGeom.h = 700; + win->setGeometry(sGeom); + + geom = win->getGeometry(); + EXPECT_TRUE(geom.x == sGeom.x); + EXPECT_TRUE(geom.y == sGeom.y); + EXPECT_TRUE(geom.w == sGeom.w); + EXPECT_TRUE(geom.h == sGeom.h); + EXPECT_TRUE(win->show() == true); EXPECT_TRUE(win->hide(true) == true); EXPECT_TRUE(win->showState() == 0); @@ -50,4 +70,4 @@ TEST_F(DSWindowTest, BasicMethods) EXPECT_TRUE(win->setFocus() == true); EXPECT_TRUE(win->hasFocus() == true); -} \ No newline at end of file +} -- 2.7.4 From 38bb11f8a6a249ea626f2eb08c755a31f0e30ef8 Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 31 Jul 2020 14:57:03 +0900 Subject: [PATCH 16/16] DSXkb: strdup a result of getenv Change-Id: I5f5ca2abd31f853aa8e50537e130a123048786af --- src/DSXkb/DSXkb.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DSXkb/DSXkb.cpp b/src/DSXkb/DSXkb.cpp index 8a80669..cda12b9 100644 --- a/src/DSXkb/DSXkb.cpp +++ b/src/DSXkb/DSXkb.cpp @@ -229,14 +229,18 @@ int DSXkbPrivate::getKeycode(std::string keyname) int DSXkbPrivate::__getKeymapFd(off_t size) { int fd = 0, blen = 0, len = 0; - char *path; + char *path = nullptr, *env = nullptr; char tmp[PATH_MAX] = {0, }; long flags; mode_t old_umask; blen = sizeof(tmp) - 20; - path = getenv("XDG_RUNTIME_DIR"); + env = getenv("XDG_RUNTIME_DIR"); + if (env) + { + path = strdup(env); + } if (!path) return -1; len = strlen(path) + 19; -- 2.7.4