From 8cfa320975bb51f966aa1fd33c0e2b6dee4d3244 Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 14 Aug 2020 15:09:06 +0900 Subject: [PATCH 01/16] DSWaylandInputPanel: add methods for control input_panel window Change-Id: Id513347571867882061d3f4b48befcffdafad12b --- src/DSTextInput/DSTextInput.cpp | 22 +- src/DSTextInput/DSTextInputPrivate.h | 8 +- src/DSWaylandServer/DSWaylandInputPanel.cpp | 244 ++++++++++++++++++++- src/DSWaylandServer/DSWaylandInputPanel.h | 14 +- src/DSWaylandServer/DSWaylandInputPanelSurface.h | 6 + .../DSWaylandInputPanelSurfacePrivate.h | 6 + src/DSWaylandServer/DSWaylandTextInput.cpp | 10 +- tests/DSWaylandInputPanel-test.cpp | 78 +++++++ tests/DSWaylandInputPanelSurface-test.cpp | 70 ++++++ 9 files changed, 445 insertions(+), 13 deletions(-) diff --git a/src/DSTextInput/DSTextInput.cpp b/src/DSTextInput/DSTextInput.cpp index abe6cc4..b418406 100644 --- a/src/DSTextInput/DSTextInput.cpp +++ b/src/DSTextInput/DSTextInput.cpp @@ -26,6 +26,7 @@ #include "DSWaylandCompositor.h" #include "DSWaylandTextInputManager.h" #include "DSWaylandInputMethod.h" +#include "DSWaylandInputPanel.h" namespace display_server { @@ -35,14 +36,16 @@ DSTextInputPrivate::DSTextInputPrivate(DSTextInput *p_ptr) __inputPanelState(InputPanelStateDidHide) { __wlCompositor = DSWaylandCompositor::getInstance(); - __wlTextInputManager = new DSWaylandTextInputManager(__wlCompositor, this); __wlInputMethod = new DSWaylandInputMethod(__wlCompositor, this); + __wlInputPanel = new DSWaylandInputPanel(__wlCompositor, this); + __wlTextInputManager = new DSWaylandTextInputManager(__wlCompositor, this); } DSTextInputPrivate::~DSTextInputPrivate() { - delete __wlInputMethod; delete __wlTextInputManager; + delete __wlInputPanel; + delete __wlInputMethod; DSWaylandCompositor::releaseInstance(); } @@ -272,6 +275,21 @@ void DSTextInputPrivate::contextCommitContent(unsigned int serial, std::string c __wlTextInputManager->contextCommitContent(serial, content, description, mimeTypes); } +void DSTextInputPrivate::updateInputPanelState(bool waitUpdate) +{ + __wlInputPanel->updateInputPanelState(waitUpdate); +} + +void DSTextInputPrivate::setInputPanelTransientFor(DSWindow *window) +{ + __wlInputPanel->setTransientFor(window); +} + +void DSTextInputPrivate::changeInputPanelVisibility(bool visible) +{ + __wlInputPanel->changeVisibility(visible); +} + DSTextInput::DSTextInput() : DS_INIT_PRIVATE_PTR(DSTextInput) diff --git a/src/DSTextInput/DSTextInputPrivate.h b/src/DSTextInput/DSTextInputPrivate.h index f742054..969bf14 100644 --- a/src/DSTextInput/DSTextInputPrivate.h +++ b/src/DSTextInput/DSTextInputPrivate.h @@ -104,10 +104,16 @@ public: void contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); void contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); + /* DSWaylandInputPanel */ + void updateInputPanelState(bool waitUpdate); + void setInputPanelTransientFor(DSWindow *window); + void changeInputPanelVisibility(bool visible); + private: DSWaylandCompositor *__wlCompositor; - DSWaylandTextInputManager *__wlTextInputManager; DSWaylandInputMethod *__wlInputMethod; + DSWaylandInputPanel *__wlInputPanel; + DSWaylandTextInputManager *__wlTextInputManager; InputPanelState __inputPanelState; }; diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp index 8c604d4..8133842 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ b/src/DSWaylandServer/DSWaylandInputPanel.cpp @@ -37,6 +37,9 @@ public: beforePos({0,0}), startPortraitPos({0,0}), startLandscapePos({0,0}), __inputPanel(inputPanel) {} ~DSWaylandInputPanelFloating() {} + void setPortraitPos(int x, int y) { startPortraitPos.x = x; startPortraitPos.y = y; initPortraitPos = true; } + void setLandscapePos(int x, int y) { startLandscapePos.x = x; startLandscapePos.y = y; initLandscapePos = true; } + bool movingRequest; bool mousePressed; bool initPortraitPos; @@ -53,7 +56,7 @@ class DSWaylandInputPanelSurfaceData { public: DSWaylandInputPanelSurfaceData(DSWaylandServer::wl_input_panel_surface::Resource *resource, void *inputPanelResource, void *surfaceResource) - : panel(false), showing(false), needShow(false), + : panel(false), showing(false), needShow(false), resizing(false), __resource(resource), __inputPanelResource(inputPanelResource), __surfaceResource(surfaceResource) {} ~DSWaylandInputPanelSurfaceData() {} @@ -63,6 +66,7 @@ public: bool panel; bool showing; bool needShow; + bool resizing; private: DSWaylandServer::wl_input_panel_surface::Resource *__resource; @@ -125,8 +129,25 @@ void DSWaylandInputPanelPrivate::input_panel_get_input_panel_surface(Resource *r DSWaylandInputPanel::DSWaylandInputPanel(DSWaylandCompositor *compositor) : DSObject(), _d_ptr(std::make_unique(this, compositor)), __compositor(compositor), + __dsTextInputPrivate(nullptr), + __eventLoop(nullptr), + __waitUpdate(false), + __rerunPanelShow(false) +{ + __inputPanelSurface = new DSWaylandInputPanelSurface(__compositor, this); + __inputPanelFloating = new DSWaylandInputPanelFloating(this); + + __eventLoop = DSEventLoop::getInstance(); + __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSWaylandInputPanel::__onEventIdleEnterer, this, std::placeholders::_1)); +} + +DSWaylandInputPanel::DSWaylandInputPanel(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate) + : DSObject(), _d_ptr(std::make_unique(this, compositor)), + __compositor(compositor), + __dsTextInputPrivate(dsTextInputPrivate), __eventLoop(nullptr), - __waitUpdate(false) + __waitUpdate(false), + __rerunPanelShow(false) { __inputPanelSurface = new DSWaylandInputPanelSurface(__compositor, this); __inputPanelFloating = new DSWaylandInputPanelFloating(this); @@ -135,6 +156,7 @@ DSWaylandInputPanel::DSWaylandInputPanel(DSWaylandCompositor *compositor) __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSWaylandInputPanel::__onEventIdleEnterer, this, std::placeholders::_1)); } + DSWaylandInputPanel::~DSWaylandInputPanel() { DSEventLoop::releaseInstance(); @@ -180,6 +202,16 @@ void DSWaylandInputPanel::updateInputPanelState(bool waitUpdate) } } +bool DSWaylandInputPanel::getRerunPanelShow() +{ + return __rerunPanelShow; +} + +void DSWaylandInputPanel::setRerunPanelShow(bool needShow) +{ + __rerunPanelShow = needShow; +} + void DSWaylandInputPanel::setFloatingMovingRequest(bool enabled) { if (!__inputPanelFloating) return; @@ -187,6 +219,47 @@ void DSWaylandInputPanel::setFloatingMovingRequest(bool enabled) __inputPanelFloating->movingRequest = enabled; } +void DSWaylandInputPanel::setTransientFor(DSWindow *parent) +{ + DSWindow *curParent = parent; + if (curParent) + { + /* TODO: + * if curParent->remoteSurface.onScreenParent + * curParent = curParent->remoteSurface.onScreenParent + */ + } + + __inputPanelSurface->setTransientForSurface(curParent); +} + +void DSWaylandInputPanel::changeVisibility(bool visible) +{ + __rerunPanelShow = visible; + //vconf_set_int (VCONFKEY_ISF_INPUT_PANEL_STATE, visible ? VCONFKEY_ISF_INPUT_PANEL_STATE_SHOW : VCONFKEY_ISF_INPUT_PANEL_STATE_HIDE); + __inputPanelSurface->updateSurfaceVisibility(visible); + /* TODO: delete waitTimer */ +} + +bool DSWaylandInputPanel::isEffectRunning(DSWindow *window) +{ + /* TODO: + * if window is animating + * return true + */ + return false; +} + +void DSWaylandInputPanel::setFloatingPosition(int x, int y) +{ + __inputPanelSurface->setFloatingPosition(x, y); +} + +DSWaylandInputPanelFloating* DSWaylandInputPanel::getFloatingData() +{ + return __inputPanelFloating; +} + void DSWaylandInputPanel::__onEventIdleEnterer(void *data) { } @@ -273,6 +346,111 @@ void DSWaylandInputPanelSurfacePrivate::show(DSWaylandInputPanelSurfaceData *sur } } +void DSWaylandInputPanelSurfacePrivate::directShow(DSWaylandInputPanelSurfaceData *surfaceData) +{ + DS_GET_PUB(DSWaylandInputPanelSurface); + + pub->setPosition(nullptr, 0, 0); /* FIXME: set correct value */ + + /* TODO: change window geometry */ +} + +void DSWaylandInputPanelSurfacePrivate::setTransientForSurface(DSWindow *parent) +{ + for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) + { + //DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; + /* TODO: + * child = surfaceData->getSurfaceResource(); + * if child->parent + * { + * if child->parent != parent + * { + * remove child in child->parent->transients list + * child->parent = nullptr + * } + * } + * if parent != child && parent != child->parent + * { + * add child in child->parent->transients list + * child->parent = parent; + * } + * if (parent) + * { + * child->icccm.fetch.transientFor = true; + * child->icccm.transientFor = parent->id; + * } + * else + * { + * child->icccm.fetch.transientFor = false; + * child->icccm.transientFor = 0; + * } + * mark window changedr + */ + } +} + +void DSWaylandInputPanelSurfacePrivate::updateSurfaceVisibility(bool visible) +{ + for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) + { + DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; + surfaceData->showing = visible; + __updateSurfaceVisibility(surfaceData); + } +} + +void DSWaylandInputPanelSurfacePrivate::setFloatingPosition(int x, int y) +{ + DS_GET_PUB(DSWaylandInputPanelSurface); + DSWaylandInputPanelSurfaceData *floatingData = nullptr; + DSWaylandInputPanelFloating *inputPanelFloating; + int curAngle = 0; + + for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) + { + //DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; + + /* TODO: + * if vkbd.floating + * floatingData = surfaceData + */ + } + + inputPanelFloating = pub->__inputPanel->getFloatingData(); + + if (!floatingData || !inputPanelFloating) return; + + /* TODO: + * if (floatingData->showing) + * curAngle = get ec angle + * else + * curAngle = get zone angle + */ + + switch (curAngle) + { + case 90: + case 270: + inputPanelFloating->setLandscapePos(x, y); + //__inputPanelFloating->startLandscapePos.x = x; + //__inputPanelFloating->startLandscapePos.y = y; + //__inputPanelFloating->initLandscapePos = true; + break; +// case 0: +// case 180: + default: + inputPanelFloating->setPortraitPos(x, y); + //__inputPanelFloating->startPortraitPos.x = x; + //__inputPanelFloating->startPortraitPos.y = y; + //__inputPanelFloating->initPortraitPos = true; + break; + } + + if (floatingData->showing) + pub->setPosition(nullptr, 0, 0); /* FIXME: set correct window and data */ +} + void DSWaylandInputPanelSurfacePrivate::input_panel_surface_destroy_resource(Resource *resource) { auto it = __dataMap.find(resource); @@ -314,7 +492,7 @@ void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_ready(Resource * if (it != __dataMap.end()) { DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; - /* TODO: find Window and update base_output resolution */ + /* TODO: find DSWindow and update base_output resolution */ show(surfaceData); } } @@ -322,7 +500,7 @@ void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_ready(Resource * void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_floating_panel(Resource *resource, uint32_t state) { /* TODO: - * set Window's vkbd.floating = !!state + * set DSWindow's vkbd.floating = !!state * if true * policy_conformant_part_del * else @@ -337,6 +515,33 @@ void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_floating_drag_en pub->__inputPanel->setFloatingMovingRequest(!!enabled); } +void DSWaylandInputPanelSurfacePrivate::__updateSurfaceVisibility(DSWaylandInputPanelSurfaceData *surfaceData) +{ + DS_GET_PUB(DSWaylandInputPanelSurface); + + if (surfaceData->showing) /* TODO: check pixmap is usable too*/ + { + if (pub->__inputPanel->getRerunPanelShow()) + pub->__inputPanel->setRerunPanelShow(false); + if (pub->isEffectRunning(nullptr)) // FIXME: change this to get window surfaceData->getDSWindow() + surfaceData->needShow = true; + else if (surfaceData->resizing) + surfaceData->needShow = true; + else + { + directShow(surfaceData); + surfaceData->needShow = false; + } + } + else + { + /* TODO: + * change window's property + */ + surfaceData->needShow = false; + } +} + DSWaylandInputPanelSurface::DSWaylandInputPanelSurface(DSWaylandCompositor *compositor, DSWaylandInputPanel *inputPanel) : DSObject(), _d_ptr(std::make_unique(this, compositor)), @@ -374,5 +579,36 @@ void DSWaylandInputPanelSurface::flushFrame() priv->flushFrame(); } +void DSWaylandInputPanelSurface::setTransientForSurface(DSWindow *parent) +{ + DS_GET_PRIV(DSWaylandInputPanelSurface); + + priv->setTransientForSurface(parent); +} + +void DSWaylandInputPanelSurface::updateSurfaceVisibility(bool visible) +{ + DS_GET_PRIV(DSWaylandInputPanelSurface); + + priv->updateSurfaceVisibility(visible); +} + +bool DSWaylandInputPanelSurface::isEffectRunning(DSWindow *window) +{ + return __inputPanel->isEffectRunning(window); +} + +void DSWaylandInputPanelSurface::setPosition(DSWindow *window, int width, int height) +{ +} + +void DSWaylandInputPanelSurface::setFloatingPosition(int x, int y) +{ + DS_GET_PRIV(DSWaylandInputPanelSurface); + + priv->setFloatingPosition(x, y); +} + + } diff --git a/src/DSWaylandServer/DSWaylandInputPanel.h b/src/DSWaylandServer/DSWaylandInputPanel.h index 33de418..a8d0378 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.h +++ b/src/DSWaylandServer/DSWaylandInputPanel.h @@ -28,6 +28,8 @@ #include "DSObject.h" #include "DSWaylandCompositor.h" #include "DSEventLoop.h" +#include "DSTextInputPrivate.h" +#include "DSWindow.h" namespace display_server { @@ -41,6 +43,7 @@ class DS_DECL_EXPORT DSWaylandInputPanel : public DSObject DS_PIMPL_USE_PRIVATE(DSWaylandInputPanel); public: DSWaylandInputPanel(DSWaylandCompositor *compositor); + DSWaylandInputPanel(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate); ~DSWaylandInputPanel() override; void createSurface(void *client, void *inputPanelResource, unsigned int id, void *surface); @@ -48,17 +51,24 @@ public: bool getWaitUpdate(); void setWaitUpdate(bool waitUpdate); void updateInputPanelState(bool waitUpdate); + bool getRerunPanelShow(); + void setRerunPanelShow(bool needShow); void setFloatingMovingRequest(bool enabled); - -protected: + void setTransientFor(DSWindow *parent); + void changeVisibility(bool visible); + bool isEffectRunning(DSWindow *window); + void setFloatingPosition(int x, int y); + DSWaylandInputPanelFloating *getFloatingData(); private: DSWaylandCompositor *__compositor; + DSTextInputPrivate *__dsTextInputPrivate; DSEventLoop *__eventLoop; DSWaylandInputPanelSurface *__inputPanelSurface; DSWaylandInputPanelFloating *__inputPanelFloating; bool __waitUpdate; + bool __rerunPanelShow; void __onEventIdleEnterer(void *data); }; diff --git a/src/DSWaylandServer/DSWaylandInputPanelSurface.h b/src/DSWaylandServer/DSWaylandInputPanelSurface.h index 594f3a9..2f036ac 100644 --- a/src/DSWaylandServer/DSWaylandInputPanelSurface.h +++ b/src/DSWaylandServer/DSWaylandInputPanelSurface.h @@ -27,6 +27,7 @@ #include "DSCore.h" #include "DSObject.h" #include "DSWaylandInputPanel.h" +#include "DSWindow.h" namespace display_server { @@ -43,6 +44,11 @@ public: void createGlobal(void *client, void *inputPanelResource, unsigned int id, void *surface); void clearGlobals(void *inputPanelResource); void flushFrame(); + void setTransientForSurface(DSWindow *parent); + void updateSurfaceVisibility(bool visible); + bool isEffectRunning(DSWindow *window); + void setPosition(DSWindow *window, int width, int height); + void setFloatingPosition(int x, int y); protected: diff --git a/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h b/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h index a3cd8c9..5989bed 100644 --- a/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h +++ b/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h @@ -46,7 +46,11 @@ public: void clearGlobals(void *inputPanelResource); void show(DSWaylandInputPanelSurfaceData *surfaceData); + void directShow(DSWaylandInputPanelSurfaceData *surfaceData); void flushFrame(); + void setTransientForSurface(DSWindow *parent); + void updateSurfaceVisibility(bool visible); + void setFloatingPosition(int x, int y); protected: void input_panel_surface_destroy_resource(Resource *resource); @@ -60,6 +64,8 @@ protected: private: DSWaylandCompositor *__compositor; std::multimap __dataMap; + + void __updateSurfaceVisibility(DSWaylandInputPanelSurfaceData *surfaceData); }; } diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp index 29ea673..5de2744 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ b/src/DSWaylandServer/DSWaylandTextInput.cpp @@ -254,13 +254,13 @@ void DSWaylandTextInputPrivate::showInputPanel(void *resource) { pub->__dsTextInputPrivate->showInputPanel(pub, id); __showClient = privateResource->client(); - /* TODO: inputpanel wait update set */ + pub->__dsTextInputPrivate->updateInputPanelState(true); if (pub->__dsTextInputPrivate->getInputPanelState() == DSTextInputPrivate::InputPanelStateWillHide) { send_private_command(privateResource->handle, 0, "CONFORMANT_RESTORE"); } pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateWillShow); - /* TODO: inputpanel transient for set */ + /* TODO: pub->__dsTextInputPrivate->setInputPanelTransientFor(getDSWindow(__activatedResource)); */ } } @@ -315,7 +315,8 @@ void DSWaylandTextInputPrivate::hideInputPanel(Resource *resource, bool forceHid if (forceHide) { - /* TODO: Control inputpanel visible status */ + pub->__dsTextInputPrivate->changeInputPanelVisibility(false); + pub->__dsTextInputPrivate->setInputPanelTransientFor(nullptr); pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateDidHide); } else @@ -466,7 +467,8 @@ void DSWaylandTextInputPrivate::text_input_set_input_panel_data(Resource *resour /* TODO: will hide timer control */ if (pub->__dsTextInputPrivate->getInputPanelState() == DSTextInputPrivate::InputPanelStateWillHide) { - /* TODO: input panel visibility control */ + pub->__dsTextInputPrivate->changeInputPanelVisibility(false); + pub->__dsTextInputPrivate->setInputPanelTransientFor(nullptr); pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateDidShow); } } diff --git a/tests/DSWaylandInputPanel-test.cpp b/tests/DSWaylandInputPanel-test.cpp index ead57a2..85f9778 100644 --- a/tests/DSWaylandInputPanel-test.cpp +++ b/tests/DSWaylandInputPanel-test.cpp @@ -102,3 +102,81 @@ TEST_F(DSWaylandInputPanelTest, SetFloatingMovingRequest) DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandInputPanelTest, GetSetRerunPanelShow) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + EXPECT_TRUE(inputPanel != nullptr); + + inputPanel->setRerunPanelShow(true); + EXPECT_TRUE(true == inputPanel->getRerunPanelShow()); + + inputPanel->setRerunPanelShow(false); + EXPECT_TRUE(false == inputPanel->getRerunPanelShow()); + + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputPanelTest, SetTransientFor) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + EXPECT_TRUE(inputPanel != nullptr); + + inputPanel->setTransientFor(nullptr); + + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputPanelTest, ChangeVisibility) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + EXPECT_TRUE(inputPanel != nullptr); + + inputPanel->changeVisibility(true); + + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputPanelTest, IsEffectRunning) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + EXPECT_TRUE(inputPanel != nullptr); + + inputPanel->isEffectRunning(nullptr); + + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputPanelTest, SetFloatingPosition) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + EXPECT_TRUE(inputPanel != nullptr); + + inputPanel->setFloatingPosition(0, 0); + + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputPanelTest, GetFloatingData) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + EXPECT_TRUE(inputPanel != nullptr); + + auto floatingData = inputPanel->getFloatingData(); + + EXPECT_TRUE(floatingData != nullptr); + + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + diff --git a/tests/DSWaylandInputPanelSurface-test.cpp b/tests/DSWaylandInputPanelSurface-test.cpp index f3c8e4a..763a8e1 100644 --- a/tests/DSWaylandInputPanelSurface-test.cpp +++ b/tests/DSWaylandInputPanelSurface-test.cpp @@ -81,3 +81,73 @@ TEST_F(DSWaylandInputPanelSurfaceTest, FlushFrame) DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandInputPanelSurfaceTest, SetTransientForSurface) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); + EXPECT_TRUE(inputPanelSurface != nullptr); + + inputPanelSurface->setTransientForSurface(nullptr); + + delete inputPanelSurface; + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputPanelSurfaceTest, UpdateSurfaceVisibility) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); + EXPECT_TRUE(inputPanelSurface != nullptr); + + inputPanelSurface->updateSurfaceVisibility(true); + + delete inputPanelSurface; + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputPanelSurfaceTest, SsEffectRunning) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); + EXPECT_TRUE(inputPanelSurface != nullptr); + + inputPanelSurface->isEffectRunning(nullptr); + + delete inputPanelSurface; + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputPanelSurfaceTest, SetPosition) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); + EXPECT_TRUE(inputPanelSurface != nullptr); + + inputPanelSurface->setPosition(nullptr, 0, 0); + + delete inputPanelSurface; + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputPanelSurfaceTest, SetFloatingPosition) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); + DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); + EXPECT_TRUE(inputPanelSurface != nullptr); + + inputPanelSurface->setFloatingPosition(0, 0); + + delete inputPanelSurface; + delete inputPanel; + DSWaylandCompositor::releaseInstance(); +} + -- 2.7.4 From 16c25efa8f85afbde404e556ffc45d67a607fe6f Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 13 Aug 2020 19:56:02 +0900 Subject: [PATCH 02/16] DSRenderViewDaliImpl: Fix wrong wording. Change-Id: I3f8205a54e3c9ecff752bbebbc87eadb9371cafb Signed-off-by: Joonbum Ko --- src/DSRender/DSRenderViewDaliImpl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSRender/DSRenderViewDaliImpl.h b/src/DSRender/DSRenderViewDaliImpl.h index a15e391..8d3a89a 100644 --- a/src/DSRender/DSRenderViewDaliImpl.h +++ b/src/DSRender/DSRenderViewDaliImpl.h @@ -45,7 +45,7 @@ public: Dali::Geometry CreateTexturedQuad(); private: - void __onWindowBufferChanged(std::shared_ptr size); + void __onWindowBufferChanged(std::shared_ptr buffer); std::shared_ptr __window; Dali::Renderer __renderer; -- 2.7.4 From 623fa9e89d071a1b2048b44e2af34fd91ac0f11a Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 14 Aug 2020 13:15:15 +0900 Subject: [PATCH 03/16] DSRenderEngineDaliImpl: Make it to render only when RenderView updated. - The ecore_evas renderer has a function to check if there is an updated evas object. Therefore, even if ecore_evas_manual_render is called each idle time, it does not actually render if nothing has been updated. - On the other hand, if DALi calls RenderOnce whenever idle time, there is an overhead of waking up the render thread even if there is nothing to draw. - Since the RenderEngine does not have a RenderView, it is difficult for the RenderEngine to know whether the RenderView has been updated. Therefore, DSRenderEngineDaliImpl inherits DSObject, and it is modified to register BufferChanged callback in DSWindow received at the time of makeRenderView call. - When BufferChanged callback is called, private member __needToRender is made true. - Even if renderFrame is called, RenderOnce is called only when __needToRender is true, and __needToRender is changed to false immediately after that. - This modification can be revised back if it is possible to change to a better structure. Change-Id: I5717abee1bd4819abf9629892ccb8843a4f6a209 Signed-off-by: Joonbum Ko --- src/DSRender/DSRenderEngineDaliImpl.cpp | 18 ++++++++++++++++-- src/DSRender/DSRenderEngineDaliImpl.h | 6 +++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp index bb415cc..a716b55 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -35,7 +35,8 @@ namespace display_server { DSRenderEngineDaliImpl::DSRenderEngineDaliImpl(std::shared_ptr bufferQueue) - : __bufferQueue(bufferQueue) + : __bufferQueue(bufferQueue), + __needToRender(false) { tbm_surface_queue_h nativeBufferQueue = (tbm_surface_queue_h)bufferQueue->getNativeBufferQueue(); __offscreenApplication = OffscreenApplication::New(nativeBufferQueue, true, OffscreenApplication::RenderMode::MANUAL); @@ -59,14 +60,27 @@ std::shared_ptr DSRenderEngineDaliImpl::makeRenderView(std::shared { std::shared_ptr renderView = std::make_shared(window, __offscreenApplication.GetWindow()); + // callbacks + window->registerCallbackBufferChanged(this, std::bind(&DSRenderEngineDaliImpl::__onWindowUpdated, this, std::placeholders::_1)); + return renderView; } bool DSRenderEngineDaliImpl::renderFrame() { - Adaptor::Get().RenderOnce(); + if (__needToRender) + Adaptor::Get().RenderOnce(); + __needToRender = false; return true; } +void DSRenderEngineDaliImpl::__onWindowUpdated(std::shared_ptr buffer) +{ + if (!__needToRender) { + DSLOG_DBG("DSRenderEngineDaliImpl", "Something updated!! with buffer(%p)", buffer.get()); + __needToRender = true; + } +} + } // namespace display_server diff --git a/src/DSRender/DSRenderEngineDaliImpl.h b/src/DSRender/DSRenderEngineDaliImpl.h index 7c23148..d9244f7 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.h +++ b/src/DSRender/DSRenderEngineDaliImpl.h @@ -35,7 +35,7 @@ namespace display_server { -class DSRenderEngineDaliImpl : public IDSRenderEngine, public Dali::ConnectionTracker +class DSRenderEngineDaliImpl : public IDSRenderEngine, public Dali::ConnectionTracker, public DSObject { public: DSRenderEngineDaliImpl(std::shared_ptr bufferQueue); @@ -47,8 +47,12 @@ public: void onInitialize(); private: + void __onWindowUpdated(std::shared_ptr buffer); + std::shared_ptr __bufferQueue; Dali::OffscreenApplication __offscreenApplication; + + bool __needToRender; }; } -- 2.7.4 From 6180219a0357ce501e96d12fe08fc69b86d2633b Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 12 Aug 2020 21:55:06 +0900 Subject: [PATCH 04/16] DSInput: add/get timestamp for pointer/touch events propagation Change-Id: Icc4e167ba5be37e504cf574e855de087120163c6 Signed-off-by: Sung-Jin Park --- src/DSInput/DSInput.cpp | 40 ++++++++++++++++++++-------------------- src/DSInput/DSInput.h | 16 ++++++---------- src/DSInput/DSInputPrivate.h | 4 ++-- src/DSInput/DSLibinput.cpp | 16 ++++++++++------ 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/DSInput/DSInput.cpp b/src/DSInput/DSInput.cpp index cb61726..7a34779 100644 --- a/src/DSInput/DSInput.cpp +++ b/src/DSInput/DSInput.cpp @@ -73,28 +73,28 @@ void DSInputPrivate::PostKeyboardEvent(int keycode, bool pressed, std::string de pub->keyUp(keycode, devIdentifier, devClass, timestamp); } -void DSInputPrivate::PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass) +void DSInputPrivate::PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DS_GET_PUB(DSInput); if (type == DSInputEvent::MouseDownEvent) - pub->mouseDown(button, x, y, z, devIdentifier, devClass); + pub->mouseDown(button, x, y, z, devIdentifier, devClass, timestamp); else if (type == DSInputEvent::MouseMoveEvent) - pub->mouseMove(button, x, y, z, devIdentifier, devClass); + pub->mouseMove(button, x, y, z, devIdentifier, devClass, timestamp); else if (type == DSInputEvent::MouseUpEvent) - pub->mouseUp(button, x, y, z, devIdentifier, devClass); + pub->mouseUp(button, x, y, z, devIdentifier, devClass, timestamp); } -void DSInputPrivate::PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass) +void DSInputPrivate::PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DS_GET_PUB(DSInput); if (type == DSInputEvent::TouchDownEvent) - pub->touchDown(index, x, y, devIdentifier, devClass); + pub->touchDown(index, x, y, devIdentifier, devClass, timestamp); else if (type == DSInputEvent::TouchMoveEvent) - pub->touchMove(index, x, y, devIdentifier, devClass); + pub->touchMove(index, x, y, devIdentifier, devClass, timestamp); else if (type == DSInputEvent::TouchUpEvent) - pub->touchUp(index, x, y, devIdentifier, devClass); + pub->touchUp(index, x, y, devIdentifier, devClass, timestamp); } int DSInput::DS_INPUT_EVENT_KEY_DOWN = 0; @@ -254,51 +254,51 @@ void DSInput::keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass ecore_event_add(DS_INPUT_EVENT_KEY_UP, (void *)ev, nullptr, nullptr); } -void DSInput::mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass) +void DSInput::mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DSLOG_DBG("DSInput", "[mouseDown] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier); DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseDownEvent, 0, button, x, y, z); + DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseDownEvent, timestamp, button, x, y, z); ecore_event_add(DS_INPUT_EVENT_MOUSE_DOWN, (void *)ev, nullptr, nullptr); } -void DSInput::mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass) +void DSInput::mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DSLOG_DBG("DSInput", "[mouseMove] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier); DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseMoveEvent, 0, button, x, y, z); + DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseMoveEvent, timestamp, button, x, y, z); ecore_event_add(DS_INPUT_EVENT_MOUSE_MOVE, (void *)ev, nullptr, nullptr); } -void DSInput::mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass) +void DSInput::mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DSLOG_DBG("DSInput", "[mouseUp] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier); DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseUpEvent, 0, button, x, y, z); + DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseUpEvent, timestamp, button, x, y, z); ecore_event_add(DS_INPUT_EVENT_MOUSE_UP, (void *)ev, nullptr, nullptr); } -void DSInput::touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass) +void DSInput::touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DSLOG_DBG("DSInput", "[touchDown] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier); DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchDownEvent, 0, index, x, y); + DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchDownEvent, timestamp, index, x, y); ecore_event_add(DS_INPUT_EVENT_TOUCH_DOWN, (void *)ev, nullptr, nullptr); } -void DSInput::touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass) +void DSInput::touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DSLOG_DBG("DSInput", "[touchMove] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier); DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchMoveEvent, 0, index, x, y); + DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchMoveEvent, timestamp, index, x, y); ecore_event_add(DS_INPUT_EVENT_TOUCH_MOVE, (void *)ev, nullptr, nullptr); } -void DSInput::touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass) +void DSInput::touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DSLOG_DBG("DSInput", "[touchUp] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier); DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchUpEvent, 0, index, x, y); + DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchUpEvent, timestamp, index, x, y); ecore_event_add(DS_INPUT_EVENT_TOUCH_UP, (void *)ev, nullptr, nullptr); } diff --git a/src/DSInput/DSInput.h b/src/DSInput/DSInput.h index 7d13d50..f8c89ab 100644 --- a/src/DSInput/DSInput.h +++ b/src/DSInput/DSInput.h @@ -26,11 +26,7 @@ #include #include -#include -#include -#include #include -#include #include @@ -67,12 +63,12 @@ public: void deviceRemove(std::string name, std::string identifier, DSInput::DeviceClass devClass, DSInput::DeviceSubclass devSubclass); void keyDown(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); void keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass); - void mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass); - void mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass); - void touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass); - void touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass); - void touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass); + void mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); void registerCallbackDeviceAdd(DSObject *slot, std::function)> func); void registerCallbackDeviceRemove(DSObject *slot, std::function)> func); diff --git a/src/DSInput/DSInputPrivate.h b/src/DSInput/DSInputPrivate.h index 59b6741..377db91 100644 --- a/src/DSInput/DSInputPrivate.h +++ b/src/DSInput/DSInputPrivate.h @@ -46,8 +46,8 @@ public: void PostDeviceAddEvent(std::string seat, std::string name, std::string identifier, DSInput::DeviceClass devClass); void PostDeviceRemoveEvent(std::string seat, std::string name, std::string identifier, DSInput::DeviceClass devClass); void PostKeyboardEvent(int keycode, bool pressed, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass); - void PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass); + void PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); private: DSLibinput *__dsLibinput; diff --git a/src/DSInput/DSLibinput.cpp b/src/DSInput/DSLibinput.cpp index dd43408..7e7ede9 100644 --- a/src/DSInput/DSLibinput.cpp +++ b/src/DSInput/DSLibinput.cpp @@ -221,14 +221,14 @@ void DSLibinput::__processPointerMotionEvent(struct ::libinput_event *event) { struct:: libinput_event_pointer *pointer_event = libinput_event_get_pointer_event(event); int dx, dy; - + uint32_t timestamp = libinput_event_pointer_get_time(pointer_event); struct ::libinput_device *device = libinput_event_get_device(event); std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); dx = libinput_event_pointer_get_dx(pointer_event); dy = libinput_event_pointer_get_dy(pointer_event); - inputPrivate->PostPointerEvent(0, dx, dy, 0, DSInputEvent::MouseMoveEvent, identifier, DSInput::PointerClass); + inputPrivate->PostPointerEvent(0, dx, dy, 0, DSInputEvent::MouseMoveEvent, identifier, DSInput::PointerClass, timestamp); } void DSLibinput::__processPointerMotionAbsoluteEvent(struct ::libinput_event *event) @@ -242,6 +242,7 @@ void DSLibinput::__processPointerButtonEvent(struct ::libinput_event *event) DSInputEvent::Type eventType; int button; int state; + uint32_t timestamp = libinput_event_pointer_get_time(pointer_event); struct ::libinput_device *device = libinput_event_get_device(event); std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); @@ -254,7 +255,7 @@ void DSLibinput::__processPointerButtonEvent(struct ::libinput_event *event) else eventType = DSInputEvent::MouseUpEvent; - inputPrivate->PostPointerEvent(button, 0, 0, 0, eventType, identifier, DSInput::PointerClass); + inputPrivate->PostPointerEvent(button, 0, 0, 0, eventType, identifier, DSInput::PointerClass, timestamp); } void DSLibinput::__processPointerAxisEvent(struct ::libinput_event *event) @@ -266,6 +267,7 @@ void DSLibinput::__processTouchDownEvent(struct ::libinput_event *event) { struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); int index, x, y; + uint32_t timestamp = libinput_event_touch_get_time(touch_event); struct ::libinput_device *device = libinput_event_get_device(event); std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); @@ -274,13 +276,14 @@ void DSLibinput::__processTouchDownEvent(struct ::libinput_event *event) x = libinput_event_touch_get_x(touch_event); y = libinput_event_touch_get_y(touch_event); - inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchDownEvent, identifier, DSInput::TouchClass); + inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchDownEvent, identifier, DSInput::TouchClass, timestamp); } void DSLibinput::__processTouchMotionEvent(struct ::libinput_event *event) { struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); int index, x, y; + uint32_t timestamp = libinput_event_touch_get_time(touch_event); struct ::libinput_device *device = libinput_event_get_device(event); std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); @@ -289,13 +292,14 @@ void DSLibinput::__processTouchMotionEvent(struct ::libinput_event *event) x = libinput_event_touch_get_x(touch_event); y = libinput_event_touch_get_y(touch_event); - inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchMoveEvent, identifier, DSInput::TouchClass); + inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchMoveEvent, identifier, DSInput::TouchClass, timestamp); } void DSLibinput::__processTouchUpEvent(struct ::libinput_event *event) { struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); int index, x, y; + uint32_t timestamp = libinput_event_touch_get_time(touch_event); struct ::libinput_device *device = libinput_event_get_device(event); std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); @@ -304,7 +308,7 @@ void DSLibinput::__processTouchUpEvent(struct ::libinput_event *event) x = 0; y = 0; - inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchUpEvent, identifier, DSInput::TouchClass); + inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchUpEvent, identifier, DSInput::TouchClass, timestamp); } void DSLibinput::__processTouchCancelEvent(struct ::libinput_event *event) -- 2.7.4 From 7cb06709e15b67af2f3d4dca1c0a22ade98a2294 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 12 Aug 2020 21:55:54 +0900 Subject: [PATCH 05/16] DSSeat: remove unnecessary log for touch event handler Change-Id: I25cc6e6025131c5f5656ccc8ad5e5c44c74d5b22 Signed-off-by: Sung-Jin Park --- src/DSSeat/DSSeat.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index 4bcd11b..f15a04c 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -412,6 +412,7 @@ void DSSeat::__onTouchEvent(DSInputTouchEvent *ev) return; } + __dswlSeat->setCurrentEventTime(ev->getTimestamp()); __touch->processEvent(ev, nullptr); } @@ -465,17 +466,6 @@ Eina_Bool DSSeat::inputEventHandlerMouse(void *data, int type, void *event) Eina_Bool DSSeat::inputEventHandlerTouch(void *data, int type, void *event) { DSInputTouchEvent *ev = static_cast< DSInputTouchEvent* >(event); - std::string typeString; - - if (ev->getType() == DSInputEvent::TouchDownEvent) - typeString = "down"; - else if (ev->getType() == DSInputEvent::TouchMoveEvent) - typeString = "move"; - else - typeString = "up"; - - DSLOG_DBG("DSSeat", "[touch %s] index: %d (%d, %d), devicename: %s\n", typeString.c_str(), ev->getIndex(), ev->getX(), ev->getY(), ev->getDevice()->getName().c_str()); - __signalHandleTouchEvent.emit(ev); return EINA_TRUE; -- 2.7.4 From cbcef546c0328e5e32390af6836422b0a5a6ebf9 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 14 Aug 2020 19:54:40 +0900 Subject: [PATCH 06/16] DSWaylandTouch: implment send touchDown/Up/Move events to touch focus client Change-Id: I7dab84ca478c3486702ba807c3790cf31920803a Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandTouch.cpp | 91 ++++++++++++++++++++++++++++- src/DSWaylandServer/DSWaylandTouch.h | 4 ++ src/DSWaylandServer/DSWaylandTouchPrivate.h | 21 ++++--- 3 files changed, 106 insertions(+), 10 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandTouch.cpp b/src/DSWaylandServer/DSWaylandTouch.cpp index 0d31119..c2a3fa1 100644 --- a/src/DSWaylandServer/DSWaylandTouch.cpp +++ b/src/DSWaylandServer/DSWaylandTouch.cpp @@ -24,6 +24,9 @@ #include "DSWaylandTouch.h" #include "DSWaylandTouchPrivate.h" #include "DSWaylandClient.h" +#include "DSWaylandSeat.h" +#include "DSWaylandSurface.h" +#include "DSWaylandCompositor.h" namespace display_server { @@ -32,7 +35,9 @@ DSWaylandTouchPrivate::DSWaylandTouchPrivate(DSWaylandSeat *seat, DSWaylandTouch : DSObjectPrivate(touch), __p_ptr(touch), __seat(seat), - __waylandSurface(nullptr) + __compositor(seat->getCompositor()), + __waylandSurface(nullptr), + __wlTouchResource(nullptr) { wl_touch(); } @@ -41,6 +46,38 @@ DSWaylandTouchPrivate::~DSWaylandTouchPrivate() { } +void DSWaylandTouchPrivate::setFocus(DSWaylandSurface *waylandSurface) +{ + DSLOG_INF("DSWaylandTouchPrivate", "touch focus changed (%p -> %p)", __waylandSurface, waylandSurface); + + __waylandSurface = waylandSurface; + + if (!waylandSurface) + return; + + struct ::wl_resource *surface = waylandSurface->getWlResource(); + auto client = wl_resource_get_client(surface); + + std::multimap::iterator iter; + std::multimap resMap = resourceMap(); + + for (iter = resMap.begin(); iter != resMap.end(); iter++) + { + Resource *res = (*iter).second; + if (res->client() == client) + { + __wlTouchResource = res->handle; + break; + } + + } +} + +DSWaylandSurface *DSWaylandTouchPrivate::getFocus() +{ + return __waylandSurface; +} + void DSWaylandTouchPrivate::touch_bind_resource(Resource *resource) { DSLOG_INF("DSWaylandTouchPrivate",""); @@ -57,6 +94,36 @@ void DSWaylandTouchPrivate::touch_release(Resource *resource) wl_resource_destroy(resource->handle); } +void DSWaylandTouchPrivate::sendDown(int32_t id, int x, int y) +{ + if (!__waylandSurface) + { + DSLOG_INF("DSWaylandTouchPrivate", "no waylandSurface available !"); + return; + } + + wl_fixed_t x_fixed = wl_fixed_from_int(x); + wl_fixed_t y_fixed = wl_fixed_from_int(y); + + struct ::wl_resource *surface = __waylandSurface->getWlResource(); + DS_ASSERT(surface != nullptr); + + send_down(__wlTouchResource, __compositor->nextSerial(), __seat->getCurrentEventTime(), surface, id, x_fixed, y_fixed); +} + +void DSWaylandTouchPrivate::sendUp(int32_t id) +{ + send_up(__wlTouchResource, __compositor->nextSerial(), __seat->getCurrentEventTime(), id); +} + +void DSWaylandTouchPrivate::sendMotion(int32_t id, int x, int y) +{ + wl_fixed_t x_fixed = wl_fixed_from_int(x); + wl_fixed_t y_fixed = wl_fixed_from_int(y); + + send_motion(__wlTouchResource, __seat->getCurrentEventTime(), id, x_fixed, y_fixed); +} + /* Begin Public Class Implementation */ DSWaylandTouch::DSWaylandTouch(DSWaylandSeat *seat) : DSObject(), _d_ptr(std::make_unique(seat, this)) @@ -88,13 +155,31 @@ void DSWaylandTouch::addClient(DSWaylandClient *client, uint32_t id, int version void DSWaylandTouch::setFocus(DSWaylandSurface *waylandSurface) { DS_GET_PRIV(DSWaylandTouch); - priv->__waylandSurface = waylandSurface; + priv->setFocus(waylandSurface); } DSWaylandSurface *DSWaylandTouch::getFocus() { DS_GET_PRIV(DSWaylandTouch); - return priv->__waylandSurface; + return priv->getFocus(); +} + +void DSWaylandTouch::sendDown(int32_t id, int x, int y) +{ + DS_GET_PRIV(DSWaylandTouch); + priv->sendDown(id, x, y); +} + +void DSWaylandTouch::sendUp(int32_t id) +{ + DS_GET_PRIV(DSWaylandTouch); + priv->sendUp(id); +} + +void DSWaylandTouch::sendMotion(int32_t id, int x, int y) +{ + DS_GET_PRIV(DSWaylandTouch); + priv->sendMotion(id, x, y); } } diff --git a/src/DSWaylandServer/DSWaylandTouch.h b/src/DSWaylandServer/DSWaylandTouch.h index d787707..beef446 100644 --- a/src/DSWaylandServer/DSWaylandTouch.h +++ b/src/DSWaylandServer/DSWaylandTouch.h @@ -48,6 +48,10 @@ public: void setFocus(DSWaylandSurface *waylandSurface); DSWaylandSurface *getFocus(); + void sendDown(int32_t id, int x, int y); + void sendUp(int32_t id); + void sendMotion(int32_t id, int x, int y); + protected: private: diff --git a/src/DSWaylandServer/DSWaylandTouchPrivate.h b/src/DSWaylandServer/DSWaylandTouchPrivate.h index bf965d8..1556ce7 100644 --- a/src/DSWaylandServer/DSWaylandTouchPrivate.h +++ b/src/DSWaylandServer/DSWaylandTouchPrivate.h @@ -29,10 +29,15 @@ #include "DSCore.h" #include "DSObjectPrivate.h" +struct wl_resource; + namespace display_server { class DSWaylandSeat; +class DSWaylandCompositor; +class DSWaylandSurface; + class DS_DECL_EXPORT DSWaylandTouchPrivate : public DSObjectPrivate, public DSWaylandServer::wl_touch { DS_PIMPL_USE_PUBLIC(DSWaylandTouch); @@ -40,7 +45,8 @@ public: DSWaylandTouchPrivate(DSWaylandSeat *seat, DSWaylandTouch *touch); ~DSWaylandTouchPrivate() override; - //TODO + void setFocus(DSWaylandSurface *waylandSurface); + DSWaylandSurface *getFocus(); protected: //virtual Resource *touch_allocate(); @@ -49,14 +55,13 @@ protected: virtual void touch_release(Resource *resource); /* APIs must be provided */ + void sendDown(int32_t id, int x, int y); + void sendUp(int32_t id); + void sendMotion(int32_t id, int x, int y); /* - void sendDown(struct ::wl_client *client, uint32_t serial, uint32_t time, struct ::wl_resource *surface, int32_t id, wl_fixed_t x, wl_fixed_t y); - void sendUp(struct ::wl_client *client, uint32_t serial, uint32_t time, int32_t id); - void sendMotion(struct ::wl_client *client, uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y); - void sendFrame(struct ::wl_client *client); - void sendCancel(struct ::wl_client *client); + void sendFrame(struct ::wl_resource *surface); + void sendCancel(struct ::wl_resource *surface); */ - /* APIs don't need to provide */ /* void send_shape(struct ::wl_resource *resource, int32_t id, wl_fixed_t major, wl_fixed_t minor); @@ -65,7 +70,9 @@ protected: private: DSWaylandSeat *__seat; + DSWaylandCompositor *__compositor; DSWaylandSurface *__waylandSurface; + struct ::wl_resource *__wlTouchResource; }; } -- 2.7.4 From c64efed65cef6ece702c6a37fd3f56cb9fbd292d Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 14 Aug 2020 19:55:53 +0900 Subject: [PATCH 07/16] DSTouch: add touchDown/Up/Move APIs Change-Id: I72c4413e76f2d9b99a7236cfffec4bc21b416b77 Signed-off-by: Sung-Jin Park --- src/DSSeat/DSTouch.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ src/DSSeat/DSTouch.h | 3 +++ 2 files changed, 46 insertions(+) diff --git a/src/DSSeat/DSTouch.cpp b/src/DSSeat/DSTouch.cpp index 3483d6e..00f8abc 100644 --- a/src/DSSeat/DSTouch.cpp +++ b/src/DSSeat/DSTouch.cpp @@ -58,6 +58,49 @@ void DSTouch::processEvent(DSInputTouchEvent *ev, void *data) DSLOG_ERR("DSTouch", "No touchFocus available."); return; } + + if (ev->getType() == DSInputEvent::TouchDownEvent) + { + DSLOG_DBG("DSTouch", "[touchDown] devicename: %s, timestamp: %u\n", + ev->getDevice()->getName().c_str(), ev->getTimestamp()); + touchDown(ev->getIndex(), ev->getX(), ev->getY()); + } + else if (ev->getType() == DSInputEvent::TouchUpEvent) + { + DSLOG_DBG("DSTouch", "[touchDown] devicename: %s, timestamp: %u\n", + ev->getDevice()->getName().c_str(), ev->getTimestamp()); + touchUp(ev->getIndex()); + } + else//DSInputEvent::TouchMoveEvent + { + DSLOG_DBG("DSTouch", "[touchDown] devicename: %s, timestamp: %u\n", + ev->getDevice()->getName().c_str(), ev->getTimestamp()); + touchMove(ev->getIndex(), ev->getX(), ev->getY()); + } +} + +void DSTouch::touchDown(int32_t id, int x, int y) +{ + if (__dswlTouch) + { + __dswlTouch->sendDown(id, x, y); + } +} + +void DSTouch::touchUp(int32_t id) +{ + if (__dswlTouch) + { + __dswlTouch->sendUp(id); + } +} + +void DSTouch::touchMove(int32_t id, int x, int y) +{ + if (__dswlTouch) + { + __dswlTouch->sendMotion(id, x, y); + } } void DSTouch::setFocus(std::shared_ptr window) diff --git a/src/DSSeat/DSTouch.h b/src/DSSeat/DSTouch.h index c210b21..99c8d7a 100644 --- a/src/DSSeat/DSTouch.h +++ b/src/DSSeat/DSTouch.h @@ -45,6 +45,9 @@ public: virtual ~DSTouch(); void processEvent(DSInputTouchEvent *ev, void *data); + void touchDown(int32_t id, int x, int y); + void touchUp(int32_t id); + void touchMove(int32_t id, int x, int y); void setFocus(std::shared_ptr window); std::shared_ptr getFocus(); -- 2.7.4 From 2bf32e80d0ecd33cceb7b8807afe6b6f3a53a1f1 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 14 Aug 2020 20:50:23 +0900 Subject: [PATCH 08/16] DSSeat: setCurrentEventTime for pointer event Change-Id: I40347f8c6a76844a045a5651cb3a06276159277f Signed-off-by: Sung-Jin Park --- src/DSSeat/DSSeat.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index f15a04c..69ca1d2 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -401,6 +401,7 @@ void DSSeat::__onPointerEvent(DSInputMouseEvent *ev) return; } + __dswlSeat->setCurrentEventTime(ev->getTimestamp()); __pointer->processEvent(ev, nullptr); } -- 2.7.4 From a1caa73dad5dfacb1aeee0c3f9e387fdffbd181d Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 14 Aug 2020 20:51:50 +0900 Subject: [PATCH 09/16] DSWaylandPointer: add set/getFocus(), send event APIs Change-Id: I056f8ab50aa47cd173850dad47218579e99c2ab5 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandPointer.cpp | 121 +++++++++++++++++++++++++- src/DSWaylandServer/DSWaylandPointer.h | 6 ++ src/DSWaylandServer/DSWaylandPointerPrivate.h | 21 +++-- 3 files changed, 138 insertions(+), 10 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandPointer.cpp b/src/DSWaylandServer/DSWaylandPointer.cpp index 6a04cfa..dea562f 100644 --- a/src/DSWaylandServer/DSWaylandPointer.cpp +++ b/src/DSWaylandServer/DSWaylandPointer.cpp @@ -24,6 +24,9 @@ #include "DSWaylandPointer.h" #include "DSWaylandPointerPrivate.h" #include "DSWaylandClient.h" +#include "DSWaylandSeat.h" +#include "DSWaylandSurface.h" +#include "DSWaylandCompositor.h" namespace display_server { @@ -33,7 +36,9 @@ DSWaylandPointerPrivate::DSWaylandPointerPrivate(DSWaylandSeat *seat, DSWaylandP : DSObjectPrivate(pointer), __p_ptr(pointer), __seat(seat), - __waylandSurface(nullptr) + __compositor(seat->getCompositor()), + __waylandSurface(nullptr), + __wlPointerResource(nullptr) { wl_pointer(); } @@ -42,6 +47,60 @@ DSWaylandPointerPrivate::~DSWaylandPointerPrivate() { } +void DSWaylandPointerPrivate::setFocus(DSWaylandSurface *waylandSurface) +{ + DSLOG_INF("DSWaylandPointerPrivate", "pointer focus changed (%p -> %p)", __waylandSurface, waylandSurface); + +#if 0 + if (__waylandSurface) + { + DSLOG_INF("DSWaylandPointerPrivate", "send leave to %p", __waylandSurface); + send_leave(__wlPointerResource, __waylandSurface->getWlResource()); + } +#endif + + __waylandSurface = waylandSurface; + + if (!waylandSurface) + { + __wlPointerResource = nullptr; + DSLOG_INF("DSWaylandPointerPrivate", "wlPointerResource has been set to null."); + return; + } + + struct ::wl_resource *surface = waylandSurface->getWlResource(); + auto client = wl_resource_get_client(surface); + + std::multimap::iterator iter; + std::multimap resMap = resourceMap(); + + for (iter = resMap.begin(); iter != resMap.end(); iter++) + { + Resource *res = (*iter).second; + if (res->client() == client) + { + __wlPointerResource = res->handle; + break; + } + + } + + if (!__wlPointerResource) + { + DSLOG_INF("DSWaylandPointerPrivate", "no wlPointerResource available"); + return; + } +#if 0 + DSLOG_INF("DSWaylandPointerPrivate", "send enter to %p", __waylandSurface); + sendEnter(__wlPointerResource, __waylandSurface->getWlResource(), surface_x, surface_y); +#endif +} + +DSWaylandSurface *DSWaylandPointerPrivate::getFocus() +{ + return __waylandSurface; +} + void DSWaylandPointerPrivate::pointer_bind_resource(Resource *resource) { DSLOG_INF("DSWaylandPointerPrivate",""); @@ -63,6 +122,32 @@ void DSWaylandPointerPrivate::pointer_release(Resource *resource) wl_resource_destroy(resource->handle); } +void DSWaylandPointerPrivate::sendEnter(struct ::wl_resource *wlResource, struct ::wl_resource *surface, int surface_x, int surface_y) +{ + wl_fixed_t surface_x_fixed = wl_fixed_from_int(surface_x); + wl_fixed_t surface_y_fixed = wl_fixed_from_int(surface_y); + + send_enter(__wlPointerResource, __compositor->nextSerial(), surface, surface_x_fixed, surface_y_fixed); +} + +void DSWaylandPointerPrivate::sendLeave(struct ::wl_resource *wlResource, struct ::wl_resource *surface) +{ + send_leave(__wlPointerResource, __compositor->nextSerial(), surface); +} + +void DSWaylandPointerPrivate::sendMotion(int surface_x, int surface_y) +{ + wl_fixed_t surface_x_fixed = wl_fixed_from_int(surface_x); + wl_fixed_t surface_y_fixed = wl_fixed_from_int(surface_y); + + send_motion(__wlPointerResource, __seat->getCurrentEventTime(), surface_x_fixed, surface_y_fixed); +} + +void DSWaylandPointerPrivate::sendButton(uint32_t button, uint32_t state) +{ + send_button(__wlPointerResource, __compositor->nextSerial(), __seat->getCurrentEventTime(), button, state); +} + /* Begin Public Class Implementation */ DSWaylandPointer::DSWaylandPointer(DSWaylandSeat *seat) : DSObject(), _d_ptr(std::make_unique(seat, this)) @@ -94,13 +179,43 @@ void DSWaylandPointer::addClient(DSWaylandClient *client, uint32_t id, int versi void DSWaylandPointer::setFocus(DSWaylandSurface *waylandSurface) { DS_GET_PRIV(DSWaylandPointer); - priv->__waylandSurface = waylandSurface; + priv->setFocus(waylandSurface); } DSWaylandSurface *DSWaylandPointer::getFocus() { DS_GET_PRIV(DSWaylandPointer); - return priv->__waylandSurface; + return priv->getFocus(); +} + +void DSWaylandPointer::sendEnter(int surface_x, int surface_y) +{ + DS_GET_PRIV(DSWaylandPointer); + priv->sendEnter(priv->__wlPointerResource, priv->__waylandSurface->getWlResource(), surface_x, surface_y); +} + +void DSWaylandPointer::sendLeave() +{ + DS_GET_PRIV(DSWaylandPointer); + priv->sendLeave(priv->__wlPointerResource, priv->__waylandSurface->getWlResource()); +} + +void DSWaylandPointer::sendMotion(int surface_x, int surface_y) +{ + DS_GET_PRIV(DSWaylandPointer); + priv->sendMotion(surface_x, surface_y); +} + +void DSWaylandPointer::sendButtonDown(uint32_t button) +{ + DS_GET_PRIV(DSWaylandPointer); + priv->sendButton(button, WL_POINTER_BUTTON_STATE_PRESSED); +} + +void DSWaylandPointer::sendButtonUp(uint32_t button) +{ + DS_GET_PRIV(DSWaylandPointer); + priv->sendButton(button, WL_POINTER_BUTTON_STATE_RELEASED); } } diff --git a/src/DSWaylandServer/DSWaylandPointer.h b/src/DSWaylandServer/DSWaylandPointer.h index d2f468a..7a1f832 100644 --- a/src/DSWaylandServer/DSWaylandPointer.h +++ b/src/DSWaylandServer/DSWaylandPointer.h @@ -48,6 +48,12 @@ public: void setFocus(DSWaylandSurface *waylandSurface); DSWaylandSurface *getFocus(); + void sendEnter(int surface_x, int surface_y); + void sendLeave(void); + void sendMotion(int surface_x, int surface_y); + void sendButtonDown(uint32_t button); + void sendButtonUp(uint32_t button); + protected: private: diff --git a/src/DSWaylandServer/DSWaylandPointerPrivate.h b/src/DSWaylandServer/DSWaylandPointerPrivate.h index a53bece..aa0809a 100644 --- a/src/DSWaylandServer/DSWaylandPointerPrivate.h +++ b/src/DSWaylandServer/DSWaylandPointerPrivate.h @@ -29,10 +29,15 @@ #include "DSCore.h" #include "DSObjectPrivate.h" +struct wl_resource; + namespace display_server { class DSWaylandSeat; +class DSWaylandCompositor; +class DSWaylandSurface; + class DS_DECL_EXPORT DSWaylandPointerPrivate : public DSObjectPrivate, public DSWaylandServer::wl_pointer { DS_PIMPL_USE_PUBLIC(DSWaylandPointer); @@ -40,6 +45,9 @@ public: DSWaylandPointerPrivate(DSWaylandSeat *seat, DSWaylandPointer *pointer); ~DSWaylandPointerPrivate() override; + void setFocus(DSWaylandSurface *waylandSurface); + DSWaylandSurface *getFocus(); + protected: //virtual Resource *pointer_allocate(); void pointer_bind_resource(Resource *resource) override; @@ -48,13 +56,10 @@ protected: void pointer_release(Resource *resource) override; /* APIs must be provided */ - /* - void sendEnter(struct ::wl_client *client, uint32_t serial, struct ::wl_resource *surface, wl_fixed_t surface_x, wl_fixed_t surface_y); - void sendLeave(struct ::wl_client *client, uint32_t serial, struct ::wl_resource *surface); - void sendMotion(struct ::wl_client *client, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y); - void sendButton(struct ::wl_client *client, uint32_t serial, uint32_t time, uint32_t button, uint32_t state); - */ - + void sendEnter(struct ::wl_resource *wlResource, struct ::wl_resource *surface, int surface_x, int surface_y); + void sendLeave(struct ::wl_resource *wlResource, struct ::wl_resource *surface); + void sendMotion(int surface_x, int surface_y); + void sendButton(uint32_t button, uint32_t state); /* APIs don't need to provide */ /* void sendAxis(struct ::wl_resource *resource, uint32_t time, uint32_t axis, wl_fixed_t value); @@ -66,7 +71,9 @@ protected: private: DSWaylandSeat *__seat; + DSWaylandCompositor *__compositor; DSWaylandSurface *__waylandSurface; + struct ::wl_resource *__wlPointerResource; }; } -- 2.7.4 From 42d205471f4f5124f6e1372157553cbe8335a665 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Sat, 15 Aug 2020 15:38:42 +0900 Subject: [PATCH 10/16] DSPointer: implement mouseDown/Move/Up/In/Out event handler Change-Id: I8221adc5b1357ca97e75a0f29776aa13e022a7ae Signed-off-by: Sung-Jin Park --- src/DSSeat/DSPointer.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++- src/DSSeat/DSPointer.h | 5 +++ 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/src/DSSeat/DSPointer.cpp b/src/DSSeat/DSPointer.cpp index ce2781d..3f6375e 100644 --- a/src/DSSeat/DSPointer.cpp +++ b/src/DSSeat/DSPointer.cpp @@ -27,6 +27,7 @@ #include "DSInputEvent.h" #include "DSWaylandPointer.h" #include "DSWaylandSurface.h" +#include "DSStruct.h" namespace display_server { @@ -59,13 +60,92 @@ void DSPointer::processEvent(DSInputMouseEvent *ev, void *data) DSLOG_ERR("DSPointer", "No ptrFocus available."); return; } + + if (ev->getType() == DSInputEvent::MouseInEvent) + { + DSLOG_DBG("DSTouch", "[mouseIn] devicename: %s, timestamp: %u\n", + ev->getDevice()->getName().c_str(), ev->getTimestamp()); + mouseIn(ev->getX(), ev->getY()); + } + else if (ev->getType() == DSInputEvent::MouseOutEvent) + { + DSLOG_DBG("DSTouch", "[mouseOut] devicename: %s, timestamp: %u\n", + ev->getDevice()->getName().c_str(), ev->getTimestamp()); + mouseOut(); + } + else if (ev->getType() == DSInputEvent::MouseDownEvent) + { + DSLOG_DBG("DSTouch", "[MouseDown] devicename: %s, timestamp: %u\n", + ev->getDevice()->getName().c_str(), ev->getTimestamp()); + mouseDown(ev->getButton()); + } + else if (ev->getType() == DSInputEvent::MouseMoveEvent) + { + DSLOG_DBG("DSTouch", "[mouseMove] devicename: %s, timestamp: %u\n", + ev->getDevice()->getName().c_str(), ev->getTimestamp()); + mouseMove(ev->getX(), ev->getY()); + } + else if (ev->getType() == DSInputEvent::MouseUpEvent) + { + DSLOG_DBG("DSTouch", "[mouseUp] devicename: %s, timestamp: %u\n", + ev->getDevice()->getName().c_str(), ev->getTimestamp()); + mouseUp(ev->getButton()); + } + else + { + DSLOG_INF("DSPointer", "Event type %d won't be handled right now.", ev->getType()); + return; + } +} + +void DSPointer::mouseDown(uint32_t button) +{ + if (__dswlPointer) + { + __dswlPointer->sendButtonDown(button); + } +} + +void DSPointer::mouseUp(uint32_t button) +{ + if (__dswlPointer) + { + __dswlPointer->sendButtonUp(button); + } +} + +void DSPointer::mouseMove(int x, int y) +{ + if (__dswlPointer) + { + __dswlPointer->sendMotion(x, y); + } +} + +void DSPointer::mouseIn(int x, int y) +{ + if (__dswlPointer) + { + __dswlPointer->sendEnter(x, y); + } +} + +void DSPointer::mouseOut() +{ + if (__dswlPointer) + { + __dswlPointer->sendLeave(); + } } void DSPointer::setFocus(std::shared_ptr window) { if (!window) { - DSLOG_ERR("DSPointer", "Given window is INVALID. (window : %p)", window); + DSLOG_ERR("DSPointer", "__ptrFocus has been changed (%p -> %p)", __ptrFocus, window); + __ptrFocus = window; + if (__dswlPointer) + __dswlPointer->setFocus(nullptr); return; } diff --git a/src/DSSeat/DSPointer.h b/src/DSSeat/DSPointer.h index d0dbdc7..5717c51 100644 --- a/src/DSSeat/DSPointer.h +++ b/src/DSSeat/DSPointer.h @@ -45,6 +45,11 @@ public: virtual ~DSPointer(); void processEvent(DSInputMouseEvent *ev, void *data); + void mouseDown(uint32_t button); + void mouseUp(uint32_t button); + void mouseMove(int x, int y); + void mouseIn(int x, int y); + void mouseOut(); void setFocus(std::shared_ptr window); std::shared_ptr getFocus(); -- 2.7.4 From b7505031563bdae29e885e001ed68ab5e77e0cf8 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Sat, 15 Aug 2020 15:40:03 +0900 Subject: [PATCH 11/16] DSSeat: get Top Window on x, y coordinates and set it as a focus window for touch/pointer Change-Id: I45e4bdae90b3f7cd9a50b50f69853aab7765a62a Signed-off-by: Sung-Jin Park --- src/DSSeat/DSSeat.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/DSSeat/DSSeat.h | 1 + 2 files changed, 58 insertions(+) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index 69ca1d2..d8aab6c 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -402,6 +402,33 @@ void DSSeat::__onPointerEvent(DSInputMouseEvent *ev) } __dswlSeat->setCurrentEventTime(ev->getTimestamp()); + + if (ev->getType() == DSInputEvent::MouseMoveEvent) + { + //get window whose geometry has intersection with the mouse coordinates + auto window = getTopWindowOnPosition(ev->getX(), ev->getY()); + + //check if the window is equal to the current pointer focus window + auto currentPointerFocus = __pointer->getFocus(); + + //if equal, no need to set focus / pointer enter/leave activities + if (window.get() != currentPointerFocus.get()) + { + //if not equal, send pointer leave to the current pointer focus window + std::shared_ptr evMouseOut = std::make_shared(ev->getDevice(), DSInputEvent::MouseOutEvent, ev->getTimestamp(), ev->getButton(), ev->getX(), ev->getY(), 0); + __pointer->processEvent(evMouseOut.get(), nullptr); + //TODO : emit MouseOut signal + + //set the window as pointer focus window + __pointer->setFocus(window); + + //send pointer enter to the new pointer focus window + std::shared_ptr evMouseIn = std::make_shared(ev->getDevice(), DSInputEvent::MouseInEvent, ev->getTimestamp(), ev->getButton(), 0, 0, 0); + __pointer->processEvent(evMouseIn.get(), nullptr); + //TODO : emit MouseIn signal + } + } + __pointer->processEvent(ev, nullptr); } @@ -413,6 +440,17 @@ void DSSeat::__onTouchEvent(DSInputTouchEvent *ev) return; } + if (ev->getType() == DSInputEvent::TouchDownEvent) + { + //get window whose geometry has intersection with the touch coordinates + auto window = getTopWindowOnPosition(ev->getX(), ev->getY()); + + //set the window as touch focus window + __touch->setFocus(window); + + //TODO : emit touch focus changed signal + } + __dswlSeat->setCurrentEventTime(ev->getTimestamp()); __touch->processEvent(ev, nullptr); } @@ -472,5 +510,24 @@ Eina_Bool DSSeat::inputEventHandlerTouch(void *data, int type, void *event) return EINA_TRUE; } +std::shared_ptr DSSeat::getTopWindowOnPosition(int x, int y) +{ + stPosition wPos; + stSize wSize; + + std::list> wList = __zone->getWindowList(); + for (auto w : wList) + { + wSize = w->getSize(); + wPos = w->getPosition(); + + if (x >= wPos.x && y >= wPos.y && x <= (int)(wPos.x+wSize.w) && y <= (int)(wPos.y+wSize.h)) + { + DSLOG_INF("DSSeat", "window(%p, x:%d, y:%d, w:%u, h:%u) contains (x:%d, y:%d)", w.get(), wPos.x, wPos.y, wSize.w, wSize.h, x, y); + return w; + } + } +} + } // namespace display_server diff --git a/src/DSSeat/DSSeat.h b/src/DSSeat/DSSeat.h index 25f84c4..9363f6c 100644 --- a/src/DSSeat/DSSeat.h +++ b/src/DSSeat/DSSeat.h @@ -72,6 +72,7 @@ public: void removeTouch(); DSXkb *getXkb(); + std::shared_ptr getTopWindowOnPosition(int x, int y); private: DSInput *__input; -- 2.7.4 From 85dcbdc07fe71ebc5c4413456f1474d380dd250f Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 18 Aug 2020 14:24:23 +0900 Subject: [PATCH 12/16] DSRenderEngineDaliImpl: set default value of __needToRender to 'true' Change-Id: I9078b360b1308fe39145f0d509456209550c6e0c Signed-off-by: Joonbum Ko --- src/DSRender/DSRenderEngineDaliImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp index a716b55..1ab9f6c 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -36,7 +36,7 @@ namespace display_server DSRenderEngineDaliImpl::DSRenderEngineDaliImpl(std::shared_ptr bufferQueue) : __bufferQueue(bufferQueue), - __needToRender(false) + __needToRender(true) { tbm_surface_queue_h nativeBufferQueue = (tbm_surface_queue_h)bufferQueue->getNativeBufferQueue(); __offscreenApplication = OffscreenApplication::New(nativeBufferQueue, true, OffscreenApplication::RenderMode::MANUAL); -- 2.7.4 From e974efe18ea2ea299ad4fddeaefa8bd0cae57604 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 18 Aug 2020 14:32:46 +0900 Subject: [PATCH 13/16] DSWaylandKeyboard: fix to initialze member variable properly, add exception handling on setFocus() Change-Id: I20211a9be278d73bd21baacb230704f347711040 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandKeyboard.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandKeyboard.cpp b/src/DSWaylandServer/DSWaylandKeyboard.cpp index 85fa455..48ce7f4 100644 --- a/src/DSWaylandServer/DSWaylandKeyboard.cpp +++ b/src/DSWaylandServer/DSWaylandKeyboard.cpp @@ -39,8 +39,8 @@ DSWaylandKeyboardPrivate::DSWaylandKeyboardPrivate(DSWaylandSeat *seat, DSWaylan : DSObjectPrivate(keyboard), __p_ptr(keyboard), __seat(seat), - __xkb(seat->getXkb()), - __compositor(seat->getCompositor()), + __xkb(seat ? (seat->getXkb()) : nullptr), + __compositor(seat ? (seat->getCompositor()) : nullptr), __focusSurface(nullptr), __focusClient(nullptr), __repeatRate(0), @@ -267,18 +267,21 @@ void DSWaylandKeyboard::setFocus(DSWaylandSurface *waylandSurface) if (priv->__focusSurface != waylandSurface) { - if (priv->__focusSurface) + if (priv->__focusSurface && priv->__focusSurface->hasResource()) { struct ::wl_resource *surfaceToLeave = priv->__focusSurface->getWlResource(); priv->sendModifiers(surfaceToLeave); priv->sendLeave(surfaceToLeave); } - struct ::wl_resource *surfaceToEnter = waylandSurface->getWlResource(); - priv->sendEnter(surfaceToEnter); + if (waylandSurface && waylandSurface->hasResource()) + { + struct ::wl_resource *surfaceToEnter = waylandSurface->getWlResource(); + priv->sendEnter(surfaceToEnter); - priv->__focusSurface = waylandSurface; - priv->__focusClient = wl_resource_get_client(waylandSurface->getWlResource()); + priv->__focusSurface = waylandSurface; + priv->__focusClient = wl_resource_get_client(waylandSurface->getWlResource()); + } } } -- 2.7.4 From c9bfc8f68a41ee0c081f0bb48ec550465075c1ec Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 18 Aug 2020 14:35:22 +0900 Subject: [PATCH 14/16] DSWaylandSurface: add hasResource() to check validity of a DSWaylandSurface instance Change-Id: I2131ca2f173a2e2a6e43f1ad1560d94cb3920b50 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandSurface.cpp | 9 +++++++++ src/DSWaylandServer/DSWaylandSurface.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp index 9896f38..60d2f56 100644 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ b/src/DSWaylandServer/DSWaylandSurface.cpp @@ -211,4 +211,13 @@ struct ::wl_resource *DSWaylandSurface::getWlResource() return priv->resource()->handle; } +bool DSWaylandSurface::hasResource() +{ + DS_GET_PRIV(DSWaylandSurface); + + if (priv->resource()) + return true; + return false; +} + } /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandSurface.h b/src/DSWaylandServer/DSWaylandSurface.h index c7519dc..7cc360b 100644 --- a/src/DSWaylandServer/DSWaylandSurface.h +++ b/src/DSWaylandServer/DSWaylandSurface.h @@ -63,6 +63,7 @@ public: void registerCallbackSurfaceCommitted(DSObject *slot, std::function commitInfo)> func); struct ::wl_resource *getWlResource(); + bool hasResource(); private: // signals -- 2.7.4 From 0126aee89744108f47837896620f21fcb277f0e1 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 18 Aug 2020 16:25:56 +0900 Subject: [PATCH 15/16] DSWaylandPointer: fix crash at the constructor and setFocus() Change-Id: Iaa6352dc3e4f391fa2135085dc3552afc981678e Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandPointer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandPointer.cpp b/src/DSWaylandServer/DSWaylandPointer.cpp index dea562f..4ae9813 100644 --- a/src/DSWaylandServer/DSWaylandPointer.cpp +++ b/src/DSWaylandServer/DSWaylandPointer.cpp @@ -36,7 +36,7 @@ DSWaylandPointerPrivate::DSWaylandPointerPrivate(DSWaylandSeat *seat, DSWaylandP : DSObjectPrivate(pointer), __p_ptr(pointer), __seat(seat), - __compositor(seat->getCompositor()), + __compositor(seat ? (seat->getCompositor()) : nullptr), __waylandSurface(nullptr), __wlPointerResource(nullptr) { @@ -61,7 +61,7 @@ void DSWaylandPointerPrivate::setFocus(DSWaylandSurface *waylandSurface) __waylandSurface = waylandSurface; - if (!waylandSurface) + if (!waylandSurface || !waylandSurface->hasResource()) { __wlPointerResource = nullptr; DSLOG_INF("DSWaylandPointerPrivate", "wlPointerResource has been set to null."); -- 2.7.4 From 3a7e72fe0377bcc69ee3d77d4a56a9cee06a516c Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 18 Aug 2020 16:28:56 +0900 Subject: [PATCH 16/16] DSWaylandTouch: fix crash at the constructor and setFocus() Change-Id: I6406ab69856a7c21467ee11888edf122f27e9f7a Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandTouch.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandTouch.cpp b/src/DSWaylandServer/DSWaylandTouch.cpp index c2a3fa1..25a267b 100644 --- a/src/DSWaylandServer/DSWaylandTouch.cpp +++ b/src/DSWaylandServer/DSWaylandTouch.cpp @@ -35,7 +35,7 @@ DSWaylandTouchPrivate::DSWaylandTouchPrivate(DSWaylandSeat *seat, DSWaylandTouch : DSObjectPrivate(touch), __p_ptr(touch), __seat(seat), - __compositor(seat->getCompositor()), + __compositor(seat ? (seat->getCompositor()) : nullptr), __waylandSurface(nullptr), __wlTouchResource(nullptr) { @@ -52,8 +52,12 @@ void DSWaylandTouchPrivate::setFocus(DSWaylandSurface *waylandSurface) __waylandSurface = waylandSurface; - if (!waylandSurface) + if (!waylandSurface || !waylandSurface->hasResource()) + { + __wlTouchResource = nullptr; + DSLOG_INF("DSWaylandTouchPrivate", "wlTouchResource has been set to null."); return; + } struct ::wl_resource *surface = waylandSurface->getWlResource(); auto client = wl_resource_get_client(surface); -- 2.7.4