[Tizen] Remove unnecessray ClipBoard creation (2) 89/286789/1 accepted/tizen/7.0/unified/20230118.093755
authorHeeyong Song <heeyong.song@samsung.com>
Thu, 12 Jan 2023 05:07:53 +0000 (14:07 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Fri, 13 Jan 2023 01:44:26 +0000 (10:44 +0900)
Change-Id: I5a15ae94f035a764128c1adc5621b80f84286846

dali/devel-api/adaptor-framework/clipboard.cpp
dali/devel-api/adaptor-framework/clipboard.h
dali/internal/clipboard/common/clipboard-impl.h
dali/internal/clipboard/generic/clipboard-impl-generic.cpp
dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp
dali/internal/clipboard/ubuntu-x11/clipboard-impl-x.cpp
dali/internal/window-system/common/event-handler.cpp

index d8b3d76..09da77b 100644 (file)
@@ -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);
index 8331d62..d64e84d 100644 (file)
@@ -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
index eac973b..ec10c59 100644 (file)
@@ -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.
    */
index 379d102..43713af 100644 (file)
@@ -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;
index e1ddf17..1cd452b 100644 (file)
@@ -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);
index 20b0964..070974f 100644 (file)
@@ -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();
index 7366ea7..cf1fb78 100644 (file)
@@ -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));