From 7d18e2970cac4dfd5b2cf37fa00abcf356443614 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 28 Jul 2020 20:46:32 +0900 Subject: [PATCH 01/16] Add build dependencies to use dali libs. Change-Id: I05a09166de68211cff88c201d8c0ff4770da5bf6 Signed-off-by: Joonbum Ko --- packaging/libds.spec | 4 ++++ src/meson.build | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packaging/libds.spec b/packaging/libds.spec index e82c1d9..9e330b4 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -27,6 +27,10 @@ BuildRequires: pkgconfig(ecore-evas) BuildRequires: pkgconfig(libinput) BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(xkbcommon) +BuildRequires: pkgconfig(dali2-core) +BuildRequires: pkgconfig(dali2-adaptor) +BuildRequires: pkgconfig(dali2-toolkit) +BuildRequires: pkgconfig(dali2-extension) # For samples and tests BuildRequires: pkgconfig(wayland-client) diff --git a/src/meson.build b/src/meson.build index 5fdf1c9..c6ac5dd 100644 --- a/src/meson.build +++ b/src/meson.build @@ -182,6 +182,11 @@ input_method_dep = dependency('input-method-server') text_dep = dependency('text-server') tizen_launch_dep = dependency('tizen-launch-server') +dali_core_dep = dependency('dali2-core') +dali_adaptor_dep = dependency('dali2-adaptor') +dali_toolkit_dep = dependency('dali2-toolkit') + +dali_deps = [dali_core_dep, dali_adaptor_dep, dali_toolkit_dep] tizen_ext_deps = [tizen_ext_dep, input_method_dep, text_dep, tizen_launch_dep, tizen_surface_dep] tizen_ext_deps = [tizen_ext_deps, xdg_shell_unstable_v6_dep, xdg_shell_dep] libds_deps = [ecore_dep] @@ -219,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], + 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 @@ -228,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], + 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 ) -- 2.7.4 From 22f2172e545ea47da3363786e5eed0fe4be1afd0 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 27 Jul 2020 20:44:28 +0900 Subject: [PATCH 02/16] Implemented initial phase to use dali render engine. Change-Id: I8456a0573aa17933f3666ccc40bde3cc8b45f968 Signed-off-by: Joonbum Ko --- src/DSRender/DSRenderEngineDaliImpl.cpp | 31 ++++++++++++++++++++++++++++--- src/DSRender/DSRenderEngineDaliImpl.h | 10 +++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp index 02245a6..42a00c5 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -2,15 +2,38 @@ #include "DSRenderViewDaliImpl.h" #include "DSDebugLog.h" +using namespace Dali; + namespace display_server { DSRenderEngineDaliImpl::DSRenderEngineDaliImpl(std::shared_ptr bufferQueue) : __bufferQueue{bufferQueue} -{} +{ + void *nativeBufferQueue = __bufferQueue->getNativeBufferQueue(); + __offscreenApplication = OffscreenApplication::New(nativeBufferQueue, true); + + __offscreenApplication.InitSignal().Connect(this, &DSRenderEngineDaliImpl::onInitialize); + + __offscreenApplication.Run(); +} DSRenderEngineDaliImpl::~DSRenderEngineDaliImpl() -{} +{ +} + +void DSRenderEngineDaliImpl::onInitialize() +{ + /* for testing -- begin -- */ + OffscreenWindow window = __offscreenApplication.GetWindow(); + + window.SetBackgroundColor(Color::YELLOW); + + Toolkit::TextLabel textlabel = Toolkit::TextLabel::New("Hello libDS"); + textlabel.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); + window.Add(textlabel); + /* for testing -- end -- */ +} std::shared_ptr DSRenderEngineDaliImpl::makeRenderView(std::shared_ptr window) { @@ -21,7 +44,9 @@ std::shared_ptr DSRenderEngineDaliImpl::makeRenderView(std::shared bool DSRenderEngineDaliImpl::renderFrame() { - return false; + Adaptor::Get().RenderOnce(); + + return true; } } // namespace display_server diff --git a/src/DSRender/DSRenderEngineDaliImpl.h b/src/DSRender/DSRenderEngineDaliImpl.h index 2b101e1..b3940d1 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.h +++ b/src/DSRender/DSRenderEngineDaliImpl.h @@ -4,10 +4,15 @@ #include "IDSRenderEngine.h" #include "IDSBufferQueue.h" +#include +#include +#include +#include + namespace display_server { -class DSRenderEngineDaliImpl : public IDSRenderEngine +class DSRenderEngineDaliImpl : public IDSRenderEngine, public Dali::ConnectionTracker { public: DSRenderEngineDaliImpl(std::shared_ptr bufferQueue); @@ -16,8 +21,11 @@ public: std::shared_ptr makeRenderView(std::shared_ptr window) override; bool renderFrame() override; + void onInitialize(); + private: std::shared_ptr __bufferQueue; + Dali::OffscreenApplication __offscreenApplication; }; } -- 2.7.4 From 19886929a01d4e4e2ddf846a788db5a182beddf4 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 30 Jul 2020 16:43:27 +0900 Subject: [PATCH 03/16] DSRenderViewDaliImpl: Implemented initial dali render view. Change-Id: I2962cfa9cec012f46c57006c7ea36ca53840a18a Signed-off-by: Joonbum Ko --- src/DSRender/DSRenderEngineDaliImpl.cpp | 11 +++-- src/DSRender/DSRenderViewDaliImpl.cpp | 86 +++++++++++++++++++++++++++++++-- src/DSRender/DSRenderViewDaliImpl.h | 10 +++- 3 files changed, 97 insertions(+), 10 deletions(-) diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp index 42a00c5..c61a8e3 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -2,16 +2,18 @@ #include "DSRenderViewDaliImpl.h" #include "DSDebugLog.h" +#include + using namespace Dali; namespace display_server { DSRenderEngineDaliImpl::DSRenderEngineDaliImpl(std::shared_ptr bufferQueue) - : __bufferQueue{bufferQueue} + : __bufferQueue(bufferQueue) { - void *nativeBufferQueue = __bufferQueue->getNativeBufferQueue(); - __offscreenApplication = OffscreenApplication::New(nativeBufferQueue, true); + tbm_surface_queue_h nativeBufferQueue = (tbm_surface_queue_h)bufferQueue->getNativeBufferQueue(); + __offscreenApplication = OffscreenApplication::New((nativeBufferQueue), true); __offscreenApplication.InitSignal().Connect(this, &DSRenderEngineDaliImpl::onInitialize); @@ -26,7 +28,6 @@ void DSRenderEngineDaliImpl::onInitialize() { /* for testing -- begin -- */ OffscreenWindow window = __offscreenApplication.GetWindow(); - window.SetBackgroundColor(Color::YELLOW); Toolkit::TextLabel textlabel = Toolkit::TextLabel::New("Hello libDS"); @@ -37,7 +38,7 @@ void DSRenderEngineDaliImpl::onInitialize() std::shared_ptr DSRenderEngineDaliImpl::makeRenderView(std::shared_ptr window) { - std::shared_ptr renderView = std::make_shared(window); + std::shared_ptr renderView = std::make_shared(window, __offscreenApplication.GetWindow()); return renderView; } diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp index 685fd48..55dcd14 100644 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ b/src/DSRender/DSRenderViewDaliImpl.cpp @@ -1,18 +1,96 @@ #include "DSRenderViewDaliImpl.h" +using namespace Dali; + namespace display_server { -DSRenderViewDaliImpl::DSRenderViewDaliImpl(std::shared_ptr window) +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( + attribute mediump vec2 aPosition;\n + varying mediump vec2 vTexCoord;\n + uniform highp mat4 uMvpMatrix;\n + uniform mediump vec3 uSize;\n + varying mediump vec2 sTexCoordRect;\n + void main()\n + {\n + gl_Position = uMvpMatrix * vec4(aPosition * uSize.xy, 0.0, 1.0);\n + vTexCoord = aPosition + vec2(0.5);\n + }\n +); + +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( + uniform lowp vec4 uColor;\n + varying mediump vec2 vTexCoord;\n + uniform samplerExternalOES sTexture;\n + void main()\n + {\n + gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n + }\n +); + +Geometry DSRenderViewDaliImpl::CreateTexturedQuad() +{ + struct Vertex + { + Vector2 position; + Vector2 texCoord; + }; + + static const Vertex data[] = { { Vector2(-0.5f, -0.5f), Vector2(0.0f, 0.0f) }, + { Vector2(0.5f, -0.5f), Vector2(1.0f, 0.0f) }, + { Vector2(-0.5f, 0.5f), Vector2(0.0f, 1.0f) }, + { Vector2(0.5f, 0.5f), Vector2(1.0f, 1.0f) } }; + + PropertyBuffer vertexBuffer; + Property::Map vertexFormat; + vertexFormat["aPosition"] = Property::VECTOR2; + vertexFormat["aTexCoord"] = Property::VECTOR2; + + //Create a vertex buffer for vertex positions and texture coordinates + vertexBuffer = PropertyBuffer::New(vertexFormat); + vertexBuffer.SetData(data, 4u); + + //Create the geometry + Geometry geometry = Geometry::New(); + geometry.AddVertexBuffer(vertexBuffer); + geometry.SetType(Geometry::TRIANGLE_STRIP); + + return geometry; +} + +DSRenderViewDaliImpl::DSRenderViewDaliImpl(std::shared_ptr window, Dali::OffscreenWindow offscreenWindow) : __window(window) -{} +{ + std::string fragmentShader = "#extension GL_OES_EGL_image_external:require\n"; + fragmentShader += FRAGMENT_SHADER; + Dali::Shader __shader = Shader::New(VERTEX_SHADER, fragmentShader); + Dali::Geometry __geometry = DSRenderViewDaliImpl::CreateTexturedQuad(); + + __renderer = Renderer::New(__geometry, __shader); + __textureViewActor = Actor::New(); + + __textureViewActor.AddRenderer(__renderer); + offscreenWindow.Add(__textureViewActor); +} DSRenderViewDaliImpl::~DSRenderViewDaliImpl() -{} +{ +} bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) { - return false; + void *nativeBuffer = buffer->getNativeBuffer(); + + NativeImageSourcePtr nativeImageSource = NativeImageSource::New(Any(nativeBuffer)); + + Texture nativeTexture = Texture::New(*nativeImageSource); + + TextureSet textureSet = TextureSet::New(); + textureSet.SetTexture(0u, nativeTexture); + + __renderer.SetTextures(textureSet); + + return true; } } // namespace display_server diff --git a/src/DSRender/DSRenderViewDaliImpl.h b/src/DSRender/DSRenderViewDaliImpl.h index d66b59f..19ce433 100644 --- a/src/DSRender/DSRenderViewDaliImpl.h +++ b/src/DSRender/DSRenderViewDaliImpl.h @@ -3,19 +3,27 @@ #include "DSRenderView.h" +#include +#include +#include + namespace display_server { class DSRenderViewDaliImpl : public DSRenderView { public: - DSRenderViewDaliImpl(std::shared_ptr window); + DSRenderViewDaliImpl(std::shared_ptr window, Dali::OffscreenWindow offscreenWindow); ~DSRenderViewDaliImpl(); bool setBuffer(std::shared_ptr buffer) override; + Dali::Geometry CreateTexturedQuad(); + private: std::shared_ptr __window; + Dali::Renderer __renderer; + Dali::Actor __textureViewActor; }; } -- 2.7.4 From 759c488f8852f6a36d47c318e31fd4e438cbcb2f Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 30 Jul 2020 16:47:39 +0900 Subject: [PATCH 04/16] DSRenderEngineDaliImpl-test: Add DSEventLoop to test dali renderer. Change-Id: I7d0a35c6b3ec57a7faa2240eb9a02df8334a301f Signed-off-by: Joonbum Ko --- tests/DSRenderEngineDaliImpl-test.cpp | 43 ++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index daca8a1..f03edfe 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -2,6 +2,8 @@ #include "DSRenderEngineDaliImpl.h" #include "DSBufferQueueTBMImpl.h" #include "DSBufferTBMImpl.h" +#include "DSEventLoop.h" +#include using namespace display_server; @@ -10,9 +12,29 @@ class DSRenderEngineDaliTest : public ::testing::Test { public: void SetUp(void) override - {} + { + Ecore_Timer *timer = nullptr; + __eventLoop = DSEventLoop::getInstance(); + double delayInSecond = 0.1; + auto timerCb = [](void *data) -> Eina_Bool { + DSEventLoop *loop = (DSEventLoop *)data; + EXPECT_TRUE(loop->quit() == true); + return EINA_FALSE; + }; + + timer = ecore_timer_loop_add(delayInSecond, timerCb, __eventLoop); + EXPECT_TRUE(timer != nullptr); + + __eventLoop->run(); + } void TearDown(void) override - {} + { + __eventLoop->quit(); + DSEventLoop::releaseInstance(); + } + +private: + DSEventLoop *__eventLoop; }; TEST_F(DSRenderEngineDaliTest, RenderEngine_Create) @@ -47,4 +69,19 @@ TEST_F(DSRenderEngineDaliTest, RenderView_SetBuffer) EXPECT_TRUE(renderView != nullptr); auto buffer = std::make_shared(100, 100, IDSBuffer::FORMAT_ARGB8888); EXPECT_TRUE(renderView->setBuffer(buffer)); -} \ No newline at end of file +} + +TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderFrame) +{ + auto bufferQueue = std::make_shared(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); + EXPECT_TRUE(bufferQueue != 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); + auto buffer = std::make_shared (100, 100, IDSBuffer::FORMAT_ARGB8888); + EXPECT_TRUE(renderView->setBuffer(buffer)); + EXPECT_TRUE(renderEngine->renderFrame()); +} -- 2.7.4 From 406718813f8875e95faceba2b62fb238f39fbf2f Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 31 Jul 2020 15:25:24 +0900 Subject: [PATCH 05/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 06/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 07/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 08/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 09/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 10/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 11/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 12/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 13/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 14/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 15/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 16/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