From 5c7a2bbe8e46c99148b35ab48b63d671b0b77892 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 4 Aug 2020 14:56:34 +0900 Subject: [PATCH 01/16] IDSDisplayDeviceHWCWindow: add interface about frame update Change-Id: I22f9ced80a40764143bb72f101407ff3b3c4348b --- .../DSDisplayDeviceHWCWindowTDMImpl.cpp | 19 ++++++++++++++++++- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h | 6 ++++++ src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp index f1f8d42..54cce58 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp @@ -16,4 +16,21 @@ tdm_hwc_window *DSDisplayDeviceHWCWindowTDMImpl::getNativeHWCWindow() { return __twindow; } -} \ No newline at end of file + +void DSDisplayDeviceHWCWindowTDMImpl::updateFrame(bool &update) +{ + // temp always false update + update = false; +} + +void DSDisplayDeviceHWCWindowTDMImpl::presentFrame() +{ + /* TODO:: */ +} + +void DSDisplayDeviceHWCWindowTDMImpl::onPresentFrameDone() +{ + /* TODO:: */ +} + +} diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h index 2efda71..4ac989b 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h @@ -3,6 +3,7 @@ #include "IDSDisplayDeviceHWCWindow.h" #include "DSWindow.h" +#include "IDSBuffer.h" #include namespace display_server @@ -13,6 +14,11 @@ public: DSDisplayDeviceHWCWindowTDMImpl(std::shared_ptr window, tdm_hwc_window *twindow); ~DSDisplayDeviceHWCWindowTDMImpl(); tdm_hwc_window *getNativeHWCWindow(); + + void updateFrame(bool &update) override; + void presentFrame() override; + void onPresentFrameDone() override; + private: std::shared_ptr __window; tdm_hwc_window *__twindow; diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h index b565032..deac3e6 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h @@ -7,6 +7,9 @@ class IDSDisplayDeviceHWCWindow { public: virtual ~IDSDisplayDeviceHWCWindow() = default; + virtual void updateFrame(bool &update) = 0; + virtual void presentFrame() = 0; + virtual void onPresentFrameDone() = 0; }; } -- 2.7.4 From 7c1262c2bdead567fcf331ad7813e7279405bf4e Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 4 Aug 2020 14:56:59 +0900 Subject: [PATCH 02/16] IDSDisplayDeviceHWCWindowTDM: add TargetImpl Change-Id: Ibc36905ca15eb3855021f32ec6fbb3ce2a4bfab5 --- .../DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 53 ++++++++++++++++++++++ .../DSDisplayDeviceHWCWindowTDMTargetImpl.h | 33 ++++++++++++++ src/meson.build | 1 + 3 files changed, 87 insertions(+) create mode 100644 src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp create mode 100644 src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp new file mode 100644 index 0000000..056b585 --- /dev/null +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -0,0 +1,53 @@ + +#include "DSDisplayDeviceHWCWindowTDMTargetImpl.h" +#include "DSDebugLog.h" + +namespace display_server +{ +DSDisplayDeviceHWCWindowTDMTargetImpl::DSDisplayDeviceHWCWindowTDMTargetImpl(IDSDisplayDeviceHWC *deviceHWC, std::shared_ptr bufferQueue) + : __deviceHWC(deviceHWC), + __bufferQueue(bufferQueue) +{} +DSDisplayDeviceHWCWindowTDMTargetImpl::~DSDisplayDeviceHWCWindowTDMTargetImpl() +{ +} + +void DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame(bool &update) +{ + std::shared_ptr dsBuffer; + + if (!__bufferQueue->canAcquireBuffer(false)) return; + + dsBuffer = __bufferQueue->acquireBuffer(); + if (!dsBuffer) { + DSLOG_ERR("TDM_HWC", "acquire buffer fails."); + return; + } + + if (__buffer) { + __bufferQueue->releaseBuffer(__buffer); + __buffer = nullptr; + } + + __buffer= dsBuffer; + + update = true; +} + +void DSDisplayDeviceHWCWindowTDMTargetImpl::presentFrame() +{ + if (__buffer) { + __presentBuffer = std::move(__buffer); + __deviceHWC->setTargetBuffer(__presentBuffer); + } +} + +void DSDisplayDeviceHWCWindowTDMTargetImpl::onPresentFrameDone() +{ + if (__presentedBuffer) + __bufferQueue->releaseBuffer(__presentedBuffer); + + __presentedBuffer = std::move(__presentBuffer); +} + +} diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h new file mode 100644 index 0000000..027d553 --- /dev/null +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h @@ -0,0 +1,33 @@ +#ifndef _I_DS_DISPLAY_DEVICE_HWC_WINDOW_TDM_TARGET_IMPL_H_ +#define _I_DS_DISPLAY_DEVICE_HWC_WINDOW_TDM_TARGET_IMPL_H_ + +#include "IDSDisplayDeviceHWCWindow.h" +#include "IDSDisplayDeviceHWC.h" +#include "IDSBufferQueue.h" +#include "DSWindow.h" +#include "IDSBuffer.h" +#include + +namespace display_server +{ +class DSDisplayDeviceHWCWindowTDMTargetImpl : public IDSDisplayDeviceHWCWindow +{ +public: + DSDisplayDeviceHWCWindowTDMTargetImpl(IDSDisplayDeviceHWC *deviceHWC, std::shared_ptr __bufferQueue); + ~DSDisplayDeviceHWCWindowTDMTargetImpl(); + + void updateFrame(bool &update) override; + void presentFrame() override; + void onPresentFrameDone() override; + +private: + IDSDisplayDeviceHWC *__deviceHWC; + std::shared_ptr __bufferQueue; + std::shared_ptr __buffer; + std::shared_ptr __presentBuffer; + std::shared_ptr __presentedBuffer; +}; + +} + +#endif diff --git a/src/meson.build b/src/meson.build index c9789dd..5fdf1c9 100644 --- a/src/meson.build +++ b/src/meson.build @@ -17,6 +17,7 @@ libds_srcs = [ 'DSDisplayArea/DSDisplayArea.cpp', 'DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp', 'DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp', + 'DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp', 'DSDisplayDevice/DSDisplayDeviceOutputModeTDMImpl.cpp', 'DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp', 'DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp', -- 2.7.4 From 60defbe45fbfe7f3c5e0a55a02c9c2314ad016cf Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 4 Aug 2020 15:07:28 +0900 Subject: [PATCH 03/16] DSDisplayDeviceHWCTDMImpl: update frame of target window in commit Change-Id: I6be02a4c80c9c4e9623ef22d1f2b64e6d8028837 --- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp | 42 +++++++++++++++++++++-- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h | 5 +++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp index 89ab367..03bdf80 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp @@ -1,6 +1,7 @@ #include "DSDisplayDeviceHWCTDMImpl.h" #include "DSDisplayDeviceHWCWindowTDMImpl.h" +#include "DSDisplayDeviceHWCWindowTDMTargetImpl.h" #include "DSDebugLog.h" #include @@ -34,6 +35,8 @@ std::shared_ptr DSDisplayDeviceHWCTDMImpl::getTargetBufferQueue( __bufferQueue = std::make_shared(tqueue); + __targetWindow = std::make_unique(this, __bufferQueue); + return __bufferQueue; } @@ -96,6 +99,12 @@ bool DSDisplayDeviceHWCTDMImpl::commit() { tdm_error terror; uint32_t numChanges; + bool frameUpdate = false; + + if (!__updateFrameWindows(frameUpdate)) { + DSLOG_ERR("HWCTDM", "__updateTarget fails."); + return false; + } if (!__validate(numChanges)) { DSLOG_ERR("HWCTDM", "__validate fails."); @@ -114,13 +123,21 @@ bool DSDisplayDeviceHWCTDMImpl::commit() return false; } - //TODO: tdm_hwc_commit - terror = tdm_hwc_commit(__thwc, 0, NULL, NULL); + if (!__presentFrameWindows()) { + DSLOG_ERR("HWCTDM", "__presentFrameWindows fails."); + return false; + } + + //TODO: commit with async + terror = tdm_hwc_commit(__thwc, true, NULL, NULL); if (terror != TDM_ERROR_NONE) { DSLOG_ERR("HWCTDM", "tdm_hwc_commit fails."); + __presentFrameDoneWindows(); return false; } + __presentFrameDoneWindows(); + return true; } @@ -209,4 +226,25 @@ bool DSDisplayDeviceHWCTDMImpl::__acceptValidation() return true; } +bool DSDisplayDeviceHWCTDMImpl::__updateFrameWindows(bool &frameUpdate) +{ + __targetWindow->updateFrame(frameUpdate); + + return true; +} + +bool DSDisplayDeviceHWCTDMImpl::__presentFrameWindows() +{ + __targetWindow->presentFrame(); + + return true; +} + +bool DSDisplayDeviceHWCTDMImpl::__presentFrameDoneWindows() +{ + __targetWindow->onPresentFrameDone(); + + return true; +} + } diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h index e08b913..3432b9e 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h @@ -26,10 +26,15 @@ private: tdm_hwc *__thwc; std::shared_ptr __bufferQueue; std::list> __visibleDeviceHWCWindowList; + std::unique_ptr __targetWindow; + bool __validate(uint32_t &numChanges); bool __updateChanges(uint32_t numChanges); bool __acceptValidation(); + bool __updateFrameWindows(bool &frameUpdate); + bool __presentFrameWindows(); + bool __presentFrameDoneWindows(); }; } -- 2.7.4 From bdb376c35df440ff4571f4d8dd193fa59cbfce2a Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 4 Aug 2020 15:45:19 +0900 Subject: [PATCH 04/16] DSBuffer: set XDG_RUNTIME_DIR in test Change-Id: I8fc16b45ef51da23cc791a72264438f6d94b5c12 --- tests/DSBufferManager-test.cpp | 8 ++++++-- tests/DSBufferRef-test.cpp | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/DSBufferManager-test.cpp b/tests/DSBufferManager-test.cpp index bbce2c0..6d836a4 100644 --- a/tests/DSBufferManager-test.cpp +++ b/tests/DSBufferManager-test.cpp @@ -10,9 +10,13 @@ class DSBufferManagerTest : public ::testing::Test { public: void SetUp(void) override - {} + { + setenv("XDG_RUNTIME_DIR", "/run", 1); + } void TearDown(void) override - {} + { + unsetenv("XDG_RUNTIME_DIR"); + } }; TEST_F(DSBufferManagerTest, GetBufferManager) diff --git a/tests/DSBufferRef-test.cpp b/tests/DSBufferRef-test.cpp index 45a8a5f..a5b7f3c 100644 --- a/tests/DSBufferRef-test.cpp +++ b/tests/DSBufferRef-test.cpp @@ -9,9 +9,14 @@ class DSBufferRefTest : public ::testing::Test { public: void SetUp(void) override - {} + { + setenv("XDG_RUNTIME_DIR", "/run", 1); + } + void TearDown(void) override - {} + { + unsetenv("XDG_RUNTIME_DIR"); + } }; TEST_F(DSBufferRefTest, CreateBufferRef) -- 2.7.4 From 544e958e8f7cdba445ced4798bf23ed8f396614d Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Tue, 4 Aug 2020 20:58:22 +0900 Subject: [PATCH 05/16] DSCompositor: add code to create DSWaylandExtension Change-Id: I4ca77cfdf79d61d18fce032d192ce1989b2044d8 --- src/DSCompositor/DSCompositor.cpp | 7 +++++++ src/DSCompositor/DSCompositorPrivate.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/DSCompositor/DSCompositor.cpp b/src/DSCompositor/DSCompositor.cpp index f042897..b6d4acb 100644 --- a/src/DSCompositor/DSCompositor.cpp +++ b/src/DSCompositor/DSCompositor.cpp @@ -7,6 +7,7 @@ #include "DSSeat.h" #include "DSInput.h" #include "DSWaylandCompositor.h" +#include "DSWaylandExtension.h" #include namespace display_server @@ -69,6 +70,7 @@ bool DSCompositorPrivate::run() __initializeWlDisplay(); __initializeOutputs(); __initializeBufferManager(); + __initializeExtension(); __canvas = pub->_onInitialized(); if (!__canvas) { DSLOG_ERR("Compositor", "_onInitialized() fails."); @@ -124,4 +126,9 @@ void DSCompositorPrivate::__initializeBufferManager() __dsBufferManager = DSBufferManager::getInstance(); } +void DSCompositorPrivate::__initializeExtension() +{ + __wlExtension = std::make_unique(__wlCompositor); +} + } // namespace display_server \ No newline at end of file diff --git a/src/DSCompositor/DSCompositorPrivate.h b/src/DSCompositor/DSCompositorPrivate.h index e84424c..a72fdf2 100644 --- a/src/DSCompositor/DSCompositorPrivate.h +++ b/src/DSCompositor/DSCompositorPrivate.h @@ -13,6 +13,7 @@ namespace display_server class DSSeat; class DSInput; class DSWaylandCompositor; +class DSWaylandExtension; class DSCompositorPrivate : public DSObjectPrivate { @@ -38,9 +39,12 @@ private: std::shared_ptr __canvas; DSBufferManager *__dsBufferManager; + std::unique_ptr __wlExtension; + void __initializeWlDisplay(); void __initializeOutputs(); void __initializeBufferManager(); + void __initializeExtension(); }; } -- 2.7.4 From 899fb16c918e53bf37d5ace4f771491dfa29d136 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Tue, 4 Aug 2020 20:59:49 +0900 Subject: [PATCH 06/16] exampleClient: bind tizen_policy Change-Id: Ie71212eab477528d56a9ead604f20b24e64abbf0 --- samples/exampleClient.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++- samples/meson.build | 3 ++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/samples/exampleClient.c b/samples/exampleClient.c index f39d621..b3b254c 100644 --- a/samples/exampleClient.c +++ b/samples/exampleClient.c @@ -11,6 +11,7 @@ #include #include #include +#include struct wl_display *display = NULL; struct wl_compositor *compositor = NULL; @@ -21,7 +22,7 @@ struct wl_keyboard *keyboard = NULL; struct wl_touch *touch = NULL; struct xkb_context *xkb_context = NULL; struct xkb_keymap *keymap = NULL; - +struct tizen_policy *tz_policy = NULL; static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { @@ -331,6 +332,70 @@ static const struct wl_seat_listener seat_listener = { seat_handle_name, }; + +static void +_tizen_policy_cb_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, uint32_t is_conformant) +{ +} + +static void +_tizen_policy_cb_conformant_area(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h) +{ +} + +static void +_tizen_policy_cb_notification_done(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, int32_t level, uint32_t state) +{ +} + +static void +_tizen_policy_cb_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id) +{ +} + +static void +_tizen_policy_cb_window_screen_mode_done(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t mode, uint32_t state) +{ +} + +static void +_tizen_policy_cb_iconify_state_changed(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, uint32_t iconified, uint32_t force) +{ +} + +static void +_tizen_policy_cb_supported_aux_hints(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, struct wl_array *hints, uint32_t num_hints) +{ +} + +static void +_tizen_policy_cb_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy , struct wl_surface *surface_resource, int id) +{ +} + +static void +_tizen_policy_cb_aux_message(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, const char *key, const char *val, struct wl_array *options) +{ +} + +static void +_tizen_policy_cb_conformant_region(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial) +{ +} + +static const struct tizen_policy_listener tz_policy_listener = { + _tizen_policy_cb_conformant, + _tizen_policy_cb_conformant_area, + _tizen_policy_cb_notification_done, + _tizen_policy_cb_transient_for_done, + _tizen_policy_cb_window_screen_mode_done, + _tizen_policy_cb_iconify_state_changed, + _tizen_policy_cb_supported_aux_hints, + _tizen_policy_cb_allowed_aux_hint, + _tizen_policy_cb_aux_message, + _tizen_policy_cb_conformant_region, +}; + static void global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) @@ -346,6 +411,11 @@ global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, seat = wl_registry_bind(registry, id, &wl_seat_interface, 4); wl_seat_add_listener(seat, &seat_listener, NULL); } + else if(strcmp(interface, "tizen_policy") == 0) + { + tz_policy = wl_registry_bind(registry, id, &tizen_policy_interface, 7); + tizen_policy_add_listener(tz_policy, &tz_policy_listener, NULL); + } } static void diff --git a/samples/meson.build b/samples/meson.build index cbc09ce..3fc8fa2 100644 --- a/samples/meson.build +++ b/samples/meson.build @@ -28,10 +28,11 @@ executable('exampleCompositor', # exampleClient written for testing exampleCompositor wayland_client_dep = dependency('wayland-client') +tizen_extension_client_dep = dependency('tizen-extension-client') libxkbcommon_dep = dependency('xkbcommon') executable('exampleClient', 'exampleClient.c', - dependencies : [libds_declared_dep, wayland_client_dep, libxkbcommon_dep], + dependencies : [libds_declared_dep, wayland_client_dep, tizen_extension_client_dep, libxkbcommon_dep], install_dir : libds_prefix_bindir, install : true ) -- 2.7.4 From 8142643cc6423d2ac86d39b4095e12a9b19aea7e Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Tue, 4 Aug 2020 21:46:54 +0900 Subject: [PATCH 07/16] Revert "DSCompositor: add code to create DSWaylandExtension" This reverts commit 28205782954df472ab10742de453633fbcf39e5b. Change-Id: I6c2e4f728d7a006ae7610894182984659c7c083d --- src/DSCompositor/DSCompositor.cpp | 7 ------- src/DSCompositor/DSCompositorPrivate.h | 4 ---- 2 files changed, 11 deletions(-) diff --git a/src/DSCompositor/DSCompositor.cpp b/src/DSCompositor/DSCompositor.cpp index b6d4acb..f042897 100644 --- a/src/DSCompositor/DSCompositor.cpp +++ b/src/DSCompositor/DSCompositor.cpp @@ -7,7 +7,6 @@ #include "DSSeat.h" #include "DSInput.h" #include "DSWaylandCompositor.h" -#include "DSWaylandExtension.h" #include namespace display_server @@ -70,7 +69,6 @@ bool DSCompositorPrivate::run() __initializeWlDisplay(); __initializeOutputs(); __initializeBufferManager(); - __initializeExtension(); __canvas = pub->_onInitialized(); if (!__canvas) { DSLOG_ERR("Compositor", "_onInitialized() fails."); @@ -126,9 +124,4 @@ void DSCompositorPrivate::__initializeBufferManager() __dsBufferManager = DSBufferManager::getInstance(); } -void DSCompositorPrivate::__initializeExtension() -{ - __wlExtension = std::make_unique(__wlCompositor); -} - } // namespace display_server \ No newline at end of file diff --git a/src/DSCompositor/DSCompositorPrivate.h b/src/DSCompositor/DSCompositorPrivate.h index a72fdf2..e84424c 100644 --- a/src/DSCompositor/DSCompositorPrivate.h +++ b/src/DSCompositor/DSCompositorPrivate.h @@ -13,7 +13,6 @@ namespace display_server class DSSeat; class DSInput; class DSWaylandCompositor; -class DSWaylandExtension; class DSCompositorPrivate : public DSObjectPrivate { @@ -39,12 +38,9 @@ private: std::shared_ptr __canvas; DSBufferManager *__dsBufferManager; - std::unique_ptr __wlExtension; - void __initializeWlDisplay(); void __initializeOutputs(); void __initializeBufferManager(); - void __initializeExtension(); }; } -- 2.7.4 From 764b08aeeae4d3083f2f7e9283c5878cee897413 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Tue, 4 Aug 2020 21:56:50 +0900 Subject: [PATCH 08/16] DSWaylandCompositor: add code to initialze DSWaylandExtension Change-Id: I9645b4d465b85904cfd58a4aa3bae7986f253cb3 --- src/DSWaylandServer/DSWaylandCompositor.cpp | 25 +++++++++++++++++++++++- src/DSWaylandServer/DSWaylandCompositor.h | 1 + src/DSWaylandServer/DSWaylandCompositorPrivate.h | 7 ++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandCompositor.cpp b/src/DSWaylandServer/DSWaylandCompositor.cpp index 7951ca4..e0c126f 100644 --- a/src/DSWaylandServer/DSWaylandCompositor.cpp +++ b/src/DSWaylandServer/DSWaylandCompositor.cpp @@ -1,5 +1,6 @@ #include "DSWaylandCompositor.h" #include "DSWaylandCompositorPrivate.h" +#include "DSWaylandExtension.h" #include "DSWaylandClient.h" #include "DSWaylandSeat.h" #include "DSWaylandSurface.h" @@ -23,7 +24,8 @@ DSWaylandCompositorPrivate::DSWaylandCompositorPrivate(DSWaylandCompositor *comp _display(nullptr), _loop(nullptr), _socket_fd_handler(nullptr), - _compositor(compositor) + _compositor(compositor), + __wlExtension(nullptr) { if (!ecore_init()) { @@ -168,6 +170,20 @@ bool DSWaylandCompositorPrivate::initCompositor() return true; } +bool DSWaylandCompositorPrivate::initExtension() +{ + if (__wlExtension) + { + DSLOG_INF("DSWaylandCompositor", "Already initialize Extension"); + return true; + } + + __wlExtension = std::make_unique(_compositor); + if (!__wlExtension) return false; + + return true; +} + Eina_Bool DSWaylandCompositorPrivate::__readEvents(void *data, Ecore_Fd_Handler *hdlr) { DSWaylandCompositorPrivate *compPrivate = (DSWaylandCompositorPrivate *) data; @@ -299,6 +315,13 @@ bool DSWaylandCompositor::create() return false; } + res = priv->initExtension(); + if (!res) + { + DSLOG_ERR("DSWaylandCompositor", "Failed on initExtension ! (res=%d)\n", res); + return false; + } + priv->_created = true; return true; } diff --git a/src/DSWaylandServer/DSWaylandCompositor.h b/src/DSWaylandServer/DSWaylandCompositor.h index e160a46..e7f1b43 100644 --- a/src/DSWaylandServer/DSWaylandCompositor.h +++ b/src/DSWaylandServer/DSWaylandCompositor.h @@ -14,6 +14,7 @@ namespace display_server class DSWaylandClient; class DSWaylandSeat; class DSWaylandSurface; +class DSWaylandExtension; class DSWaylandCompositorPrivate; diff --git a/src/DSWaylandServer/DSWaylandCompositorPrivate.h b/src/DSWaylandServer/DSWaylandCompositorPrivate.h index 0e33b3e..af99b70 100644 --- a/src/DSWaylandServer/DSWaylandCompositorPrivate.h +++ b/src/DSWaylandServer/DSWaylandCompositorPrivate.h @@ -17,6 +17,8 @@ namespace display_server class DSWaylandClient; class DSWaylandSeat; class DSWaylandCompositor; +class DSWaylendExtension; + class DS_DECL_EXPORT DSWaylandCompositorPrivate : public DSObjectPrivate, public DSWaylandServer::wl_compositor { DS_PIMPL_USE_PUBLIC(DSWaylandCompositor); @@ -25,6 +27,7 @@ public: ~DSWaylandCompositorPrivate() override; bool initCompositor(); + bool initExtension(); void initSocket(std::string sName, std::string sDir); inline void addClient(DSWaylandClient *client); inline void removeClient(DSWaylandClient *client); @@ -61,6 +64,8 @@ protected: private: static Eina_Bool __readEvents(void *data, Ecore_Fd_Handler *hdlr); static void __prepareFunc(void *data, Ecore_Fd_Handler *hdlr); + + std::unique_ptr __wlExtension; }; void DSWaylandCompositorPrivate::addClient(DSWaylandClient *client) @@ -83,4 +88,4 @@ void DSWaylandCompositorPrivate::removeClient(DSWaylandClient *client) } -#endif //__DS_WAYLAND_COMPOSITOR_PRIVATE_H__ \ No newline at end of file +#endif //__DS_WAYLAND_COMPOSITOR_PRIVATE_H__ -- 2.7.4 From 51581c27efa2b95edc721bbd01280d1abfe0cb58 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Wed, 5 Aug 2020 09:28:47 +0900 Subject: [PATCH 09/16] DSZone: remove unnecessary header file Change-Id: I9872f0178555ec0c0be18014c1577b0801944023 --- src/DSZone/DSZone.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index 4a39c0a..4de5a00 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -1,8 +1,6 @@ #ifndef __DS_ZONE_H__ #define __DS_ZONE_H__ -#include "wayland-server-core.h" - #include #include "DSWindow.h" #include "DSWindowShell.h" -- 2.7.4 From ac36ce13172ee28e132dfab59f9bc065c98b3641 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Wed, 5 Aug 2020 09:33:09 +0900 Subject: [PATCH 10/16] DSWaylandExtension: change log level in init() Change-Id: I84e24c8aac3f95177dff8fbf9cbf9a9941ca3239 --- src/DSWaylandExtension/DSWaylandExtension.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSWaylandExtension/DSWaylandExtension.cpp b/src/DSWaylandExtension/DSWaylandExtension.cpp index c1e3661..bc6e57c 100644 --- a/src/DSWaylandExtension/DSWaylandExtension.cpp +++ b/src/DSWaylandExtension/DSWaylandExtension.cpp @@ -42,7 +42,7 @@ bool DSWaylandExtensionPrivate::init(DSWaylandCompositor *compositor) return false; } - DSLOG_ERR("DSWaylandExtension", "Initialize succeed"); + DSLOG_INF("DSWaylandExtension", "Initialize succeed"); return true; } -- 2.7.4 From 389adc9d7793f11f15b0d29ca2dc027467aac964 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 5 Aug 2020 13:46:10 +0900 Subject: [PATCH 11/16] DSWaylandSurface: add checking client attach null buffer Change-Id: I6e03e7390c6a8fb7cd6a2334e6edfabf4ab4f164 --- src/DSWaylandServer/DSWaylandSurface.cpp | 12 ++++++++---- src/DSWindow/DSWindow.cpp | 12 +++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp index 450b4af..d521d70 100644 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ b/src/DSWaylandServer/DSWaylandSurface.cpp @@ -17,7 +17,7 @@ DSWaylandSurfaceCommitInfoPrivate::~DSWaylandSurfaceCommitInfoPrivate() std::shared_ptr DSWaylandSurfaceCommitInfoPrivate::getBuffer() { - return bufferRef->refDSBufferGet(); + return bufferRef ? bufferRef->refDSBufferGet() : nullptr; } //////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -78,14 +78,18 @@ void DSWaylandSurfacePrivate::surface_destroy(Resource *resource) void DSWaylandSurfacePrivate::surface_attach(Resource *resource, struct ::wl_resource *buffer, int32_t x, int32_t y) { DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); - std::shared_ptr dsBuffer = __bufferManager->getDSBuffer(buffer); + std::shared_ptr dsBuffer; commitInfoPendingPriv->attach.x = x; commitInfoPendingPriv->attach.y = y; commitInfoPendingPriv->attach.buffer = buffer; - commitInfoPendingPriv->bufferRef.reset(nullptr); - commitInfoPendingPriv->bufferRef = std::make_unique(dsBuffer); + + if (buffer) { + dsBuffer = __bufferManager->getDSBuffer(buffer); + commitInfoPendingPriv->bufferRef = std::make_unique(dsBuffer); + + } } void DSWaylandSurfacePrivate::surface_damage(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 365d0f0..9ac15bf 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -84,12 +84,14 @@ void DSWindowPrivate::__onSurfaceCommitted(std::shared_ptr buffer = waylandSurfaceCommitInfo->getBuffer(); - std::shared_ptr bufferSize = buffer->getSize(); - __w = bufferSize->w; - __h = bufferSize->h; + if (buffer) { + std::shared_ptr bufferSize = buffer->getSize(); + __w = bufferSize->w; + __h = bufferSize->h; - // emit a signal of the size changed - pub->__sizeChangedSignal.emit(bufferSize); + // emit a signal of the size changed + pub->__sizeChangedSignal.emit(bufferSize); + } // TODO: get more information from waylandSurfaceCommitInfo. ex) damageSurface, damageBuffer, transform, scale and so on } -- 2.7.4 From b89058e0d0f529b51fd0572126610f62954b2c6c Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 5 Aug 2020 10:41:54 +0900 Subject: [PATCH 12/16] DSInput: fix print() to leave log with DSLOG_INF() Change-Id: I7fc012304253843352cbeeef13f9bd6fb343be41 Signed-off-by: Sung-Jin Park --- src/DSInput/DSInput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSInput/DSInput.cpp b/src/DSInput/DSInput.cpp index 817755a..eb93266 100644 --- a/src/DSInput/DSInput.cpp +++ b/src/DSInput/DSInput.cpp @@ -353,7 +353,7 @@ DSInputDevice::~DSInputDevice() void DSInputDevice::print() { - std::cout << "DeviceInfo: " << "name: " << getName() << ", identifier: " << getIdentifier() << ", class: " << getClass() << ", subclass: " << getSubclass() << std::endl; + DSLOG_INF("DSInputDevice", "DeviceInfo: name: %s, identifier: %s , class: %d, subclass: %d", getName().c_str(), getIdentifier().c_str(), getClass(), getSubclass()); } bool DSInputDevice::operator==(DSInputDevice& device) -- 2.7.4 From c7d313a61cd9847e1638de3a1dc882d1dc966637 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 5 Aug 2020 14:23:09 +0900 Subject: [PATCH 13/16] DSWaylandSeat: add APIs (getName/getPointer/getKeyboard/getTouch) Change-Id: I98c9acfeda2dda7fdec3add446ac0d48aa3f4894 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandSeat.cpp | 25 ++++++++++++++++++ src/DSWaylandServer/DSWaylandSeat.h | 9 +++++++ tests/DSWaylandSeat-test.cpp | 49 +++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/src/DSWaylandServer/DSWaylandSeat.cpp b/src/DSWaylandServer/DSWaylandSeat.cpp index 6a46cc6..93d7474 100644 --- a/src/DSWaylandServer/DSWaylandSeat.cpp +++ b/src/DSWaylandServer/DSWaylandSeat.cpp @@ -172,4 +172,29 @@ void DSWaylandSeat::setName(std::string name) priv->__seatName = name; } +std::string DSWaylandSeat::getName() +{ + DS_GET_PRIV(DSWaylandSeat); + + return priv->__seatName; +} + +DSWaylandPointer *DSWaylandSeat::getPointer() +{ + DS_GET_PRIV(DSWaylandSeat); + return priv->__pointer; +} + +DSWaylandKeyboard *DSWaylandSeat::getKeyboard() +{ + DS_GET_PRIV(DSWaylandSeat); + return priv->__keyboard; +} + +DSWaylandTouch *DSWaylandSeat::getTouch() +{ + DS_GET_PRIV(DSWaylandSeat); + return priv->__touch; +} + } diff --git a/src/DSWaylandServer/DSWaylandSeat.h b/src/DSWaylandServer/DSWaylandSeat.h index 55b93d6..a2ecd07 100644 --- a/src/DSWaylandServer/DSWaylandSeat.h +++ b/src/DSWaylandServer/DSWaylandSeat.h @@ -9,6 +9,10 @@ namespace display_server class DSWaylandSeatPrivate; class DSWaylandCompositor; +class DSWaylandPointer; +class DSWaylandKeyboard; +class DSWaylandTouch; + class DS_DECL_EXPORT DSWaylandSeat : public DSObject { DS_PIMPL_USE_PRIVATE(DSWaylandSeat); @@ -32,6 +36,11 @@ public: void setCapability(DSWaylandSeat::seatCapability cap); DSWaylandSeat::seatCapability getCapability(void); void setName(std::string name); + std::string getName(); + + DSWaylandPointer *getPointer(); + DSWaylandKeyboard *getKeyboard(); + DSWaylandTouch *getTouch(); protected: diff --git a/tests/DSWaylandSeat-test.cpp b/tests/DSWaylandSeat-test.cpp index cae51ab..d4bf446 100644 --- a/tests/DSWaylandSeat-test.cpp +++ b/tests/DSWaylandSeat-test.cpp @@ -65,3 +65,52 @@ TEST_F(DSWaylandSeatTest, SetUpdateGetCapabilities) } } +TEST_F(DSWaylandSeatTest, SetGetName) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + EXPECT_TRUE(comp != nullptr); + + if (comp) + { + DSWaylandSeat *seat = new DSWaylandSeat(comp, DSWaylandSeat::capDefault); + EXPECT_TRUE(seat != nullptr); + + if (seat) + { + std::string sName{"seat0"}; + std::string gName; + + seat->setName(sName); + gName = seat->getName(); + EXPECT_TRUE(gName.compare(std::string{"seat0"}) == 0); + + delete seat; + } + + DSWaylandCompositor::releaseInstance(); + } +} + +TEST_F(DSWaylandSeatTest, getKeyboardPointerTouch) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + EXPECT_TRUE(comp != nullptr); + + if (comp) + { + DSWaylandSeat *seat = new DSWaylandSeat(comp, DSWaylandSeat::capDefault); + EXPECT_TRUE(seat != nullptr); + + if (seat) + { + EXPECT_TRUE(seat->getPointer () != nullptr); + EXPECT_TRUE(seat->getKeyboard () != nullptr); + EXPECT_TRUE(seat->getTouch () != nullptr); + + delete seat; + } + + DSWaylandCompositor::releaseInstance(); + } +} + -- 2.7.4 From 3a77a31bfc7391254c4d666d38370150bc4dc466 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 5 Aug 2020 14:24:53 +0900 Subject: [PATCH 14/16] DSWaylandServer: add getFocus()/setFocus() APIs for DSWaylandPointer/Keyboard/Touch Change-Id: I2ab9eac5d708a906acd8ef0c44c375d169555a7f Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandKeyboard.cpp | 13 ++++++++++++ src/DSWaylandServer/DSWaylandKeyboard.h | 3 +++ src/DSWaylandServer/DSWaylandKeyboardPrivate.h | 13 ++++++++++++ src/DSWaylandServer/DSWaylandPointer.cpp | 15 +++++++++++++- src/DSWaylandServer/DSWaylandPointer.h | 3 +++ src/DSWaylandServer/DSWaylandPointerPrivate.h | 28 +++++++++++++++++++++----- src/DSWaylandServer/DSWaylandTouch.cpp | 15 +++++++++++++- src/DSWaylandServer/DSWaylandTouch.h | 3 +++ src/DSWaylandServer/DSWaylandTouchPrivate.h | 24 ++++++++++++++++++---- tests/DSWaylandKeyboard-test.cpp | 22 ++++++++++++++++++++ tests/DSWaylandPointer-test.cpp | 22 ++++++++++++++++++++ tests/DSWaylandTouch-test.cpp | 22 ++++++++++++++++++++ 12 files changed, 172 insertions(+), 11 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandKeyboard.cpp b/src/DSWaylandServer/DSWaylandKeyboard.cpp index f6e505f..3dc8880 100644 --- a/src/DSWaylandServer/DSWaylandKeyboard.cpp +++ b/src/DSWaylandServer/DSWaylandKeyboard.cpp @@ -10,6 +10,7 @@ DSWaylandKeyboardPrivate::DSWaylandKeyboardPrivate(DSWaylandSeat *seat, DSWaylan : DSObjectPrivate(keyboard), __p_ptr(keyboard), __seat(seat), + __waylandSurface(nullptr), __repeatRate(0), __repeatDelay(0) { @@ -92,4 +93,16 @@ void DSWaylandKeyboard::addClient(DSWaylandClient *client, uint32_t id, int vers priv->add(client->wlClient(), id, version); } +void DSWaylandKeyboard::setFocus(DSWaylandSurface *waylandSurface) +{ + DS_GET_PRIV(DSWaylandKeyboard); + priv->__waylandSurface = waylandSurface; +} + +DSWaylandSurface *DSWaylandKeyboard::getFocus() +{ + DS_GET_PRIV(DSWaylandKeyboard); + return priv->__waylandSurface; +} + } diff --git a/src/DSWaylandServer/DSWaylandKeyboard.h b/src/DSWaylandServer/DSWaylandKeyboard.h index 62a3c1f..c927100 100644 --- a/src/DSWaylandServer/DSWaylandKeyboard.h +++ b/src/DSWaylandServer/DSWaylandKeyboard.h @@ -10,6 +10,7 @@ namespace display_server class DSWaylandSeat; class DSWaylandKeyboardPrivate; class DSWaylandClient; +class DSWaylandSurface; class DS_DECL_EXPORT DSWaylandKeyboard : public DSObject { @@ -26,6 +27,8 @@ public: uint32_t repeatDelay(void); void addClient(DSWaylandClient *client, uint32_t id, int version); + void setFocus(DSWaylandSurface *waylandSurface); + DSWaylandSurface *getFocus(); protected: diff --git a/src/DSWaylandServer/DSWaylandKeyboardPrivate.h b/src/DSWaylandServer/DSWaylandKeyboardPrivate.h index ecb34af..1946d7f 100644 --- a/src/DSWaylandServer/DSWaylandKeyboardPrivate.h +++ b/src/DSWaylandServer/DSWaylandKeyboardPrivate.h @@ -10,6 +10,8 @@ namespace display_server { class DSWaylandSeat; +class DSWaylandSurface; + class DS_DECL_EXPORT DSWaylandKeyboardPrivate : public DSObjectPrivate, public DSWaylandServer::wl_keyboard { DS_PIMPL_USE_PUBLIC(DSWaylandKeyboard); @@ -25,8 +27,19 @@ protected: virtual void keyboard_destroy_resource(Resource *resource); virtual void keyboard_release(Resource *resource); + /* APIs must be provided */ + /* + void sendKeymap(struct ::wl_client *client, uint32_t format, int32_t fd, uint32_t size); + void sendEnter(struct ::wl_client *client, uint32_t serial, struct ::wl_resource *surface, const std::string &keys); + void sendLeave(struct ::wl_client *client, uint32_t serial, struct ::wl_resource *surface); + void sendKey(struct ::wl_client *client, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); + void sendModifiers(struct ::wl_client *client, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); + void sendRepeat_info(struct ::wl_client *client, int32_t rate, int32_t delay); + */ + private: DSWaylandSeat *__seat; + DSWaylandSurface *__waylandSurface; uint32_t __repeatRate; uint32_t __repeatDelay; diff --git a/src/DSWaylandServer/DSWaylandPointer.cpp b/src/DSWaylandServer/DSWaylandPointer.cpp index 0261306..adc314c 100644 --- a/src/DSWaylandServer/DSWaylandPointer.cpp +++ b/src/DSWaylandServer/DSWaylandPointer.cpp @@ -9,7 +9,8 @@ namespace display_server DSWaylandPointerPrivate::DSWaylandPointerPrivate(DSWaylandSeat *seat, DSWaylandPointer *pointer) : DSObjectPrivate(pointer), __p_ptr(pointer), - __seat(seat) + __seat(seat), + __waylandSurface(nullptr) { wl_pointer(); } @@ -67,4 +68,16 @@ void DSWaylandPointer::addClient(DSWaylandClient *client, uint32_t id, int versi priv->add(client->wlClient(), id, version); } +void DSWaylandPointer::setFocus(DSWaylandSurface *waylandSurface) +{ + DS_GET_PRIV(DSWaylandPointer); + priv->__waylandSurface = waylandSurface; +} + +DSWaylandSurface *DSWaylandPointer::getFocus() +{ + DS_GET_PRIV(DSWaylandPointer); + return priv->__waylandSurface; +} + } \ No newline at end of file diff --git a/src/DSWaylandServer/DSWaylandPointer.h b/src/DSWaylandServer/DSWaylandPointer.h index d788796..5d528e7 100644 --- a/src/DSWaylandServer/DSWaylandPointer.h +++ b/src/DSWaylandServer/DSWaylandPointer.h @@ -10,6 +10,7 @@ namespace display_server class DSWaylandSeat; class DSWaylandPointerPrivate; class DSWaylandClient; +class DSWaylandSurface; class DS_DECL_EXPORT DSWaylandPointer : public DSObject { @@ -21,6 +22,8 @@ public: DSWaylandSeat *seat(); void addClient(DSWaylandClient *client, uint32_t id, int version); + void setFocus(DSWaylandSurface *waylandSurface); + DSWaylandSurface *getFocus(); protected: diff --git a/src/DSWaylandServer/DSWaylandPointerPrivate.h b/src/DSWaylandServer/DSWaylandPointerPrivate.h index 6c4b530..320d78a 100644 --- a/src/DSWaylandServer/DSWaylandPointerPrivate.h +++ b/src/DSWaylandServer/DSWaylandPointerPrivate.h @@ -18,14 +18,32 @@ public: ~DSWaylandPointerPrivate() override; protected: - //virtual Resource *pointer_allocate(); - void pointer_bind_resource(Resource *resource) override; - void pointer_destroy_resource(Resource *resource) override; - void pointer_set_cursor(Resource *resource, uint32_t serial, struct ::wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y) override; - void pointer_release(Resource *resource) override; + //virtual Resource *pointer_allocate(); + void pointer_bind_resource(Resource *resource) override; + void pointer_destroy_resource(Resource *resource) override; + void pointer_set_cursor(Resource *resource, uint32_t serial, struct ::wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y) override; + void pointer_release(Resource *resource) override; + + /* APIs must be provided */ + /* + void sendEnter(struct ::wl_client *client, uint32_t serial, struct ::wl_resource *surface, wl_fixed_t surface_x, wl_fixed_t surface_y); + void sendLeave(struct ::wl_client *client, uint32_t serial, struct ::wl_resource *surface); + void sendMotion(struct ::wl_client *client, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y); + void sendButton(struct ::wl_client *client, uint32_t serial, uint32_t time, uint32_t button, uint32_t state); + */ + + /* APIs don't need to provide */ + /* + void sendAxis(struct ::wl_resource *resource, uint32_t time, uint32_t axis, wl_fixed_t value); + void send_frame(struct ::wl_resource *resource); + void send_axis_source(struct ::wl_resource *resource, uint32_t axis_source); + void send_axis_stop(struct ::wl_resource *resource, uint32_t time, uint32_t axis); + void send_axis_discrete(struct ::wl_resource *resource, uint32_t axis, int32_t discrete); + */ private: DSWaylandSeat *__seat; + DSWaylandSurface *__waylandSurface; }; } diff --git a/src/DSWaylandServer/DSWaylandTouch.cpp b/src/DSWaylandServer/DSWaylandTouch.cpp index 5af72f2..eb8a954 100644 --- a/src/DSWaylandServer/DSWaylandTouch.cpp +++ b/src/DSWaylandServer/DSWaylandTouch.cpp @@ -8,7 +8,8 @@ namespace display_server { DSWaylandTouchPrivate::DSWaylandTouchPrivate(DSWaylandSeat *seat, DSWaylandTouch *touch) : DSObjectPrivate(touch), __p_ptr(touch), - __seat(seat) + __seat(seat), + __waylandSurface(nullptr) { wl_touch(); } @@ -61,4 +62,16 @@ void DSWaylandTouch::addClient(DSWaylandClient *client, uint32_t id, int version priv->add(client->wlClient(), id, version); } +void DSWaylandTouch::setFocus(DSWaylandSurface *waylandSurface) +{ + DS_GET_PRIV(DSWaylandTouch); + priv->__waylandSurface = waylandSurface; +} + +DSWaylandSurface *DSWaylandTouch::getFocus() +{ + DS_GET_PRIV(DSWaylandTouch); + return priv->__waylandSurface; +} + } \ No newline at end of file diff --git a/src/DSWaylandServer/DSWaylandTouch.h b/src/DSWaylandServer/DSWaylandTouch.h index eab11ea..c2d62b9 100644 --- a/src/DSWaylandServer/DSWaylandTouch.h +++ b/src/DSWaylandServer/DSWaylandTouch.h @@ -10,6 +10,7 @@ namespace display_server class DSWaylandSeat; class DSWaylandTouchPrivate; class DSWaylandClient; +class DSWaylandSurface; class DS_DECL_EXPORT DSWaylandTouch : public DSObject { @@ -21,6 +22,8 @@ public: DSWaylandSeat *seat(); void addClient(DSWaylandClient *client, uint32_t id, int version); + void setFocus(DSWaylandSurface *waylandSurface); + DSWaylandSurface *getFocus(); protected: diff --git a/src/DSWaylandServer/DSWaylandTouchPrivate.h b/src/DSWaylandServer/DSWaylandTouchPrivate.h index 3dd6031..5444bf2 100644 --- a/src/DSWaylandServer/DSWaylandTouchPrivate.h +++ b/src/DSWaylandServer/DSWaylandTouchPrivate.h @@ -20,13 +20,29 @@ public: //TODO protected: - //virtual Resource *touch_allocate(); - virtual void touch_bind_resource(Resource *resource); - virtual void touch_destroy_resource(Resource *resource); - virtual void touch_release(Resource *resource); + //virtual Resource *touch_allocate(); + virtual void touch_bind_resource(Resource *resource); + virtual void touch_destroy_resource(Resource *resource); + virtual void touch_release(Resource *resource); + + /* APIs must be provided */ + /* + void sendDown(struct ::wl_client *client, uint32_t serial, uint32_t time, struct ::wl_resource *surface, int32_t id, wl_fixed_t x, wl_fixed_t y); + void sendUp(struct ::wl_client *client, uint32_t serial, uint32_t time, int32_t id); + void sendMotion(struct ::wl_client *client, uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y); + void sendFrame(struct ::wl_client *client); + void sendCancel(struct ::wl_client *client); + */ + + /* APIs don't need to provide */ + /* + void send_shape(struct ::wl_resource *resource, int32_t id, wl_fixed_t major, wl_fixed_t minor); + void send_orientation(struct ::wl_resource *resource, int32_t id, wl_fixed_t orientation); + */ private: DSWaylandSeat *__seat; + DSWaylandSurface *__waylandSurface; }; } diff --git a/tests/DSWaylandKeyboard-test.cpp b/tests/DSWaylandKeyboard-test.cpp index 4701297..3769679 100644 --- a/tests/DSWaylandKeyboard-test.cpp +++ b/tests/DSWaylandKeyboard-test.cpp @@ -1,6 +1,7 @@ #include "libds-tests.h" #include "DSWaylandKeyboard.h" #include "DSWaylandSeat.h" +#include "DSWaylandSurface.h" using namespace display_server; @@ -9,9 +10,11 @@ class DSWaylandKeyboardTest : public ::testing::Test public: void SetUp(void) override { + setenv("XDG_RUNTIME_DIR", "/run", 1); } void TearDown(void) override { + unsetenv("XDG_RUNTIME_DIR"); } }; @@ -65,3 +68,22 @@ TEST_F(DSWaylandKeyboardTest, SetGetRepeatRateDelay) delete keyboard; } } + +TEST_F(DSWaylandKeyboardTest, SetGetFocus) +{ + auto keyboard = new DSWaylandKeyboard(nullptr); + EXPECT_TRUE(keyboard != nullptr); + + if (keyboard) + { + auto waylandSurface = std::make_unique(); + EXPECT_TRUE(waylandSurface != nullptr); + + if (waylandSurface) + { + keyboard->setFocus(waylandSurface.get()); + EXPECT_TRUE(waylandSurface.get() == keyboard->getFocus()); + } + } +} + diff --git a/tests/DSWaylandPointer-test.cpp b/tests/DSWaylandPointer-test.cpp index 24281fd..d79bb97 100644 --- a/tests/DSWaylandPointer-test.cpp +++ b/tests/DSWaylandPointer-test.cpp @@ -1,6 +1,7 @@ #include "libds-tests.h" #include "DSWaylandPointer.h" #include "DSWaylandSeat.h" +#include "DSWaylandSurface.h" using namespace display_server; @@ -9,9 +10,11 @@ class DSWaylandPointerTest : public ::testing::Test public: void SetUp(void) override { + setenv("XDG_RUNTIME_DIR", "/run", 1); } void TearDown(void) override { + unsetenv("XDG_RUNTIME_DIR"); } }; @@ -45,3 +48,22 @@ TEST_F(DSWaylandPointerTest, GetSeat) delete seat; } } + +TEST_F(DSWaylandPointerTest, SetGetFocus) +{ + auto pointer = new DSWaylandPointer(nullptr); + EXPECT_TRUE(pointer != nullptr); + + if (pointer) + { + auto waylandSurface = std::make_unique(); + EXPECT_TRUE(waylandSurface != nullptr); + + if (waylandSurface) + { + pointer->setFocus(waylandSurface.get()); + EXPECT_TRUE(waylandSurface.get() == pointer->getFocus()); + } + } +} + diff --git a/tests/DSWaylandTouch-test.cpp b/tests/DSWaylandTouch-test.cpp index 3fe8b85..9f6a7b0 100644 --- a/tests/DSWaylandTouch-test.cpp +++ b/tests/DSWaylandTouch-test.cpp @@ -1,6 +1,7 @@ #include "libds-tests.h" #include "DSWaylandTouch.h" #include "DSWaylandSeat.h" +#include "DSWaylandSurface.h" using namespace display_server; @@ -9,9 +10,11 @@ class DSWaylandTouchTest : public ::testing::Test public: void SetUp(void) override { + setenv("XDG_RUNTIME_DIR", "/run", 1); } void TearDown(void) override { + unsetenv("XDG_RUNTIME_DIR"); } }; @@ -45,3 +48,22 @@ TEST_F(DSWaylandTouchTest, GetSeat) delete seat; } } + +TEST_F(DSWaylandTouchTest, SetGetFocus) +{ + auto touch = new DSWaylandTouch(nullptr); + EXPECT_TRUE(touch != nullptr); + + if (touch) + { + auto waylandSurface = std::make_unique(); + EXPECT_TRUE(waylandSurface != nullptr); + + if (waylandSurface) + { + touch->setFocus(waylandSurface.get()); + EXPECT_TRUE(waylandSurface.get() == touch->getFocus()); + } + } +} + -- 2.7.4 From 7d18e2970cac4dfd5b2cf37fa00abcf356443614 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 28 Jul 2020 20:46:32 +0900 Subject: [PATCH 15/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 16/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