From 3a7ad8d9d7553980ff37a99f93a28bcd13872782 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 14:40:47 +0900 Subject: [PATCH 01/16] DSDisplayDeviceHWCWindowTDMTargetImpl: add ecore_init()/ecore_shutdown() Change-Id: Ie9e232c347602db60b43ef4238bd9c0fa7bde988 --- src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index 983f4fa..5377c3b 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -33,6 +33,10 @@ DSDisplayDeviceHWCWindowTDMTargetImpl::DSDisplayDeviceHWCWindowTDMTargetImpl(IDS __bufferQueue(bufferQueue), __ecoreFdHandler(nullptr) { + if (!ecore_init()) { + DSLOG_ERR("EventLoop", "ecore_init() fails."); + } + __eventFd = eventfd(0, EFD_NONBLOCK); __ecoreFdHandler = ecore_main_fd_handler_add(__eventFd, ECORE_FD_READ, __onFdHandler, this, NULL, NULL); __bufferQueue->registerCallbackAcquirable(this, std::bind(&DSDisplayDeviceHWCWindowTDMTargetImpl::__onAcquirable, this, std::placeholders::_1)); @@ -42,6 +46,8 @@ DSDisplayDeviceHWCWindowTDMTargetImpl::~DSDisplayDeviceHWCWindowTDMTargetImpl() { ecore_main_fd_handler_del(__ecoreFdHandler); close(__eventFd); + + ecore_shutdown(); } bool DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame() -- 2.7.4 From f3d7bdebdd4b2e0e01fbb33098ac5556673c99f8 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 15:36:20 +0900 Subject: [PATCH 02/16] test: free waylandSurface before releasing DSWaylandCompositor Change-Id: I106f6860270dc9ad89eb05f1a4507de5f18c1542 Signed-off-by: SooChan Lim --- tests/libds-mock.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/libds-mock.h b/tests/libds-mock.h index ac77287..b473762 100644 --- a/tests/libds-mock.h +++ b/tests/libds-mock.h @@ -57,6 +57,7 @@ public: ~MockWaylandCompositor() { + __waylandSurface.reset(); DSWaylandCompositor::releaseInstance(); DSEventLoop::releaseInstance(); } -- 2.7.4 From 69c467710143b4e50c7ab9b84531a081d9c101d0 Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 15:00:46 +0900 Subject: [PATCH 03/16] protocols: update wayland protocols Change-Id: Ic1d34e543022fbbccdd7f194cc7b9fc865255588 --- .../dswayland-server-input-method.cpp | 20 ++++++++++++++++++++ src/DSWaylandServer/dswayland-server-input-method.h | 2 ++ src/DSWaylandServer/dswayland-server-text.cpp | 19 ++++++++++++++++++- src/DSWaylandServer/dswayland-server-text.h | 5 +++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/dswayland-server-input-method.cpp b/src/DSWaylandServer/dswayland-server-input-method.cpp index 3fcce7a..68351db 100644 --- a/src/DSWaylandServer/dswayland-server-input-method.cpp +++ b/src/DSWaylandServer/dswayland-server-input-method.cpp @@ -1090,6 +1090,26 @@ namespace DSWaylandServer { } + void wl_input_method_context::send_input_panel_enabled(uint32_t enabled) + { + DS_ASSERT_X(m_resource, "wl_input_method_context::input_panel_enabled", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call wl_input_method_context::input_panel_enabled as it's not initialised"); + return; + } + send_input_panel_enabled( + m_resource->handle, + enabled); + } + + void wl_input_method_context::send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled) + { + wl_input_method_context_send_input_panel_enabled( + resource, + enabled); + } + + wl_input_method::wl_input_method(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) diff --git a/src/DSWaylandServer/dswayland-server-input-method.h b/src/DSWaylandServer/dswayland-server-input-method.h index 3d2b501..1f800ec 100644 --- a/src/DSWaylandServer/dswayland-server-input-method.h +++ b/src/DSWaylandServer/dswayland-server-input-method.h @@ -102,6 +102,8 @@ namespace DSWaylandServer { void send_finalized_content(struct ::wl_resource *resource, const std::string &text, uint32_t cursor_position); void send_prediction_hint_data(const std::string &key, const std::string &value); void send_prediction_hint_data(struct ::wl_resource *resource, const std::string &key, const std::string &value); + void send_input_panel_enabled(uint32_t enabled); + void send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled); protected: virtual Resource *input_method_context_allocate(); diff --git a/src/DSWaylandServer/dswayland-server-text.cpp b/src/DSWaylandServer/dswayland-server-text.cpp index a5e4d3c..e4bed15 100644 --- a/src/DSWaylandServer/dswayland-server-text.cpp +++ b/src/DSWaylandServer/dswayland-server-text.cpp @@ -204,7 +204,8 @@ namespace DSWaylandServer { wl_text_input::handle_set_mime_type, wl_text_input::handle_set_input_panel_position, wl_text_input::handle_finalize_content, - wl_text_input::handle_prediction_hint_data + wl_text_input::handle_prediction_hint_data, + wl_text_input::handle_input_panel_enabled }; void wl_text_input::text_input_destroy(Resource *) @@ -307,6 +308,10 @@ namespace DSWaylandServer { { } + void wl_text_input::text_input_input_panel_enabled(Resource *, uint32_t ) + { + } + void wl_text_input::handle_destroy( ::wl_client *client, @@ -638,6 +643,18 @@ namespace DSWaylandServer { std::string(value)); } + void wl_text_input::handle_input_panel_enabled( + ::wl_client *client, + struct wl_resource *resource, + uint32_t enabled) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->text_input_object)->text_input_input_panel_enabled( + r, + enabled); + } + void wl_text_input::send_enter(struct ::wl_resource *surface) { DS_ASSERT_X(m_resource, "wl_text_input::enter", "Uninitialised resource"); diff --git a/src/DSWaylandServer/dswayland-server-text.h b/src/DSWaylandServer/dswayland-server-text.h index eb437ef..622f5d6 100644 --- a/src/DSWaylandServer/dswayland-server-text.h +++ b/src/DSWaylandServer/dswayland-server-text.h @@ -244,6 +244,7 @@ namespace DSWaylandServer { virtual void text_input_set_input_panel_position(Resource *resource, uint32_t x, uint32_t y); virtual void text_input_finalize_content(Resource *resource, const std::string &text, uint32_t cursor_position); virtual void text_input_prediction_hint_data(Resource *resource, const std::string &key, const std::string &value); + virtual void text_input_input_panel_enabled(Resource *resource, uint32_t enabled); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -370,6 +371,10 @@ namespace DSWaylandServer { struct wl_resource *resource, const char *key, const char *value); + static void handle_input_panel_enabled( + ::wl_client *client, + struct wl_resource *resource, + uint32_t enabled); std::multimap m_resource_map; Resource *m_resource; -- 2.7.4 From 6c18252d00e2605d67bc12e98a78e4dfe55af808 Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 15:01:10 +0900 Subject: [PATCH 04/16] DSWaylandTextInput: add skeleton codes for input_panel_enabled request Change-Id: I595bf67198084fb8ba7756d878f2795050df4821 --- src/DSWaylandServer/DSWaylandTextInput.cpp | 5 +++++ src/DSWaylandServer/DSWaylandTextInputPrivate.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp index 5de2744..a865654 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ b/src/DSWaylandServer/DSWaylandTextInput.cpp @@ -606,6 +606,11 @@ void DSWaylandTextInputPrivate::text_input_prediction_hint_data(Resource *resour pub->__dsTextInputPrivate->predictionHintData(key, value); } +void DSWaylandTextInputPrivate::text_input_input_panel_enabled(Resource *resource, uint32_t enabled) +{ +} + + void DSWaylandTextInputPrivate::sendCommitString(unsigned int serial, std::string text) { if (!__activatedResource) diff --git a/src/DSWaylandServer/DSWaylandTextInputPrivate.h b/src/DSWaylandServer/DSWaylandTextInputPrivate.h index 12268f2..7d98454 100644 --- a/src/DSWaylandServer/DSWaylandTextInputPrivate.h +++ b/src/DSWaylandServer/DSWaylandTextInputPrivate.h @@ -92,6 +92,7 @@ protected: void text_input_set_input_panel_position(Resource *resource, uint32_t x, uint32_t y); void text_input_finalize_content(Resource *resource, const std::string &text, uint32_t cursor_position); void text_input_prediction_hint_data(Resource *resource, const std::string &key, const std::string &value); + void text_input_input_panel_enabled(Resource *resource, uint32_t enabled); private: DSWaylandCompositor *__compositor; -- 2.7.4 From 3a09e8f6900f54314dbca882d4cccf76129f753c Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 14:13:06 +0900 Subject: [PATCH 05/16] DSWaylandTextInput: fix error and invalid methods to prevent crash Change-Id: I4e5f2d2a07e70bfde455417090564644f4aa9ea9 --- src/DSWaylandServer/DSWaylandInputMethod.cpp | 38 ++++++++++++++--------- src/DSWaylandServer/DSWaylandInputMethodPrivate.h | 12 ++++--- src/DSWaylandServer/DSWaylandInputPanel.cpp | 1 + src/DSWaylandServer/DSWaylandTextInput.cpp | 14 ++++----- src/DSWaylandServer/DSWaylandTextInput.h | 2 +- src/DSWaylandServer/DSWaylandTextInputManager.h | 2 +- src/DSWaylandServer/DSWaylandTextInputPrivate.h | 2 +- 7 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandInputMethod.cpp b/src/DSWaylandServer/DSWaylandInputMethod.cpp index 96248dd..fc79bf1 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.cpp +++ b/src/DSWaylandServer/DSWaylandInputMethod.cpp @@ -495,11 +495,11 @@ DSWaylandInputMethodPrivate::~DSWaylandInputMethodPrivate() { } -int DSWaylandInputMethodPrivate::getResourceId(Resource *resource) +int DSWaylandInputMethodPrivate::getResourceId(DSWaylandInputMethodContextPrivate::Resource *resource) { int id = -1; - std::multimap::iterator it; + std::multimap::iterator it; for (it = __contextMap.begin(); it != __contextMap.end(); it++) { if (resource == (*it).first) @@ -512,11 +512,12 @@ int DSWaylandInputMethodPrivate::getResourceId(Resource *resource) return id; } -DSWaylandServer::wl_input_method::Resource* DSWaylandInputMethodPrivate::getResource(int id) +DSWaylandInputMethodContextPrivate::Resource* DSWaylandInputMethodPrivate::getResource(int id) { - Resource *resource = nullptr; + DSWaylandInputMethodContextPrivate::Resource *resource = nullptr; - std::multimap::iterator it; + + std::multimap::iterator it; for (it = __contextMap.begin(); it != __contextMap.end(); it++) { if (id == (*it).second) @@ -531,26 +532,28 @@ DSWaylandServer::wl_input_method::Resource* DSWaylandInputMethodPrivate::getReso void DSWaylandInputMethodPrivate::sendActivate(void *contextResource, int textInputId, bool focusInEvent) { - Resource *resource = Resource::fromResource((struct ::wl_resource *)contextResource); - __contextMap.insert(std::pair(resource, textInputId)); + DSWaylandInputMethodContextPrivate::Resource *resource = DSWaylandInputMethodContextPrivate::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); + DSWaylandInputMethodContextPrivate::Resource *resource = DSWaylandInputMethodContextPrivate::Resource::fromResource((struct ::wl_resource *)contextResource); __contextMap.erase(resource); send_deactivate(__resource->handle, (struct ::wl_resource *)contextResource, focusInEvent); } -void DSWaylandInputMethodPrivate::showInputPanel(void *contextResource) +void DSWaylandInputMethodPrivate::showInputPanel(void *contextResource, int textInputId) { - send_show_input_panel((struct ::wl_resource *)contextResource); + //Resource *resource = getResource(textInputId); + send_show_input_panel(__resource->handle, (struct ::wl_resource *)contextResource); } -void DSWaylandInputMethodPrivate::hideInputPanel(void *contextResource) +void DSWaylandInputMethodPrivate::hideInputPanel(void *contextResource, int textInputId) { - send_hide_input_panel((struct ::wl_resource *)contextResource); + //Resource *resource = getResource(textInputId); + send_hide_input_panel(__resource->handle, (struct ::wl_resource *)contextResource); } void DSWaylandInputMethodPrivate::input_method_bind_resource(Resource *resource) @@ -631,15 +634,20 @@ void DSWaylandInputMethod::showInputPanel(int textInputId) DS_GET_PRIV(DSWaylandInputMethod); if (__activateContext) - priv->showInputPanel(__activateContext); + priv->showInputPanel(__activateContext, textInputId); } void DSWaylandInputMethod::hideInputPanel(int textInputId) { DS_GET_PRIV(DSWaylandInputMethod); + if (textInputId < 0) + { + textInputId = priv->getResourceId(DSWaylandInputMethodContextPrivate::Resource::fromResource((struct ::wl_resource *)__activateContext)); + } + if (__activateContext) - priv->hideInputPanel(__activateContext); + priv->hideInputPanel(__activateContext, textInputId); } void DSWaylandInputMethod::resetTextInput() @@ -814,7 +822,7 @@ void DSWaylandInputMethod::contextHideInputPanel(unsigned int serial) if (__activateContext) { - priv->hideInputPanel(__activateContext); + priv->hideInputPanel(__activateContext, -1); } } diff --git a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h index 1b9cf3d..49a86cf 100644 --- a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h +++ b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h @@ -33,6 +33,8 @@ namespace display_server { +class DSWaylandInputMethodContextPrivate; + class DS_DECL_EXPORT DSWaylandInputMethodPrivate : public DSObjectPrivate, public DSWaylandServer::wl_input_method { DS_PIMPL_USE_PUBLIC(DSWaylandInputMethod); @@ -42,10 +44,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); + void showInputPanel(void *contextResource, int textInputId); + void hideInputPanel(void *contextResource, int textInputId); + int getResourceId(DSWaylandInputMethodContextPrivate::Resource *resource); + DSWaylandInputMethodContextPrivate::Resource* getResource(int id); protected: void input_method_bind_resource(Resource *resource); @@ -54,7 +56,7 @@ protected: private: DSWaylandCompositor *__compositor; Resource *__resource; - std::multimap __contextMap; + std::multimap __contextMap; }; } diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp index c1f99b0..dc35b73 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ b/src/DSWaylandServer/DSWaylandInputPanel.cpp @@ -418,6 +418,7 @@ void DSWaylandInputPanelSurfacePrivate::setFloatingPosition(int x, int y) inputPanelFloating = pub->__inputPanel->getFloatingData(); (void) inputPanelFloating; + (void) floatingData; #if 0//Unreachable code ! Thus, disable temporarily. if (!floatingData || !inputPanelFloating) return; diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp index a865654..fdfc2dd 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ b/src/DSWaylandServer/DSWaylandTextInput.cpp @@ -47,7 +47,7 @@ void DSWaylandTextInputManagerPrivate::text_input_manager_create_text_input(Reso { DS_GET_PUB(DSWaylandTextInputManager); - pub->createTextInput((void *)(resource->client())); + pub->createTextInput((void *)(resource->client()), id); } @@ -73,9 +73,9 @@ DSWaylandTextInputManager::~DSWaylandTextInputManager() { } -void DSWaylandTextInputManager::createTextInput(void *client) +void DSWaylandTextInputManager::createTextInput(void *client, unsigned int managerId) { - __textInput->createGlobal(client, allocTextInputId()); + __textInput->createGlobal(client, managerId, allocTextInputId()); } int DSWaylandTextInputManager::allocTextInputId() @@ -208,9 +208,9 @@ DSWaylandTextInputPrivate::~DSWaylandTextInputPrivate() { } -void DSWaylandTextInputPrivate::createGlobal(void *client, int id) +void DSWaylandTextInputPrivate::createGlobal(void *client, unsigned int managerId, int id) { - Resource *resource = add((struct ::wl_client *)client, 1); + Resource *resource = add((struct ::wl_client *)client, managerId, 1); __resourceIdMap.insert(std::pair(resource, id)); } @@ -860,11 +860,11 @@ DSWaylandTextInput::~DSWaylandTextInput() { } -void DSWaylandTextInput::createGlobal(void *client, int id) +void DSWaylandTextInput::createGlobal(void *client, unsigned int managerId, int id) { DS_GET_PRIV(DSWaylandTextInput); - priv->createGlobal(client, id); + priv->createGlobal(client, managerId, id); } void DSWaylandTextInput::showInputPanel() diff --git a/src/DSWaylandServer/DSWaylandTextInput.h b/src/DSWaylandServer/DSWaylandTextInput.h index c40c922..7648814 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.h +++ b/src/DSWaylandServer/DSWaylandTextInput.h @@ -42,7 +42,7 @@ public: DSWaylandTextInput(DSWaylandCompositor *compositor, DSWaylandTextInputManager *textInputManager, DSTextInputPrivate *dsTextInputPrivate); ~DSWaylandTextInput() override; - void createGlobal(void *client, int id); + void createGlobal(void *client, unsigned int managerId, int id); void showInputPanel(); void hideInputPanel(); diff --git a/src/DSWaylandServer/DSWaylandTextInputManager.h b/src/DSWaylandServer/DSWaylandTextInputManager.h index 7a314e5..da94210 100644 --- a/src/DSWaylandServer/DSWaylandTextInputManager.h +++ b/src/DSWaylandServer/DSWaylandTextInputManager.h @@ -43,7 +43,7 @@ public: DSWaylandTextInputManager(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate); ~DSWaylandTextInputManager() override; - void createTextInput(void *client); + void createTextInput(void *client, unsigned int managerId); int allocTextInputId(); void contextCommitString(unsigned int serial, std::string text); diff --git a/src/DSWaylandServer/DSWaylandTextInputPrivate.h b/src/DSWaylandServer/DSWaylandTextInputPrivate.h index 7d98454..2d168d6 100644 --- a/src/DSWaylandServer/DSWaylandTextInputPrivate.h +++ b/src/DSWaylandServer/DSWaylandTextInputPrivate.h @@ -40,7 +40,7 @@ public: DSWaylandTextInputPrivate(DSWaylandTextInput *p_ptr, DSWaylandCompositor *compositor); ~DSWaylandTextInputPrivate() override; - void createGlobal(void *client, int id); + void createGlobal(void *client, unsigned int managerId, int id); int getResourceId(Resource *resource); void showInputPanel(void *resource); void hideInputPanel(Resource *resource, bool forceHide); -- 2.7.4 From 00d075005c103f8139093d4ebce0bdee6b0db88d Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 14:13:32 +0900 Subject: [PATCH 06/16] exampleCompositor: enable a DSTextInput Change-Id: I79bda1490aba4bcfa20dca54ea62fb1b19e41ec0 --- samples/exampleCompositor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/exampleCompositor.cpp b/samples/exampleCompositor.cpp index a544023..27787f5 100644 --- a/samples/exampleCompositor.cpp +++ b/samples/exampleCompositor.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "DSDebugLog.h" using namespace display_server; @@ -67,6 +68,8 @@ public: __canvas->attachPolicyArea(__policyArea); __canvas->attachDisplayArea(__displayArea); + __textInput = std::make_shared(); + return __canvas; } @@ -99,6 +102,7 @@ private: std::shared_ptr __seat; std::shared_ptr __policyArea; std::shared_ptr __displayArea; + std::shared_ptr __textInput; }; int main() { -- 2.7.4 From e9b09f07f64cc25f7c60578c301e09ec959bb3ce Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Fri, 21 Aug 2020 10:23:42 +0900 Subject: [PATCH 07/16] DSWaylandTizenVisibility: add skeleton code Change-Id: I4d51f0f34118177d83f9a296caf1b5cc4e821dbd --- src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 6 ++ src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h | 2 + src/DSWaylandServer/DSWaylandTizenVisibility.cpp | 81 ++++++++++++++++++++++ src/DSWaylandServer/DSWaylandTizenVisibility.h | 50 +++++++++++++ .../DSWaylandTizenVisibilityPrivate.h | 58 ++++++++++++++++ src/meson.build | 1 + 6 files changed, 198 insertions(+) create mode 100644 src/DSWaylandServer/DSWaylandTizenVisibility.cpp create mode 100644 src/DSWaylandServer/DSWaylandTizenVisibility.h create mode 100644 src/DSWaylandServer/DSWaylandTizenVisibilityPrivate.h diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index 33e47b0..2a28cb5 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -24,6 +24,7 @@ #include "DSWaylandTizenPolicy.h" #include "DSWaylandTizenPolicyPrivate.h" +#include "DSWaylandTizenVisibility.h" #include "DSWaylandTizenPosition.h" const int TIZEN_POLICY_VERSION = 7; @@ -75,6 +76,11 @@ void DSWaylandTizenPolicyPrivate::tizen_policy_destroy_resource(Resource *resour void DSWaylandTizenPolicyPrivate::tizen_policy_get_visibility(Resource *resource, uint32_t id, struct ::wl_resource *surface) { DSLOG_DBG("TizenPolicyPriv", "get_visibility... resource:%p, id:%d", resource, id); + + std::shared_ptr tzVis = std::make_shared(resource->client(), id, TIZEN_POLICY_VERSION, surface); + __tzVisList.push_front(tzVis); + + // TODO: we have to remove tzVis when it's resource is destroyed } void DSWaylandTizenPolicyPrivate::tizen_policy_get_position(Resource *resource, uint32_t id, struct ::wl_resource *surface) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h index af39461..ac08165 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h +++ b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h @@ -31,6 +31,7 @@ namespace display_server { +class DSWaylandTizenVisibility; class DSWaylandTizenPosition; class DSWaylandTizenPolicyPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_policy @@ -93,6 +94,7 @@ protected: private: DSWindowManager *__wm; std::list> __tzPosList; + std::list> __tzVisList; }; } diff --git a/src/DSWaylandServer/DSWaylandTizenVisibility.cpp b/src/DSWaylandServer/DSWaylandTizenVisibility.cpp new file mode 100644 index 0000000..3bc43ff --- /dev/null +++ b/src/DSWaylandServer/DSWaylandTizenVisibility.cpp @@ -0,0 +1,81 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "DSWaylandTizenVisibility.h" +#include "DSWaylandTizenVisibilityPrivate.h" +#include "DSWindowManager.h" + +namespace display_server +{ + +DSWaylandTizenVisibilityPrivate::DSWaylandTizenVisibilityPrivate(DSWaylandTizenVisibility *p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr), + __wlSurface(nullptr), + __dswlSurface(nullptr) +{ +} + +DSWaylandTizenVisibilityPrivate::~DSWaylandTizenVisibilityPrivate() +{ +} + +void DSWaylandTizenVisibilityPrivate::init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) +{ + tizen_visibility::init(client, id, version); + __wlSurface = surface; + __dswlSurface = DSWaylandSurface::fromWlResource(surface); +} + +void DSWaylandTizenVisibilityPrivate::tizen_visibility_bind_resource(Resource *resource) +{ +} + +void DSWaylandTizenVisibilityPrivate::tizen_visibility_destroy_resource(Resource *resource) +{ +} + +void DSWaylandTizenVisibilityPrivate::tizen_visibility_destroy(Resource *resource) +{ +} + + + +DSWaylandTizenVisibility::DSWaylandTizenVisibility(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) + : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandTizenVisibility) +{ + init(client, id, version, surface); +} + +DSWaylandTizenVisibility::~DSWaylandTizenVisibility() +{ +} + +void DSWaylandTizenVisibility::init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) +{ + DS_GET_PRIV(DSWaylandTizenVisibility); + priv->init(client, id, version, surface); +} + + +} // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandTizenVisibility.h b/src/DSWaylandServer/DSWaylandTizenVisibility.h new file mode 100644 index 0000000..a0fe5d3 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandTizenVisibility.h @@ -0,0 +1,50 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __DS_WAYLAND_TIZEN_VISIBILITY_H__ +#define __DS_WAYLAND_TIZEN_VISIBILITY_H__ + +#include "DSCore.h" +#include "DSObject.h" +#include "DSWaylandSurface.h" +#include + +namespace display_server +{ + +class DSWaylandTizenVisibilityPrivate; + +class DSWaylandTizenVisibility : public DSObject +{ +DS_PIMPL_USE_PRIVATE(DSWaylandTizenVisibility); + +public: + DSWaylandTizenVisibility(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); + ~DSWaylandTizenVisibility() override; + + void init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); +}; + +} // namespace display_server + +#endif //__DS_WAYLAND_TIZEN_VISIBILITY_H__ diff --git a/src/DSWaylandServer/DSWaylandTizenVisibilityPrivate.h b/src/DSWaylandServer/DSWaylandTizenVisibilityPrivate.h new file mode 100644 index 0000000..9dfafab --- /dev/null +++ b/src/DSWaylandServer/DSWaylandTizenVisibilityPrivate.h @@ -0,0 +1,58 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __DS_WAYLAND_TIZEN_VISIBILITY_PRIVATE__ +#define __DS_WAYLAND_TIZEN_VISIBILITY_PRIVATE__ + +#include "dswayland-server-tizen-extension.h" +#include "DSWaylandTizenVisibility.h" + +namespace display_server +{ + +class DSWaylandTizenVisibilityPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_visibility +{ +DS_PIMPL_USE_PUBLIC(DSWaylandTizenVisibility); + +public: + DSWaylandTizenVisibilityPrivate() = delete; + DSWaylandTizenVisibilityPrivate(DSWaylandTizenVisibility *p_ptr); + ~DSWaylandTizenVisibilityPrivate() override; + + void init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); + +protected: + void tizen_visibility_bind_resource(Resource *resource) override; + void tizen_visibility_destroy_resource(Resource *resource) override; + + void tizen_visibility_destroy(Resource *resource) override; + +private: + struct ::wl_resource *__wlSurface; + DSWaylandSurface *__dswlSurface; + +}; + +} + +#endif //__DS_WAYLAND_TIZEN_VISIBILITY_PRIVATE__ diff --git a/src/meson.build b/src/meson.build index 61eaa73..d1731f2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -114,6 +114,7 @@ libds_wayland_srcs = [ 'DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h', 'DSWaylandServer/DSWaylandTizenPolicy.cpp', 'DSWaylandServer/DSWaylandTizenPosition.cpp', + 'DSWaylandServer/DSWaylandTizenVisibility.cpp', 'DSWaylandServer/DSWaylandTizenSurface.cpp', 'DSWaylandServer/DSWaylandTizenSurface.h', 'DSWaylandServer/DSWaylandTizenSurfacePrivate.h', -- 2.7.4 From f098e7d30a54ab397c6e3ba6f33d6e00fdbad22c Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Fri, 21 Aug 2020 15:20:49 +0900 Subject: [PATCH 08/16] DSWindowManager/DSZone/DSWindowShell/DSWindow: add codes to handle window's vkbd floating Change-Id: Id6c386e3505585c97feaee491798546f5de57ae3 Signed-off-by: Junseok, Kim --- src/DSWindow/DSWindow.cpp | 29 +++++++++++++++++++++- src/DSWindow/DSWindow.h | 3 +++ src/DSWindow/DSWindowPrivate.h | 5 ++++ src/DSWindowManager/DSWindowManager.cpp | 36 ++++++++++++++++++++++++++++ src/DSWindowManager/DSWindowManager.h | 3 +++ src/DSWindowManager/DSWindowManagerPrivate.h | 3 +++ src/DSWindowShell/DSWindowShell.cpp | 14 +++++++++++ src/DSWindowShell/DSWindowShell.h | 3 +++ src/DSWindowShell/DSWindowShellPrivate.cpp | 21 ++++++++++++++++ src/DSWindowShell/DSWindowShellPrivate.h | 3 +++ src/DSZone/DSZone.cpp | 15 ++++++++++++ src/DSZone/DSZone.h | 3 +++ 12 files changed, 137 insertions(+), 1 deletion(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 2b31ec1..ede2584 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -45,7 +45,8 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) __firstCommit(true), __changedGeometry(false), __acceptsFocus(true), - __title("") + __title(""), + __vkbd_floating(false) { } @@ -157,6 +158,17 @@ void DSWindowPrivate::sendConfigure(void) } } +bool DSWindowPrivate::setVkbdFloating(bool set) +{ + __vkbd_floating = set; + return true; +} + +bool DSWindowPrivate::getVkbdFloating() +{ + return __vkbd_floating; +} + void DSWindowPrivate::__onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo) { DS_GET_PUB(DSWindow); @@ -367,6 +379,21 @@ void DSWindow::setSize(stSize size) priv->__changedGeometry = true; } + +bool DSWindow::setVkbdFloating(bool set) +{ + DS_GET_PRIV(DSWindow); + + return priv->setVkbdFloating(set); +} + +bool DSWindow::getVkbdFloating() +{ + DS_GET_PRIV(DSWindow); + + return priv->getVkbdFloating(); +} + DSWaylandSurface *DSWindow::surface() { DS_GET_PRIV(DSWindow); diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index eeb4a04..710f784 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -73,6 +73,9 @@ public: void setSize(unsigned int w, unsigned int h); void setSize(stSize size); + bool setVkbdFloating(bool set); + bool getVkbdFloating(); + DSWaylandSurface *surface(); bool setWindowShell(DSWindowShell *winShell); diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index b5a36f4..a6a8c7d 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -68,6 +68,9 @@ public: void sendConfigure(void); + bool setVkbdFloating(bool set); + bool getVkbdFloating(); + private: void __onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo); @@ -83,6 +86,8 @@ private: bool __changedGeometry; bool __acceptsFocus; std::string __title; + + bool __vkbd_floating; }; } diff --git a/src/DSWindowManager/DSWindowManager.cpp b/src/DSWindowManager/DSWindowManager.cpp index 818fd33..ecb0420 100644 --- a/src/DSWindowManager/DSWindowManager.cpp +++ b/src/DSWindowManager/DSWindowManager.cpp @@ -298,6 +298,30 @@ void DSWindowManagerPrivate::setWindowSkipFocus(DSWaylandSurface *dswlSurface, b } } +bool DSWindowManagerPrivate::setWindowVkbdFloating(DSWaylandSurface *dswlSurface, bool set) +{ + // find dswlSurface's window + DSZone *zone = __getZone(dswlSurface); + if (zone) + { + return zone->setWindowVkbdFloating(dswlSurface, set); + } + else + return false; +} + +bool DSWindowManagerPrivate::getWindowVkbdFloating(DSWaylandSurface *dswlSurface) +{ + // find dswlSurface's window + DSZone *zone = __getZone(dswlSurface); + if (zone) + { + return zone->getWindowVkbdFloating(dswlSurface); + } + else + return false; +} + DSWindowManager::DSWindowManager(DSObject *parent) : DS_INIT_PRIVATE_PTR(DSWindowManager) @@ -445,5 +469,17 @@ void DSWindowManager::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set priv->setWindowSkipFocus(dswlSurface, set); } +bool DSWindowManager::setWindowVkbdFloating(DSWaylandSurface *dswlSurface, bool set) +{ + DS_GET_PRIV(DSWindowManager); + return priv->setWindowVkbdFloating(dswlSurface, set); +} + +bool DSWindowManager::getWindowVkbdFloating(DSWaylandSurface *dswlSurface) +{ + DS_GET_PRIV(DSWindowManager); + return priv->getWindowVkbdFloating(dswlSurface); +} + } // namespace display_server diff --git a/src/DSWindowManager/DSWindowManager.h b/src/DSWindowManager/DSWindowManager.h index ed69080..e7a135b 100644 --- a/src/DSWindowManager/DSWindowManager.h +++ b/src/DSWindowManager/DSWindowManager.h @@ -66,6 +66,9 @@ public: void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); + bool setWindowVkbdFloating(DSWaylandSurface *dswlSurface, bool set); + bool getWindowVkbdFloating(DSWaylandSurface *dswlSurface); + protected: private: diff --git a/src/DSWindowManager/DSWindowManagerPrivate.h b/src/DSWindowManager/DSWindowManagerPrivate.h index f1066a0..be3610c 100644 --- a/src/DSWindowManager/DSWindowManagerPrivate.h +++ b/src/DSWindowManager/DSWindowManagerPrivate.h @@ -61,6 +61,9 @@ public: void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); + bool setWindowVkbdFloating(DSWaylandSurface *dswlSurface, bool set); + bool getWindowVkbdFloating(DSWaylandSurface *dswlSurface); + private: DSZone *__getZone(DSWindow *window); DSZone *__getZone(DSWaylandSurface *surface); diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp index 94029b0..a7c1550 100644 --- a/src/DSWindowShell/DSWindowShell.cpp +++ b/src/DSWindowShell/DSWindowShell.cpp @@ -288,6 +288,20 @@ const char* DSWindowShell::getRole(void) return priv->getRole(); } +bool DSWindowShell::setVkbdFloating(bool set) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->setVkbdFloating(set); +} + +bool DSWindowShell::getVkbdFloating() +{ + DS_GET_PRIV(DSWindowShell); + + return priv->getVkbdFloating(); +} + void DSWindowShell::sendConfigure(void) { DS_GET_PRIV(DSWindowShell); diff --git a/src/DSWindowShell/DSWindowShell.h b/src/DSWindowShell/DSWindowShell.h index 53d2bcb..435d0ce 100644 --- a/src/DSWindowShell/DSWindowShell.h +++ b/src/DSWindowShell/DSWindowShell.h @@ -96,6 +96,9 @@ public: bool setRole(const char *role); const char* getRole(void); + bool setVkbdFloating(bool set); + bool getVkbdFloating(); + void sendConfigure(void); protected: diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index 56eee9b..dab6105 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -295,6 +295,27 @@ const char* DSWindowShellPrivate::getRole(void) return nullptr; } +bool DSWindowShellPrivate::setVkbdFloating(bool set) +{ + if (__window) + { + __window->setVkbdFloating(set); + return true; + } + else + return false; +} + +bool DSWindowShellPrivate::getVkbdFloating() +{ + if (__window) + { + return __window->getVkbdFloating(); + } + else + return false; +} + void DSWindowShellPrivate::sendConfigure(void) { if (__shellSurface) diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h index 8cebc66..d2c6273 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -92,6 +92,9 @@ public: bool setRole(const char *role); const char* getRole(void); + bool setVkbdFloating(bool set); + bool getVkbdFloating(); + void sendConfigure(void); private: diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index 7ce4399..52c55f9 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -420,4 +420,19 @@ void DSZone::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set) wShell->setSkipFocus(set); } +bool DSZone::setWindowVkbdFloating(DSWaylandSurface *dswlsurface, bool set) +{ + DSWindowShell *wShell = __findWindowShell(dswlsurface); + if (!wShell) return false; + + return wShell->setVkbdFloating(set); +} + +bool DSZone::getWindowVkbdFloating(DSWaylandSurface *dswlsurface) +{ + DSWindowShell *wShell = __findWindowShell(dswlsurface); + if (!wShell) return false; + + return wShell->getVkbdFloating(); +} } // namespace display_server diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index 01a8c9b..9d5083b 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -74,6 +74,9 @@ public: void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); + bool setWindowVkbdFloating(DSWaylandSurface *dswlSurface, bool set); + bool getWindowVkbdFloating(DSWaylandSurface *dswlSurface); + std::list> getWindowList(); std::list> getWindowShellList(); -- 2.7.4 From 88011ea2078e2f8edb6c3810112db264b2915d17 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 21 Aug 2020 17:15:14 +0900 Subject: [PATCH 09/16] DSWindow: add unsetFocus() Change-Id: I35e738c2d7d381d3ac7234663db74999956e8aa3 Signed-off-by: Sung-Jin Park --- src/DSWindow/DSWindow.cpp | 14 ++++++++++++++ src/DSWindow/DSWindow.h | 1 + src/DSWindow/DSWindowPrivate.h | 1 + tests/DSWindow-test.cpp | 3 +++ 4 files changed, 19 insertions(+) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index ede2584..4f063fc 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -123,8 +123,15 @@ bool DSWindowPrivate::lower(void) return true; } +bool DSWindowPrivate::unsetFocus(void) +{ + __hasFocus = false; + return true; +} + bool DSWindowPrivate::setFocus(void) { + __hasFocus = true; return true; } @@ -313,6 +320,13 @@ bool DSWindow::lower(void) return priv->lower(); } +bool DSWindow::unsetFocus(void) +{ + DS_GET_PRIV(DSWindow); + + return priv->unsetFocus(); +} + bool DSWindow::setFocus(void) { DS_GET_PRIV(DSWindow); diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index 710f784..9024dbc 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -63,6 +63,7 @@ public: bool raise(void); bool lower(void); + bool unsetFocus(void); bool setFocus(void); bool hasFocus(void); diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index a6a8c7d..8b429e6 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -60,6 +60,7 @@ public: bool raise(void); bool lower(void); + bool unsetFocus(void); bool setFocus(void); bool isCreated(); diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp index 8ee7f19..c037f6d 100644 --- a/tests/DSWindow-test.cpp +++ b/tests/DSWindow-test.cpp @@ -68,6 +68,9 @@ TEST_F(DSWindowTest, BasicMethods) EXPECT_TRUE(win->hasFocus() == false); EXPECT_TRUE(win->setFocus() == true); + EXPECT_TRUE(win->hasFocus() == true); + EXPECT_TRUE(win->unsetFocus() == true); + EXPECT_TRUE(win->hasFocus() != true); } TEST_F(DSWindowTest, SizeTest) -- 2.7.4 From 6ca9eeffc0af82caabbee09918538d5c311714c2 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 21 Aug 2020 17:16:26 +0900 Subject: [PATCH 10/16] DSWindowShell: add unsetFocus() Change-Id: I8e9221fdd893e2ec0372621ef77be0f51522ddf6 Signed-off-by: Sung-Jin Park --- src/DSWindowShell/DSWindowShell.cpp | 6 ++++++ src/DSWindowShell/DSWindowShell.h | 1 + src/DSWindowShell/DSWindowShellPrivate.cpp | 14 ++++++++++++-- src/DSWindowShell/DSWindowShellPrivate.h | 1 + tests/DSWindowShell-test.cpp | 13 +++++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp index a7c1550..357f5d1 100644 --- a/src/DSWindowShell/DSWindowShell.cpp +++ b/src/DSWindowShell/DSWindowShell.cpp @@ -162,6 +162,12 @@ bool DSWindowShell::lower(void) return priv->lower(); } +bool DSWindowShell::unsetFocus(void) +{ + DS_GET_PRIV(DSWindowShell); + + return priv->unsetFocus(); +} bool DSWindowShell::setFocus(void) { diff --git a/src/DSWindowShell/DSWindowShell.h b/src/DSWindowShell/DSWindowShell.h index 435d0ce..c0aa944 100644 --- a/src/DSWindowShell/DSWindowShell.h +++ b/src/DSWindowShell/DSWindowShell.h @@ -72,6 +72,7 @@ public: bool raise(void); bool lower(void); + bool unsetFocus(void); bool setFocus(void); bool isFocused(void); diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index dab6105..62dcd98 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -203,15 +203,25 @@ bool DSWindowShellPrivate::lower(void) return true; } +bool DSWindowShellPrivate::unsetFocus(void) +{ + if (__window) + return __window->unsetFocus(); + return false; +} bool DSWindowShellPrivate::setFocus(void) { - return true; + if (__window) + return __window->setFocus(); + return false; } bool DSWindowShellPrivate::isFocused(void) { - return true; + if (__window) + return __window->hasFocus(); + return false; } diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h index d2c6273..77582d1 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -68,6 +68,7 @@ public: bool raise(void); bool lower(void); + bool unsetFocus(void); bool setFocus(void); bool isFocused(void); diff --git a/tests/DSWindowShell-test.cpp b/tests/DSWindowShell-test.cpp index dcd84ce..73af28c 100644 --- a/tests/DSWindowShell-test.cpp +++ b/tests/DSWindowShell-test.cpp @@ -213,6 +213,19 @@ TEST_F(DSWindowShellTest, isFocused_P1) EXPECT_TRUE(shell->isFocused() == true); } +TEST_F(DSWindowShellTest, unsetFocus) +{ + auto window = std::make_shared(); + std::unique_ptr shell = std::make_unique(window.get()); + EXPECT_TRUE(shell != nullptr); + + EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(shell->setFocus() == true); + EXPECT_TRUE(shell->isFocused() == true); + EXPECT_TRUE(shell->unsetFocus() == true); + EXPECT_TRUE(shell->isFocused() != true); +} + TEST_F(DSWindowShellTest, activate_P1) { auto window = std::make_shared(); -- 2.7.4 From c40828be8ee63e8d55005ae67f6d1ea4346802ca Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 21 Aug 2020 17:17:10 +0900 Subject: [PATCH 11/16] DSSeat: renew focus on Window created/destroy handlers Change-Id: Ide2333d094cff0fd303fd4bedc5485070b07779e Signed-off-by: Sung-Jin Park --- src/DSSeat/DSSeat.cpp | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index 86d3cc7..8199ea2 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -467,11 +467,24 @@ void DSSeat::__onWindowCreated(std::shared_ptr window) /* FIXME : get focus window for keyboard from DSWindowManager/DSWindowPolicy later */ if (__keyboard) { - std::shared_ptr focusWin = getTopWindow(__focusWin); - DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", __focusWin ? __focusWin.get() : nullptr, focusWin ? focusWin.get() : nullptr); + std::shared_ptr focusWin = getTopWindow(nullptr); + DSWindow *currentWin = __focusWin ? __focusWin.get() : nullptr; + DSWindow *newWin = focusWin ? focusWin.get() : nullptr; - if (focusWin) - __keyboard->setFocus(focusWin); + if (currentWin != newWin) + { + DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", currentWin, newWin); + + if (focusWin) + { + if (__focusWin && __focusWin->hasFocus()) + __focusWin->unsetFocus(); + + __focusWin = focusWin; + __keyboard->setFocus(focusWin); + focusWin->setFocus(); + } + } } } @@ -492,10 +505,23 @@ void DSSeat::__onWindowDestroy(std::shared_ptr window) if (__keyboard) { std::shared_ptr focusWin = getTopWindow(window); - DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", __focusWin ? __focusWin.get() : nullptr, focusWin ? focusWin.get() : nullptr); + DSWindow *currentWin = __focusWin ? __focusWin.get() : nullptr; + DSWindow *newWin = focusWin ? focusWin.get() : nullptr; - if (focusWin) - __keyboard->setFocus(focusWin); + if (currentWin != newWin) + { + DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", currentWin, newWin); + + if (focusWin) + { + if (__focusWin && __focusWin->hasFocus()) + __focusWin->unsetFocus(); + + __focusWin = focusWin; + __keyboard->setFocus(focusWin); + focusWin->setFocus(); + } + } } } @@ -527,7 +553,11 @@ std::shared_ptr DSSeat::getTopWindow(std::shared_ptr winExcl { for (std::shared_ptr w : __zone->getWindowList()) { - if (w && w.get() == winExcl.get()) + /* skip if w is not valid or has skip focus */ + if (!w || w->getSkipFocus()) + continue; + /* skip if w equals to winExcl */ + if (winExcl && winExcl.get() == w.get()) continue; /* We suppose that the window located at the top of the window stack is at the front of the list. */ -- 2.7.4 From 0384f2b4a2923188975330724d963616e81794e9 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 21 Aug 2020 19:05:27 +0900 Subject: [PATCH 12/16] DSRenderEngineDaliImpl: call Adaptor::Get().RenderOnce() twice Need to check dali engine later. why should libds calls RenderOnce() twice Change-Id: I4b0348318678e244b5dc0b2d4e3c03519d546e78 --- src/DSRender/DSRenderEngineDaliImpl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp index 082e815..a76fc95 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -70,6 +70,9 @@ std::shared_ptr DSRenderEngineDaliImpl::makeRenderView(std::shared bool DSRenderEngineDaliImpl::renderFrame() { if (__needToRender) { + // TODO: do not get the acquired buffer with only one call of Adaptor::Get().RenderOnce(); + // NEED do check it. + Adaptor::Get().RenderOnce(); Adaptor::Get().RenderOnce(); DSLOG_DBG("DSRenderEngineDaliImpl", "RENDER RENDER RENDER~!!!!"); } -- 2.7.4 From c1c44ed3920723fef60574d96ccec3ad7276827e Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 17:10:09 +0900 Subject: [PATCH 13/16] DSTextInput: change argument DSWindow to DSWaylandSurface Change-Id: I20ba8de29a83fe39d130dcbc005126e053a496fe --- src/DSTextInput/DSTextInput.cpp | 2 +- src/DSTextInput/DSTextInputPrivate.h | 3 +- src/DSWaylandServer/DSWaylandInputPanel.cpp | 90 +++++++++++----------- src/DSWaylandServer/DSWaylandInputPanel.h | 6 +- src/DSWaylandServer/DSWaylandInputPanelSurface.h | 8 +- .../DSWaylandInputPanelSurfacePrivate.h | 2 +- 6 files changed, 54 insertions(+), 57 deletions(-) diff --git a/src/DSTextInput/DSTextInput.cpp b/src/DSTextInput/DSTextInput.cpp index b418406..59d5c73 100644 --- a/src/DSTextInput/DSTextInput.cpp +++ b/src/DSTextInput/DSTextInput.cpp @@ -280,7 +280,7 @@ void DSTextInputPrivate::updateInputPanelState(bool waitUpdate) __wlInputPanel->updateInputPanelState(waitUpdate); } -void DSTextInputPrivate::setInputPanelTransientFor(DSWindow *window) +void DSTextInputPrivate::setInputPanelTransientFor(DSWaylandSurface *window) { __wlInputPanel->setTransientFor(window); } diff --git a/src/DSTextInput/DSTextInputPrivate.h b/src/DSTextInput/DSTextInputPrivate.h index 969bf14..c187846 100644 --- a/src/DSTextInput/DSTextInputPrivate.h +++ b/src/DSTextInput/DSTextInputPrivate.h @@ -37,6 +37,7 @@ class DSWaylandInputMethod; class DSWaylandInputMethodContext; class DSWaylandInputPanel; class DSWaylandInputPanelSurface; +class DSWaylandSurface; class DSTextInputPrivate : public DSObjectPrivate { @@ -106,7 +107,7 @@ public: /* DSWaylandInputPanel */ void updateInputPanelState(bool waitUpdate); - void setInputPanelTransientFor(DSWindow *window); + void setInputPanelTransientFor(DSWaylandSurface *window); void changeInputPanelVisibility(bool visible); private: diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp index dc35b73..82e2570 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ b/src/DSWaylandServer/DSWaylandInputPanel.cpp @@ -25,7 +25,9 @@ #include "DSWaylandInputPanelPrivate.h" #include "DSWaylandInputPanelSurface.h" #include "DSWaylandInputPanelSurfacePrivate.h" +#include "DSWaylandSurface.h" #include "DSStruct.h" +#include "DSWindowManager.h" namespace display_server { @@ -55,13 +57,18 @@ private: class DSWaylandInputPanelSurfaceData { public: + DSWaylandInputPanelSurfaceData(DSWaylandServer::wl_input_panel_surface::Resource *resource, void *inputPanelResource) + : panel(false), showing(false), needShow(false), resizing(false), + __resource(resource), + __inputPanelResource(inputPanelResource), __wlSurface(nullptr) {} DSWaylandInputPanelSurfaceData(DSWaylandServer::wl_input_panel_surface::Resource *resource, void *inputPanelResource, void *surfaceResource) : panel(false), showing(false), needShow(false), resizing(false), - __resource(resource), __inputPanelResource(inputPanelResource), __surfaceResource(surfaceResource) {} + __resource(resource), + __inputPanelResource(inputPanelResource) { __wlSurface = DSWaylandSurface::fromWlResource((struct ::wl_resource *)surfaceResource); } ~DSWaylandInputPanelSurfaceData() {} void *getInputPanelResource() {return __inputPanelResource;} - void *getSurfaceResource() {return __surfaceResource;} + DSWaylandSurface* getWlSurface() {return __wlSurface;} bool panel; bool showing; @@ -71,32 +78,9 @@ public: private: DSWaylandServer::wl_input_panel_surface::Resource *__resource; void *__inputPanelResource; - void *__surfaceResource; + DSWaylandSurface *__wlSurface; }; -#if 0 -DSWaylandInputPanelSurfaceData::DSWaylandInputPanelSurfaceData(DSWaylandServer::wl_input_panel_surface::Resource *resource, void *inputPanelResource, void *surfaceResource) - : __resource(resource), - __inputPanelResource(inputPanelResource), - __surfaceResource(surfaceResource) -{ -} - -DSWaylandInputPanelSurfaceData::~DSWaylandInputPanelSurfaceData() -{ -} - -void *DSWaylandInputPanelSurfaceData::getInputPanelResource() -{ - return __inputPanelResource; -} - -void *DSWaylandInputPanelSurfaceData::getSurfaceResource() -{ - return __surfaceResource; -} -#endif - DSWaylandInputPanelPrivate::DSWaylandInputPanelPrivate(DSWaylandInputPanel *p_ptr, DSWaylandCompositor *compositor) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), __compositor(compositor) @@ -219,9 +203,9 @@ void DSWaylandInputPanel::setFloatingMovingRequest(bool enabled) __inputPanelFloating->movingRequest = enabled; } -void DSWaylandInputPanel::setTransientFor(DSWindow *parent) +void DSWaylandInputPanel::setTransientFor(DSWaylandSurface *parent) { - DSWindow *curParent = parent; + DSWaylandSurface *curParent = parent; if (curParent) { /* TODO: @@ -241,7 +225,7 @@ void DSWaylandInputPanel::changeVisibility(bool visible) /* TODO: delete waitTimer */ } -bool DSWaylandInputPanel::isEffectRunning(DSWindow *window) +bool DSWaylandInputPanel::isEffectRunning(DSWaylandSurface *window) { /* TODO: * if window is animating @@ -301,7 +285,7 @@ void DSWaylandInputPanelSurfacePrivate::flushFrame() for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) { DSWaylandInputPanelSurfaceData *_surfaceData = (*it).second; - if (_surfaceData->getSurfaceResource()) + if (_surfaceData->getWlSurface()) { /* TODO: clear pixmap image */ } @@ -312,29 +296,37 @@ void DSWaylandInputPanelSurfacePrivate::show(DSWaylandInputPanelSurfaceData *sur { DS_GET_PUB(DSWaylandInputPanelSurface); +#if false if (!surfaceData) { for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) { - //DSWaylandInputPanelSurfaceData *_surfaceData = (*it).second; - /* TODO: - * surfaceData = _surfaceData->getSurfaceResource(); - * if surfaceData is focused - * surfaceData = _surfaceData; - * break; - */ + DSWaylandInputPanelSurfaceData *data = (*it).second; + if (!data) continue; + + DSWaylandSurface *wlSurface = data->getWlSurface(); + if (wlSurface->parent == DSKeyboard::getFocus()) + { + surfaceData = data; + break; + } } } +#endif if (!surfaceData) return; if (pub->__inputPanel->getWaitUpdate()) { + pub->__inputPanel->setWaitUpdate(false); + pub->__inputPanel->changeVisibility(true); + pub->__inputPanel->updateInputPanelState(true); // temporary code /* TODO: - * if (getfocus(surfaceData->getSurfaceResource())->parent) + * if (getfocus(surfaceData->getWlSurface())->parent) * { - * if (getfocus(surfaceData->getSurfaceResource())->parent == focused) + * if (getfocus(surfaceData->getWlSurface())->parent == focused) * { + * pub->__inputPanel->visibilityChange(true); * pub->__inputPanel->updateInputPanelState(true); * } * else @@ -351,17 +343,21 @@ void DSWaylandInputPanelSurfacePrivate::directShow(DSWaylandInputPanelSurfaceDat DS_GET_PUB(DSWaylandInputPanelSurface); pub->setPosition(nullptr, 0, 0); /* FIXME: set correct value */ + DSWindowManager *windowManager = DSWindowManager::getInstance(); + windowManager->activateWindow(surfaceData->getWlSurface()); + + windowManager->releaseInstance(); /* TODO: change window geometry */ } -void DSWaylandInputPanelSurfacePrivate::setTransientForSurface(DSWindow *parent) +void DSWaylandInputPanelSurfacePrivate::setTransientForSurface(DSWaylandSurface *parent) { for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) { //DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; /* TODO: - * child = surfaceData->getSurfaceResource(); + * child = surfaceData->getWlSurface(); * if child->parent * { * if child->parent != parent @@ -497,7 +493,7 @@ void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_ready(Resource * if (it != __dataMap.end()) { DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; - /* TODO: find DSWindow and update base_output resolution */ + /* TODO: find DSWaylandSurface and update base_output resolution */ show(surfaceData); } } @@ -505,7 +501,7 @@ void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_ready(Resource * void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_floating_panel(Resource *resource, uint32_t state) { /* TODO: - * set DSWindow's vkbd.floating = !!state + * set DSWaylandSurface's vkbd.floating = !!state * if true * policy_conformant_part_del * else @@ -528,7 +524,7 @@ void DSWaylandInputPanelSurfacePrivate::__updateSurfaceVisibility(DSWaylandInput { if (pub->__inputPanel->getRerunPanelShow()) pub->__inputPanel->setRerunPanelShow(false); - if (pub->isEffectRunning(nullptr)) // FIXME: change this to get window surfaceData->getDSWindow() + if (pub->isEffectRunning(nullptr)) // FIXME: change this to get window surfaceData->getDSWaylandSurface() surfaceData->needShow = true; else if (surfaceData->resizing) surfaceData->needShow = true; @@ -584,7 +580,7 @@ void DSWaylandInputPanelSurface::flushFrame() priv->flushFrame(); } -void DSWaylandInputPanelSurface::setTransientForSurface(DSWindow *parent) +void DSWaylandInputPanelSurface::setTransientForSurface(DSWaylandSurface *parent) { DS_GET_PRIV(DSWaylandInputPanelSurface); @@ -598,12 +594,12 @@ void DSWaylandInputPanelSurface::updateSurfaceVisibility(bool visible) priv->updateSurfaceVisibility(visible); } -bool DSWaylandInputPanelSurface::isEffectRunning(DSWindow *window) +bool DSWaylandInputPanelSurface::isEffectRunning(DSWaylandSurface *window) { return __inputPanel->isEffectRunning(window); } -void DSWaylandInputPanelSurface::setPosition(DSWindow *window, int width, int height) +void DSWaylandInputPanelSurface::setPosition(DSWaylandSurface *window, int width, int height) { } diff --git a/src/DSWaylandServer/DSWaylandInputPanel.h b/src/DSWaylandServer/DSWaylandInputPanel.h index a8d0378..ab2f8bb 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.h +++ b/src/DSWaylandServer/DSWaylandInputPanel.h @@ -29,7 +29,6 @@ #include "DSWaylandCompositor.h" #include "DSEventLoop.h" #include "DSTextInputPrivate.h" -#include "DSWindow.h" namespace display_server { @@ -37,6 +36,7 @@ namespace display_server class DSWaylandInputPanelPrivate; class DSWaylandInputPanelSurface; class DSWaylandInputPanelFloating; +class DSWaylandSurface; class DS_DECL_EXPORT DSWaylandInputPanel : public DSObject { @@ -55,9 +55,9 @@ public: void setRerunPanelShow(bool needShow); void setFloatingMovingRequest(bool enabled); - void setTransientFor(DSWindow *parent); + void setTransientFor(DSWaylandSurface *parent); void changeVisibility(bool visible); - bool isEffectRunning(DSWindow *window); + bool isEffectRunning(DSWaylandSurface *window); void setFloatingPosition(int x, int y); DSWaylandInputPanelFloating *getFloatingData(); diff --git a/src/DSWaylandServer/DSWaylandInputPanelSurface.h b/src/DSWaylandServer/DSWaylandInputPanelSurface.h index 2f036ac..becea30 100644 --- a/src/DSWaylandServer/DSWaylandInputPanelSurface.h +++ b/src/DSWaylandServer/DSWaylandInputPanelSurface.h @@ -27,12 +27,12 @@ #include "DSCore.h" #include "DSObject.h" #include "DSWaylandInputPanel.h" -#include "DSWindow.h" namespace display_server { class DSWaylandInputPanelSurfacePrivate; +class DSWaylandSurface; class DS_DECL_EXPORT DSWaylandInputPanelSurface : public DSObject { @@ -44,10 +44,10 @@ public: void createGlobal(void *client, void *inputPanelResource, unsigned int id, void *surface); void clearGlobals(void *inputPanelResource); void flushFrame(); - void setTransientForSurface(DSWindow *parent); + void setTransientForSurface(DSWaylandSurface *parent); void updateSurfaceVisibility(bool visible); - bool isEffectRunning(DSWindow *window); - void setPosition(DSWindow *window, int width, int height); + bool isEffectRunning(DSWaylandSurface *window); + void setPosition(DSWaylandSurface *window, int width, int height); void setFloatingPosition(int x, int y); protected: diff --git a/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h b/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h index 5989bed..03300df 100644 --- a/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h +++ b/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h @@ -48,7 +48,7 @@ public: void show(DSWaylandInputPanelSurfaceData *surfaceData); void directShow(DSWaylandInputPanelSurfaceData *surfaceData); void flushFrame(); - void setTransientForSurface(DSWindow *parent); + void setTransientForSurface(DSWaylandSurface *parent); void updateSurfaceVisibility(bool visible); void setFloatingPosition(int x, int y); -- 2.7.4 From 523cd8f827f86c10d7232012d6641754b983ccd1 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Fri, 21 Aug 2020 21:10:33 +0900 Subject: [PATCH 14/16] DSSeat: release shared_ptr of the last focus window Change-Id: I40b942456fbabbe2298eebe460fc6a8a94e3c856 Signed-off-by: Sung-Jin Park --- src/DSSeat/DSSeat.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp index 8199ea2..645b45f 100644 --- a/src/DSSeat/DSSeat.cpp +++ b/src/DSSeat/DSSeat.cpp @@ -521,6 +521,10 @@ void DSSeat::__onWindowDestroy(std::shared_ptr window) __keyboard->setFocus(focusWin); focusWin->setFocus(); } + else + { + __focusWin = nullptr; + } } } } -- 2.7.4 From 169b288b451de9046e8202e559111bf27c89477a Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 17:39:06 +0900 Subject: [PATCH 15/16] DSUtilSocket: add skeleton codes to control socket Change-Id: I1dab0ff9c770782171b54f013bd7cfeac55299ef --- src/DSUtil/DSUtilSocket.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++++ src/DSUtil/DSUtilSocket.h | 50 +++++++++++++++++++++++++++ src/meson.build | 3 ++ 3 files changed, 137 insertions(+) create mode 100644 src/DSUtil/DSUtilSocket.cpp create mode 100644 src/DSUtil/DSUtilSocket.h diff --git a/src/DSUtil/DSUtilSocket.cpp b/src/DSUtil/DSUtilSocket.cpp new file mode 100644 index 0000000..4307a75 --- /dev/null +++ b/src/DSUtil/DSUtilSocket.cpp @@ -0,0 +1,84 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "DSUtilSocket.h" + +namespace display_server +{ + +/* reference count, mutex and compositor pointer for DSUtilSocket singleton */ +int DSUtilSocket::__refCount { 0 }; +std::mutex DSUtilSocket::__mutex; +DSUtilSocket* DSUtilSocket::__utilSocket { nullptr }; + +DSUtilSocket::DSUtilSocket() +{ +} + +DSUtilSocket::~DSUtilSocket() +{ +} + +/* getInstance for DSUtilSocket singleton */ +//static +DSUtilSocket *DSUtilSocket::getInstance() +{ + std::lock_guard tLock(__mutex); + + DSLOG_INF("DSUtilSocket", + "[Get] instance __refCount=%d !", __refCount); + + if (!__utilSocket && (__refCount == 0)) + { + __utilSocket = new DSUtilSocket(); + DSLOG_INF("DSUtilSocket", + "DSUtilSocket instance has been created !"); + } + + ++__refCount; + return __utilSocket; +} + +/* releaseInstance for DSUtilSocket singleton */ +// static +void DSUtilSocket::releaseInstance() +{ + std::lock_guard tLock(__mutex); + + --__refCount; + if (__refCount < 0) + __refCount = 0; + DSLOG_INF("DSUtilSocket", + "[Release] instance __refCount=%d !", __refCount); + + if ((0 == __refCount) && __utilSocket) + { + delete __utilSocket; + __utilSocket = nullptr; + DSLOG_INF("DSUtilSocket", + "DSUtilSocket instance has been removed !"); + } +} + + +} diff --git a/src/DSUtil/DSUtilSocket.h b/src/DSUtil/DSUtilSocket.h new file mode 100644 index 0000000..309f1ef --- /dev/null +++ b/src/DSUtil/DSUtilSocket.h @@ -0,0 +1,50 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __DS_UTIL_SOCKET_H_ +#define __DS_UTIL_SOCKET_H_ + +#include + +namespace display_server +{ + +class DSUtilSocket +{ +public: + static DSUtilSocket *getInstance(); + static void releaseInstance(); + +private: + DSUtilSocket(); + ~DSUtilSocket(); + DSUtilSocket& operator=(const DSUtilSocket&) = delete; + + static std::mutex __mutex; + static DSUtilSocket *__utilSocket; + static int __refCount; +}; + +} + +#endif diff --git a/src/meson.build b/src/meson.build index d1731f2..6b988da 100644 --- a/src/meson.build +++ b/src/meson.build @@ -76,6 +76,8 @@ libds_srcs = [ 'DSTextInput/DSTextInputPrivate.h', 'DSTextInput/DSTextInput.h', 'DSTextInput/DSTextInput.cpp', + 'DSUtil/DSUtilSocket.h', + 'DSUtil/DSUtilSocket.cpp', ] libds_wayland_srcs = [ @@ -235,6 +237,7 @@ libds_include_dirs = include_directories( './DSXkb', './DSTextInput', './DSTizenAppinfo', + './DSUtil', ) libds_lib = shared_library( -- 2.7.4 From b6845a03812b952911b3f8f1c6ebbb6cf05bb623 Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 21 Aug 2020 20:49:05 +0900 Subject: [PATCH 16/16] DSUtilSocket: set permission to sockets Change-Id: I3328fa30d8a55b2f11accc01a28821b3e2d2ecc9 --- src/DSBuffer/DSBufferManager.cpp | 5 + src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp | 5 + src/DSUtil/DSUtilSocket.cpp | 150 +++++++++++++++++++++++++ src/DSUtil/DSUtilSocket.h | 4 + src/DSWaylandServer/DSWaylandCompositor.cpp | 5 + 5 files changed, 169 insertions(+) diff --git a/src/DSBuffer/DSBufferManager.cpp b/src/DSBuffer/DSBufferManager.cpp index 3c3cc14..3e2b7ae 100644 --- a/src/DSBuffer/DSBufferManager.cpp +++ b/src/DSBuffer/DSBufferManager.cpp @@ -25,6 +25,7 @@ #include "DSBufferManagerPrivate.h" #include "DSDebugLog.h" #include "DSBufferTBMImpl.h" +#include "DSUtilSocket.h" namespace display_server { @@ -137,6 +138,10 @@ DSBufferManagerPrivate::DSBufferManagerPrivate(DSBufferManager *p_ptr) if (__waylandCompositor && bufmgr) tbm_bufmgr_bind_native_display(bufmgr, __waylandCompositor->display()); + DSUtilSocket *utilSocket = DSUtilSocket::getInstance(); + utilSocket->initSocket("tbm-drm-auth"); + utilSocket->releaseInstance(); + } std::shared_ptr DSBufferManagerPrivate::getDSBuffer(struct ::wl_resource *bufferResource) diff --git a/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp index ecf0415..b2c4339 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp @@ -25,6 +25,7 @@ #include "DSDisplayDeviceOutputTDMImpl.h" #include "DSDisplayDeviceHWCTDMImpl.h" #include "DSDebugLog.h" +#include "DSUtilSocket.h" namespace display_server { @@ -55,6 +56,10 @@ DSDisplayDeviceTDMImpl::DSDisplayDeviceTDMImpl() __outputList.emplace_back(std::make_shared(toutput)); } + + DSUtilSocket *utilSocket = DSUtilSocket::getInstance(); + utilSocket->initSocket("tdm-socket"); + utilSocket->releaseInstance(); } DSDisplayDeviceTDMImpl::~DSDisplayDeviceTDMImpl() diff --git a/src/DSUtil/DSUtilSocket.cpp b/src/DSUtil/DSUtilSocket.cpp index 4307a75..9c0e0ff 100644 --- a/src/DSUtil/DSUtilSocket.cpp +++ b/src/DSUtil/DSUtilSocket.cpp @@ -22,6 +22,15 @@ */ #include "DSUtilSocket.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace display_server { @@ -80,5 +89,146 @@ void DSUtilSocket::releaseInstance() } } +void DSUtilSocket::initSocket(std::string socketName) +{ + char *dir = nullptr; + int res; +#undef STRERR_BUFSIZE +#define STRERR_BUFSIZE 1024 + char buf[STRERR_BUFSIZE]; + + if (socketName.empty()) return; + + dir = getenv("XDG_RUNTIME_DIR"); + if (!dir) return; + + std::string xdgDir(dir); + + /* check whether buffer size is less than concatenated string which + * is made of XDG_RUNTIME_DIR, '/', socket name and NULL. + */ + + int dirLength = xdgDir.length(); + int nameLength = socketName.length(); + if ((dirLength + nameLength + 2) > STRERR_BUFSIZE) + { + DSLOG_WRN("DSUtilSocket", "Size of buffer is not enough. dir:%s name:%s", xdgDir, socketName); + return; + } + + //snprintf(socket_path, sizeof(socket_path), "%s/%s", dir, name); + std::string socketPath = xdgDir + "/" + socketName; + + uid_t uid = __getpwnam("root"); + gid_t gid = __getgrnam("display"); + + res = chmod(socketPath.c_str(), 509); + if (res < 0) + { + DSLOG_WRN("DSUtilSocket", "Could not change modes of socket file:%s (%s)", socketPath.c_str(), strerror_r(errno, buf, STRERR_BUFSIZE)); + //PRCTL("[Winsys] Could not chane modes of socket file: %s", socketPath.c_str()); + return; + } + + res = chown(socketPath.c_str(), uid, gid); + if (res < 0) + { + DSLOG_WRN("DSUtilSocket", "Could not change owner of socket file:%s (%s)", socketPath.c_str(), strerror_r(errno, buf, STRERR_BUFSIZE)); + //PRCTL("[Winsys] Could not change owner of socket file: %s", socketPath.c_str()); + return; + } +} + +int DSUtilSocket::__getpwnam(std::string name) +{ + struct ::passwd *u; + struct ::passwd *uRes; + char* buf; + size_t bufLen; + int ret; +#undef BUFLEN +#define BUFLEN 2048 + bufLen = sysconf(_SC_GETPW_R_SIZE_MAX); + if ((int)bufLen == -1) /* Value was indeterminate */ + bufLen = BUFLEN; /* Should be more than enough */ +#undef BUFLEN + + buf = (char *)malloc(bufLen); + if (buf == NULL) + { + DSLOG_WRN("DSUtilSocket", "failed to create buffer"); + return 0; + } + + u = (struct ::passwd *)malloc(sizeof(struct passwd)); + if (!u) + { + DSLOG_WRN("DSUtilSocket", "failed to create password struct"); + free(buf); + return 0; + } + + ret = getpwnam_r(name.c_str(), u, buf, bufLen, &uRes); + if (uRes == nullptr) + { + if (ret == 0) DSLOG_WRN("DSUtilSocket", "password not found"); + else DSLOG_WRN("DSUtilSocket", "errno returned by getpwnam_r is %d", ret); + free(buf); + free(u); + return 0; + } + ret = u->pw_uid; + free(buf); + free(u); + + return ret; +} + +int DSUtilSocket::__getgrnam(std::string name) +{ + struct ::group *g; + struct ::group *grpRes; + char* buf; + size_t bufLen; + int ret; +#undef BUFLEN +#define BUFLEN 2048 + bufLen = sysconf(_SC_GETGR_R_SIZE_MAX); + if ((int)bufLen == -1) /* Value was indeterminate */ + bufLen = BUFLEN; /* Should be more than enough */ +#undef BUFLEN + + buf = (char *)malloc(bufLen); + if (buf == nullptr) + { + DSLOG_WRN("DSUtilSocket", "failed to create buffer"); + return 0; + } + + g = (struct ::group *)malloc(sizeof(struct group)); + if (!g) + { + DSLOG_WRN("DSUtilSocket", "failed to create group struct"); + free(buf); + return 0; + } + + ret = getgrnam_r(name.c_str(), g, buf, bufLen, &grpRes); + if (grpRes == NULL) + { + if (ret == 0) DSLOG_WRN("DSUtilSocket", "Group not found"); + else DSLOG_WRN("DSUtilSocket", "errno returned by getpwnam_r is %d", ret); + free(buf); + free(g); + return 0; + } + + ret = g->gr_gid; + free(buf); + free(g); + return ret; +} + + } diff --git a/src/DSUtil/DSUtilSocket.h b/src/DSUtil/DSUtilSocket.h index 309f1ef..dffdee4 100644 --- a/src/DSUtil/DSUtilSocket.h +++ b/src/DSUtil/DSUtilSocket.h @@ -35,10 +35,14 @@ public: static DSUtilSocket *getInstance(); static void releaseInstance(); + void initSocket(std::string socketName); + private: DSUtilSocket(); ~DSUtilSocket(); DSUtilSocket& operator=(const DSUtilSocket&) = delete; + int __getpwnam(std::string name); + int __getgrnam(std::string name); static std::mutex __mutex; static DSUtilSocket *__utilSocket; diff --git a/src/DSWaylandServer/DSWaylandCompositor.cpp b/src/DSWaylandServer/DSWaylandCompositor.cpp index 9f823ee..1570727 100644 --- a/src/DSWaylandServer/DSWaylandCompositor.cpp +++ b/src/DSWaylandServer/DSWaylandCompositor.cpp @@ -29,6 +29,7 @@ #include "DSWaylandSurface.h" #include "DSWaylandRegion.h" #include "DSDebugLog.h" +#include "DSUtilSocket.h" namespace display_server { @@ -126,6 +127,10 @@ void DSWaylandCompositorPrivate::initSocket(std::string sName, std::string sDir) (void) socketPath; + DSUtilSocket *utilSocket = DSUtilSocket::getInstance(); + utilSocket->initSocket(sName); + utilSocket->releaseInstance(); + //TODO : set permissions for Owner, Group and Other //TODO : set Smack attributes for socket //TODO : set symbolic link for socket -- 2.7.4