From 406718813f8875e95faceba2b62fb238f39fbf2f Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 31 Jul 2020 15:25:24 +0900 Subject: [PATCH 01/16] DSRenderEngineDaliImpl-test: Add a TC to test texture mapping. Change-Id: I97fcf518b9ea0cbd3c2a60655e524d6dd5fd516f Signed-off-by: Joonbum Ko --- tests/DSRenderEngineDaliImpl-test.cpp | 106 ++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index f03edfe..6f35f9f 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -5,6 +5,15 @@ #include "DSEventLoop.h" #include +#include "DSDisplayDeviceTDMImpl.h" +#include "DSDisplayDeviceOutputTDMImpl.h" + +#include +#include + +#include + +//#include using namespace display_server; @@ -26,11 +35,42 @@ public: EXPECT_TRUE(timer != nullptr); __eventLoop->run(); + + setenv("XDG_RUNTIME_DIR", "/run", 1); + setenv("TBM_DISPLAY_SERVER", "1", 1); } void TearDown(void) override { __eventLoop->quit(); DSEventLoop::releaseInstance(); + + unsetenv("XDG_RUNTIME_DIR"); + unsetenv("TBM_DISPLAY_SERVER"); + } + + tbm_surface_h createTbmTexture(int w, int h, unsigned char r, unsigned char g, unsigned char b, unsigned char a) + { + tbm_surface_h tbmSurface; + tbm_surface_info_s tbmSurface_info; + + tbmSurface = tbm_surface_create(w, h, TBM_FORMAT_ARGB8888); + tbm_surface_map(tbmSurface, TBM_SURF_OPTION_WRITE | TBM_SURF_OPTION_READ, &tbmSurface_info); + + unsigned char *ptr = tbmSurface_info.planes[0].ptr; + for (int j = 0; j < h; j++) + { + for (int i = 0; i < w; i++) + { + ptr[0] = r; + ptr[1] = g; + ptr[2] = b; + ptr[3] = a; + ptr += 4; + } + } + tbm_surface_unmap(tbmSurface); + + return tbmSurface; } private: @@ -85,3 +125,69 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderFrame) EXPECT_TRUE(renderView->setBuffer(buffer)); EXPECT_TRUE(renderEngine->renderFrame()); } + +TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) +{ + std::unique_ptr displayDevice = std::make_unique(); + std::list> outputList = displayDevice->getOutputList(); + EXPECT_TRUE(outputList.size() != 0); + + IDSDisplayDeviceOutput::ConnectorType connType; + IDSDisplayDeviceOutput::ConnectState connState; + std::shared_ptr deviceHWC; + std::shared_ptr deviceHWCWindow; + + //eldbus_init(); + + for (std::shared_ptr output : outputList) { + connType = output->getConnectType(); + EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); + connState = output->getConnectState(); + EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); + if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) + continue; + + auto bestMode = (output->getAvailableModes()).front(); + EXPECT_TRUE(output->setMode(bestMode) == true); + EXPECT_TRUE(output->getMode() == bestMode); + + deviceHWC = output->getHWC(); + EXPECT_TRUE(deviceHWC != nullptr); + + auto bufferQueue = deviceHWC->getTargetBufferQueue(); + EXPECT_TRUE(deviceHWC != nullptr); + + auto renderEngine = std::make_unique(bufferQueue); + EXPECT_TRUE(renderEngine != nullptr); + auto window = std::make_shared(); + EXPECT_TRUE(window != nullptr); + auto renderView = renderEngine->makeRenderView(window); + EXPECT_TRUE(renderView != nullptr); + + deviceHWCWindow = deviceHWC->makeHWCWindow(window); + EXPECT_TRUE(deviceHWC != nullptr); + EXPECT_TRUE(deviceHWC->addVisibleHWCWindow(deviceHWCWindow)); + + tbm_surface_h tbmTexture = DSRenderEngineDaliTest::createTbmTexture( + 100, 100, 255, 0, 0, 255); + EXPECT_TRUE(tbmTexture != nullptr); + + auto imageSourceBuffer = std::make_shared (100, 100, IDSBuffer::FORMAT_ARGB8888, tbmTexture); + EXPECT_TRUE(renderView->setBuffer(imageSourceBuffer)); + EXPECT_TRUE(renderEngine->renderFrame()); + + EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); + + auto buffer = bufferQueue->acquireBuffer(); + EXPECT_TRUE(buffer != nullptr); + + tbm_surface_internal_capture_buffer((tbm_surface_h)buffer->getNativeBuffer(), "/home/owner/media/OSA", "redImg", "png"); + + EXPECT_TRUE(deviceHWC->setTargetBuffer(buffer)); + + // commit + EXPECT_TRUE(deviceHWC->commit()); + + usleep(10000000); + } +} -- 2.7.4 From 6336f63927c033d8043ba72c286a0fd70a4290f2 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 31 Jul 2020 17:36:09 +0900 Subject: [PATCH 02/16] Add eldbus dependency for testing. Change-Id: I57389ee0e0bd14c09367dedd048b728c77ba24ac Signed-off-by: Joonbum Ko --- packaging/libds.spec | 1 + src/meson.build | 5 +++-- tests/DSRenderEngineDaliImpl-test.cpp | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packaging/libds.spec b/packaging/libds.spec index 9e330b4..c0fdaad 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -24,6 +24,7 @@ BuildRequires: pkgconfig(xdg-shell-unstable-v6-server) BuildRequires: pkgconfig(xdg-shell-server) BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(ecore-evas) +BuildRequires: pkgconfig(eldbus) BuildRequires: pkgconfig(libinput) BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(xkbcommon) diff --git a/src/meson.build b/src/meson.build index c6ac5dd..fc3efbb 100644 --- a/src/meson.build +++ b/src/meson.build @@ -173,6 +173,7 @@ wayland_dep = dependency('wayland-server') libinput_dep = dependency('libinput') libudev_dep = dependency('libudev') xkbcommon_dep = dependency('xkbcommon') +eldbus_dep = dependency('eldbus') tizen_ext_dep = dependency('tizen-extension-server') xdg_shell_unstable_v6_dep = dependency('xdg-shell-unstable-v6-server') @@ -224,7 +225,7 @@ libds_include_dirs = include_directories( libds_lib = shared_library( 'ds', libds_srcs, - dependencies : [dlog_dep, libtdm_dep, wayland_dep, tizen_ext_deps, ecore_dep, ecore_evas_dep, libinput_dep, libudev_dep, xkbcommon_dep, libtbm_dep, wayland_tbm_server_dep, dali_deps], + dependencies : [dlog_dep, libtdm_dep, wayland_dep, tizen_ext_deps, ecore_dep, ecore_evas_dep, libinput_dep, libudev_dep, xkbcommon_dep, libtbm_dep, wayland_tbm_server_dep, dali_deps, eldbus_dep], include_directories : [libds_include_dirs], version : meson.project_version(), install : true @@ -233,7 +234,7 @@ libds_lib = shared_library( libds_static_lib = static_library( 'ds', libds_srcs, - dependencies : [dlog_dep, libtdm_dep, wayland_dep, tizen_ext_deps, ecore_dep, ecore_evas_dep, libinput_dep, libudev_dep, xkbcommon_dep, libtbm_dep, wayland_tbm_server_dep, dali_deps], + dependencies : [dlog_dep, libtdm_dep, wayland_dep, tizen_ext_deps, ecore_dep, ecore_evas_dep, libinput_dep, libudev_dep, xkbcommon_dep, libtbm_dep, wayland_tbm_server_dep, dali_deps, eldbus_dep], include_directories : [libds_include_dirs], install : true ) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index 6f35f9f..61ac29a 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -13,7 +13,7 @@ #include -//#include +#include using namespace display_server; @@ -137,7 +137,7 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) std::shared_ptr deviceHWC; std::shared_ptr deviceHWCWindow; - //eldbus_init(); + eldbus_init(); for (std::shared_ptr output : outputList) { connType = output->getConnectType(); -- 2.7.4 From 19d39e8c7ea8a49258620f59bfd8803c1c11902e Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 4 Aug 2020 10:59:24 +0900 Subject: [PATCH 03/16] DSRenderEngineDaliImpl-test: Give time sleep to wait to call eglSwapBuffers. - It is temporary patch for testing it. so, it will be deprecated. Change-Id: If56bf95713377a36be0192c626c8f1027282891d Signed-off-by: Joonbum Ko --- tests/DSRenderEngineDaliImpl-test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index 61ac29a..30230ff 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -176,6 +176,8 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) EXPECT_TRUE(renderView->setBuffer(imageSourceBuffer)); EXPECT_TRUE(renderEngine->renderFrame()); + usleep(1000000); + EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); auto buffer = bufferQueue->acquireBuffer(); @@ -188,6 +190,6 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) // commit EXPECT_TRUE(deviceHWC->commit()); - usleep(10000000); + usleep(1000000); } } -- 2.7.4 From 4135a9721da04804f2a2e3058d3f79fd3e9e2abd Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 5 Aug 2020 15:28:44 +0900 Subject: [PATCH 04/16] DSRenderEngineDaliImpl-test: Set color value to the correct color index Change-Id: I25f3ace0e5d564b01805a5a729dd0609ae68fb76 Signed-off-by: Joonbum Ko --- tests/DSRenderEngineDaliImpl-test.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index 30230ff..d5519f5 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -61,9 +61,9 @@ public: { for (int i = 0; i < w; i++) { - ptr[0] = r; + ptr[0] = b; ptr[1] = g; - ptr[2] = b; + ptr[2] = r; ptr[3] = a; ptr += 4; } @@ -183,8 +183,6 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) auto buffer = bufferQueue->acquireBuffer(); EXPECT_TRUE(buffer != nullptr); - tbm_surface_internal_capture_buffer((tbm_surface_h)buffer->getNativeBuffer(), "/home/owner/media/OSA", "redImg", "png"); - EXPECT_TRUE(deviceHWC->setTargetBuffer(buffer)); // commit -- 2.7.4 From e762904b0e4039c2ed037a1d915b9e26b4fb6b90 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 5 Aug 2020 15:30:16 +0900 Subject: [PATCH 05/16] DSRenderEngineDaliImpl: Added properties to actor. Change-Id: Ic5b7cb40c03baf052bbc2ef9f6398bcef909b6a5 Signed-off-by: Joonbum Ko --- src/DSRender/DSRenderEngineDaliImpl.cpp | 7 +++++++ src/DSRender/DSRenderViewDaliImpl.cpp | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp index c61a8e3..ccc053a 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -2,6 +2,8 @@ #include "DSRenderViewDaliImpl.h" #include "DSDebugLog.h" +#include + #include using namespace Dali; @@ -32,6 +34,11 @@ void DSRenderEngineDaliImpl::onInitialize() Toolkit::TextLabel textlabel = Toolkit::TextLabel::New("Hello libDS"); textlabel.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); + textlabel.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + textlabel.SetProperty(Dali::DevelActor::Property::POSITION_USES_ANCHOR_POINT, false); + textlabel.SetProperty(Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f )); + textlabel.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE); + textlabel.SetProperty(Toolkit::TextLabel::Property::POINT_SIZE, 30.f); window.Add(textlabel); /* for testing -- end -- */ } diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp index 55dcd14..23536c9 100644 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ b/src/DSRender/DSRenderViewDaliImpl.cpp @@ -1,4 +1,5 @@ #include "DSRenderViewDaliImpl.h" +#include using namespace Dali; @@ -70,6 +71,14 @@ DSRenderViewDaliImpl::DSRenderViewDaliImpl(std::shared_ptr window, Dal __textureViewActor = Actor::New(); __textureViewActor.AddRenderer(__renderer); + + // belows for testing // + __textureViewActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + __textureViewActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); + __textureViewActor.SetProperty(Actor::Property::POSITION, Vector3( 0.0f, 100.f, 0.0f )); + __textureViewActor.SetProperty(Actor::Property::SIZE, Vector2(500, 500)); + + offscreenWindow.Add(__textureViewActor); } @@ -79,7 +88,7 @@ DSRenderViewDaliImpl::~DSRenderViewDaliImpl() bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) { - void *nativeBuffer = buffer->getNativeBuffer(); + tbm_surface_h nativeBuffer = (tbm_surface_h)buffer->getNativeBuffer(); NativeImageSourcePtr nativeImageSource = NativeImageSource::New(Any(nativeBuffer)); -- 2.7.4 From a327c2ace27b0127a9ae9924d83c06edb026d2f9 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 5 Aug 2020 15:31:05 +0900 Subject: [PATCH 06/16] DSRenderEngineDaliImpl: Changed default bg color to TRANSPARENT. Change-Id: I42f5c4b075ee4c4b66d818c73bcbfb9313cfb942 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 ccc053a..fa39a88 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -30,7 +30,7 @@ void DSRenderEngineDaliImpl::onInitialize() { /* for testing -- begin -- */ OffscreenWindow window = __offscreenApplication.GetWindow(); - window.SetBackgroundColor(Color::YELLOW); + window.SetBackgroundColor(Color::TRANSPARENT); Toolkit::TextLabel textlabel = Toolkit::TextLabel::New("Hello libDS"); textlabel.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); -- 2.7.4 From aff5bb7f7642fefa56708c3ba0bd63a22230da54 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 5 Aug 2020 18:04:11 +0900 Subject: [PATCH 07/16] Delete eldbus dependency. Change-Id: I458377826e51df848e4c8e572cbfaa5a2152d746 Signed-off-by: Joonbum Ko --- packaging/libds.spec | 1 - src/meson.build | 5 ++--- tests/DSRenderEngineDaliImpl-test.cpp | 4 ---- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/packaging/libds.spec b/packaging/libds.spec index c0fdaad..9e330b4 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -24,7 +24,6 @@ BuildRequires: pkgconfig(xdg-shell-unstable-v6-server) BuildRequires: pkgconfig(xdg-shell-server) BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(ecore-evas) -BuildRequires: pkgconfig(eldbus) BuildRequires: pkgconfig(libinput) BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(xkbcommon) diff --git a/src/meson.build b/src/meson.build index fc3efbb..c6ac5dd 100644 --- a/src/meson.build +++ b/src/meson.build @@ -173,7 +173,6 @@ wayland_dep = dependency('wayland-server') libinput_dep = dependency('libinput') libudev_dep = dependency('libudev') xkbcommon_dep = dependency('xkbcommon') -eldbus_dep = dependency('eldbus') tizen_ext_dep = dependency('tizen-extension-server') xdg_shell_unstable_v6_dep = dependency('xdg-shell-unstable-v6-server') @@ -225,7 +224,7 @@ libds_include_dirs = include_directories( libds_lib = shared_library( 'ds', libds_srcs, - dependencies : [dlog_dep, libtdm_dep, wayland_dep, tizen_ext_deps, ecore_dep, ecore_evas_dep, libinput_dep, libudev_dep, xkbcommon_dep, libtbm_dep, wayland_tbm_server_dep, dali_deps, eldbus_dep], + dependencies : [dlog_dep, libtdm_dep, wayland_dep, tizen_ext_deps, ecore_dep, ecore_evas_dep, libinput_dep, libudev_dep, xkbcommon_dep, libtbm_dep, wayland_tbm_server_dep, dali_deps], include_directories : [libds_include_dirs], version : meson.project_version(), install : true @@ -234,7 +233,7 @@ libds_lib = shared_library( libds_static_lib = static_library( 'ds', libds_srcs, - dependencies : [dlog_dep, libtdm_dep, wayland_dep, tizen_ext_deps, ecore_dep, ecore_evas_dep, libinput_dep, libudev_dep, xkbcommon_dep, libtbm_dep, wayland_tbm_server_dep, dali_deps, eldbus_dep], + dependencies : [dlog_dep, libtdm_dep, wayland_dep, tizen_ext_deps, ecore_dep, ecore_evas_dep, libinput_dep, libudev_dep, xkbcommon_dep, libtbm_dep, wayland_tbm_server_dep, dali_deps], include_directories : [libds_include_dirs], install : true ) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index d5519f5..3f553ad 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -13,8 +13,6 @@ #include -#include - using namespace display_server; class DSRenderEngineDaliTest : public ::testing::Test @@ -137,8 +135,6 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) std::shared_ptr deviceHWC; std::shared_ptr deviceHWCWindow; - eldbus_init(); - for (std::shared_ptr output : outputList) { connType = output->getConnectType(); EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); -- 2.7.4 From d1f89e367abed31af4d1ec68b2ee4cded20dc6da Mon Sep 17 00:00:00 2001 From: jeon Date: Wed, 5 Aug 2020 21:13:48 +0900 Subject: [PATCH 08/16] DSWaylandTextInput: process wl_text_input requests Change-Id: I09abdbf918ad316a20d36163cc7778633559fbe4 --- src/DSTextInput/DSTextInput.cpp | 108 +++++- src/DSTextInput/DSTextInputPrivate.h | 31 ++ src/DSWaylandServer/DSWaylandInputMethod.cpp | 405 +++++++++++++++++++-- src/DSWaylandServer/DSWaylandInputMethod.h | 20 + src/DSWaylandServer/DSWaylandInputMethodContext.h | 20 +- .../DSWaylandInputMethodContextPrivate.h | 20 +- src/DSWaylandServer/DSWaylandInputMethodPrivate.h | 7 +- src/DSWaylandServer/DSWaylandTextInput.cpp | 286 ++++++++++++++- src/DSWaylandServer/DSWaylandTextInputPrivate.h | 5 + tests/DSWaylandInputMethod-test.cpp | 266 ++++++++++++++ tests/DSWaylandInputMethodContext-test.cpp | 238 ++++++++++++ 11 files changed, 1366 insertions(+), 40 deletions(-) diff --git a/src/DSTextInput/DSTextInput.cpp b/src/DSTextInput/DSTextInput.cpp index 09133cd..9c2f256 100644 --- a/src/DSTextInput/DSTextInput.cpp +++ b/src/DSTextInput/DSTextInput.cpp @@ -8,7 +8,8 @@ namespace display_server { DSTextInputPrivate::DSTextInputPrivate(DSTextInput *p_ptr) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) + : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), + __inputPanelState(InputPanelStateDidHide) { __wlCompositor = DSWaylandCompositor::getInstance(); __wlTextInputManager = new DSWaylandTextInputManager(__wlCompositor, this); @@ -22,6 +23,16 @@ DSTextInputPrivate::~DSTextInputPrivate() DSWaylandCompositor::releaseInstance(); } +void DSTextInputPrivate::setInputPanelState(InputPanelState state) +{ + __inputPanelState = state; +} + +DSTextInputPrivate::InputPanelState DSTextInputPrivate::getInputPanelState() +{ + return __inputPanelState; +} + void DSTextInputPrivate::activateTextInput(DSWaylandTextInput *wlTextInput, int id) { __wlInputMethod->activate(id); @@ -32,6 +43,101 @@ void DSTextInputPrivate::deactivateTextInput(DSWaylandTextInput *wlTextInput) __wlInputMethod->deactivate(); } +void DSTextInputPrivate::showInputPanel(DSWaylandTextInput *wlTextInput, int id) +{ + __wlInputMethod->showInputPanel(id); +} + +void DSTextInputPrivate::hideInputPanel(int id) +{ + __wlInputMethod->hideInputPanel(id); +} + +void DSTextInputPrivate::resetTextInput() +{ + __wlInputMethod->resetTextInput(); +} + +void DSTextInputPrivate::setContentType(unsigned int hint, unsigned int purpose) +{ + __wlInputMethod->setContentType(hint, purpose); +} + +void DSTextInputPrivate::setPreferredLanguage(const std::string language) +{ + __wlInputMethod->setPreferredLanguage(language); +} + +void DSTextInputPrivate::commitState(unsigned int serial) +{ + __wlInputMethod->commitState(serial); +} + +void DSTextInputPrivate::invokeAction(unsigned int button, unsigned int index) +{ + __wlInputMethod->invokeAction(button, index); +} + +void DSTextInputPrivate::setReturnKeyType(unsigned int returnKeyType) +{ + __wlInputMethod->setReturnKeyType(returnKeyType); +} + +void DSTextInputPrivate::returnKeyDisabled(unsigned int returnKeyDisabled) +{ + __wlInputMethod->returnKeyDisabled(returnKeyDisabled); +} + +void DSTextInputPrivate::setInputPanelData(std::string inputPanelData, unsigned int inputPanelLength) +{ + __wlInputMethod->setInputPanelData(inputPanelData, inputPanelLength); +} + +void DSTextInputPrivate::bidiDirection(unsigned int direction) +{ + __wlInputMethod->bidiDirection(direction); +} + +void DSTextInputPrivate::setCursorPosition(unsigned int cursorPosition) +{ + __wlInputMethod->setCursorPosition(cursorPosition); +} + +void DSTextInputPrivate::processInputDeviceEvent(unsigned int eventType, std::string eventData, unsigned int eventLength) +{ + __wlInputMethod->processInputDeviceEvent(eventType, eventData, eventLength); +} + +void DSTextInputPrivate::filterKeyEvent(unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode) +{ + __wlInputMethod->filterKeyEvent(serial, time, keyName, state, modifiers, devName, devClass, devSubclass, keycode); +} + +void DSTextInputPrivate::setCapitalMode(unsigned int mode) +{ + __wlInputMethod->setCapitalMode(mode); +} + +void DSTextInputPrivate::predictionHint(std::string text) +{ + __wlInputMethod->predictionHint(text); +} + +void DSTextInputPrivate::setMimeType(std::string type) +{ + __wlInputMethod->setMimeType(type); +} + +void DSTextInputPrivate::finalizeContent(std::string text, unsigned int cursorPosition) +{ + __wlInputMethod->finalizeContent(text, cursorPosition); +} + +void DSTextInputPrivate::predictionHintData(std::string key, std::string value) +{ + __wlInputMethod->predictionHintData(key, value); +} + DSTextInput::DSTextInput() : DS_INIT_PRIVATE_PTR(DSTextInput) diff --git a/src/DSTextInput/DSTextInputPrivate.h b/src/DSTextInput/DSTextInputPrivate.h index 55838ba..dec7d69 100644 --- a/src/DSTextInput/DSTextInputPrivate.h +++ b/src/DSTextInput/DSTextInputPrivate.h @@ -19,17 +19,48 @@ class DSTextInputPrivate : public DSObjectPrivate { DS_PIMPL_USE_PUBLIC(DSTextInput); public: + enum InputPanelState + { + InputPanelStateDidHide, + InputPanelStateWillHide, + InputPanelStateDidShow, + InputPanelStateWillShow + }; + DSTextInputPrivate() = delete; DSTextInputPrivate(DSTextInput *p_ptr); ~DSTextInputPrivate(); + void setInputPanelState(InputPanelState state); + InputPanelState getInputPanelState(); + void activateTextInput(DSWaylandTextInput *wlTextInput, int id); void deactivateTextInput(DSWaylandTextInput *wlTextInput); + void showInputPanel(DSWaylandTextInput *wlTextInput, int id); + void hideInputPanel(int id); + void resetTextInput(); + void setContentType(unsigned int hint, unsigned int purpose); + void setPreferredLanguage(const std::string language); + void commitState(unsigned int serial); + void invokeAction(unsigned int button, unsigned int index); + void setReturnKeyType(unsigned int returnKeyType); + void returnKeyDisabled(unsigned int returnKeyDisabled); + void setInputPanelData(std::string inputPanelData, unsigned int inputPanelLength); + void bidiDirection(unsigned int direction); + void setCursorPosition(unsigned int cursorPosition); + void processInputDeviceEvent(unsigned int eventType, std::string eventData, unsigned int eventLength); + void filterKeyEvent(unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode); + void setCapitalMode(unsigned int mode); + void predictionHint(std::string text); + void setMimeType(std::string type); + void finalizeContent(std::string text, unsigned int cursorPosition); + void predictionHintData(std::string key, std::string value); private: DSWaylandCompositor *__wlCompositor; DSWaylandTextInputManager *__wlTextInputManager; DSWaylandInputMethod *__wlInputMethod; + InputPanelState __inputPanelState; }; } diff --git a/src/DSWaylandServer/DSWaylandInputMethod.cpp b/src/DSWaylandServer/DSWaylandInputMethod.cpp index 93e61a4..9a9acbf 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.cpp +++ b/src/DSWaylandServer/DSWaylandInputMethod.cpp @@ -16,15 +16,96 @@ DSWaylandInputMethodContextPrivate::~DSWaylandInputMethodContextPrivate() { } -void DSWaylandInputMethodContextPrivate::createGlobal(void *client) +void* DSWaylandInputMethodContextPrivate::createGlobal(void *client) { - //add((struct ::wl_client *)client, 1); - init((struct ::wl_client *)client, 0, 1); + Resource *resource = add((struct ::wl_client *)client, 1); + return resource->handle; + //init((struct ::wl_client *)client, 0, 1); } -void *DSWaylandInputMethodContextPrivate::getWlResource() +void DSWaylandInputMethodContextPrivate::sendReset(void *contextResource) { - return (void *)(resource()->handle); + send_reset((struct ::wl_resource *)contextResource); +} + +void DSWaylandInputMethodContextPrivate::sendContentType(void *contextResource, unsigned int hint, unsigned int purpose) +{ + send_content_type((struct ::wl_resource *)contextResource, hint, purpose); +} + +void DSWaylandInputMethodContextPrivate::sendPreferredLanguage(void *contextResource, const std::string language) +{ + send_preferred_language((struct ::wl_resource *)contextResource, language); +} + +void DSWaylandInputMethodContextPrivate::sendCommitState(void *contextResource, unsigned int serial) +{ + send_commit_state((struct ::wl_resource *)contextResource, serial); +} + +void DSWaylandInputMethodContextPrivate::sendInvokeAction(void *contextResource, unsigned int button, unsigned int index) +{ + send_invoke_action((struct ::wl_resource *)contextResource, button, index); +} + +void DSWaylandInputMethodContextPrivate::sendReturnKeyType(void *contextResource, unsigned int returnKeyType) +{ + send_return_key_type((struct ::wl_resource *)contextResource, returnKeyType); +} + +void DSWaylandInputMethodContextPrivate::sendReturnKeyDisabled(void *contextResource, unsigned int returnKeyDisabled) +{ + send_return_key_disabled((struct ::wl_resource *)contextResource, returnKeyDisabled); +} + +void DSWaylandInputMethodContextPrivate::sendInputPanelData(void *contextResource, std::string inputPanelData, unsigned int inputPanelLength) +{ + send_input_panel_data((struct ::wl_resource *)contextResource, inputPanelData, inputPanelLength); +} + +void DSWaylandInputMethodContextPrivate::sendBidiDirection(void *contextResource, unsigned int direction) +{ + send_bidi_direction((struct ::wl_resource *)contextResource, direction); +} + +void DSWaylandInputMethodContextPrivate::sendCursorPosition(void *contextResource, unsigned int cursorPosition) +{ + send_cursor_position((struct ::wl_resource *)contextResource, cursorPosition); +} + +void DSWaylandInputMethodContextPrivate::sendProcessInputDeviceEvent(void *contextResource, unsigned int eventType, std::string eventData, unsigned int eventLength) +{ + send_process_input_device_event((struct ::wl_resource *)contextResource, eventType, eventData, eventLength); +} + +void DSWaylandInputMethodContextPrivate::sendFilterKeyEvent(void *contextResource, unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode) +{ + send_filter_key_event((struct ::wl_resource *)contextResource, serial, time, keyName, state, modifiers, devName, devClass, devSubclass, keycode); +} + +void DSWaylandInputMethodContextPrivate::sendCapitalMode(void *contextResource, unsigned int mode) +{ + send_capital_mode((struct ::wl_resource *)contextResource, mode); +} + +void DSWaylandInputMethodContextPrivate::sendPredictionHint(void *contextResource, std::string text) +{ + send_prediction_hint((struct ::wl_resource *)contextResource, text); +} + +void DSWaylandInputMethodContextPrivate::sendMimeType(void *contextResource, std::string type) +{ + send_mime_type((struct ::wl_resource *)contextResource, type); +} + +void DSWaylandInputMethodContextPrivate::sendFinalizedContent(void *contextResource, std::string text, unsigned int cursorPosition) +{ + send_finalized_content((struct ::wl_resource *)contextResource, text, cursorPosition); +} + +void DSWaylandInputMethodContextPrivate::sendPredictionHintData(void *contextResource, std::string key, std::string value) +{ + send_prediction_hint_data((struct ::wl_resource *)contextResource, key, value); } void DSWaylandInputMethodContextPrivate::input_method_context_destroy(Resource *resource) @@ -147,18 +228,147 @@ DSWaylandInputMethodContext::~DSWaylandInputMethodContext() { } -void DSWaylandInputMethodContext::createGlobal(void *client) +void* DSWaylandInputMethodContext::createGlobal(void *client) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + return priv->createGlobal(client); +} + +void DSWaylandInputMethodContext::sendReset(void *contextResource) { DS_GET_PRIV(DSWaylandInputMethodContext); - priv->createGlobal(client); + if (contextResource) + return priv->sendReset(contextResource); } -void *DSWaylandInputMethodContext::getWlResource() +void DSWaylandInputMethodContext::sendContentType(void *contextResource, unsigned int hint, unsigned int purpose) { DS_GET_PRIV(DSWaylandInputMethodContext); - return priv->getWlResource(); + if (contextResource) + return priv->sendContentType(contextResource, hint, purpose); +} + +void DSWaylandInputMethodContext::sendPreferredLanguage(void *contextResource, const std::string language) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendPreferredLanguage(contextResource, language); +} + +void DSWaylandInputMethodContext::sendCommitState(void *contextResource, unsigned int serial) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendCommitState(contextResource, serial); +} + +void DSWaylandInputMethodContext::sendInvokeAction(void *contextResource, unsigned int button, unsigned int index) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendInvokeAction(contextResource, button, index); +} + +void DSWaylandInputMethodContext::sendReturnKeyType(void *contextResource, unsigned int returnKeyType) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendReturnKeyType(contextResource, returnKeyType); +} + +void DSWaylandInputMethodContext::sendReturnKeyDisabled(void *contextResource, unsigned int returnKeyDisabled) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendReturnKeyDisabled(contextResource, returnKeyDisabled); +} + +void DSWaylandInputMethodContext::sendInputPanelData(void *contextResource, std::string inputPanelData, unsigned int inputPanelLength) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendInputPanelData(contextResource, inputPanelData, inputPanelLength); +} + +void DSWaylandInputMethodContext::sendBidiDirection(void *contextResource, unsigned int direction) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendBidiDirection(contextResource, direction); +} + +void DSWaylandInputMethodContext::sendCursorPosition(void *contextResource, unsigned int cursorPosition) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendCursorPosition(contextResource, cursorPosition); +} + +void DSWaylandInputMethodContext::sendProcessInputDeviceEvent(void *contextResource, unsigned int eventType, std::string eventData, unsigned int eventLength) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendProcessInputDeviceEvent(contextResource, eventType, eventData, eventLength); +} + +void DSWaylandInputMethodContext::sendFilterKeyEvent(void *contextResource, unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendFilterKeyEvent(contextResource, serial, time, keyName, state, modifiers, devName, devClass, devSubclass, keycode); +} + +void DSWaylandInputMethodContext::sendCapitalMode(void *contextResource, unsigned int mode) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendCapitalMode(contextResource, mode); +} + +void DSWaylandInputMethodContext::sendPredictionHint(void *contextResource, std::string text) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendPredictionHint(contextResource, text); +} + +void DSWaylandInputMethodContext::sendMimeType(void *contextResource, std::string type) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendMimeType(contextResource, type); +} + +void DSWaylandInputMethodContext::sendFinalizedContent(void *contextResource, std::string text, unsigned int cursorPosition) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendFinalizedContent(contextResource, text, cursorPosition); +} + +void DSWaylandInputMethodContext::sendPredictionHintData(void *contextResource, std::string key, std::string value) +{ + DS_GET_PRIV(DSWaylandInputMethodContext); + + if (contextResource) + return priv->sendPredictionHintData(contextResource, key, value); } @@ -178,16 +388,64 @@ DSWaylandInputMethodPrivate::~DSWaylandInputMethodPrivate() { } +int DSWaylandInputMethodPrivate::getResourceId(Resource *resource) +{ + int id = -1; + + std::multimap::iterator it; + for (it = __contextMap.begin(); it != __contextMap.end(); it++) + { + if (resource == (*it).first) + { + id = (*it).second; + break; + } + } + + return id; +} + +DSWaylandServer::wl_input_method::Resource* DSWaylandInputMethodPrivate::getResource(int id) +{ + Resource *resource = nullptr; + + std::multimap::iterator it; + for (it = __contextMap.begin(); it != __contextMap.end(); it++) + { + if (id == (*it).second) + { + resource = (*it).first; + break; + } + } + + return resource; +} + void DSWaylandInputMethodPrivate::sendActivate(void *contextResource, int textInputId, bool focusInEvent) { + Resource *resource = Resource::fromResource((struct ::wl_resource *)contextResource); + __contextMap.insert(std::pair(resource, textInputId)); send_activate(__resource->handle, (struct ::wl_resource *)contextResource, textInputId, focusInEvent); } void DSWaylandInputMethodPrivate::sendDeactivate(void *contextResource, bool focusInEvent) { + Resource *resource = Resource::fromResource((struct ::wl_resource *)contextResource); + __contextMap.erase(resource); send_deactivate(__resource->handle, (struct ::wl_resource *)contextResource, focusInEvent); } +void DSWaylandInputMethodPrivate::showInputPanel(void *contextResource) +{ + send_show_input_panel((struct ::wl_resource *)contextResource); +} + +void DSWaylandInputMethodPrivate::hideInputPanel(void *contextResource) +{ + send_hide_input_panel((struct ::wl_resource *)contextResource); +} + void DSWaylandInputMethodPrivate::input_method_bind_resource(Resource *resource) { __resource = resource; @@ -204,7 +462,8 @@ void DSWaylandInputMethodPrivate::input_method_destroy_resource(Resource *resour DSWaylandInputMethod::DSWaylandInputMethod(DSWaylandCompositor *compositor) : DSObject(), _d_ptr(std::make_unique(this, compositor)), __dsTextInputPrivate(nullptr), - __compositor(compositor) + __compositor(compositor), + __activateContext(nullptr) { __inputMethodContext = new DSWaylandInputMethodContext(compositor, this); } @@ -212,7 +471,8 @@ DSWaylandInputMethod::DSWaylandInputMethod(DSWaylandCompositor *compositor) DSWaylandInputMethod::DSWaylandInputMethod(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate) : DSObject(), _d_ptr(std::make_unique(this, compositor)), __dsTextInputPrivate(dsTextInputPrivate), - __compositor(compositor) + __compositor(compositor), + __activateContext(nullptr) { __inputMethodContext = new DSWaylandInputMethodContext(compositor, this); } @@ -229,24 +489,127 @@ DSWaylandInputMethodContext* DSWaylandInputMethod::getContext() void DSWaylandInputMethod::activate(int textInputId) { DS_GET_PRIV(DSWaylandInputMethod); - void *contextResource = __inputMethodContext->getWlResource(); - if (!contextResource) - __inputMethodContext->createGlobal((void *)(priv->__resource->client())); + if (!__activateContext) + { + if (priv->__resource) + __activateContext = __inputMethodContext->createGlobal((void *)(priv->__resource->client())); + } - contextResource = __inputMethodContext->getWlResource(); - - if (contextResource) - priv->sendActivate(contextResource, textInputId, true); + if (__activateContext) + priv->sendActivate(__activateContext, textInputId, true); } void DSWaylandInputMethod::deactivate() { DS_GET_PRIV(DSWaylandInputMethod); - void *contextResource = __inputMethodContext->getWlResource(); - if (contextResource) - priv->sendDeactivate(contextResource, true); + if (__activateContext) + { + priv->sendDeactivate(__activateContext, true); + __activateContext = nullptr; + } +} + +void DSWaylandInputMethod::showInputPanel(int textInputId) +{ + DS_GET_PRIV(DSWaylandInputMethod); + + if (__activateContext) + priv->showInputPanel(__activateContext); +} + +void DSWaylandInputMethod::hideInputPanel(int textInputId) +{ + DS_GET_PRIV(DSWaylandInputMethod); + + if (__activateContext) + priv->hideInputPanel(__activateContext); +} + +void DSWaylandInputMethod::resetTextInput() +{ + __inputMethodContext->sendReset(__activateContext); +} + +void DSWaylandInputMethod::setContentType(unsigned int hint, unsigned int purpose) +{ + __inputMethodContext->sendContentType(__activateContext, hint, purpose); +} + +void DSWaylandInputMethod::setPreferredLanguage(const std::string language) +{ + __inputMethodContext->sendPreferredLanguage(__activateContext, language); +} + +void DSWaylandInputMethod::commitState(unsigned int serial) +{ + __inputMethodContext->sendCommitState(__activateContext, serial); +} + +void DSWaylandInputMethod::invokeAction(unsigned int button, unsigned int index) +{ + __inputMethodContext->sendInvokeAction(__activateContext, button, index); +} + +void DSWaylandInputMethod::setReturnKeyType(unsigned int returnKeyType) +{ + __inputMethodContext->sendReturnKeyType(__activateContext, returnKeyType); +} + +void DSWaylandInputMethod::returnKeyDisabled(unsigned int returnKeyDisabled) +{ + __inputMethodContext->sendReturnKeyDisabled(__activateContext, returnKeyDisabled); +} + +void DSWaylandInputMethod::setInputPanelData(std::string inputPanelData, unsigned int inputPanelLength) +{ + __inputMethodContext->sendInputPanelData(__activateContext, inputPanelData, inputPanelLength); +} + +void DSWaylandInputMethod::bidiDirection(unsigned int direction) +{ + __inputMethodContext->sendBidiDirection(__activateContext, direction); +} + +void DSWaylandInputMethod::setCursorPosition(unsigned int cursorPosition) +{ + __inputMethodContext->sendCursorPosition(__activateContext, cursorPosition); +} + +void DSWaylandInputMethod::processInputDeviceEvent(unsigned int eventType, std::string eventData, unsigned int eventLength) +{ + __inputMethodContext->sendProcessInputDeviceEvent(__activateContext, eventType, eventData, eventLength); +} + +void DSWaylandInputMethod::filterKeyEvent(unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode) +{ + __inputMethodContext->sendFilterKeyEvent(__activateContext, serial, time, keyName, state, modifiers, devName, devClass, devSubclass, keycode); +} + +void DSWaylandInputMethod::setCapitalMode(unsigned int mode) +{ + __inputMethodContext->sendCapitalMode(__activateContext, mode); +} + +void DSWaylandInputMethod::predictionHint(std::string text) +{ + __inputMethodContext->sendPredictionHint(__activateContext, text); +} + +void DSWaylandInputMethod::setMimeType(std::string type) +{ + __inputMethodContext->sendMimeType(__activateContext, type); +} + +void DSWaylandInputMethod::finalizeContent(std::string text, unsigned int cursorPosition) +{ + __inputMethodContext->sendFinalizedContent(__activateContext, text, cursorPosition); +} + +void DSWaylandInputMethod::predictionHintData(std::string key, std::string value) +{ + __inputMethodContext->sendPredictionHintData(__activateContext, key, value); } diff --git a/src/DSWaylandServer/DSWaylandInputMethod.h b/src/DSWaylandServer/DSWaylandInputMethod.h index cef16ae..4360e50 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.h +++ b/src/DSWaylandServer/DSWaylandInputMethod.h @@ -23,6 +23,25 @@ public: DSWaylandInputMethodContext* getContext(); void activate(int textInputId); void deactivate(); + void showInputPanel(int textInputId); + void hideInputPanel(int textInputId); + void resetTextInput(); + void setContentType(unsigned int hint, unsigned int purpose); + void setPreferredLanguage(const std::string language); + void commitState(unsigned int serial); + void invokeAction(unsigned int button, unsigned int index); + void setReturnKeyType(unsigned int returnKeyType); + void returnKeyDisabled(unsigned int returnKeyDisabled); + void setInputPanelData(std::string inputPanelData, unsigned int inputPanelLength); + void bidiDirection(unsigned int direction); + void setCursorPosition(unsigned int cursorPosition); + void processInputDeviceEvent(unsigned int eventType, std::string eventData, unsigned int eventLength); + void filterKeyEvent(unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode); + void setCapitalMode(unsigned int mode); + void predictionHint(std::string text); + void setMimeType(std::string type); + void finalizeContent(std::string text, unsigned int cursorPosition); + void predictionHintData(std::string key, std::string value); protected: @@ -30,6 +49,7 @@ private: DSTextInputPrivate *__dsTextInputPrivate; DSWaylandCompositor *__compositor; DSWaylandInputMethodContext *__inputMethodContext; + void *__activateContext; }; } diff --git a/src/DSWaylandServer/DSWaylandInputMethodContext.h b/src/DSWaylandServer/DSWaylandInputMethodContext.h index ad7ebd6..3de82f2 100644 --- a/src/DSWaylandServer/DSWaylandInputMethodContext.h +++ b/src/DSWaylandServer/DSWaylandInputMethodContext.h @@ -18,8 +18,24 @@ public: DSWaylandInputMethodContext(DSWaylandCompositor *compositor, DSWaylandInputMethod *inputMethod); ~DSWaylandInputMethodContext() override; - void createGlobal(void *client); - void *getWlResource(); + void* createGlobal(void *client); + void sendReset(void *contextResource); + void sendContentType(void *contextResource, unsigned int hint, unsigned int purpose); + void sendPreferredLanguage(void *contextResource, const std::string language); + void sendCommitState(void *contextResource, unsigned int serial); + void sendInvokeAction(void *contextResource, unsigned int button, unsigned int index); + void sendReturnKeyType(void *contextResource, unsigned int returnKeyType); + void sendReturnKeyDisabled(void *contextResource, unsigned int returnKeyDisabled); + void sendInputPanelData(void *contextResource, std::string inputPanelData, unsigned int inputPanelLength); + void sendBidiDirection(void *contextResource, unsigned int direction); + void sendCursorPosition(void *contextResource, unsigned int cursorPosition); + void sendProcessInputDeviceEvent(void *contextResource, unsigned int eventType, std::string eventData, unsigned int eventLength); + void sendFilterKeyEvent(void *contextResource, unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode); + void sendCapitalMode(void *contextResource, unsigned int mode); + void sendPredictionHint(void *contextResource, std::string text); + void sendMimeType(void *contextResource, std::string type); + void sendFinalizedContent(void *contextResource, std::string text, unsigned int cursorPosition); + void sendPredictionHintData(void *contextResource, std::string key, std::string value); protected: diff --git a/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h b/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h index 75d63e2..8ea1dab 100644 --- a/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h +++ b/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h @@ -17,8 +17,24 @@ public: DSWaylandInputMethodContextPrivate(DSWaylandInputMethodContext *p_ptr, DSWaylandCompositor *compositor); ~DSWaylandInputMethodContextPrivate() override; - void createGlobal(void *client); - void *getWlResource(); + void* createGlobal(void *client); + void sendReset(void *contextResource); + void sendContentType(void *contextResource, unsigned int hint, unsigned int purpose); + void sendPreferredLanguage(void *contextResource, const std::string language); + void sendCommitState(void *contextResource, unsigned int serial); + void sendInvokeAction(void *contextResource, unsigned int button, unsigned int index); + void sendReturnKeyType(void *contextResource, unsigned int returnKeyType); + void sendReturnKeyDisabled(void *contextResource, unsigned int returnKeyDisabled); + void sendInputPanelData(void *contextResource, std::string inputPanelData, unsigned int inputPanelLength); + void sendBidiDirection(void *contextResource, unsigned int direction); + void sendCursorPosition(void *contextResource, unsigned int cursorPosition); + void sendProcessInputDeviceEvent(void *contextResource, unsigned int eventType, std::string eventData, unsigned int eventLength); + void sendFilterKeyEvent(void *contextResource, unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode); + void sendCapitalMode(void *contextResource, unsigned int mode); + void sendPredictionHint(void *contextResource, std::string text); + void sendMimeType(void *contextResource, std::string type); + void sendFinalizedContent(void *contextResource, std::string text, unsigned int cursorPosition); + void sendPredictionHintData(void *contextResource, std::string key, std::string value); protected: void input_method_context_destroy(Resource *resource); diff --git a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h index a3af9f9..da4aec3 100644 --- a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h +++ b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h @@ -19,6 +19,10 @@ public: void sendActivate(void *contextResource, int textInputId, bool focusInEvent); void sendDeactivate(void *contextResource, bool focusInEvent); + void showInputPanel(void *contextResource); + void hideInputPanel(void *contextResource); + int getResourceId(Resource *resource); + Resource* getResource(int id); protected: void input_method_bind_resource(Resource *resource); @@ -26,9 +30,8 @@ protected: private: DSWaylandCompositor *__compositor; - //struct ::wl_client *__wlClient; - //struct ::wl_resource Resource *__resource; + std::multimap __contextMap; }; } diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp index 23afa83..bab5d34 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ b/src/DSWaylandServer/DSWaylandTextInput.cpp @@ -63,7 +63,10 @@ int DSWaylandTextInputManager::allocTextInputId() DSWaylandTextInputPrivate::DSWaylandTextInputPrivate(DSWaylandTextInput *p_ptr, DSWaylandCompositor *compositor) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), - __compositor(compositor) + __compositor(compositor), + __showClient(nullptr), + __activatedResource(nullptr), + __clientSurface(nullptr) { } @@ -77,19 +80,14 @@ void DSWaylandTextInputPrivate::createGlobal(void *client, int id) __resourceIdMap.insert(std::pair(resource, id)); } -void DSWaylandTextInputPrivate::text_input_destroy(Resource *resource) -{ - __resourceIdMap.erase(resource); -} - -void DSWaylandTextInputPrivate::text_input_activate(Resource *resource, struct ::wl_resource *seat, struct ::wl_resource *surface) +int DSWaylandTextInputPrivate::getResourceId(Resource *resource) { DS_GET_PUB(DSWaylandTextInput); + int id = -1; + if (pub->__dsTextInputPrivate) { - int id = -1; - std::multimap::iterator it; for (it = __resourceIdMap.begin(); it != __resourceIdMap.end(); it++) { @@ -99,106 +97,370 @@ void DSWaylandTextInputPrivate::text_input_activate(Resource *resource, struct : break; } } - if (id >= 0) - pub->__dsTextInputPrivate->activateTextInput(pub, id); } + + return id; +} + +void DSWaylandTextInputPrivate::text_input_destroy(Resource *resource) +{ + __resourceIdMap.erase(resource); +} + +void DSWaylandTextInputPrivate::text_input_activate(Resource *resource, struct ::wl_resource *seat, struct ::wl_resource *surface) +{ + DS_GET_PUB(DSWaylandTextInput); + + int id = getResourceId(resource); + + if (__activatedResource) + { + pub->__dsTextInputPrivate->deactivateTextInput(pub); + send_leave(__activatedResource->handle); + } + + if (id >= 0) + pub->__dsTextInputPrivate->activateTextInput(pub, id); + + __activatedResource = resource; + __clientSurface = surface; } void DSWaylandTextInputPrivate::text_input_deactivate(Resource *resource, struct ::wl_resource *seat) { DS_GET_PUB(DSWaylandTextInput); + /* NOTE: need to check __activatedResource and current resource? */ + pub->__dsTextInputPrivate->deactivateTextInput(pub); send_leave(resource->handle); + + __activatedResource = nullptr; } void DSWaylandTextInputPrivate::text_input_show_input_panel(Resource *resource) { + DS_GET_PUB(DSWaylandTextInput); + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + /* NOTE: bug, sometimes in this time, input_method_context is not exist */ + int id = getResourceId(resource); + + if (id >= 0) + { + pub->__dsTextInputPrivate->showInputPanel(pub, id); + __showClient = resource->client(); + /* TODO: inputpanel wait update set */ + if (pub->__dsTextInputPrivate->getInputPanelState() == DSTextInputPrivate::InputPanelStateWillHide) + { + send_private_command(resource->handle, 0, "CONFORMANT_RESTORE"); + } + pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateWillShow); + /* TODO: inputpanel transient for set */ + } +} + +void DSWaylandTextInputPrivate::hideInputPanel(Resource *resource, bool forceHide) +{ + DS_GET_PUB(DSWaylandTextInput); + + send_input_panel_geometry(resource->handle, 0, 0, 0, 0); + send_input_panel_state(resource->handle, WL_TEXT_INPUT_INPUT_PANEL_STATE_HIDE); + + if (forceHide) + { + /* TODO: Control inputpanel visible status */ + pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateDidHide); + } + else + { + pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateWillHide); + send_private_command(resource->handle, 0, "CONFORMANT_RESET"); + + /* TODO: temporary ignore timer */ + } + /* TODO: bug, sometimes in this time, input_method_context is not exist */ + int id = getResourceId(resource); + if (id >= 0) + pub->__dsTextInputPrivate->hideInputPanel(id); + /* TODO: inputpanel wait update set */ } void DSWaylandTextInputPrivate::text_input_hide_input_panel(Resource *resource) { + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + if (__showClient == resource->client()) + { + hideInputPanel(resource, false); + __showClient = nullptr; + } } void DSWaylandTextInputPrivate::text_input_reset(Resource *resource) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->resetTextInput(); } void DSWaylandTextInputPrivate::text_input_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->setContentType(hint, purpose); } void DSWaylandTextInputPrivate::text_input_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + /* NOTE: Nothing to do in this request */ } void DSWaylandTextInputPrivate::text_input_set_preferred_language(Resource *resource, const std::string &language) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->setPreferredLanguage(language); } void DSWaylandTextInputPrivate::text_input_commit_state(Resource *resource, uint32_t serial) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->commitState(serial); } void DSWaylandTextInputPrivate::text_input_invoke_action(Resource *resource, uint32_t button, uint32_t index) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->invokeAction(button, index); } void DSWaylandTextInputPrivate::text_input_set_return_key_type(Resource *resource, uint32_t return_key_type) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->setReturnKeyType(return_key_type); } void DSWaylandTextInputPrivate::text_input_set_return_key_disabled(Resource *resource, uint32_t return_key_disabled) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->returnKeyDisabled(return_key_disabled); } void DSWaylandTextInputPrivate::text_input_set_input_panel_data(Resource *resource, const std::string &input_panel_data, uint32_t input_panel_length) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->setInputPanelData(input_panel_data, input_panel_length); + + if (!input_panel_data.compare("WILL_HIDE_ACK")) + { + /* TODO: will hide timer control */ + if (pub->__dsTextInputPrivate->getInputPanelState() == DSTextInputPrivate::InputPanelStateWillHide) + { + /* TODO: input panel visibility control */ + pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateDidShow); + } + } } void DSWaylandTextInputPrivate::text_input_bidi_direction(Resource *resource, uint32_t direction) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->bidiDirection(direction); } void DSWaylandTextInputPrivate::text_input_set_cursor_position(Resource *resource, uint32_t cursor_position) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->setCursorPosition(cursor_position); } void DSWaylandTextInputPrivate::text_input_process_input_device_event(Resource *resource, uint32_t event_type, const std::string &event_data, uint32_t event_length) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->processInputDeviceEvent(event_type, event_data, event_length); } void DSWaylandTextInputPrivate::text_input_filter_key_event(Resource *resource, uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + pub->__dsTextInputPrivate->filterKeyEvent(serial, time, keyname, state, modifiers, dev_name, dev_class, dev_subclass, keycode); + } + else + { + send_filter_key_event_done(resource->handle, serial, false); + } } void DSWaylandTextInputPrivate::text_input_get_hide_permission(Resource *resource) { + unsigned int permission = 1; + + /* TODO: compare __clientSurface is focused */ + + send_hide_permission(resource->handle, permission); } void DSWaylandTextInputPrivate::text_input_set_capital_mode(Resource *resource, uint32_t mode) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->setCapitalMode(mode); } void DSWaylandTextInputPrivate::text_input_prediction_hint(Resource *resource, const std::string &text) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->predictionHint(text); } void DSWaylandTextInputPrivate::text_input_set_mime_type(Resource *resource, const std::string &type) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->setMimeType(type); } void DSWaylandTextInputPrivate::text_input_set_input_panel_position(Resource *resource, uint32_t x, uint32_t y) { + /* TODO: input panel position set */ } void DSWaylandTextInputPrivate::text_input_finalize_content(Resource *resource, const std::string &text, uint32_t cursor_position) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->finalizeContent(text, cursor_position); } void DSWaylandTextInputPrivate::text_input_prediction_hint_data(Resource *resource, const std::string &key, const std::string &value) { + DS_GET_PUB(DSWaylandTextInput); + + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + pub->__dsTextInputPrivate->predictionHintData(key, value); } @@ -229,4 +491,4 @@ void DSWaylandTextInput::createGlobal(void *client, int id) priv->createGlobal(client, id); } -} \ No newline at end of file +} diff --git a/src/DSWaylandServer/DSWaylandTextInputPrivate.h b/src/DSWaylandServer/DSWaylandTextInputPrivate.h index f1eb87a..cb4ca6a 100644 --- a/src/DSWaylandServer/DSWaylandTextInputPrivate.h +++ b/src/DSWaylandServer/DSWaylandTextInputPrivate.h @@ -18,6 +18,8 @@ public: ~DSWaylandTextInputPrivate() override; void createGlobal(void *client, int id); + int getResourceId(Resource *resource); + void hideInputPanel(Resource *resource, bool forceHide); protected: void text_input_destroy(Resource *resource); @@ -49,6 +51,9 @@ protected: private: DSWaylandCompositor *__compositor; std::multimap __resourceIdMap; + struct ::wl_client *__showClient; + Resource *__activatedResource; + struct ::wl_resource *__clientSurface; }; } diff --git a/tests/DSWaylandInputMethod-test.cpp b/tests/DSWaylandInputMethod-test.cpp index 8a6910f..7e78c92 100644 --- a/tests/DSWaylandInputMethod-test.cpp +++ b/tests/DSWaylandInputMethod-test.cpp @@ -27,3 +27,269 @@ TEST_F(DSWaylandInputMethodTest, NewDSWaylandInputMethod) DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandInputMethodTest, ActivateDeactivate) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ShowHideInputPanel) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->showInputPanel(0); + inputMethod->hideInputPanel(0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ResetTextInput) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->resetTextInput(); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, SetContentType) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->setContentType(10, 0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, SetPreferredLanguage) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->setPreferredLanguage("en_US"); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, CommitState) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->commitState(5); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, InvokeAction) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->invokeAction(1, 0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, SetReturnKeyType) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->setReturnKeyType(0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ReturnKeyDisabled) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->returnKeyDisabled(0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, SetInputPanelData) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->setInputPanelData("WILL_HIDE_ACK", 13); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, BidiDirection) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->bidiDirection(1); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, SetCursorPosition) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->setCursorPosition(0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ProcessInputDeviceEvent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->processInputDeviceEvent(0, "", 0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, FilterKeyEvent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->filterKeyEvent(1, 0, "A", 1, 1, "ime", 2, 12, 0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, SetCapitalMode) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->setCapitalMode(0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, PredictionHint) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->predictionHint(""); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, SetMimeType) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->setMimeType(""); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, FinalizeContent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->finalizeContent("", 0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, PredictionHintData) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->predictionHintData("appid", ""); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + diff --git a/tests/DSWaylandInputMethodContext-test.cpp b/tests/DSWaylandInputMethodContext-test.cpp index 998876c..a49d6c7 100644 --- a/tests/DSWaylandInputMethodContext-test.cpp +++ b/tests/DSWaylandInputMethodContext-test.cpp @@ -30,3 +30,241 @@ TEST_F(DSWaylandInputMethodContextTest, NewDSWaylandInputMethodContext) DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandInputMethodContextTest, SendReset) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendReset(nullptr); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendContentType) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendContentType(nullptr, 10, 0); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendPreferredLanguage) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendPreferredLanguage(nullptr, "en_US"); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendCommitState) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendCommitState(nullptr, 5); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendInvokeAction) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendInvokeAction(nullptr, 1, 0); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendReturnKeyType) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendReturnKeyType(nullptr, 0); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendReturnKeyDisabled) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendReturnKeyDisabled(nullptr, 0); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendInputPanelData) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendInputPanelData(nullptr, "WILL_HIDE_ACK", 13); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendBidiDirection) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendBidiDirection(nullptr, 1); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendCursorPosition) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendCursorPosition(nullptr, 0); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendProcessInputDeviceEvent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendProcessInputDeviceEvent(nullptr, 0, "", 0); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendFilterKeyEvent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendFilterKeyEvent(nullptr, 1, 0, "A", 1, 1, "ime", 2, 12, 0); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendCapitalMode) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendCapitalMode(nullptr, 0); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendPredictionHint) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendPredictionHint(nullptr, ""); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendMimeType) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendMimeType(nullptr, ""); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendFinalizedContent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendFinalizedContent(nullptr, "", 0); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodContextTest, SendPredictionHintData) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); + EXPECT_TRUE(inputMethodContext != nullptr); + + inputMethodContext->sendPredictionHintData(nullptr, "appid", ""); + + delete inputMethodContext; + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + -- 2.7.4 From be53afa3f1a9bff2ac9a5f5e979b28921cc32709 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 5 Aug 2020 20:49:08 +0900 Subject: [PATCH 09/16] DSWaylandServer: add processEvent(), set/getFocus() in DSPointer/DSKeyboard/DSTouch class Change-Id: Ie0abbaab240d2c9a8e0a4b3e0c92573d293b55e6 Signed-off-by: Sung-Jin Park --- src/DSSeat/DSKeyboard.cpp | 69 +++++++++++++++++++++++++++++++++++--- src/DSSeat/DSKeyboard.h | 27 +++++++++++---- src/DSSeat/DSPointer.cpp | 63 ++++++++++++++++++++++++++++++++--- src/DSSeat/DSPointer.h | 27 +++++++++++---- src/DSSeat/DSTouch.cpp | 62 +++++++++++++++++++++++++++++++--- src/DSSeat/DSTouch.h | 27 +++++++++++---- tests/DSKeyboard-test.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++++++ tests/DSPointer-test.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++++++ tests/DSTouch-test.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 3 ++ 10 files changed, 500 insertions(+), 30 deletions(-) create mode 100644 tests/DSKeyboard-test.cpp create mode 100644 tests/DSPointer-test.cpp create mode 100644 tests/DSTouch-test.cpp diff --git a/src/DSSeat/DSKeyboard.cpp b/src/DSSeat/DSKeyboard.cpp index c8ea7a7..36f14cf 100644 --- a/src/DSSeat/DSKeyboard.cpp +++ b/src/DSSeat/DSKeyboard.cpp @@ -1,19 +1,80 @@ #include "DSKeyboard.h" +#include "DSSeat.h" +#include "DSWindow.h" +#include "DSInputEvent.h" +#include "DSWaylandKeyboard.h" +#include "DSWaylandSurface.h" namespace display_server { -DSKeyboard::DSKeyboard() - : __seat(nullptr) +DSKeyboard::DSKeyboard(DSSeat *seat) + : __seat(seat), + __dswlKeyboard(nullptr), + __dswlCompositor(nullptr), + __kbdFocus(nullptr) { + if (nullptr == __dswlKeyboard) + { + //TODO : register slot for monitoring the creation of DSWaylandKeyboard + ; + } } -DSKeyboard::DSKeyboard(DSSeat *seat) - : __seat(seat) +DSKeyboard::DSKeyboard(DSSeat *seat, DSWaylandKeyboard *keyboard) + : __seat(seat), + __dswlKeyboard(keyboard), + __dswlCompositor(nullptr), + __kbdFocus(nullptr) { } DSKeyboard::~DSKeyboard() {} +void DSKeyboard::processEvent(DSInputKeyboardEvent *ev, void *data) +{ + //TODO : get kbdFocus and send event to it via DSWaylandKeyboard instance + + if (!__kbdFocus) + { + DSLOG_ERR("DSKeyboard", "No kbdFocus available."); + return; + } +} + +void DSKeyboard::setFocus(std::shared_ptr window) +{ + if (!window) + { + DSLOG_ERR("DSKeyboard", "Given window is INVALID. (window : %p)", window); + return; + } + + DSWaylandSurface * waylandSurface = window->surface(); + + if (!waylandSurface) + { + DSLOG_ERR("DSKeyboard", "Wayland surface of the given window is INVALID. (window : %p, surface : %p)", window, waylandSurface); + return; + } + + DSLOG_INF("DSKeyboard", "focus window has been changed. (%p -> %p)", __kbdFocus, window); + __kbdFocus = window; + + if (!__dswlKeyboard) + { + DSLOG_ERR("DSKeyboard", "waylandKeyboard is NOT available !"); + return; + } + + __dswlKeyboard->setFocus(waylandSurface); + +} + +std::shared_ptr DSKeyboard::getFocus() +{ + return __kbdFocus; +} + } // namespace display_server \ No newline at end of file diff --git a/src/DSSeat/DSKeyboard.h b/src/DSSeat/DSKeyboard.h index db5081e..800326c 100644 --- a/src/DSSeat/DSKeyboard.h +++ b/src/DSSeat/DSKeyboard.h @@ -1,22 +1,37 @@ -#ifndef _DSKEYBOARD_H_ -#define _DSKEYBOARD_H_ +#ifndef __DSKEYBOARD_H__ +#define __DSKEYBOARD_H__ -#include +#include "DSCore.h" +#include "DSObject.h" namespace display_server { -class DSKeyboard +class DSSeat; +class DSWindow; +class DSInputKeyboardEvent; +class DSWaylandKeyboard; +class DSWaylandCompositor; + +class DSKeyboard : public DSObject { public: - DSKeyboard(); + DSKeyboard() = delete; DSKeyboard(DSSeat *seat); + DSKeyboard(DSSeat *seat, DSWaylandKeyboard *keyboard); virtual ~DSKeyboard(); + void processEvent(DSInputKeyboardEvent *ev, void *data); + void setFocus(std::shared_ptr window); + std::shared_ptr getFocus(); + private: DSSeat *__seat; + DSWaylandKeyboard *__dswlKeyboard; + DSWaylandCompositor *__dswlCompositor; + std::shared_ptr __kbdFocus; }; } -#endif \ No newline at end of file +#endif //__DSKEYBOARD_H__ \ No newline at end of file diff --git a/src/DSSeat/DSPointer.cpp b/src/DSSeat/DSPointer.cpp index 8f243ef..525fd85 100644 --- a/src/DSSeat/DSPointer.cpp +++ b/src/DSSeat/DSPointer.cpp @@ -1,19 +1,74 @@ #include "DSPointer.h" +#include "DSSeat.h" +#include "DSWindow.h" +#include "DSInputEvent.h" +#include "DSWaylandPointer.h" +#include "DSWaylandSurface.h" namespace display_server { -DSPointer::DSPointer() - : __seat(nullptr) +DSPointer::DSPointer(DSSeat *seat) + : __seat(seat), + __dswlPointer(nullptr), + __dswlCompositor(nullptr), + __ptrFocus(nullptr) { } -DSPointer::DSPointer(DSSeat *seat) - : __seat(seat) +DSPointer::DSPointer(DSSeat *seat, DSWaylandPointer *pointer) + : __seat(seat), + __dswlPointer(pointer), + __dswlCompositor(nullptr), + __ptrFocus(nullptr) { } DSPointer::~DSPointer() {} +void DSPointer::processEvent(DSInputMouseEvent *ev, void *data) +{ + //TODO : get ptrFocus and send event to it via DSWaylandPointer instance + + if (!__ptrFocus) + { + DSLOG_ERR("DSPointer", "No ptrFocus available."); + return; + } +} + +void DSPointer::setFocus(std::shared_ptr window) +{ + if (!window) + { + DSLOG_ERR("DSPointer", "Given window is INVALID. (window : %p)", window); + return; + } + + DSWaylandSurface * waylandSurface = window->surface(); + + if (!waylandSurface) + { + DSLOG_ERR("DSPointer", "Wayland surface of the given window is INVALID. (window : %p, surface : %p)", window, waylandSurface); + return; + } + + DSLOG_INF("DSPointer", "focus window has been changed. (%p -> %p)", __ptrFocus, window); + __ptrFocus = window; + + if (!__dswlPointer) + { + DSLOG_ERR("DSPointer", "waylandPointer is NOT available !"); + return; + } + + __dswlPointer->setFocus(waylandSurface); +} + +std::shared_ptr DSPointer::getFocus() +{ + return __ptrFocus; +} + } // namespace display_server \ No newline at end of file diff --git a/src/DSSeat/DSPointer.h b/src/DSSeat/DSPointer.h index d5ac041..05e58e5 100644 --- a/src/DSSeat/DSPointer.h +++ b/src/DSSeat/DSPointer.h @@ -1,22 +1,37 @@ -#ifndef _DSKEYBOARD_H_ -#define _DSPOINTER_H_ +#ifndef __DSPOINTER_H__ +#define __DSPOINTER_H__ -#include +#include "DSCore.h" +#include "DSObject.h" namespace display_server { -class DSPointer +class DSSeat; +class DSWindow; +class DSInputMouseEvent; +class DSWaylandPointer; +class DSWaylandCompositor; + +class DSPointer : public DSObject { public: - DSPointer(); + DSPointer() = delete; DSPointer(DSSeat *seat); + DSPointer(DSSeat *seat, DSWaylandPointer *pointer); virtual ~DSPointer(); + void processEvent(DSInputMouseEvent *ev, void *data); + void setFocus(std::shared_ptr window); + std::shared_ptr getFocus(); + private: DSSeat *__seat; + DSWaylandPointer *__dswlPointer; + DSWaylandCompositor *__dswlCompositor; + std::shared_ptr __ptrFocus; }; } -#endif \ No newline at end of file +#endif //__DSPOINTER_H__ \ No newline at end of file diff --git a/src/DSSeat/DSTouch.cpp b/src/DSSeat/DSTouch.cpp index 6913f4d..ea72127 100644 --- a/src/DSSeat/DSTouch.cpp +++ b/src/DSSeat/DSTouch.cpp @@ -1,19 +1,73 @@ #include "DSTouch.h" +#include "DSSeat.h" +#include "DSWindow.h" +#include "DSInputEvent.h" +#include "DSWaylandTouch.h" namespace display_server { -DSTouch::DSTouch() - : __seat(nullptr) +DSTouch::DSTouch(DSSeat *seat) + : __seat(seat), + __dswlTouch(nullptr), + __dswlCompositor(nullptr), + __touchFocus(nullptr) { } -DSTouch::DSTouch(DSSeat *seat) - : __seat(seat) +DSTouch::DSTouch(DSSeat *seat, DSWaylandTouch *touch) + : __seat(seat), + __dswlTouch(touch), + __dswlCompositor(nullptr), + __touchFocus(nullptr) { } DSTouch::~DSTouch() {} +void DSTouch::processEvent(DSInputTouchEvent *ev, void *data) +{ + //TODO : get touchFocus and send event to it via DSWaylandTouch instance + + if (!__touchFocus) + { + DSLOG_ERR("DSTouch", "No touchFocus available."); + return; + } +} + +void DSTouch::setFocus(std::shared_ptr window) +{ + if (!window) + { + DSLOG_ERR("DSTouch", "Given window is INVALID. (window : %p)", window); + return; + } + + DSWaylandSurface * waylandSurface = window->surface(); + + if (!waylandSurface) + { + DSLOG_ERR("DSTouch", "Wayland surface of the given window is INVALID. (window : %p, surface : %p)", window, waylandSurface); + return; + } + + DSLOG_INF("DSTouch", "focus window has been changed. (%p -> %p)", __touchFocus, window); + __touchFocus = window; + + if (!__dswlTouch) + { + DSLOG_ERR("DSTouch", "waylandTouch is NOT available !"); + return; + } + + __dswlTouch->setFocus(waylandSurface); +} + +std::shared_ptr DSTouch::getFocus() +{ + return __touchFocus; +} + } // namespace display_server \ No newline at end of file diff --git a/src/DSSeat/DSTouch.h b/src/DSSeat/DSTouch.h index df3e8f3..61e809f 100644 --- a/src/DSSeat/DSTouch.h +++ b/src/DSSeat/DSTouch.h @@ -1,22 +1,37 @@ -#ifndef _DSTOUCH_H_ -#define _DSTOUCH_H_ +#ifndef __DSTOUCH_H__ +#define __DSTOUCH_H__ -#include +#include "DSCore.h" +#include "DSObject.h" namespace display_server { -class DSTouch +class DSSeat; +class DSWindow; +class DSWaylandTouch; +class DSInputTouchEvent; +class DSWaylandCompositor; + +class DSTouch : public DSObject { public: - DSTouch(); + DSTouch() = delete; DSTouch(DSSeat *seat); + DSTouch(DSSeat *seat, DSWaylandTouch *touch); virtual ~DSTouch(); + void processEvent(DSInputTouchEvent *ev, void *data); + void setFocus(std::shared_ptr window); + std::shared_ptr getFocus(); + private: DSSeat *__seat; + DSWaylandTouch *__dswlTouch; + DSWaylandCompositor *__dswlCompositor; + std::shared_ptr __touchFocus; }; } -#endif \ No newline at end of file +#endif //__DSTOUCH_H__ \ No newline at end of file diff --git a/tests/DSKeyboard-test.cpp b/tests/DSKeyboard-test.cpp new file mode 100644 index 0000000..0db9a36 --- /dev/null +++ b/tests/DSKeyboard-test.cpp @@ -0,0 +1,84 @@ +#include "libds-tests.h" +#include "DSKeyboard.h" +#include "DSSeat.h" +#include "DSWaylandKeyboard.h" +#include "DSWaylandSeat.h" +#include "DSWaylandCompositor.h" +#include "DSWindow.h" + +using namespace display_server; + +class DSKeyboardTest : public ::testing::Test +{ +public: + void SetUp(void) override + { + setenv("XDG_RUNTIME_DIR", "/run", 1); + } + void TearDown(void) override + { + unsetenv("XDG_RUNTIME_DIR"); + } +}; + +TEST_F(DSKeyboardTest, NewDSKeyboardWithDSSeat) +{ + auto seat = new DSSeat(); + EXPECT_TRUE(seat != nullptr); + + if (seat) + { + auto keyboard = new DSKeyboard(seat); + EXPECT_TRUE(keyboard != nullptr); + } +} + +TEST_F(DSKeyboardTest, NewDSKeyboardWithDSWaylandKeyboard) +{ + auto waylandCompositor = DSWaylandCompositor::getInstance(); + EXPECT_TRUE(waylandCompositor != nullptr); + + if (waylandCompositor) + { + auto seat = new DSSeat(); + EXPECT_TRUE(seat != nullptr); + + auto waylandSeat = new DSWaylandSeat(waylandCompositor, DSWaylandSeat::capAll); + EXPECT_TRUE(waylandSeat != nullptr); + + if (seat && waylandSeat) + { + auto waylandKeyboard = new DSWaylandKeyboard(waylandSeat); + EXPECT_TRUE(waylandKeyboard != nullptr); + + if (waylandKeyboard) + { + auto keyboard = new DSKeyboard(seat, waylandKeyboard); + EXPECT_TRUE(keyboard != nullptr); + } + } + + DSWaylandCompositor::releaseInstance(); + } + +} +TEST_F(DSKeyboardTest, BasicMethods) +{ + auto seat = new DSSeat(); + EXPECT_TRUE(seat != nullptr); + + auto window = std::make_shared(); + EXPECT_TRUE(window != nullptr); + + if (seat && window) + { + auto keyboard = new DSKeyboard(seat); + EXPECT_TRUE(keyboard != nullptr); + + if (keyboard) + { + keyboard->setFocus(window); + EXPECT_TRUE(window == keyboard->getFocus()); + } + } +} diff --git a/tests/DSPointer-test.cpp b/tests/DSPointer-test.cpp new file mode 100644 index 0000000..b6be57d --- /dev/null +++ b/tests/DSPointer-test.cpp @@ -0,0 +1,84 @@ +#include "libds-tests.h" +#include "DSPointer.h" +#include "DSSeat.h" +#include "DSWaylandPointer.h" +#include "DSWaylandSeat.h" +#include "DSWaylandCompositor.h" +#include "DSWindow.h" + +using namespace display_server; + +class DSPointerTest : public ::testing::Test +{ +public: + void SetUp(void) override + { + setenv("XDG_RUNTIME_DIR", "/run", 1); + } + void TearDown(void) override + { + unsetenv("XDG_RUNTIME_DIR"); + } +}; + +TEST_F(DSPointerTest, NewDSPointerWithDSSeat) +{ + auto seat = new DSSeat(); + EXPECT_TRUE(seat != nullptr); + + if (seat) + { + auto pointer = new DSPointer(seat); + EXPECT_TRUE(pointer != nullptr); + } +} + +TEST_F(DSPointerTest, NewDSPointerWithDSWaylandPointer) +{ + auto waylandCompositor = DSWaylandCompositor::getInstance(); + EXPECT_TRUE(waylandCompositor != nullptr); + + if (waylandCompositor) + { + auto seat = new DSSeat(); + EXPECT_TRUE(seat != nullptr); + + auto waylandSeat = new DSWaylandSeat(waylandCompositor, DSWaylandSeat::capAll); + EXPECT_TRUE(waylandSeat != nullptr); + + if (seat && waylandSeat) + { + auto waylandPointer = new DSWaylandPointer(waylandSeat); + EXPECT_TRUE(waylandPointer != nullptr); + + if (waylandPointer) + { + auto pointer = new DSPointer(seat, waylandPointer); + EXPECT_TRUE(pointer != nullptr); + } + } + + DSWaylandCompositor::releaseInstance(); + } + +} +TEST_F(DSPointerTest, BasicMethods) +{ + auto seat = new DSSeat(); + EXPECT_TRUE(seat != nullptr); + + auto window = std::make_shared(); + EXPECT_TRUE(window != nullptr); + + if (seat && window) + { + auto pointer = new DSPointer(seat); + EXPECT_TRUE(pointer != nullptr); + + if (pointer) + { + pointer->setFocus(window); + EXPECT_TRUE(window == pointer->getFocus()); + } + } +} diff --git a/tests/DSTouch-test.cpp b/tests/DSTouch-test.cpp new file mode 100644 index 0000000..56b4b1a --- /dev/null +++ b/tests/DSTouch-test.cpp @@ -0,0 +1,84 @@ +#include "libds-tests.h" +#include "DSTouch.h" +#include "DSSeat.h" +#include "DSWaylandTouch.h" +#include "DSWaylandSeat.h" +#include "DSWaylandCompositor.h" +#include "DSWindow.h" + +using namespace display_server; + +class DSTouchTest : public ::testing::Test +{ +public: + void SetUp(void) override + { + setenv("XDG_RUNTIME_DIR", "/run", 1); + } + void TearDown(void) override + { + unsetenv("XDG_RUNTIME_DIR"); + } +}; + +TEST_F(DSTouchTest, NewDSTouchWithDSSeat) +{ + auto seat = new DSSeat(); + EXPECT_TRUE(seat != nullptr); + + if (seat) + { + auto touch = new DSTouch(seat); + EXPECT_TRUE(touch != nullptr); + } +} + +TEST_F(DSTouchTest, NewDSTouchWithDSWaylandTouch) +{ + auto waylandCompositor = DSWaylandCompositor::getInstance(); + EXPECT_TRUE(waylandCompositor != nullptr); + + if (waylandCompositor) + { + auto seat = new DSSeat(); + EXPECT_TRUE(seat != nullptr); + + auto waylandSeat = new DSWaylandSeat(waylandCompositor, DSWaylandSeat::capAll); + EXPECT_TRUE(waylandSeat != nullptr); + + if (seat && waylandSeat) + { + auto waylandTouch = new DSWaylandTouch(waylandSeat); + EXPECT_TRUE(waylandTouch != nullptr); + + if (waylandTouch) + { + auto touch = new DSTouch(seat, waylandTouch); + EXPECT_TRUE(touch != nullptr); + } + } + + DSWaylandCompositor::releaseInstance(); + } + +} +TEST_F(DSTouchTest, BasicMethods) +{ + auto seat = new DSSeat(); + EXPECT_TRUE(seat != nullptr); + + auto window = std::make_shared(); + EXPECT_TRUE(window != nullptr); + + if (seat && window) + { + auto touch = new DSTouch(seat); + EXPECT_TRUE(touch != nullptr); + + if (touch) + { + touch->setFocus(window); + EXPECT_TRUE(window == touch->getFocus()); + } + } +} diff --git a/tests/meson.build b/tests/meson.build index 6f427ed..b97f3d4 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -48,6 +48,9 @@ libds_tests_srcs = [ 'DSWaylandInputPanel-test.cpp', 'DSWaylandInputPanelSurface-test.cpp', 'DSXkb-test.cpp', + 'DSPointer-test.cpp', + 'DSKeyboard-test.cpp', + 'DSTouch-test.cpp', ] gmock_dep = dependency('gmock', method : 'pkg-config') -- 2.7.4 From 73ed49079008844c6d20204af8464501d78d552c Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 6 Aug 2020 14:37:21 +0900 Subject: [PATCH 10/16] DSRenderViewDaliImpl: add __onWindowSizeChanged callback function which is registered at registerCallbackSizeChanged function of DSWindow Change-Id: Iafe0c701ab567b4f533d41cd2f1099b6609a72ec --- src/DSRender/DSRenderViewDaliImpl.cpp | 9 ++++++++- src/DSRender/DSRenderViewDaliImpl.h | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp index 23536c9..eaef822 100644 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ b/src/DSRender/DSRenderViewDaliImpl.cpp @@ -78,8 +78,10 @@ DSRenderViewDaliImpl::DSRenderViewDaliImpl(std::shared_ptr window, Dal __textureViewActor.SetProperty(Actor::Property::POSITION, Vector3( 0.0f, 100.f, 0.0f )); __textureViewActor.SetProperty(Actor::Property::SIZE, Vector2(500, 500)); - offscreenWindow.Add(__textureViewActor); + + // callbacks + window->registerCallbackSizeChanged(this, std::bind(&DSRenderViewDaliImpl::__onWindowSizeChanged, this, std::placeholders::_1)); } DSRenderViewDaliImpl::~DSRenderViewDaliImpl() @@ -102,4 +104,9 @@ bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) return true; } +void DSRenderViewDaliImpl::__onWindowSizeChanged(std::shared_ptr size) +{ + //TODO: set the View Size with size +} + } // namespace display_server diff --git a/src/DSRender/DSRenderViewDaliImpl.h b/src/DSRender/DSRenderViewDaliImpl.h index 19ce433..f5de171 100644 --- a/src/DSRender/DSRenderViewDaliImpl.h +++ b/src/DSRender/DSRenderViewDaliImpl.h @@ -2,6 +2,7 @@ #define __DS_RENDER_VIEW_DALI_IMPL_H_ #include "DSRenderView.h" +#include "DSObject.h" #include #include @@ -10,7 +11,7 @@ namespace display_server { -class DSRenderViewDaliImpl : public DSRenderView +class DSRenderViewDaliImpl : public DSRenderView, public DSObject { public: DSRenderViewDaliImpl(std::shared_ptr window, Dali::OffscreenWindow offscreenWindow); @@ -21,6 +22,8 @@ public: Dali::Geometry CreateTexturedQuad(); private: + void __onWindowSizeChanged(std::shared_ptr size); + std::shared_ptr __window; Dali::Renderer __renderer; Dali::Actor __textureViewActor; -- 2.7.4 From d4018f511226cc4a1afebf522b6e7697f5a824d6 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 6 Aug 2020 14:42:30 +0900 Subject: [PATCH 11/16] DSRenderViewEcoreEvasImpl: add __onWindowSizeChanged callback function which is registered at registerCallbackSizeChanged function of DSWindow Change-Id: I203487ce26fae832d15836b57472e322874c74c0 --- src/DSRender/DSRenderViewEcoreEvasImpl.cpp | 9 +++++++++ src/DSRender/DSRenderViewEcoreEvasImpl.h | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp index 15147e2..ea80459 100644 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp +++ b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp @@ -10,6 +10,9 @@ DSRenderViewEcoreEvasImpl::DSRenderViewEcoreEvasImpl(Ecore_Evas *ee, std::shared __evasView = evas_object_image_filled_add(ecore_evas_get(ee)); evas_object_image_border_center_fill_set(__evasView, EVAS_BORDER_FILL_SOLID); evas_object_image_colorspace_set(__evasView, EVAS_COLORSPACE_ARGB8888); + + // callbacks + window->registerCallbackSizeChanged(this, std::bind(&DSRenderViewEcoreEvasImpl::__onWindowSizeChanged, this, std::placeholders::_1)); } DSRenderViewEcoreEvasImpl::~DSRenderViewEcoreEvasImpl() @@ -30,4 +33,10 @@ bool DSRenderViewEcoreEvasImpl::setBuffer(std::shared_ptr buffer) return true; } + +void DSRenderViewEcoreEvasImpl::__onWindowSizeChanged(std::shared_ptr size) +{ + //TODO: set the View Size with size +} + } // namespace display_server diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.h b/src/DSRender/DSRenderViewEcoreEvasImpl.h index e82f54c..d6ba6cb 100644 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.h +++ b/src/DSRender/DSRenderViewEcoreEvasImpl.h @@ -2,12 +2,13 @@ #define __DS_RENDER_VIEW_ECORE_EVAS_IMPL_H_ #include "DSRenderView.h" +#include "DSObject.h" #include namespace display_server { -class DSRenderViewEcoreEvasImpl : public DSRenderView +class DSRenderViewEcoreEvasImpl : public DSRenderView, public DSObject { public: DSRenderViewEcoreEvasImpl(Ecore_Evas *ee, std::shared_ptr window); @@ -16,6 +17,8 @@ public: bool setBuffer(std::shared_ptr buffer) override; private: + void __onWindowSizeChanged(std::shared_ptr size); + Evas_Object *__evasView; std::shared_ptr __window; }; -- 2.7.4 From 79020cab14891948b2454efc4cc849a82467bece Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Thu, 6 Aug 2020 16:11:16 +0900 Subject: [PATCH 12/16] DSZone: modify code to create DSWindowShell on surfaceCreate callback Change-Id: I84dffe95a49deb251c0bf5cce58a685c7e62a9c3 --- src/DSZone/DSZone.cpp | 30 ++++++++++++++++++++---------- src/DSZone/DSZone.h | 5 +++-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index 4b41491..b268f95 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -13,7 +13,7 @@ DSZone::DSZone() __waylandCompositor(nullptr) { __waylandCompositor = DSWaylandCompositor::getInstance(); - __waylandCompositor->registerCallbackSurfaceCreated(this, std::bind(&DSZone::onSurfaceCreated, this, std::placeholders::_1)); + __waylandCompositor->registerCallbackSurfaceCreated(this, std::bind(&DSZone::__onSurfaceCreated, this, std::placeholders::_1)); } DSZone::~DSZone() @@ -66,14 +66,15 @@ void DSZone::callCallbackWindowCreated() __windowCreatedSignal.emit(nullptr); } -void DSZone::onSurfaceCreated(std::shared_ptr waylandSurface) +void DSZone::__onSurfaceCreated(std::shared_ptr waylandSurface) { + DSLOG_DBG("DSZone", "waylandSurface:(shared:%p, pure:%p)", waylandSurface, waylandSurface.get()); + // create DSWindow - std::shared_ptr window = std::make_shared(waylandSurface); - __windowList.push_front(window); + std::shared_ptr window = __createWindow(waylandSurface); - // emit a signal of the surface committed - __windowCreatedSignal.emit(window); + // create DSWindowShell + std::shared_ptr shell = __createWindowShell(window); } // for Test @@ -102,18 +103,27 @@ std::shared_ptr DSZone::__findWindow(DSWaylandSurface *dswlSurface) return nullptr; } -void DSZone::__onShellSurfaceCreated(std::shared_ptr shellSurface) +std::shared_ptr DSZone::__createWindow(std::shared_ptr waylandSurface) { - struct ::wl_resource *surface = shellSurface->getWlSurface(); - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); + std::shared_ptr window = std::make_shared(waylandSurface); + __windowList.push_front(window); - std::shared_ptr window = __findWindow(dswlSurface); + // emit a signal of the surface committed + __windowCreatedSignal.emit(window); + + return window; +} +std::shared_ptr DSZone::__createWindowShell(std::shared_ptr window) +{ std::shared_ptr shell = std::make_shared(window.get()); __windowShellList.push_front(shell); // emit a signal of the shell created __windowShellCreatedSignal.emit(shell); + + return shell; } + } // namespace display_server diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index 4de5a00..fb72088 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -35,8 +35,9 @@ public: std::list> getWindowList(); private: - void onSurfaceCreated(std::shared_ptr waylandSurface); - void __onShellSurfaceCreated(std::shared_ptr shellSurface); + void __onSurfaceCreated(std::shared_ptr waylandSurface); + std::shared_ptr __createWindow(std::shared_ptr waylandSurface); + std::shared_ptr __createWindowShell(std::shared_ptr window); std::shared_ptr __findWindow(DSWaylandSurface *dswlSurface); stPosition __position; -- 2.7.4 From 269558a5be6cf10bda40fae1c1fa4aacef275edf Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 6 Aug 2020 17:08:31 +0900 Subject: [PATCH 13/16] DSSeat: adds basic APIs and implements input event handlers Change-Id: I43e118be926a504f3b0fef6f929a9593121fb80a Signed-off-by: Sung-Jin Park --- src/DSSeat/DSSeat.cpp | 317 ++++++++++++++++++++++++++++++++++++++++++++++---- src/DSSeat/DSSeat.h | 47 +++++++- 2 files changed, 336 insertions(+), 28 deletions(-) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index 2a49039..2458ee6 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -6,38 +6,53 @@ #include "DSWaylandCompositor.h" #include "DSInputEvent.h" #include "DSXkb.h" +#include "DSZone.h" + +#include "DSPointer.h" +#include "DSKeyboard.h" +#include "DSTouch.h" +#include "DSWaylandPointer.h" +#include "DSWaylandKeyboard.h" +#include "DSWaylandTouch.h" namespace display_server { +DSSignal DSSeat::__signalHandleKeyEvent; +DSSignal DSSeat::__signalHandlePointerEvent; +DSSignal DSSeat::__signalHandleTouchEvent; DSSeat::DSSeat() : __input(nullptr), - __keyboard(nullptr), - __pointer(nullptr), - __touch(nullptr), __dswlSeat(nullptr), __dswlComp(nullptr), __compositor(nullptr), __xkb(nullptr), + __zone(nullptr), + __keyboard(nullptr), + __pointer(nullptr), + __touch(nullptr), __numPointer(0), __numKeyboard(0), - __numTouch(0) + __numTouch(0), + __focusWin(nullptr) { } DSSeat::DSSeat(DSCompositor *compositor, std::string name) : __input(nullptr), - __keyboard(nullptr), - __pointer(nullptr), - __touch(nullptr), __dswlSeat(nullptr), __dswlComp(nullptr), __compositor(compositor), __xkb(new DSXkb(this)), + __zone(nullptr), + __keyboard(nullptr), + __pointer(nullptr), + __touch(nullptr), __numPointer(0), __numKeyboard(0), - __numTouch(0) + __numTouch(0), + __focusWin(nullptr) { if (!compositor) return; @@ -54,6 +69,10 @@ DSSeat::DSSeat(DSCompositor *compositor, std::string name) __input = new DSInput(this, __xkb); DS_ASSERT(__input != nullptr); + __signalHandleKeyEvent.connect(this, std::bind(&DSSeat::__onKeyEvent, this, std::placeholders::_1)); + __signalHandlePointerEvent.connect(this, std::bind(&DSSeat::__onPointerEvent, this, std::placeholders::_1)); + __signalHandleTouchEvent.connect(this, std::bind(&DSSeat::__onTouchEvent, this, std::placeholders::_1)); + __input->registerCallbackDeviceAdd(this, std::bind(&DSSeat::slotDeviceAdd, this, std::placeholders::_1)); __input->registerCallbackDeviceRemove(this, std::bind(&DSSeat::slotDeviceRemove, this, std::placeholders::_1)); __input->registerCallbackKeyDown(this, inputEventHandlerKey); @@ -79,31 +98,71 @@ DSSeat::~DSSeat() DSWaylandCompositor::releaseInstance(); } +bool DSSeat::attachZone(std::shared_ptr zone) +{ + DSLOG_INF("DSSeat", "The attached zone has been changed (%p -> %p)", __zone, zone); + + __zone = zone; + __zone->registerCallbackWindowCreated(this, std::bind(&DSSeat::__onWindowCreated, this, std::placeholders::_1)); + + return true; +} + +std::shared_ptr DSSeat::getZone() +{ + return __zone; +} + +bool DSSeat::detachZone() +{ + if (!__zone) + { + DSLOG_ERR("DSSeat", "No Zone is not available !"); + return false; + } + + //__zone->deregisterCallbackWindowCreated(this, std::bind(&DSSeat::__onWindowCreated, this, std::placeholders::_1)); + + DSLOG_INF("DSSeat", "Zone(%p) has been detached !", __zone); + __zone = nullptr; + + return true; +} + void DSSeat::slotDeviceAdd(std::shared_ptr device) { - std::cout << "DSSeat slotDeviceAdd!" << std::endl; + DSLOG_INF("DSSeat", ""); device->print(); uint32_t cap = (uint32_t)__dswlSeat->getCapability(); bool capNeedUpdate = false; - if ((device->getClass() == DSInput::PointerClass) && (__numPointer == 0)) + if ((device->getClass() == DSInput::PointerClass) && (__numPointer++ == 0)) { - __numPointer++; cap = cap | DSWaylandSeat::capPointer; capNeedUpdate = true; + + DSWaylandPointer *dswlPointer = __dswlSeat->getPointer(); + __pointer = new DSPointer(this, dswlPointer); + DS_ASSERT(__pointer != nullptr); } - else if ((device->getClass() == DSInput::KeyboardClass) && (__numKeyboard == 0)) + else if ((device->getClass() == DSInput::KeyboardClass) && (__numKeyboard++ == 0)) { - __numKeyboard++; cap = cap | DSWaylandSeat::capKeyboard; capNeedUpdate = true; + + DSWaylandKeyboard *dswlKeyboard = __dswlSeat->getKeyboard(); + __keyboard = new DSKeyboard(this, dswlKeyboard); + DS_ASSERT(__keyboard != nullptr); } - else if ((device->getClass() == DSInput::TouchClass) && (__numTouch == 0)) + else if ((device->getClass() == DSInput::TouchClass) && (__numTouch++ == 0)) { - __numTouch++; cap = cap | DSWaylandSeat::capTouch; capNeedUpdate = true; + + DSWaylandTouch *dswlTouch = __dswlSeat->getTouch(); + __touch = new DSTouch(this, dswlTouch); + DS_ASSERT(__touch != nullptr); } if (capNeedUpdate) @@ -112,7 +171,7 @@ void DSSeat::slotDeviceAdd(std::shared_ptr device) void DSSeat::slotDeviceRemove(std::shared_ptr device) { - std::cout << "DSSeat slotDeviceRemove!" << std::endl; + DSLOG_INF("DSSeat", ""); device->print(); uint32_t cap = (uint32_t)__dswlSeat->getCapability(); @@ -122,25 +181,234 @@ void DSSeat::slotDeviceRemove(std::shared_ptr device) { cap = cap & (~DSWaylandSeat::capPointer); capNeedUpdate = true; + + if (__pointer) + { + delete __pointer; + __pointer = nullptr; + } } else if ((device->getClass() == DSInput::KeyboardClass) && ((--__numKeyboard) == 0)) { cap = cap & (~DSWaylandSeat::capKeyboard); capNeedUpdate = true; + + if (__keyboard) + { + delete __keyboard; + __keyboard = nullptr; + } } else if ((device->getClass() == DSInput::TouchClass) && ((--__numTouch) == 0)) { cap = cap & (~DSWaylandSeat::capTouch); capNeedUpdate = true; + + if (__touch) + { + delete __touch; + __touch = nullptr; + } } if (capNeedUpdate) __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); } +void DSSeat::addPointer() +{ + if (0 < __numPointer) + { + DSLOG_INF("DSSeat", "Pointer exists already. (num=%d)", __numPointer); + __numPointer++; + return; + } + + __pointer = new DSPointer(this); + DS_ASSERT(__pointer != nullptr); + + __numPointer++; + + uint32_t cap = (uint32_t)__dswlSeat->getCapability(); + cap = cap | DSWaylandSeat::capPointer; + __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); +} + +void DSSeat::addKeyboard() +{ + if (0 < __numKeyboard) + { + DSLOG_INF("DSSeat", "Keyboard exists already. (num=%d)", __numKeyboard); + __numKeyboard++; + return; + } + + __keyboard = new DSKeyboard(this); + DS_ASSERT(__keyboard != nullptr); + + __numKeyboard++; + + uint32_t cap = (uint32_t)__dswlSeat->getCapability(); + cap = cap | DSWaylandSeat::capKeyboard; + __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); +} + +void DSSeat::addTouch() +{ + if (0 < __numTouch) + { + DSLOG_INF("DSSeat", "Touch exists already. (num=%d)", __numTouch); + __numTouch++; + return; + } + + __touch = new DSTouch(this); + DS_ASSERT(__touch != nullptr); + + __numTouch++; + + uint32_t cap = (uint32_t)__dswlSeat->getCapability(); + cap = cap | DSWaylandSeat::capTouch; + __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); +} + +void DSSeat::removePointer() +{ + if (0 >= __numPointer) + { + DSLOG_INF("DSSeat", "No pointer exists already. (num=%d)", __numPointer); + return; + } + + DS_ASSERT(__pointer != nullptr); + --__numPointer; + + if (0 == __numPointer) + { + uint32_t cap = (uint32_t)__dswlSeat->getCapability(); + cap = cap & (~DSWaylandSeat::capPointer); + __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); + + delete __pointer; + __pointer = nullptr; + } +} + +void DSSeat::removeKeyboard() +{ + if (0 >= __numKeyboard) + { + DSLOG_INF("DSSeat", "No keyboard exists already. (num=%d)", __numKeyboard); + return; + } + + DS_ASSERT(__keyboard != nullptr); + --__numKeyboard; + + if (0 == __numKeyboard) + { + uint32_t cap = (uint32_t)__dswlSeat->getCapability(); + cap = cap & (~DSWaylandSeat::capKeyboard); + __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); + + delete __keyboard; + __keyboard = nullptr; + } +} + +void DSSeat::removeTouch() +{ + if (0 >= __numTouch) + { + DSLOG_INF("DSSeat", "No touch exists already. (num=%d)", __numTouch); + return; + } + + DS_ASSERT(__touch != nullptr); + --__numTouch; + + if (0 == __numTouch) + { + uint32_t cap = (uint32_t)__dswlSeat->getCapability(); + cap = cap & (~DSWaylandSeat::capTouch); + __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); + + delete __touch; + __touch = nullptr; + } +} + +std::string DSSeat::getName() +{ + return __dswlSeat->getName(); +} + +void DSSeat::__onKeyEvent(DSInputKeyboardEvent *event) +{ + if (__keyboard == nullptr) + { + DSLOG_DBG("DSSeat", "No keyboard device exists. Key events will be dropped."); + return; + } + + __keyboard->processEvent(event, nullptr); +} + +void DSSeat::__onPointerEvent(DSInputMouseEvent *event) +{ + if (__pointer == nullptr) + { + DSLOG_DBG("DSSeat", "No pointer device exists. Mouse events will be dropped."); + return; + } + + __pointer->processEvent(event, nullptr); +} + +void DSSeat::__onTouchEvent(DSInputTouchEvent *event) +{ + if (__touch == nullptr) + { + DSLOG_DBG("DSSeat", "No touch device exists. Touch events will be dropped."); + return; + } + + __touch->processEvent(event, nullptr); +} + +void DSSeat::__onWindowCreated(std::shared_ptr window) +{ + DSLOG_INF("DSSeat", "window created : %p", window); + + if (window == nullptr) + { + DSLOG_ERR("DSSeat", "Invalid window is given."); + return; + } + + /* Set newly created window as focus window for keyboard/pointer/touch temporarily */ + /* FIXME when DSWindowShell and DSWMPolicy has been implmented properly */ + if (__keyboard) + { + DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", __focusWin, window); + __keyboard->setFocus(window); + } + + if (__pointer) + { + DSLOG_INF("DSSeat", "pointer focus : %p -> %p", __focusWin, window); + __pointer->setFocus(window); + } + + if (__touch) + { + DSLOG_INF("DSSeat", "touch focus : %p -> %p", __focusWin, window); + __touch->setFocus(window); + } +} + Eina_Bool DSSeat::inputEventHandlerKey(void *data, int type, void *event) { - //DSSeat *seat = static_cast< DSSeat* >(data); DSInputKeyboardEvent *ev = static_cast< DSInputKeyboardEvent* >(event); std::string typeString; @@ -149,14 +417,15 @@ Eina_Bool DSSeat::inputEventHandlerKey(void *data, int type, void *event) else typeString = "up"; - DSLOG_DBG("DSSeat", "[key%s] keycode: %d, devicename: %s\n", typeString.c_str(), ev->getKeycode(), ev->getDevice()->getName().c_str()); + DSLOG_DBG("DSSeat", "[key %s] keycode: %d, devicename: %s\n", typeString.c_str(), ev->getKeycode(), ev->getDevice()->getName().c_str()); + + __signalHandleKeyEvent.emit(ev); return EINA_TRUE; } Eina_Bool DSSeat::inputEventHandlerMouse(void *data, int type, void *event) { - //DSSeat *seat = static_cast< DSSeat* >(data); DSInputMouseEvent *ev = static_cast< DSInputMouseEvent* >(event); std::string typeString; @@ -167,14 +436,15 @@ Eina_Bool DSSeat::inputEventHandlerMouse(void *data, int type, void *event) else typeString = "up"; - DSLOG_DBG("DSSeat", "[mouse%s] button: %d (%d, %d, %d), devicename: %s\n", typeString.c_str(), ev->getButton(), ev->getX(), ev->getY(), ev->getZ(), ev->getDevice()->getName().c_str()); + DSLOG_DBG("DSSeat", "[mouse %s] button: %d (%d, %d, %d), devicename: %s\n", typeString.c_str(), ev->getButton(), ev->getX(), ev->getY(), ev->getZ(), ev->getDevice()->getName().c_str()); + + __signalHandlePointerEvent.emit(ev); return EINA_TRUE; } Eina_Bool DSSeat::inputEventHandlerTouch(void *data, int type, void *event) { - //DSSeat *seat = static_cast< DSSeat* >(data); DSInputTouchEvent *ev = static_cast< DSInputTouchEvent* >(event); std::string typeString; @@ -185,11 +455,12 @@ Eina_Bool DSSeat::inputEventHandlerTouch(void *data, int type, void *event) 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()); + 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; } - } // namespace display_server diff --git a/src/DSSeat/DSSeat.h b/src/DSSeat/DSSeat.h index 5842428..d98f28e 100644 --- a/src/DSSeat/DSSeat.h +++ b/src/DSSeat/DSSeat.h @@ -1,13 +1,16 @@ #ifndef _DSSEAT_H_ #define _DSSEAT_H_ -#include +#include "DSCore.h" +#include "DSObject.h" +#include "DSSignal.h" #include #include namespace display_server { +class DSInput; class DSKeyboard; class DSPointer; class DSTouch; @@ -16,6 +19,11 @@ class DSCompositor; class DSWaylandSeat; class DSWaylandCompositor; class DSXkb; +class DSZone; +class DSWindow; +class DSInputKeyboardEvent; +class DSInputMouseEvent; +class DSInputTouchEvent; class DSSeat : public DSObject { @@ -24,28 +32,57 @@ public: DSSeat(DSCompositor *compositor, std::string name); virtual ~DSSeat(); + bool attachZone(std::shared_ptr zone); + std::shared_ptr getZone(); + bool detachZone(); + void slotDeviceAdd(std::shared_ptr device); void slotDeviceRemove(std::shared_ptr device); + std::string getName(); + + void addPointer(); + void addKeyboard(); + void addTouch(); + void removePointer(); + void removeKeyboard(); + void removeTouch(); + private: DSInput *__input; - DSKeyboard *__keyboard; - DSPointer *__pointer; - DSTouch *__touch; DSWaylandSeat *__dswlSeat; DSWaylandCompositor *__dswlComp; DSCompositor *__compositor; DSXkb *__xkb; + std::shared_ptr __zone; + DSKeyboard *__keyboard; + DSPointer *__pointer; + DSTouch *__touch; uint32_t __numPointer; uint32_t __numKeyboard; uint32_t __numTouch; + std::shared_ptr __focusWin; + + /* ecore key/mouse/touch event handler */ static Eina_Bool inputEventHandlerKey(void *data, int type, void *event); static Eina_Bool inputEventHandlerMouse(void *data, int type, void *event); static Eina_Bool inputEventHandlerTouch(void *data, int type, void *event); + + /* signals */ + static DSSignal __signalHandleKeyEvent; + static DSSignal __signalHandlePointerEvent; + static DSSignal __signalHandleTouchEvent; + + /* slots */ + void __onKeyEvent(DSInputKeyboardEvent *event); + void __onPointerEvent(DSInputMouseEvent *event); + void __onTouchEvent(DSInputTouchEvent *event); + void __onWindowCreated(std::shared_ptr window); + }; } -#endif \ No newline at end of file +#endif -- 2.7.4 From 11529ce47a9668a1eb43bad3074e14388862d400 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 6 Aug 2020 17:10:56 +0900 Subject: [PATCH 14/16] DSPolicyArea: attach a zone to the corresponding seat Change-Id: I5e5a33f5b8f8a7dc9c9adce3d5168085a576be15 Signed-off-by: Sung-Jin Park --- src/DSPolicyArea/DSPolicyArea.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/DSPolicyArea/DSPolicyArea.cpp b/src/DSPolicyArea/DSPolicyArea.cpp index 3c39ca7..55d86bf 100644 --- a/src/DSPolicyArea/DSPolicyArea.cpp +++ b/src/DSPolicyArea/DSPolicyArea.cpp @@ -82,7 +82,13 @@ bool DSPolicyAreaPrivate::setSize(int width, int height) bool DSPolicyAreaPrivate::attachSeat(std::shared_ptr seat) { + if (__seat) + { + DSLOG_INF("DSPolicyAreaPrivate", "Seat has been changed. (%p -> %p)", __seat, seat); + } + __seat = seat; + __seat->attachZone(__zone); return true; } -- 2.7.4 From cc3c2f5f81b32cce4fd9859f0ac855c3eb2cde4b Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 6 Aug 2020 16:08:15 +0900 Subject: [PATCH 15/16] samples: make the wayland rendering sample without wl_shell Change-Id: I221441092b21d7d63a4b99bbe72d4cdaefb04004 --- samples/exampleClientNoShellRendering.cpp | 374 +++++++++++++++++++++ ...ndering.cpp => exampleClientShellRendering.cpp} | 2 +- samples/meson.build | 13 +- 3 files changed, 386 insertions(+), 3 deletions(-) create mode 100644 samples/exampleClientNoShellRendering.cpp rename samples/{exampleWlClientSimpleRendering.cpp => exampleClientShellRendering.cpp} (99%) diff --git a/samples/exampleClientNoShellRendering.cpp b/samples/exampleClientNoShellRendering.cpp new file mode 100644 index 0000000..1cbe5cc --- /dev/null +++ b/samples/exampleClientNoShellRendering.cpp @@ -0,0 +1,374 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define BUF_WIDTH 400 +#define BUF_HEIGHT 200 +#define TEST_COUNT 200 +#define BUF_NUM 3 + +class WlClientSimpleRendering { + int __width; + int __height; + int __stride; + int __size; + int __count; + tbm_format __format; + tbm_surface_h __tbmSurface[BUF_NUM]; + + Ecore_Wl2_Display *__ecoreWl2Dpy; + struct wl_display *__wlDisplay; + struct wl_registry *__wlRegistry; + +public: + WlClientSimpleRendering(int width, int height, tbm_format format) + :__width(width), + __height(height), + __format(format) + { + __stride = width * 4; + __size = height * __stride; + __count = 0; + + for (int i = 0; i < BUF_NUM; i++) + { + __tbmSurface[i] = nullptr; + __wlBuffer[i] = nullptr; + } + + __ecoreWl2Dpy = nullptr; + __wlDisplay = nullptr; + __wlRegistry = nullptr; + __wlCompositor = nullptr; + __wlSurface = nullptr; + __wlTbmClient = nullptr; + } + + ~WlClientSimpleRendering() + { + for (int i = 0; i < BUF_NUM; i++) + { + if (__wlBuffer[i] != nullptr) wl_buffer_destroy(__wlBuffer[i]); + if (__tbmSurface[i] != nullptr) tbm_surface_destroy(__tbmSurface[i]); + } + if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); + if (__wlCompositor != nullptr) wl_compositor_destroy(__wlCompositor); + + if (__wlRegistry != nullptr) wl_registry_destroy(__wlRegistry); + if (__ecoreWl2Dpy != nullptr) ecore_wl2_display_disconnect(__ecoreWl2Dpy); + } + + int ConnectDisplay(); + void DisconnectDisplay(); + int CreateBuffer(int bufferNum); + void DestroyBuffer(int bufferNum); + int RenderingBuffer(int bufferNum, unsigned char color); + void CommitBuffer(int bufferNum); + + struct wl_compositor *__wlCompositor; + struct wl_surface *__wlSurface; + struct wl_buffer *__wlBuffer[BUF_NUM]; + struct wayland_tbm_client *__wlTbmClient; +}; + +static void +handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) +{ + WlClientSimpleRendering *temp = (WlClientSimpleRendering *)data; + + if (strcmp(interface, "wl_compositor") == 0) { + temp->__wlCompositor = (struct wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 3); + if (temp->__wlCompositor == nullptr) + std::cout << __func__ << " Error. fail to bind " << interface << std::endl; + else + std::cout << __func__ << " bind " << interface << std::endl; + } else { + std::cout << __func__ << " Not bind" << interface << std::endl; + } +} + +static void +handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) +{ +} + +static const struct wl_registry_listener registry_listener = { + handle_global, + handle_global_remove +}; + +int WlClientSimpleRendering::ConnectDisplay() +{ + __ecoreWl2Dpy = ecore_wl2_display_connect(NULL); + if (__ecoreWl2Dpy == nullptr) + { + std::cout << __func__ << " Error. fail ecore_wl2_display_connect" << std::endl; + return -1; + } + + __wlDisplay = ecore_wl2_display_get(__ecoreWl2Dpy); + if (__wlDisplay == nullptr) + { + std::cout << __func__ << " Error. fail ecore_wl2_display_get" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + __wlRegistry = wl_display_get_registry(__wlDisplay); + if (__wlRegistry == nullptr) + { + std::cout << __func__ << " Error. fail wl_display_get_registry" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + wl_registry_add_listener(__wlRegistry, ®istry_listener, this); + wl_display_dispatch(__wlDisplay); + wl_display_roundtrip(__wlDisplay); + + if (__wlCompositor == nullptr) + { + std::cout << __func__ << " Error. fail binding" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + __wlTbmClient = wayland_tbm_client_init(__wlDisplay); + if (__wlTbmClient == nullptr) + { + std::cout << __func__ << " Error. fail wayland_tbm_client_init" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + __wlSurface = wl_compositor_create_surface(__wlCompositor); + if (__wlSurface == nullptr) + { + std::cout << __func__ << " Error. fail wl_compositor_create_surface" << std::endl; + this->DisconnectDisplay(); + return -1; + } + + return 0; +} + +void WlClientSimpleRendering::DisconnectDisplay() +{ + int i; + + for (i = 0; i < BUF_NUM; i++) + { + this->DestroyBuffer(i); + } + if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); + __wlTbmClient = nullptr; + + if (__wlCompositor) wl_compositor_destroy(__wlCompositor); + __wlCompositor = nullptr; + + if (__wlRegistry != nullptr) wl_registry_destroy(__wlRegistry); + __wlRegistry = nullptr; + __wlDisplay = nullptr; + if (__ecoreWl2Dpy != nullptr) ecore_wl2_display_disconnect(__ecoreWl2Dpy); + __ecoreWl2Dpy = nullptr; +} + +int WlClientSimpleRendering::CreateBuffer(int bufferNum) +{ + tbm_surface_h tbm_surface; + + if (bufferNum >= BUF_NUM) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return -1; + } + + if (__wlTbmClient == nullptr) + { + std::cout << __func__ << " Error. no __wlTbmClient. execute ConnectDisplay first" << std::endl; + return -1; + } + + tbm_surface = tbm_surface_create(__width, __height, __format); + if (tbm_surface == nullptr) + { + std::cout << __func__ << " Error. fail to create tbm_surface" << std::endl; + return -1; + } + + if (__tbmSurface[bufferNum] != nullptr) + { + std::cout << __func__ << " destroy prev tbm_surface " << bufferNum << ":" << __tbmSurface[bufferNum] << std::endl; + this->DestroyBuffer(bufferNum); + } + __tbmSurface[bufferNum] = tbm_surface; + + __wlBuffer[bufferNum] = wayland_tbm_client_create_buffer(__wlTbmClient, __tbmSurface[bufferNum]); + if (__wlBuffer[bufferNum] == nullptr) + { + std::cout << __func__ << " Error. fail to create wl_buffer" << std::endl; + tbm_surface_destroy(__tbmSurface[bufferNum]); + __tbmSurface[bufferNum] = nullptr; + return -1; + } + + std::cout << __func__ << " create " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; + + return 0; +} + +void WlClientSimpleRendering::DestroyBuffer(int bufferNum) +{ + if (bufferNum >= BUF_NUM) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return; + } + + if (__tbmSurface[bufferNum] == nullptr) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return; + } + + std::cout << __func__ << " destroy " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; + + wl_buffer_destroy(__wlBuffer[bufferNum]); + __wlBuffer[bufferNum] = nullptr; + tbm_surface_destroy(__tbmSurface[bufferNum]); + __tbmSurface[bufferNum] = nullptr; +} + +int WlClientSimpleRendering::RenderingBuffer(int bufferNum, unsigned char color) +{ + tbm_surface_h tbm_surface; + tbm_surface_info_s info; + int ret = 0; + + if (bufferNum >= BUF_NUM) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return -1; + } + + tbm_surface = __tbmSurface[bufferNum]; + if (tbm_surface == nullptr) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return -1; + } + + ret = tbm_surface_map(tbm_surface, TBM_SURF_OPTION_WRITE, &info); + if (ret != 0) + { + std::cout << __func__ << " Error. fail to tbm_surface_map " << ret << std::endl; + return ret; + } + + memset(info.planes[0].ptr, color, info.planes[0].stride * info.height); + + tbm_surface_unmap(tbm_surface); + + return ret; +} + +void WlClientSimpleRendering::CommitBuffer(int bufferNum) +{ + int ret = 0; + + if (__wlSurface == nullptr || __wlDisplay == nullptr) + { + std::cout << __func__ << " Error. execute connect first" << std::endl; + return; + } + + if (bufferNum >= BUF_NUM || __wlBuffer[bufferNum] == nullptr) + { + std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; + return; + } + + wl_surface_attach(__wlSurface, __wlBuffer[bufferNum], 0, 0); + wl_surface_damage(__wlSurface, 0, 0, __width, __height); + wl_surface_commit(__wlSurface); + + std::cout << __func__ << " commit " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; +#if 0 + ret = wl_display_dispatch(__wlDisplay); + if (ret < 0) { + std::cout << __func__ << " Error. wl_display_dispatch error:" << ret << std::endl; + return; + } +#endif + wl_display_roundtrip(__wlDisplay); +} + +int main (void) +{ + WlClientSimpleRendering *simpleRenderSample = nullptr; + int count = 0; + int ret = 0; + int i; + unsigned char color; + + ecore_wl2_init(); + + simpleRenderSample = new WlClientSimpleRendering(BUF_WIDTH, BUF_HEIGHT, TBM_FORMAT_ARGB8888); + if (simpleRenderSample == nullptr) + { + std::cout << __func__ << " Error. fail create WlClientSimpleRendering" << std::endl; + ecore_wl2_shutdown(); + return -1; + } + + ret = simpleRenderSample->ConnectDisplay(); + if (ret) + { + std::cout << __func__ << " Error. fail ConnectDisplay" << std::endl; + ecore_wl2_shutdown(); + return -1; + } + + for (i = 0; i < BUF_NUM; i++) + { + ret = simpleRenderSample->CreateBuffer(i); + if (ret) + { + std::cout << __func__ << " Error. fail CreateBuffer " << i << std::endl; + goto finish; + } + } + + /* main loop */ + i = 0; + color = 0x11; + std::cout << __func__ << " loop start." << std::endl; + while (count < TEST_COUNT) { + simpleRenderSample->RenderingBuffer(i, color); + simpleRenderSample->CommitBuffer(i); + count++; + i++; + if (i == BUF_NUM) i = 0; + if (color == 0xff) + color = 0x11; + else + color += 0x11; + std::cout << __func__ << " loop running " << count << std::endl; + usleep(100000); + } + std::cout << __func__ << " loop end." << std::endl; + +finish: + simpleRenderSample->DisconnectDisplay(); + + delete simpleRenderSample; + + ecore_wl2_shutdown(); + + return 0; +} diff --git a/samples/exampleWlClientSimpleRendering.cpp b/samples/exampleClientShellRendering.cpp similarity index 99% rename from samples/exampleWlClientSimpleRendering.cpp rename to samples/exampleClientShellRendering.cpp index 6d8228c..91f6006 100644 --- a/samples/exampleWlClientSimpleRendering.cpp +++ b/samples/exampleClientShellRendering.cpp @@ -345,7 +345,7 @@ int main (void) ecore_wl2_init(); - simpleRenderSample = new WlClientSimpleRendering(BUF_WIDTH, BUF_HEIGHT, TBM_FORMAT_XRGB8888); + simpleRenderSample = new WlClientSimpleRendering(BUF_WIDTH, BUF_HEIGHT, TBM_FORMAT_ARGB8888); if (simpleRenderSample == nullptr) { std::cout << __func__ << " Error. fail create WlClientSimpleRendering" << std::endl; diff --git a/samples/meson.build b/samples/meson.build index 3fc8fa2..435afec 100644 --- a/samples/meson.build +++ b/samples/meson.build @@ -37,10 +37,19 @@ executable('exampleClient', install : true ) + ecore_wayland2_dep = dependency('ecore-wl2') wayland_tbm_client_dep = dependency('wayland-tbm-client') -executable('exampleWlClientSimpleRendering', - 'exampleWlClientSimpleRendering.cpp', +executable('exampleClientNoShellRendering', + 'exampleClientNoShellRendering.cpp', + dependencies : [libds_declared_dep, wayland_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], + install_dir : libds_prefix_bindir, + install : true + ) + +wayland_tbm_client_dep = dependency('wayland-tbm-client') +executable('exampleClientShellRendering', + 'exampleClientShellRendering.cpp', dependencies : [libds_declared_dep, wayland_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], install_dir : libds_prefix_bindir, install : true -- 2.7.4 From b0b2fb3f9f81c0a10b9f649cfd57c430670f4376 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 6 Aug 2020 17:32:44 +0900 Subject: [PATCH 16/16] DSDisplayArea: do HWC Commit and renderFrame at Idle handler of main loop Change-Id: I570d731ffe62f487e99ed78f44bfab0b9687eea5 --- src/DSDisplayArea/DSDisplayArea.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index 7930252..b711f01 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -118,8 +118,13 @@ void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) void DSDisplayAreaPrivate::__onEventIdleEnterer(void *data) { - // TODO:: __displayDeviceHWC->commit(); - // TODO:: __renderEngine->renderFrame(); + DSLOG_INF("DSDisplayAreaPrivate", "__onEventIdleEnterer"); + + if (!__displayDeviceHWC->commit()) + DSLOG_INF("DSDisplayAreaPrivate", "No commit at this time."); + + if (!__renderEngine->renderFrame()) + DSLOG_INF("DSDisplayAreaPrivate", "No renderFrame at this time."); } } // namespace display_server -- 2.7.4