From: Heeyong Song Date: Thu, 12 Jan 2023 05:07:53 +0000 (+0900) Subject: [Tizen] Remove unnecessray ClipBoard creation (2) X-Git-Tag: accepted/tizen/7.0/unified/20230118.093755^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=787c35f2c82278bc0885ff481cc368dc0446a3d3 [Tizen] Remove unnecessray ClipBoard creation (2) Change-Id: I5a15ae94f035a764128c1adc5621b80f84286846 --- diff --git a/dali/devel-api/adaptor-framework/clipboard.cpp b/dali/devel-api/adaptor-framework/clipboard.cpp index d8b3d76..09da77b 100644 --- a/dali/devel-api/adaptor-framework/clipboard.cpp +++ b/dali/devel-api/adaptor-framework/clipboard.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,11 @@ Clipboard Clipboard::Get() return Internal::Adaptor::Clipboard::Get(); } +bool Clipboard::IsAvailable() +{ + return Internal::Adaptor::Clipboard::IsAvailable(); +} + bool Clipboard::SetItem(const std::string& itemData) { return GetImplementation(*this).SetItem(itemData); diff --git a/dali/devel-api/adaptor-framework/clipboard.h b/dali/devel-api/adaptor-framework/clipboard.h index 8331d62..d64e84d 100644 --- a/dali/devel-api/adaptor-framework/clipboard.h +++ b/dali/devel-api/adaptor-framework/clipboard.h @@ -2,7 +2,7 @@ #define DALI_CLIPBOARD_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,6 +73,13 @@ public: static Clipboard Get(); /** + * @brief Checks whether the clipboard is available. + * + * @return true, if it is available, false otherwise. + */ + static bool IsAvailable(); + + /** * @brief Send the given string to the clipboard. * * @param[in] itemData string to send to clip board diff --git a/dali/internal/clipboard/common/clipboard-impl.h b/dali/internal/clipboard/common/clipboard-impl.h index eac973b..ec10c59 100644 --- a/dali/internal/clipboard/common/clipboard-impl.h +++ b/dali/internal/clipboard/common/clipboard-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_CLIPBOARD_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,11 +41,16 @@ public: struct Impl; /** - * @copydoc Dali::ClipboardEventNotifier::Get() + * @copydoc Dali::Clipboard::Get() */ static Dali::Clipboard Get(); /** + * @copydoc Dali::Clipboard::IsAvailable() + */ + static bool IsAvailable(); + + /** * Constructor * @param[in] impl Some data from a specific windowing system. */ diff --git a/dali/internal/clipboard/generic/clipboard-impl-generic.cpp b/dali/internal/clipboard/generic/clipboard-impl-generic.cpp index 379d102..43713af 100644 --- a/dali/internal/clipboard/generic/clipboard-impl-generic.cpp +++ b/dali/internal/clipboard/generic/clipboard-impl-generic.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,6 +65,20 @@ Dali::Clipboard Clipboard::Get() return clipboard; } +bool Clipboard::IsAvailable() +{ + Dali::SingletonService service(SingletonService::Get()); + if(service) + { + Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard)); + if(handle) + { + return true; + } + } + return false; +} + bool Clipboard::SetItem(const std::string& itemData) { return true; diff --git a/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp b/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp index e1ddf17..1cd452b 100644 --- a/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp +++ b/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -310,6 +310,20 @@ Dali::Clipboard Clipboard::Get() return clipboard; } +bool Clipboard::IsAvailable() +{ + Dali::SingletonService service(SingletonService::Get()); + if(service) + { + Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard)); + if(handle) + { + return true; + } + } + return false; +} + bool Clipboard::SetItem(const std::string& itemData) { mImpl->SetItem(itemData); diff --git a/dali/internal/clipboard/ubuntu-x11/clipboard-impl-x.cpp b/dali/internal/clipboard/ubuntu-x11/clipboard-impl-x.cpp index 20b0964..070974f 100644 --- a/dali/internal/clipboard/ubuntu-x11/clipboard-impl-x.cpp +++ b/dali/internal/clipboard/ubuntu-x11/clipboard-impl-x.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,6 +108,21 @@ Dali::Clipboard Clipboard::Get() return clipboard; } + +bool Clipboard::IsAvailable() +{ + Dali::SingletonService service(SingletonService::Get()); + if(service) + { + Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard)); + if(handle) + { + return true; + } + } + return false; +} + bool Clipboard::SetItem(const std::string& itemData) { Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow(); diff --git a/dali/internal/window-system/common/event-handler.cpp b/dali/internal/window-system/common/event-handler.cpp index 7366ea7..cf1fb78 100644 --- a/dali/internal/window-system/common/event-handler.cpp +++ b/dali/internal/window-system/common/event-handler.cpp @@ -52,7 +52,7 @@ Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::N EventHandler::EventHandler(WindowBase* windowBase, DamageObserver& damageObserver) : mStyleMonitor(StyleMonitor::Get()), mDamageObserver(damageObserver), - mClipboardEventNotifier(ClipboardEventNotifier::Get()), + mClipboardEventNotifier(), mPaused(false) { // Connect signals @@ -126,22 +126,25 @@ void EventHandler::OnKeyEvent(Integration::KeyEvent& keyEvent) void EventHandler::OnFocusChanged(bool focusIn) { // If the window gains focus and we hid the keyboard then show it again. - if(focusIn) + if(Clipboard::IsAvailable()) { - Dali::Clipboard clipboard = Clipboard::Get(); - if(clipboard) + if(focusIn) { - clipboard.HideClipboard(); + Dali::Clipboard clipboard = Clipboard::Get(); + if(clipboard) + { + clipboard.HideClipboard(); + } } - } - else - { - // Hiding clipboard event will be ignored once because window focus out event is always received on showing clipboard - Dali::Clipboard clipboard = Clipboard::Get(); - if(clipboard) + else { - Clipboard& clipBoardImpl(GetImplementation(clipboard)); - clipBoardImpl.HideClipboard(true); + // Hiding clipboard event will be ignored once because window focus out event is always received on showing clipboard + Dali::Clipboard clipboard = Clipboard::Get(); + if(clipboard) + { + Clipboard& clipBoardImpl(GetImplementation(clipboard)); + clipBoardImpl.HideClipboard(true); + } } } } @@ -180,6 +183,11 @@ void EventHandler::OnSelectionDataReceived(void* event) selectionData = clipBoardImpl.ExcuteBuffered(false, event); } + if(!mClipboardEventNotifier) + { + mClipboardEventNotifier = ClipboardEventNotifier::Get(); + } + if(selectionData && mClipboardEventNotifier) { ClipboardEventNotifier& clipboardEventNotifier(ClipboardEventNotifier::GetImplementation(mClipboardEventNotifier));