SET( adaptor_adaptor_dir ${ADAPTOR_ROOT}/dali/internal/adaptor )
include( ${ADAPTOR_ROOT}/dali/internal/adaptor/file.list )
-SET( adaptor_text_clipboard_dir ${ADAPTOR_ROOT}/dali/internal/text-clipboard )
-include( ${ADAPTOR_ROOT}/dali/internal/text-clipboard/file.list )
+SET( adaptor_clipboard_dir ${ADAPTOR_ROOT}/dali/internal/clipboard )
+include( ${ADAPTOR_ROOT}/dali/internal/clipboard/file.list )
SET( adaptor_drag_and_drop_dir ${ADAPTOR_ROOT}/dali/internal/drag-and-drop )
include( ${ADAPTOR_ROOT}/dali/internal/drag-and-drop/file.list )
SET( adaptor_adaptor_dir ${ADAPTOR_ROOT}/dali/internal/adaptor )
include( ${ADAPTOR_ROOT}/dali/internal/adaptor/file.list )
-SET( adaptor_text_clipboard_dir ${ADAPTOR_ROOT}/dali/internal/text-clipboard )
-include( ${ADAPTOR_ROOT}/dali/internal/text-clipboard/file.list )
+SET( adaptor_clipboard_dir ${ADAPTOR_ROOT}/dali/internal/clipboard )
+include( ${ADAPTOR_ROOT}/dali/internal/clipboard/file.list )
SET( adaptor_drag_and_drop_dir ${ADAPTOR_ROOT}/dali/internal/drag-and-drop )
include( ${ADAPTOR_ROOT}/dali/internal/drag-and-drop/file.list )
${adaptor_accessibility_android_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_canvas_renderer_generic_src_files}
+ ${adaptor_clipboard_android_src_files}
${adaptor_drag_and_drop_generic_src_files}
${adaptor_framework_android_src_files}
${devel_api_src_files}
${adaptor_styling_common_src_files}
${adaptor_system_common_src_files}
${adaptor_system_android_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_android_src_files}
${adaptor_text_common_src_files}
${adaptor_resampler_src_files}
${adaptor_vector_animation_common_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_tizen_wayland_src_files}
${adaptor_canvas_renderer_tizen_src_files}
+ ${adaptor_clipboard_tizen_wayland_src_files}
${adaptor_drag_and_drop_tizen_wayland_src_files}
${adaptor_framework_generic_src_files}
${devel_api_src_files}
${adaptor_system_common_src_files}
${adaptor_system_linux_src_files}
${adaptor_system_tizen_wayland_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_tizen_wayland_src_files}
${adaptor_text_common_src_files}
${adaptor_resampler_src_files}
${adaptor_vector_animation_common_src_files}
${adaptor_addons_ubuntu_src_files}
${adaptor_camera_common_src_files}
${adaptor_canvas_renderer_generic_src_files}
+ ${adaptor_clipboard_glib_x11_src_files}
${adaptor_drag_and_drop_generic_src_files}
${adaptor_framework_generic_src_files}
${devel_api_src_files}
${adaptor_system_common_src_files}
${adaptor_system_glib_src_files}
${adaptor_resampler_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_glib_x11_src_files}
${adaptor_text_common_src_files}
${adaptor_thread_common_src_files}
${adaptor_thread_linux_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_tizen_wayland_src_files}
${adaptor_canvas_renderer_tizen_src_files}
+ ${adaptor_clipboard_tizen_wayland_src_files}
${adaptor_drag_and_drop_tizen_wayland_src_files}
${adaptor_framework_generic_src_files}
${devel_api_src_files}
${adaptor_system_common_src_files}
${adaptor_system_linux_src_files}
${adaptor_system_tizen_wayland_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_tizen_wayland_src_files}
${adaptor_text_common_src_files}
${adaptor_resampler_src_files}
${adaptor_vector_animation_common_src_files}
${adaptor_addons_ubuntu_src_files}
${adaptor_camera_common_src_files}
${adaptor_canvas_renderer_generic_src_files}
+ ${adaptor_clipboard_libuv_x11_src_files}
${adaptor_drag_and_drop_generic_src_files}
${adaptor_framework_generic_src_files}
${devel_api_src_files}
${adaptor_system_common_src_files}
${adaptor_system_libuv_src_files}
${adaptor_resampler_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_libuv_x11_src_files}
${adaptor_text_common_src_files}
${adaptor_thread_common_src_files}
${adaptor_thread_linux_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_canvas_renderer_generic_src_files}
${adaptor_adaptor_macos_src_files}
+ ${adaptor_clipboard_macos_src_files}
${adaptor_drag_and_drop_generic_src_files}
${adaptor_framework_generic_src_files}
${devel_api_src_files}
${adaptor_system_common_src_files}
${adaptor_system_macos_src_files}
${adaptor_system_macos_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_macos_src_files}
${adaptor_text_common_src_files}
${adaptor_text_macos_src_files}
${adaptor_resampler_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_tizen_wayland_src_files}
${adaptor_canvas_renderer_tizen_src_files}
+ ${adaptor_clipboard_tizen_wayland_src_files}
${adaptor_drag_and_drop_tizen_wayland_src_files}
${adaptor_framework_generic_src_files}
${devel_api_src_files}
${adaptor_system_common_src_files}
${adaptor_system_linux_src_files}
${adaptor_system_tizen_wayland_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_tizen_wayland_src_files}
${adaptor_text_common_src_files}
${adaptor_resampler_src_files}
${adaptor_vector_animation_common_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_tizen_wayland_src_files}
${adaptor_canvas_renderer_tizen_src_files}
+ ${adaptor_clipboard_tizen_wayland_src_files}
${adaptor_drag_and_drop_tizen_wayland_src_files}
${adaptor_framework_generic_src_files}
${devel_api_src_files}
${adaptor_system_common_src_files}
${adaptor_system_linux_src_files}
${adaptor_system_tizen_wayland_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_tizen_wayland_src_files}
${adaptor_text_common_src_files}
${adaptor_resampler_src_files}
${adaptor_vector_animation_common_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_ubuntu_src_files}
${adaptor_canvas_renderer_ubuntu_src_files}
+ ${adaptor_clipboard_ubuntu_x11_src_files}
${adaptor_drag_and_drop_generic_src_files}
${adaptor_framework_generic_src_files}
${devel_api_src_files}
${adaptor_system_common_src_files}
${adaptor_system_linux_src_files}
${adaptor_system_ubuntu_x11_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_ubuntu_x11_src_files}
${adaptor_text_common_src_files}
${adaptor_text_ubuntu_src_files}
${adaptor_resampler_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_tizen_wayland_src_files}
${adaptor_adaptor_tizen_wearable_src_files}
+ ${adaptor_clipboard_tizen_wayland_src_files}
${adaptor_drag_and_drop_tizen_wayland_src_files}
${adaptor_canvas_renderer_tizen_src_files}
${adaptor_framework_generic_src_files}
${adaptor_system_linux_src_files}
${adaptor_system_tizen_wayland_src_files}
${adaptor_system_tizen_wearable_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_tizen_wayland_src_files}
${adaptor_text_common_src_files}
${adaptor_resampler_src_files}
${adaptor_vector_animation_common_src_files}
${adaptor_accessibility_windows_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_canvas_renderer_generic_src_files}
+ ${adaptor_clipboard_windows_src_files}
${adaptor_drag_and_drop_generic_src_files}
${adaptor_framework_generic_src_files}
${devel_api_src_files}
${adaptor_window_system_windows_src_files}
${adaptor_graphics_windows_src_files}
${adaptor_input_windows_src_files}
- ${adaptor_text_clipboard_common_src_files}
- ${adaptor_text_clipboard_windows_src_files}
${adaptor_imaging_windows_src_files}
${adaptor_addons_common_src_files}
${adaptor_addons_dummy_src_files}
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/devel-api/adaptor-framework/clipboard.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/clipboard/common/clipboard-impl.h>
+
+namespace Dali
+{
+Clipboard::Clipboard()
+{
+}
+
+Clipboard::~Clipboard()
+{
+}
+
+Clipboard::Clipboard(Internal::Adaptor::Clipboard* impl)
+: BaseHandle(impl)
+{
+}
+
+Clipboard Clipboard::Get()
+{
+ return Internal::Adaptor::Clipboard::Get();
+}
+
+bool Clipboard::IsAvailable()
+{
+ return Internal::Adaptor::Clipboard::IsAvailable();
+}
+
+Clipboard::DataSentSignalType& Clipboard::DataSentSignal()
+{
+ return GetImplementation(*this).DataSentSignal();
+}
+
+Clipboard::DataReceivedSignalType& Clipboard::DataReceivedSignal()
+{
+ return GetImplementation(*this).DataReceivedSignal();
+}
+
+bool Clipboard::SetData(const ClipData& clipData)
+{
+ return GetImplementation(*this).SetData(clipData);
+}
+
+uint32_t Clipboard::GetData(const std::string& mimeType)
+{
+ return GetImplementation(*this).GetData(mimeType);
+}
+
+size_t Clipboard::NumberOfItems()
+{
+ return GetImplementation(*this).NumberOfItems();
+}
+
+void Clipboard::ShowClipboard()
+{
+ GetImplementation(*this).ShowClipboard();
+}
+
+void Clipboard::HideClipboard()
+{
+ GetImplementation(*this).HideClipboard(false);
+}
+
+bool Clipboard::IsVisible() const
+{
+ return GetImplementation(*this).IsVisible();
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_CLIPBOARD_H
+#define DALI_CLIPBOARD_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class Clipboard;
+}
+} // namespace DALI_INTERNAL
+
+/**
+ * @brief Interface to the device's clipboard.
+ *
+ * Clipboard class supports the copy and paste functionality for multi-window.
+ */
+
+class DALI_ADAPTOR_API Clipboard : public BaseHandle
+{
+public:
+ /**
+ * @brief Structure that contains information about the clipboard data information.
+ */
+ struct ClipData
+ {
+ ClipData(const char* mimeType = nullptr, const char* data = nullptr)
+ {
+ this->mimeType = mimeType;
+ this->data = data;
+ }
+ void SetMimeType(const char* mimeType)
+ {
+ this->mimeType = mimeType;
+ }
+ const char* GetMimeType() const
+ {
+ return mimeType;
+ }
+ void SetData(const char* data)
+ {
+ this->data = data;
+ }
+ const char* GetData() const
+ {
+ return data;
+ }
+
+ private:
+ const char* mimeType {nullptr}; ///< The mime type of clipboard data.
+ const char* data {nullptr}; ///< The clipboard data.
+ };
+
+ /// @brief Data send completed signal.
+ typedef Signal<void(const char*, const char*)> DataSentSignalType;
+
+ /// @brief Data receive completed signal.
+ typedef Signal<void(uint32_t, const char*, const char*)> DataReceivedSignalType;
+
+ /**
+ * @brief Create an uninitialized Clipboard.
+ * this can be initialized with one of the derived Clipboard's New() methods
+ */
+ Clipboard();
+
+ /**
+ * @brief Destructor
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~Clipboard();
+
+ /**
+ * @brief This constructor is used by Adaptor::GetClipboard().
+ * @param[in] clipboard A pointer to the clipboard.
+ */
+ explicit DALI_INTERNAL Clipboard(Internal::Adaptor::Clipboard* clipboard);
+
+ /**
+ * @brief Retrieve a handle to the Clipboard instance.
+ * @return A handle to the Clipboard
+ */
+ static Clipboard Get();
+
+ /**
+ * @brief Checks whether the clipboard is available.
+ * @return true if it is available, false otherwise.
+ */
+ static bool IsAvailable();
+
+ /**
+ * @brief This signal is emitted when the data send complete.
+ * @note
+ * SetData() opertion does not follow a synchronous call.
+ * It follows the sequence below.
+ * SetData() -> EcoreEventDataSend() -> SendData() -> DataSentSignal() Emit
+ */
+ DataSentSignalType& DataSentSignal();
+
+ /**
+ * @brief This signal is emitted when the data receive complete.
+ * @note
+ * GetData() opertion does not follow a synchronous call.
+ * It follows the sequence below.
+ * GetData() -> EcoreEventOfferDataReady() -> ReceiveData() -> DataReceivedSignal() Emit
+ */
+ DataReceivedSignalType& DataReceivedSignal();
+
+ /**
+ * @brief Send the given data to the clipboard.
+ * @param[in] clipData data to send to the clipboard
+ * @return bool true if the internal clipboard sending was successful.
+ */
+ bool SetData(const ClipData& clipData);
+
+ /**
+ * @brief Request data from the clipboard.
+ * @param[in] mimeType mime type of data to request.
+ * @return uint32_t Returns the data request id.
+ */
+ uint32_t GetData(const std::string& mimeType);
+
+ /**
+ * @brief Returns the number of item currently in the clipboard.
+ * @return size_t number of clipboard items.
+ */
+ size_t NumberOfItems();
+
+ /**
+ * @brief Show the clipboard window.
+ */
+ void ShowClipboard();
+
+ /**
+ * @brief Hide the clipboard window.
+ */
+ void HideClipboard();
+
+ /**
+ * @brief Retrieves the clipboard's visibility.
+ * @return bool true if the clipboard is visible.
+ */
+ bool IsVisible() const;
+};
+} // namespace Dali
+
+#endif // DALI_CLIPBOARD_H
+++ /dev/null
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/devel-api/adaptor-framework/text-clipboard-event-notifier.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/text-clipboard/common/text-clipboard-event-notifier-impl.h>
-
-namespace Dali
-{
-TextClipboardEventNotifier::TextClipboardEventNotifier()
-{
-}
-
-TextClipboardEventNotifier TextClipboardEventNotifier::Get()
-{
- return Internal::Adaptor::TextClipboardEventNotifier::Get();
-}
-
-TextClipboardEventNotifier::~TextClipboardEventNotifier()
-{
-}
-
-const std::string& TextClipboardEventNotifier::GetContent() const
-{
- return Internal::Adaptor::TextClipboardEventNotifier::GetImplementation(*this).GetContent();
-}
-
-void TextClipboardEventNotifier::SetContent(const std::string& content)
-{
- Internal::Adaptor::TextClipboardEventNotifier::GetImplementation(*this).SetContent(content);
-}
-
-void TextClipboardEventNotifier::ClearContent()
-{
- Internal::Adaptor::TextClipboardEventNotifier::GetImplementation(*this).ClearContent();
-}
-
-void TextClipboardEventNotifier::EmitContentSelectedSignal()
-{
- Internal::Adaptor::TextClipboardEventNotifier::GetImplementation(*this).EmitContentSelectedSignal();
-}
-
-TextClipboardEventNotifier::TextClipboardEventSignalType& TextClipboardEventNotifier::ContentSelectedSignal()
-{
- return Internal::Adaptor::TextClipboardEventNotifier::GetImplementation(*this).ContentSelectedSignal();
-}
-
-TextClipboardEventNotifier::TextClipboardEventNotifier(Internal::Adaptor::TextClipboardEventNotifier* notifier)
-: BaseHandle(notifier)
-{
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_TEXT_CLIPBOARD_EVENT_NOTIFIER_H
-#define DALI_TEXT_CLIPBOARD_EVENT_NOTIFIER_H
-
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
-
-namespace Dali
-{
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class TextClipboardEventNotifier;
-}
-} // namespace DALI_INTERNAL
-
-/**
- * @brief The TextClipboardEventNotifier provides signals when clipboard events are received from the device.
- */
-class DALI_ADAPTOR_API TextClipboardEventNotifier : public BaseHandle
-{
-public:
- // Typedefs
-
- /**
- * @brief TextClipboard event
- */
- typedef Signal<void(TextClipboardEventNotifier&)> TextClipboardEventSignalType;
-
- /**
- * @brief Create an uninitialized handle.
- *
- * This can be initialized by getting the notifier from Dali::Adaptor.
- */
- TextClipboardEventNotifier();
-
- /**
- * @brief Retrieve a handle to the TextClipboardEventNotifier instance.
- *
- * @return A handle to the TextClipboardEventNotifier
- */
- static TextClipboardEventNotifier Get();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~TextClipboardEventNotifier();
-
- /**
- * @brief Returns the selected content.
- * @return A reference to the string representing the selected content.
- */
- const std::string& GetContent() const;
-
- /**
- * @brief Sets the selected content.
- * @param[in] content A string that represents the content that has been selected.
- */
- void SetContent(const std::string& content);
-
- /**
- * @brief Clears the stored content.
- */
- void ClearContent();
-
- /**
- * @brief Called when content is selected in the clipboard.
- */
- void EmitContentSelectedSignal();
-
-public: // Signals
- /**
- * @brief This is emitted when content is selected from the clipboard.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallback( TextClipboardEventNotifier& notifier );
- * @endcode
- * @return The signal to connect to.
- */
- TextClipboardEventSignalType& ContentSelectedSignal();
-
-public: // Not intended for application developers
- /**
- * @brief This constructor is used by TextClipboardEventNotifier::Get().
- *
- * @param[in] notifier A pointer to the drag and drop notifier.
- */
- explicit DALI_INTERNAL TextClipboardEventNotifier(Internal::Adaptor::TextClipboardEventNotifier* notifier);
-};
-
-} // namespace Dali
-
-#endif // DALI_TEXT_CLIPBOARD_EVENT_NOTIFIER_H
+++ /dev/null
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/devel-api/adaptor-framework/text-clipboard.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/text-clipboard/common/text-clipboard-impl.h>
-
-namespace Dali
-{
-TextClipboard::TextClipboard()
-{
-}
-TextClipboard::~TextClipboard()
-{
-}
-TextClipboard::TextClipboard(Internal::Adaptor::TextClipboard* impl)
-: BaseHandle(impl)
-{
-}
-
-TextClipboard TextClipboard::Get()
-{
- return Internal::Adaptor::TextClipboard::Get();
-}
-
-bool TextClipboard::IsAvailable()
-{
- return Internal::Adaptor::TextClipboard::IsAvailable();
-}
-
-bool TextClipboard::SetItem(const std::string& itemData)
-{
- return GetImplementation(*this).SetItem(itemData);
-}
-
-void TextClipboard::RequestItem()
-{
- GetImplementation(*this).RequestItem();
-}
-
-unsigned int TextClipboard::NumberOfItems()
-{
- return GetImplementation(*this).NumberOfItems();
-}
-
-void TextClipboard::ShowClipboard()
-{
- GetImplementation(*this).ShowClipboard();
-}
-
-void TextClipboard::HideClipboard()
-{
- GetImplementation(*this).HideClipboard(false);
-}
-
-bool TextClipboard::IsVisible() const
-{
- return GetImplementation(*this).IsVisible();
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_TEXT_CLIPBOARD_H
-#define DALI_TEXT_CLIPBOARD_H
-
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/object/base-handle.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
-
-namespace Dali
-{
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class TextClipboard;
-}
-} // namespace DALI_INTERNAL
-
-/**
- * @brief Interface to the device's clipboard.
- *
- * Clipboard can manage it's item and set show / hide status.
- */
-
-class DALI_ADAPTOR_API TextClipboard : public BaseHandle
-{
-public:
- /**
- * @brief Create an uninitialized Clipboard.
- *
- * this can be initialized with one of the derived Clipboard' New() methods
- */
- TextClipboard();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~TextClipboard();
-
- /**
- * @brief This constructor is used by Adaptor::GetClipboard().
- *
- * @param[in] clipboard A pointer to the clipboard.
- */
- explicit DALI_INTERNAL TextClipboard(Internal::Adaptor::TextClipboard* clipboard);
-
- /**
- * @brief Retrieve a handle to the TextClipboardEventNotifier instance.
- *
- * @return A handle to the TextClipboard
- */
- static TextClipboard 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
- * @return bool true if the internal clip board sending was successful.
- */
- bool SetItem(const std::string& itemData);
-
- /**
- * @brief Request clipboard service to retrieve an item
- *
- * Calling this method will trigger a signal from the clipboard event notifier.
- * @see Dali::TextClipboardEventNotifier::ContentSelectedSignal()
- */
- void RequestItem();
-
- /**
- * @brief Returns the number of item currently in the clipboard.
- *
- * @return unsigned int number of clipboard items
- */
- unsigned int NumberOfItems();
-
- /**
- * @brief Show the clipboard window.
- */
- void ShowClipboard();
-
- /**
- * @brief Hide the clipboard window.
- */
- void HideClipboard();
-
- /**
- * @brief Retrieves the clipboard's visibility
- * @return bool true if the clipboard is visible.
- */
- bool IsVisible() const;
-};
-} // namespace Dali
-
-#endif // DALI_TEXT_CLIPBOARD_H
${adaptor_devel_api_dir}/adaptor-framework/atspi-accessibility.cpp
${adaptor_devel_api_dir}/adaptor-framework/bitmap-saver.cpp
${adaptor_devel_api_dir}/adaptor-framework/capture-devel.cpp
- ${adaptor_devel_api_dir}/adaptor-framework/text-clipboard.cpp
- ${adaptor_devel_api_dir}/adaptor-framework/text-clipboard-event-notifier.cpp
+ ${adaptor_devel_api_dir}/adaptor-framework/clipboard.cpp
${adaptor_devel_api_dir}/adaptor-framework/drag-and-drop.cpp
${adaptor_devel_api_dir}/adaptor-framework/color-controller.cpp
${adaptor_devel_api_dir}/adaptor-framework/environment-variable.cpp
${adaptor_devel_api_dir}/adaptor-framework/atspi-accessibility.h
${adaptor_devel_api_dir}/adaptor-framework/bitmap-saver.h
${adaptor_devel_api_dir}/adaptor-framework/capture-devel.h
- ${adaptor_devel_api_dir}/adaptor-framework/text-clipboard-event-notifier.h
- ${adaptor_devel_api_dir}/adaptor-framework/text-clipboard.h
+ ${adaptor_devel_api_dir}/adaptor-framework/clipboard.h
${adaptor_devel_api_dir}/adaptor-framework/drag-and-drop.h
${adaptor_devel_api_dir}/adaptor-framework/color-controller-plugin.h
${adaptor_devel_api_dir}/adaptor-framework/color-controller.h
#include <dali/internal/accessibility/bridge/bridge-editable-text.h>
// INTERNAL INCLUDES
-#include <dali/internal/text-clipboard/common/text-clipboard-impl.h>
+#include <dali/internal/clipboard/common/clipboard-impl.h>
using namespace Dali::Accessibility;
#include <dali/internal/system/common/callback-manager.h>
#include <dali/internal/system/common/object-profiler.h>
#include <dali/internal/system/common/system-factory.h>
-#include <dali/internal/text-clipboard/common/text-clipboard-impl.h>
#include <dali/internal/window-system/common/display-connection.h>
#include <dali/internal/window-system/common/display-utils.h> // For Utils::MakeUnique
#include <dali/internal/window-system/common/event-handler.h>
#include <dali/public-api/signals/callback.h>
// INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/text-clipboard.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
--- /dev/null
+#ifndef DALI_INTERNAL_CLIPBOARD_H
+#define DALI_INTERNAL_CLIPBOARD_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/clipboard.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Implementation of the Clipboard
+ */
+class Clipboard : public Dali::BaseObject, public ConnectionTracker
+{
+public:
+ struct Impl;
+
+ /**
+ * @copydoc Dali::Clipboard::Get()
+ */
+ static Dali::Clipboard Get();
+
+ /**
+ * @copydoc Dali::Clipboard::IsAvailable()
+ */
+ static bool IsAvailable();
+
+ /**
+ * Constructor
+ * @param[in] impl Clipboard impl.
+ */
+ Clipboard(Impl* impl);
+
+ /**
+ * Destructor
+ */
+ ~Clipboard() override;
+
+ /**
+ * @copydoc Dali::Clipboard::DataSentSignal()
+ */
+ Dali::Clipboard::DataSentSignalType& DataSentSignal();
+
+ /**
+ * @copydoc Dali::Clipboard::DataReceivedSignal()
+ */
+ Dali::Clipboard::DataReceivedSignalType& DataReceivedSignal();
+
+ /**
+ * @copydoc Dali::Clipboard::SetData()
+ */
+ bool SetData(const Dali::Clipboard::ClipData& clipData);
+
+ /**
+ * @copydoc Dali::Clipboard::GetData()
+ */
+ uint32_t GetData(const std::string &mimeType);
+
+ /**
+ * @copydoc Dali::Clipboard::NumberOfClipboardItems()
+ */
+ size_t NumberOfItems();
+
+ /**
+ * @copydoc Dali::Clipboard::ShowClipboard()
+ */
+ void ShowClipboard();
+
+ /**
+ * @copydoc Dali::Clipboard::HideClipboard()
+ */
+ void HideClipboard(bool skipFirstHide);
+
+ /**
+ * @copydoc Dali::Clipboard::IsVisible()
+ */
+ bool IsVisible() const;
+
+ /**
+ * This is called after a timeout when no new data event is received for a certain period of time on X.
+ * @return will return false; one-shot timer.
+ */
+ bool OnReceiveData();
+
+private:
+ // Undefined
+ Clipboard(const Clipboard&);
+ Clipboard& operator=(Clipboard&);
+
+private:
+ Impl* mImpl;
+
+public:
+}; // class Clipboard
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+inline static Internal::Adaptor::Clipboard& GetImplementation(Dali::Clipboard& clipboard)
+{
+ DALI_ASSERT_ALWAYS(clipboard && "Clipboard handle is empty");
+ BaseObject& handle = clipboard.GetBaseObject();
+ return static_cast<Internal::Adaptor::Clipboard&>(handle);
+}
+
+inline static const Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
+{
+ DALI_ASSERT_ALWAYS(clipboard && "Clipboard handle is empty");
+ const BaseObject& handle = clipboard.GetBaseObject();
+ return static_cast<const Internal::Adaptor::Clipboard&>(handle);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_CLIPBOARD_H
--- /dev/null
+
+# module: clipboard, backend: tizen-wayland
+SET( adaptor_clipboard_tizen_wayland_src_files
+ ${adaptor_clipboard_dir}/tizen-wayland/clipboard-impl-ecore-wl.cpp
+)
+
+# module: clipboard, backend: ubuntu-x11
+SET( adaptor_clipboard_ubuntu_x11_src_files
+ ${adaptor_clipboard_dir}/ubuntu-x11/clipboard-impl-x.cpp
+)
+
+# module: clipboard, backend: android
+SET( adaptor_clipboard_android_src_files
+ ${adaptor_clipboard_dir}/generic/clipboard-impl-generic.cpp
+)
+
+# module: clipboard, backend: windows
+SET( adaptor_clipboard_windows_src_files
+ ${adaptor_clipboard_dir}/generic/clipboard-impl-generic.cpp
+)
+
+# module: clipboard, backend: macos
+SET( adaptor_clipboard_macos_src_files
+ ${adaptor_clipboard_dir}/generic/clipboard-impl-generic.cpp
+)
+
+# module: clipboard, backend: libuv-x11
+SET( adaptor_clipboard_libuv_x11_src_files
+ ${adaptor_clipboard_dir}/generic/clipboard-impl-generic.cpp
+)
+
+# module: clipboard, backend: glib-x11
+SET( adaptor_clipboard_glib_x11_src_files
+ ${adaptor_clipboard_dir}/generic/clipboard-impl-generic.cpp
+)
*/
// CLASS HEADER
-#include <dali/internal/text-clipboard/common/text-clipboard-impl.h>
+#include <dali/internal/clipboard/common/clipboard-impl.h>
// INTERNAL INCLUDES
#include <dali/devel-api/common/singleton-service.h>
{
namespace Adaptor
{
-struct TextClipboard::Impl
+struct Clipboard::Impl
{
+ Dali::Clipboard::DataSentSignalType mDataSentSignal;
+ Dali::Clipboard::DataReceivedSignalType mDataReceivedSignal;
};
-TextClipboard::TextClipboard(Impl* impl)
+Clipboard::Clipboard(Impl* impl)
: mImpl(impl)
{
}
-TextClipboard::~TextClipboard()
+Clipboard::~Clipboard()
{
}
-Dali::TextClipboard TextClipboard::Get()
+Dali::Clipboard Clipboard::Get()
{
- Dali::TextClipboard clipboard;
+ Dali::Clipboard clipboard;
Dali::SingletonService service(SingletonService::Get());
if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::TextClipboard));
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard));
if(handle)
{
// If so, downcast the handle
- clipboard = Dali::TextClipboard(dynamic_cast<TextClipboard*>(handle.GetObjectPtr()));
+ clipboard = Dali::Clipboard(dynamic_cast<Clipboard*>(handle.GetObjectPtr()));
}
else
{
- TextClipboard::Impl* impl(new TextClipboard::Impl());
- clipboard = Dali::TextClipboard(new TextClipboard(impl));
- service.Register(typeid(Dali::TextClipboard), clipboard);
+ Clipboard::Impl* impl(new Clipboard::Impl());
+ clipboard = Dali::Clipboard(new Clipboard(impl));
+ service.Register(typeid(Dali::Clipboard), clipboard);
}
}
return clipboard;
}
-bool TextClipboard::IsAvailable()
+bool Clipboard::IsAvailable()
{
Dali::SingletonService service(SingletonService::Get());
if(service)
{
- Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::TextClipboard));
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard));
if(handle)
{
return true;
return false;
}
-bool TextClipboard::SetItem(const std::string& itemData)
+Dali::Clipboard::DataSentSignalType& Clipboard::DataSentSignal()
{
- return true;
+ return mImpl->mDataSentSignal;
}
-void TextClipboard::RequestItem()
+Dali::Clipboard::DataReceivedSignalType& Clipboard::DataReceivedSignal()
{
+ return mImpl->mDataReceivedSignal;
+}
+
+bool Clipboard::SetData(const Dali::Clipboard::ClipData& clipData)
+{
+ return true;
}
-unsigned int TextClipboard::NumberOfItems()
+uint32_t Clipboard::GetData(const std::string &mimeType)
{
return 0u;
}
-void TextClipboard::ShowClipboard()
+size_t Clipboard::NumberOfItems()
{
+ return 0u;
}
-void TextClipboard::HideClipboard(bool skipFirstHide)
+void Clipboard::ShowClipboard()
{
}
-bool TextClipboard::IsVisible() const
+void Clipboard::HideClipboard(bool skipFirstHide)
{
- return false;
}
-void TextClipboard::ExcuteSend(void* event)
+bool Clipboard::IsVisible() const
{
+ return false;
}
-void TextClipboard::ExcuteReceive(void* event, char*& data, int& length)
+bool Clipboard::OnReceiveData()
{
+ return false;
}
} // namespace Adaptor
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/clipboard/common/clipboard-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/common/singleton-service.h>
+#include <dali/internal/adaptor/tizen-wayland/dali-ecore-wl2.h>
+#include <dali/integration-api/debug.h>
+#include <unistd.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+static Eina_Bool EcoreEventDataSend(void* data, int type, void* event);
+static Eina_Bool EcoreEventOfferDataReady(void* data, int type, void* event);
+
+struct Clipboard::Impl
+{
+ Impl()
+ {
+ mSendHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this);
+ mReceiveHandler = ecore_event_handler_add(ECORE_WL2_EVENT_OFFER_DATA_READY, EcoreEventOfferDataReady, this);
+ }
+ ~Impl()
+ {
+ ecore_event_handler_del(mSendHandler);
+ ecore_event_handler_del(mReceiveHandler);
+ }
+
+ bool SetData(const Dali::Clipboard::ClipData& clipData)
+ {
+ mMimeType = clipData.GetMimeType();
+ mData = clipData.GetData();
+
+ if(mData.empty())
+ {
+ DALI_LOG_ERROR("ClipData is empty, return false.\n");
+ return false;
+ }
+
+ const char* mimeTypes[2];
+ mimeTypes[0] = mMimeType.c_str();
+ mimeTypes[1] = nullptr;
+
+ Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
+ Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
+ mSerial = ecore_wl2_dnd_selection_set(input, mimeTypes);
+ DALI_LOG_RELEASE_INFO("selection_set success, serial:%u, type:%s, data:%s\n", mSerial, mMimeType.c_str(), mData.c_str());
+
+ return true;
+ }
+
+ uint32_t GetData(const std::string &mimeType)
+ {
+ const char* type = mimeType.c_str();
+ if(type)
+ {
+ Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
+ Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
+ Ecore_Wl2_Offer* offer = ecore_wl2_dnd_selection_get(input);
+
+ if(!offer)
+ {
+ DALI_LOG_ERROR("selection_get fail, request type:%s\n", mimeType.c_str());
+ return 0u;
+ }
+ else
+ {
+ Eina_Array* availableTypes = ecore_wl2_offer_mimes_get(offer);
+ char* selectedType = nullptr;
+
+ for(unsigned int i = 0; i < (unsigned int)eina_array_count((Eina_Array *)availableTypes) && !selectedType; ++i)
+ {
+ char* availableType = (char*)eina_array_data_get((Eina_Array *)availableTypes, i);
+ if(!mimeType.compare(availableType))
+ {
+ selectedType = availableType;
+ break;
+ }
+ }
+
+ if(selectedType)
+ {
+ mDataId++;
+ mDataRequestIds.push_back(mDataId);
+ mDataRequestItems[mDataId] = std::make_pair(mimeType, offer);
+ ecore_wl2_offer_receive(offer, const_cast<char*>(type));
+ ecore_wl2_display_flush(ecore_wl2_input_display_get(input));
+ DALI_LOG_RELEASE_INFO("offer_receive, id:%u, request type:%s\n", mDataId, mimeType.c_str());
+ return mDataId;
+ }
+ else
+ {
+ DALI_LOG_ERROR("no matching type, request type:%s\n", mimeType.c_str());
+ return 0u;
+ }
+ }
+ }
+
+ DALI_LOG_ERROR("no request type, type is null.\n");
+ return 0u;
+ }
+
+ void SendData(void* event)
+ {
+ Ecore_Wl2_Event_Data_Source_Send* ev = reinterpret_cast<Ecore_Wl2_Event_Data_Source_Send*>(event);
+
+ if(ev->serial != mSerial)
+ {
+ return;
+ }
+
+ // no matching mime type.
+ if(mMimeType.compare(ev->type))
+ {
+ auto it = mDataRequestIds.begin();
+ while(it != mDataRequestIds.end())
+ {
+ uint32_t dataRequestId = *it;
+ auto item = mDataRequestItems.find(dataRequestId);
+ if(item != mDataRequestItems.end())
+ {
+ std::string mimeType = static_cast<std::string>(item->second.first);
+ if(!mimeType.compare(ev->type))
+ {
+ mDataRequestItems.erase(dataRequestId);
+ it = mDataRequestIds.erase(it);
+ DALI_LOG_ERROR("no matching type, empty signal emit, request type:%s, available type:%s\n", ev->type, mMimeType.c_str());
+ mDataReceivedSignal.Emit(dataRequestId, "", "");
+ }
+ else
+ {
+ ++it;
+ }
+ }
+ }
+ return;
+ }
+
+ size_t dataLength = strlen(mData.c_str());
+ size_t bufferSize = dataLength + 1u;
+
+ char* buffer = new char[bufferSize];
+ if(!buffer)
+ {
+ return;
+ }
+
+ memcpy(buffer, mData.c_str(), dataLength);
+ buffer[dataLength] = '\0';
+
+ auto ret = write(ev->fd, buffer, bufferSize);
+ if(DALI_UNLIKELY(ret != static_cast<ssize_t>(bufferSize)))
+ {
+ DALI_LOG_ERROR("write(ev->fd) return %zd\n", ret);
+ }
+
+ close(ev->fd);
+ delete[] buffer;
+
+ DALI_LOG_RELEASE_INFO("send data, type:%s, data:%s \n", mMimeType.c_str(), mData.c_str());
+ mDataSentSignal.Emit(ev->type, mData.c_str());
+ }
+
+ void ReceiveData(void* event)
+ {
+ Ecore_Wl2_Event_Offer_Data_Ready* ev = reinterpret_cast<Ecore_Wl2_Event_Offer_Data_Ready*>(event);
+
+ size_t dataLength = strlen(ev->data);
+ size_t bufferSize = static_cast<size_t>(ev->len);
+ std::string content;
+
+ if(dataLength < bufferSize)
+ {
+ content.append(ev->data, dataLength);
+ }
+ else
+ {
+ content.append(ev->data, bufferSize);
+ }
+
+ DALI_LOG_RELEASE_INFO("receive data, type:%s, data:%s\n", ev->mimetype, content.c_str());
+
+ auto it = mDataRequestIds.begin();
+ while(it != mDataRequestIds.end())
+ {
+ uint32_t dataRequestId = *it;
+ auto item = mDataRequestItems.find(dataRequestId);
+ if(item != mDataRequestItems.end())
+ {
+ Ecore_Wl2_Offer* offer = static_cast<Ecore_Wl2_Offer*>(item->second.second);
+ if(offer == ev->offer)
+ {
+ std::string mimeType = static_cast<std::string>(item->second.first);
+ mDataRequestItems.erase(dataRequestId);
+ it = mDataRequestIds.erase(it);
+ DALI_LOG_RELEASE_INFO("receive data, success signal emit, id:%u, type:%s\n", dataRequestId, mimeType.c_str());
+ mDataReceivedSignal.Emit(dataRequestId, mimeType.c_str(), content.c_str());
+ }
+ else
+ {
+ ++it;
+ }
+ }
+ }
+ }
+
+ uint32_t mSerial{0u};
+ std::string mMimeType;
+ std::string mData;
+ Ecore_Event_Handler* mSendHandler{nullptr};
+ Ecore_Event_Handler* mReceiveHandler{nullptr};
+
+ Dali::Clipboard::DataSentSignalType mDataSentSignal;
+ Dali::Clipboard::DataReceivedSignalType mDataReceivedSignal;
+
+ uint32_t mDataId{0};
+ std::vector<uint32_t> mDataRequestIds;
+ std::unordered_map<uint32_t, std::pair<std::string, Ecore_Wl2_Offer*>> mDataRequestItems;
+};
+
+static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
+{
+ Clipboard::Impl* impl = reinterpret_cast<Clipboard::Impl*>(data);
+ impl->SendData(event);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool EcoreEventOfferDataReady(void* data, int type, void* event)
+{
+ Clipboard::Impl* impl = reinterpret_cast<Clipboard::Impl*>(data);
+ impl->ReceiveData(event);
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+Clipboard::Clipboard(Impl* impl)
+: mImpl(impl)
+{
+}
+
+Clipboard::~Clipboard()
+{
+ delete mImpl;
+}
+
+Dali::Clipboard Clipboard::Get()
+{
+ Dali::Clipboard clipboard;
+
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard));
+ if(handle)
+ {
+ // If so, downcast the handle
+ clipboard = Dali::Clipboard(dynamic_cast<Clipboard*>(handle.GetObjectPtr()));
+ }
+ else
+ {
+ Clipboard::Impl* impl(new Clipboard::Impl());
+ clipboard = Dali::Clipboard(new Clipboard(impl));
+ service.Register(typeid(Dali::Clipboard), clipboard);
+ }
+ }
+
+ 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;
+}
+
+Dali::Clipboard::DataSentSignalType& Clipboard::DataSentSignal()
+{
+ return mImpl->mDataSentSignal;
+}
+
+Dali::Clipboard::DataReceivedSignalType& Clipboard::DataReceivedSignal()
+{
+ return mImpl->mDataReceivedSignal;
+}
+
+bool Clipboard::SetData(const Dali::Clipboard::ClipData& clipData)
+{
+ return mImpl->SetData(clipData);
+}
+
+uint32_t Clipboard::GetData(const std::string &mimeType)
+{
+ return mImpl->GetData(mimeType);
+}
+
+size_t Clipboard::NumberOfItems()
+{
+ // TODO: We should to check if the data is empty in the clipboard service.
+ return 1u;
+}
+
+void Clipboard::ShowClipboard()
+{
+}
+
+void Clipboard::HideClipboard(bool skipFirstHide)
+{
+}
+
+bool Clipboard::IsVisible() const
+{
+ return false;
+}
+
+bool Clipboard::OnReceiveData()
+{
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/clipboard/common/clipboard-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/internal/system/linux/dali-ecore-x.h>
+#include <dali/public-api/adaptor-framework/timer.h>
+#include <dali/public-api/object/any.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/common/singleton-service.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/window-system/ubuntu-x11/window-interface-ecore-x.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+struct Clipboard::Impl
+{
+ Impl(Ecore_X_Window ecoreXwin)
+ {
+ mApplicationWindow = ecoreXwin;
+ }
+
+ bool SetData(const Dali::Clipboard::ClipData& clipData)
+ {
+ mMimeType = clipData.GetMimeType();
+ mData = clipData.GetData();
+
+ if(mData.empty())
+ {
+ return false;
+ }
+
+ mDataSentSignal.Emit(mMimeType.c_str(), mData.c_str());
+
+ return true;
+ }
+
+ uint32_t GetData(const std::string &mimeType)
+ {
+ if(!mMimeType.compare(mimeType.c_str()))
+ {
+ mDataId++;
+ // For consistency of operation with tizen Wl2, a fake callback is occurs using a timer.
+ if(mDataReceiveTimer.IsRunning())
+ {
+ mDataReceiveTimer.Stop();
+ }
+ mDataReceiveTimer.Start();
+ DALI_LOG_RELEASE_INFO("request data, id:%u, request type:%s\n", mDataId, mimeType.c_str());
+ return mDataId;
+ }
+ return 0u;
+ }
+
+ bool OnReceiveData()
+ {
+ DALI_LOG_RELEASE_INFO("receive data, success signal emit, id:%u, type:%s, data:%s\n", mDataId, mMimeType.c_str(), mData.c_str());
+ mDataReceivedSignal.Emit(mDataId, mMimeType.c_str(), mData.c_str());
+ return false;
+ }
+
+ Ecore_X_Window mApplicationWindow;
+ std::string mMimeType;
+ std::string mData;
+ uint32_t mDataId{0};
+
+ Dali::Clipboard::DataSentSignalType mDataSentSignal;
+ Dali::Clipboard::DataReceivedSignalType mDataReceivedSignal;
+
+ Dali::Timer mDataReceiveTimer;
+};
+
+Clipboard::Clipboard(Impl* impl)
+: mImpl(impl)
+{
+ mImpl->mDataReceiveTimer = Dali::Timer::New(10);
+ mImpl->mDataReceiveTimer.TickSignal().Connect(this, &Clipboard::OnReceiveData);
+}
+
+Clipboard::~Clipboard()
+{
+ delete mImpl;
+}
+
+Dali::Clipboard Clipboard::Get()
+{
+ Dali::Clipboard clipboard;
+
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard));
+ if(handle)
+ {
+ // If so, downcast the handle
+ clipboard = Dali::Clipboard(dynamic_cast<Clipboard*>(handle.GetObjectPtr()));
+ }
+ else
+ {
+ Adaptor& adaptorImpl(Adaptor::GetImplementation(Adaptor::Get()));
+ Any nativewindow = adaptorImpl.GetNativeWindowHandle();
+
+ // The Ecore_X_Window needs to use the Clipboard.
+ // Only when the render surface is window, we can get the Ecore_X_Window.
+ Ecore_X_Window ecoreXwin(AnyCast<Ecore_X_Window>(nativewindow));
+ if(ecoreXwin)
+ {
+ // If we fail to get Ecore_X_Window, we can't use the Clipboard correctly.
+ // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
+ // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
+ Clipboard::Impl* impl(new Clipboard::Impl(ecoreXwin));
+ clipboard = Dali::Clipboard(new Clipboard(impl));
+ service.Register(typeid(clipboard), clipboard);
+ }
+ }
+ }
+
+ 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;
+}
+
+Dali::Clipboard::DataSentSignalType& Clipboard::DataSentSignal()
+{
+ return mImpl->mDataSentSignal;
+}
+
+Dali::Clipboard::DataReceivedSignalType& Clipboard::DataReceivedSignal()
+{
+ return mImpl->mDataReceivedSignal;
+}
+
+bool Clipboard::SetData(const Dali::Clipboard::ClipData& clipData)
+{
+ return mImpl->SetData(clipData);
+}
+
+uint32_t Clipboard::GetData(const std::string &mimeType)
+{
+ return mImpl->GetData(mimeType);
+}
+
+size_t Clipboard::NumberOfItems()
+{
+ // TODO: We should to check if the data is empty in the clipboard service.
+ return 1u;
+}
+
+void Clipboard::ShowClipboard()
+{
+}
+
+void Clipboard::HideClipboard(bool skipFirstHide)
+{
+}
+
+bool Clipboard::IsVisible() const
+{
+ return false;
+}
+
+bool Clipboard::OnReceiveData()
+{
+ return mImpl->OnReceiveData();
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+++ /dev/null
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/text-clipboard/common/text-clipboard-event-notifier-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/common/singleton-service.h>
-#include <dali/public-api/object/type-registry.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-Dali::TextClipboardEventNotifier TextClipboardEventNotifier::New()
-{
- Dali::TextClipboardEventNotifier notifier = Dali::TextClipboardEventNotifier(new TextClipboardEventNotifier());
-
- return notifier;
-}
-
-Dali::TextClipboardEventNotifier TextClipboardEventNotifier::Get()
-{
- Dali::TextClipboardEventNotifier notifier;
-
- Dali::SingletonService service(SingletonService::Get());
- if(service)
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::TextClipboardEventNotifier));
- if(handle)
- {
- // If so, downcast the handle
- notifier = Dali::TextClipboardEventNotifier(dynamic_cast<TextClipboardEventNotifier*>(handle.GetObjectPtr()));
- }
- else
- {
- notifier = Dali::TextClipboardEventNotifier(TextClipboardEventNotifier::New());
- service.Register(typeid(notifier), notifier);
- }
- }
-
- return notifier;
-}
-
-const std::string& TextClipboardEventNotifier::GetContent() const
-{
- return mContent;
-}
-
-void TextClipboardEventNotifier::SetContent(const std::string& content)
-{
- mContent = content;
-}
-
-void TextClipboardEventNotifier::ClearContent()
-{
- mContent.clear();
-}
-
-void TextClipboardEventNotifier::EmitContentSelectedSignal()
-{
- if(!mContentSelectedSignal.Empty())
- {
- Dali::TextClipboardEventNotifier handle(this);
- mContentSelectedSignal.Emit(handle);
- }
-}
-
-TextClipboardEventNotifier::TextClipboardEventNotifier()
-: mContent()
-{
-}
-
-TextClipboardEventNotifier::~TextClipboardEventNotifier()
-{
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_INTERNAL_TEXT_CLIPBOARD_EVENT_NOTIFIER_H
-#define DALI_INTERNAL_TEXT_CLIPBOARD_EVENT_NOTIFIER_H
-
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/object/base-object.h>
-#include <string>
-
-// INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/text-clipboard-event-notifier.h>
-#include <dali/public-api/dali-adaptor-common.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-/**
- * This class listens to TextClipboard events.
- */
-class TextClipboardEventNotifier : public Dali::BaseObject
-{
-public:
- typedef Dali::TextClipboardEventNotifier::TextClipboardEventSignalType TextClipboardEventSignalType;
-
- // Creation
-
- /**
- * Create a TextClipboardEventNotifier.
- * @return A newly allocated text-clipboard-event-notifier.
- */
- static Dali::TextClipboardEventNotifier New();
-
- /**
- * @copydoc Dali::TextClipboardEventNotifier::Get()
- */
- static Dali::TextClipboardEventNotifier Get();
-
- // Public API
-
- /**
- * @copydoc Dali::TextClipboardEventNotifier::GetContent() const
- */
- const std::string& GetContent() const;
-
- /**
- * Sets the selected content.
- * @param[in] content A string that represents the content that has been selected.
- */
- void SetContent(const std::string& content);
-
- /**
- * Clears the stored content.
- */
- void ClearContent();
-
- /**
- * Called when content is selected in the clipboard.
- */
- void EmitContentSelectedSignal();
-
-public: // Signals
- /**
- * @copydoc Dali::TextClipboardEventNotifier::ContentSelectedSignal
- */
- TextClipboardEventSignalType& ContentSelectedSignal()
- {
- return mContentSelectedSignal;
- }
-
-private:
- // Construction & Destruction
-
- /**
- * Constructor.
- */
- TextClipboardEventNotifier();
-
- /**
- * Destructor.
- */
- ~TextClipboardEventNotifier() override;
-
- // Undefined
- TextClipboardEventNotifier(const TextClipboardEventNotifier&);
- TextClipboardEventNotifier& operator=(TextClipboardEventNotifier&);
-
-private:
- std::string mContent; ///< The current selected content.
-
- TextClipboardEventSignalType mContentSelectedSignal;
-
-public:
- // Helpers for public-api forwarding methods
-
- inline static Internal::Adaptor::TextClipboardEventNotifier& GetImplementation(Dali::TextClipboardEventNotifier& detector)
- {
- DALI_ASSERT_ALWAYS(detector && "TextClipboardEventNotifier handle is empty");
-
- BaseObject& handle = detector.GetBaseObject();
-
- return static_cast<Internal::Adaptor::TextClipboardEventNotifier&>(handle);
- }
-
- inline static const Internal::Adaptor::TextClipboardEventNotifier& GetImplementation(const Dali::TextClipboardEventNotifier& detector)
- {
- DALI_ASSERT_ALWAYS(detector && "TextClipboardEventNotifier handle is empty");
-
- const BaseObject& handle = detector.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::TextClipboardEventNotifier&>(handle);
- }
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_TEXT_CLIPBOARD_EVENT_NOTIFIER_H
+++ /dev/null
-#ifndef DALI_INTERNAL_TEXT_CLIPBOARD_H
-#define DALI_INTERNAL_TEXT_CLIPBOARD_H
-
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-object.h>
-
-// INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/text-clipboard.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-/**
- * Implementation of the Clip Board
- */
-
-class TextClipboard : public Dali::BaseObject
-{
-public:
- // Hide the specific windowing system
- struct Impl;
-
- /**
- * @copydoc Dali::TextClipboard::Get()
- */
- static Dali::TextClipboard Get();
-
- /**
- * @copydoc Dali::TextClipboard::IsAvailable()
- */
- static bool IsAvailable();
-
- /**
- * Constructor
- * @param[in] impl Some data from a specific windowing system.
- */
- TextClipboard(Impl* impl);
-
- /**
- * Destructor
- */
- ~TextClipboard() override;
-
- /**
- * @copydoc Dali::TextClipboard::SetItem()
- */
- bool SetItem(const std::string& itemData);
-
- /**
- * @copydoc Dali::TextClipboard::RequestItem()
- */
- void RequestItem();
-
- /**
- * @copydoc Dali::TextClipboard::NumberOfClipboardItems()
- */
- unsigned int NumberOfItems();
-
- /**
- * @copydoc Dali::TextClipboard::ShowClipboard()
- */
- void ShowClipboard();
-
- /**
- * @copydoc Dali::TextClipboard::HideClipboard()
- */
- void HideClipboard(bool skipFirstHide);
-
- /**
- * @copydoc Dali::TextClipboard::IsVisible()
- */
- bool IsVisible() const;
-
- /**
- * @brief sending buffered data
- *
- * @param[in] event information pointer
- */
- void ExcuteSend(void* event);
-
- /**
- * @brief receiving buffered data
- *
- * @param[in] event information pointer
- * @param[out] data The buffer pointer for receive data
- * @param[out] length The buffer length for receive data
- */
- void ExcuteReceive(void* event, char*& data, int& length);
-
-private:
- // Undefined
- TextClipboard(const TextClipboard&);
- TextClipboard& operator=(TextClipboard&);
-
-private:
- Impl* mImpl;
-
-public:
-}; // class TextClipboard
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-inline static Internal::Adaptor::TextClipboard& GetImplementation(Dali::TextClipboard& clipboard)
-{
- DALI_ASSERT_ALWAYS(clipboard && "TextClipboard handle is empty");
- BaseObject& handle = clipboard.GetBaseObject();
- return static_cast<Internal::Adaptor::TextClipboard&>(handle);
-}
-
-inline static const Internal::Adaptor::TextClipboard& GetImplementation(const Dali::TextClipboard& clipboard)
-{
- DALI_ASSERT_ALWAYS(clipboard && "TextClipboard handle is empty");
- const BaseObject& handle = clipboard.GetBaseObject();
- return static_cast<const Internal::Adaptor::TextClipboard&>(handle);
-}
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_TEXT_CLIPBOARD_H
+++ /dev/null
-
-# module: text-clipboard, backend: common
-SET( adaptor_text_clipboard_common_src_files
- ${adaptor_text_clipboard_dir}/common/text-clipboard-event-notifier-impl.cpp
-)
-
-# module: text-clipboard, backend: tizen-wayland
-SET( adaptor_text_clipboard_tizen_wayland_src_files
- ${adaptor_text_clipboard_dir}/tizen-wayland/text-clipboard-impl-ecore-wl.cpp
-)
-
-# module: text-clipboard, backend: ubuntu-x11
-SET( adaptor_text_clipboard_ubuntu_x11_src_files
- ${adaptor_text_clipboard_dir}/ubuntu-x11/text-clipboard-impl-x.cpp
-)
-
-# module: text-clipboard, backend: android
-SET( adaptor_text_clipboard_android_src_files
- ${adaptor_text_clipboard_dir}/generic/text-clipboard-impl-generic.cpp
-)
-
-# module: text-clipboard, backend: windows
-SET( adaptor_text_clipboard_windows_src_files
- ${adaptor_text_clipboard_dir}/generic/text-clipboard-impl-generic.cpp
-)
-
-# module: text-clipboard, backend: macos
-SET( adaptor_text_clipboard_macos_src_files
- ${adaptor_text_clipboard_dir}/generic/text-clipboard-impl-generic.cpp
-)
-
-# module: text-clipboard, backend: libuv-x11
-SET( adaptor_text_clipboard_libuv_x11_src_files
- ${adaptor_text_clipboard_dir}/generic/text-clipboard-impl-generic.cpp
-)
-
-# module: text-clipboard, backend: glib-x11
-SET( adaptor_text_clipboard_glib_x11_src_files
- ${adaptor_text_clipboard_dir}/generic/text-clipboard-impl-generic.cpp
-)
+++ /dev/null
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/devel-api/adaptor-framework/text-clipboard-event-notifier.h>
-#include <dali/internal/text-clipboard/common/text-clipboard-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/internal/system/linux/dali-ecore.h>
-
-#ifdef ECORE_WAYLAND2
-#include <dali/internal/adaptor/tizen-wayland/dali-ecore-wl2.h>
-#else
-#include <dali/internal/adaptor/tizen-wayland/dali-ecore-wayland.h>
-#endif
-
-#include <dali/devel-api/common/singleton-service.h>
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/object/any.h>
-#include <dali/public-api/object/type-registry.h>
-#include <unistd.h>
-
-#ifdef DALI_ELDBUS_AVAILABLE
-#include <Eldbus.h>
-#endif // DALI_ELDBUS_AVAILABLE
-
-#define CBHM_DBUS_OBJPATH "/org/tizen/cbhm/dbus"
-#ifndef CBHM_DBUS_INTERFACE
-#define CBHM_DBUS_INTERFACE "org.tizen.cbhm.dbus"
-#endif /* CBHM_DBUS_INTERFACE */
-#define CBHM_COUNT_ALL 0 // ATOM_INDEX_CBHM_COUNT_ALL
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// TextClipboard
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-struct TextClipboard::Impl
-{
- Impl()
- {
-#ifdef DALI_ELDBUS_AVAILABLE
- Eldbus_Object* eldbus_obj;
- eldbus_init();
- cbhm_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
- eldbus_obj = eldbus_object_get(cbhm_conn, CBHM_DBUS_INTERFACE, CBHM_DBUS_OBJPATH);
- eldbus_proxy = eldbus_proxy_get(eldbus_obj, CBHM_DBUS_INTERFACE);
- eldbus_name_owner_changed_callback_add(cbhm_conn, CBHM_DBUS_INTERFACE, NULL, cbhm_conn, EINA_TRUE);
- eldbus_proxy_signal_handler_add(eldbus_proxy, "ItemClicked", _on_item_clicked, this);
-#endif // DALI_ELDBUS_AVAILABLE
- mVisible = false;
- mIsFirstTimeHidden = true;
- }
-
- ~Impl()
- {
-#ifdef DALI_ELDBUS_AVAILABLE
- if(cbhm_conn)
- eldbus_connection_unref(cbhm_conn);
- eldbus_shutdown();
-#endif // DALI_ELDBUS_AVAILABLE
- }
-
-#ifdef DALI_ELDBUS_AVAILABLE
- Eldbus_Proxy* cbhm_proxy_get()
- {
- return eldbus_proxy;
- }
-
- Eldbus_Connection* cbhm_connection_get()
- {
- return cbhm_conn;
- }
-#endif // DALI_ELDBUS_AVAILABLE
-
- void SetItem(const std::string& itemData)
- {
- const char* types[10] = {
- 0,
- };
- int i = -1;
-
- if(itemData.length() == 0)
- {
- return;
- }
- mSendBuffer = itemData;
-
- // ELM_SEL_TYPE_CLIPBOARD - To distinguish clipboard selection in cbhm
- types[++i] = "CLIPBOARD_BEGIN";
-
- types[++i] = "text/plain;charset=utf-8";
-
- // ELM_SEL_TYPE_CLIPBOARD - To distinguish clipboard selection in cbhm
- types[++i] = "CLIPBOARD_END";
-
-#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
- mSerial = ecore_wl2_dnd_selection_set(input, types);
-#else
- mSerial = ecore_wl_dnd_selection_set(ecore_wl_input_get(), types);
-#endif
- }
-
- void RequestItem()
- {
- const char* types[10] = {
- 0,
- };
- int i = -1;
-
- types[++i] = "text/plain;charset=utf-8";
-
-#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
- Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
- Ecore_Wl2_Offer* offer = ecore_wl2_dnd_selection_get(input);
-
- ecore_wl2_offer_receive(offer, const_cast<char*>(*types));
- ecore_wl2_display_flush(ecore_wl2_input_display_get(input));
-#else
- ecore_wl_dnd_selection_get(ecore_wl_input_get(), *types);
-#endif
- }
-
- void ExcuteSend(void* event)
- {
-#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Event_Data_Source_Send* ev = reinterpret_cast<Ecore_Wl2_Event_Data_Source_Send*>(event);
-#else
- Ecore_Wl_Event_Data_Source_Send* ev = reinterpret_cast<Ecore_Wl_Event_Data_Source_Send*>(event);
-#endif
-
- if(ev->serial != mSerial)
- {
- return;
- }
-
- int len_buf = mSendBuffer.length() + 1; // we should consider the char* buffer length
- int len_remained = len_buf;
- int len_written = 0, ret;
- const char* buf = mSendBuffer.c_str(); // last char in the buffer must be \0
-
- while(len_written < len_buf)
- {
- ret = write(ev->fd, buf, len_remained);
- if(ret == -1) break;
- buf += ret;
- len_written += ret;
- len_remained -= ret;
- }
- close(ev->fd);
- }
-
- void ExcuteReceive(void* event, char*& data, int& length)
- {
-#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Event_Offer_Data_Ready* ev = reinterpret_cast<Ecore_Wl2_Event_Offer_Data_Ready*>(event);
-#else
- Ecore_Wl_Event_Selection_Data_Ready* ev = reinterpret_cast<Ecore_Wl_Event_Selection_Data_Ready*>(event);
-#endif
- data = reinterpret_cast<char*>(ev->data);
- length = ev->len;
- }
-
- int GetCount()
- {
-#ifdef DALI_ELDBUS_AVAILABLE
- Eldbus_Message *reply, *req;
- const char * errname = NULL, *errmsg = NULL;
-#endif // DALI_ELDBUS_AVAILABLE
- int count = -1;
-
-#ifdef DALI_ELDBUS_AVAILABLE
- if(!(req = eldbus_proxy_method_call_new(eldbus_proxy, "CbhmGetCount")))
- {
- DALI_LOG_ERROR("Failed to create method call on org.freedesktop.DBus.Properties.Get");
- return -1;
- }
-
- eldbus_message_ref(req);
- eldbus_message_arguments_append(req, "i", CBHM_COUNT_ALL);
- reply = eldbus_proxy_send_and_block(eldbus_proxy, req, 100);
- if(!reply || eldbus_message_error_get(reply, &errname, &errmsg))
- {
- DALI_LOG_ERROR("Unable to call method org.freedesktop.DBus.Properties.Get: %s %s",
- errname,
- errmsg);
- eldbus_message_unref(req);
- if(reply)
- {
- eldbus_message_unref(reply);
- }
- return -1;
- }
-
- if(!eldbus_message_arguments_get(reply, "i", &count))
- {
- DALI_LOG_ERROR("Cannot get arguments from eldbus");
- eldbus_message_unref(req);
- eldbus_message_unref(reply);
- return -1;
- }
-
- eldbus_message_unref(req);
- eldbus_message_unref(reply);
- DALI_LOG_ERROR("cbhm item count(%d)", count);
-#endif // DALI_ELDBUS_AVAILABLE
- return count;
- }
-
- void ShowClipboard()
- {
-#ifdef DALI_ELDBUS_AVAILABLE
- eldbus_proxy_call(cbhm_proxy_get(), "CbhmShow", NULL, NULL, -1, "s", "0");
-#endif // DALI_ELDBUS_AVAILABLE
- mIsFirstTimeHidden = true;
- mVisible = true;
- }
-
- void HideClipboard(bool skipFirstHide)
- {
- if(skipFirstHide && mIsFirstTimeHidden)
- {
- mIsFirstTimeHidden = false;
- return;
- }
-#ifdef DALI_ELDBUS_AVAILABLE
- eldbus_proxy_call(cbhm_proxy_get(), "CbhmHide", NULL, NULL, -1, "");
-#endif // DALI_ELDBUS_AVAILABLE
- mIsFirstTimeHidden = false;
- mVisible = false;
- }
-
- bool IsVisible() const
- {
- return mVisible;
- }
-
-#ifdef DALI_ELDBUS_AVAILABLE
- static void _on_item_clicked(void* data, const Eldbus_Message* msg EINA_UNUSED)
- {
- static_cast<TextClipboard::Impl*>(data)->RequestItem();
- }
-
- Eldbus_Proxy* eldbus_proxy;
- Eldbus_Connection* cbhm_conn;
-#endif // DALI_ELDBUS_AVAILABLE
-
- std::string mSendBuffer;
- bool mVisible;
- bool mIsFirstTimeHidden;
- uint32_t mSerial{0u};
-};
-
-TextClipboard::TextClipboard(Impl* impl)
-: mImpl(impl)
-{
-}
-
-TextClipboard::~TextClipboard()
-{
- delete mImpl;
-}
-
-Dali::TextClipboard TextClipboard::Get()
-{
- Dali::TextClipboard clipboard;
-
- Dali::SingletonService service(SingletonService::Get());
- if(service)
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::TextClipboard));
- if(handle)
- {
- // If so, downcast the handle
- clipboard = Dali::TextClipboard(dynamic_cast<TextClipboard*>(handle.GetObjectPtr()));
- }
- else
- {
- TextClipboard::Impl* impl(new TextClipboard::Impl());
- clipboard = Dali::TextClipboard(new TextClipboard(impl));
- service.Register(typeid(Dali::TextClipboard), clipboard);
- }
- }
-
- return clipboard;
-}
-
-bool TextClipboard::IsAvailable()
-{
- Dali::SingletonService service(SingletonService::Get());
- if(service)
- {
- Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::TextClipboard));
- if(handle)
- {
- return true;
- }
- }
- return false;
-}
-
-bool TextClipboard::SetItem(const std::string& itemData)
-{
- mImpl->SetItem(itemData);
- return true;
-}
-
-/*
- * Request clipboard service to give an item
- */
-void TextClipboard::RequestItem()
-{
- mImpl->RequestItem();
-}
-
-/*
- * Get number of items in clipboard
- */
-unsigned int TextClipboard::NumberOfItems()
-{
- int count = mImpl->GetCount();
- return (count < 0 ? 0 : count);
-}
-
-void TextClipboard::ShowClipboard()
-{
- mImpl->ShowClipboard();
-}
-
-void TextClipboard::HideClipboard(bool skipFirstHide)
-{
- mImpl->HideClipboard(skipFirstHide);
-}
-
-bool TextClipboard::IsVisible() const
-{
- return mImpl->IsVisible();
-}
-
-void TextClipboard::ExcuteSend(void* event)
-{
- mImpl->ExcuteSend(event);
-}
-
-void TextClipboard::ExcuteReceive(void* event, char*& data, int& length)
-{
- mImpl->ExcuteReceive(event, data, length);
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/text-clipboard/common/text-clipboard-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/internal/system/linux/dali-ecore-x.h>
-#include <dali/public-api/object/any.h>
-#include <dali/public-api/object/type-registry.h>
-
-// INTERNAL INCLUDES
-#include <dali/devel-api/common/singleton-service.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/internal/text-clipboard/common/text-clipboard-event-notifier-impl.h>
-#include <dali/internal/window-system/ubuntu-x11/window-interface-ecore-x.h>
-
-namespace //unnamed namespace
-{
-const char* const CBHM_WINDOW = "CBHM_XWIN";
-const char* const CBHM_MSG = "CBHM_MSG";
-const char* const CBHM_ITEM = "CBHM_ITEM";
-const char* const CBHM_cCOUNT = "CBHM_cCOUNT";
-const char* const CBHM_ERROR = "CBHM_ERROR";
-const char* const SET_ITEM = "SET_ITEM";
-const char* const SHOW = "show0";
-const char* const HIDE = "cbhm_hide";
-} // namespace
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// TextClipboard
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-struct TextClipboard::Impl
-{
- Impl(Ecore_X_Window ecoreXwin)
- {
- mApplicationWindow = ecoreXwin;
- }
-
- Ecore_X_Window mApplicationWindow;
-};
-
-TextClipboard::TextClipboard(Impl* impl)
-: mImpl(impl)
-{
-}
-
-TextClipboard::~TextClipboard()
-{
- delete mImpl;
-}
-
-Dali::TextClipboard TextClipboard::Get()
-{
- Dali::TextClipboard clipboard;
-
- Dali::SingletonService service(SingletonService::Get());
- if(service)
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::TextClipboard));
- if(handle)
- {
- // If so, downcast the handle
- clipboard = Dali::TextClipboard(dynamic_cast<TextClipboard*>(handle.GetObjectPtr()));
- }
- else
- {
- Adaptor& adaptorImpl(Adaptor::GetImplementation(Adaptor::Get()));
- Any nativewindow = adaptorImpl.GetNativeWindowHandle();
-
- // The Ecore_X_Window needs to use the Clipboard.
- // Only when the render surface is window, we can get the Ecore_X_Window.
- Ecore_X_Window ecoreXwin(AnyCast<Ecore_X_Window>(nativewindow));
- if(ecoreXwin)
- {
- // If we fail to get Ecore_X_Window, we can't use the Clipboard correctly.
- // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
- // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
- TextClipboard::Impl* impl(new TextClipboard::Impl(ecoreXwin));
- clipboard = Dali::TextClipboard(new TextClipboard(impl));
- service.Register(typeid(clipboard), clipboard);
- }
- }
- }
-
- return clipboard;
-}
-
-bool TextClipboard::IsAvailable()
-{
- Dali::SingletonService service(SingletonService::Get());
- if(service)
- {
- Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::TextClipboard));
- if(handle)
- {
- return true;
- }
- }
- return false;
-}
-
-bool TextClipboard::SetItem(const std::string& itemData)
-{
- Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow();
- Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(CBHM_ITEM);
- Ecore_X_Atom dataType = ECORE_X_ATOM_STRING;
-
- // Set item (property) to send
- ecore_x_window_prop_property_set(cbhmWin, atomCbhmItem, dataType, 8, const_cast<char*>(itemData.c_str()), itemData.length() + 1);
- ecore_x_sync();
-
- // Trigger sending of item (property)
- Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get(CBHM_MSG);
- ECore::WindowInterface::SendXEvent(ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, SET_ITEM);
- return true;
-}
-
-/*
- * Request clipboard service to retrieve an item
- */
-void TextClipboard::RequestItem()
-{
- int index = 0;
- char sendBuf[20];
- snprintf(sendBuf, 20, "%s%d", CBHM_ITEM, index);
- Ecore_X_Atom xAtomCbhmItem = ecore_x_atom_get(sendBuf);
- Ecore_X_Atom xAtomItemType = 0;
-
- std::string clipboardString(ECore::WindowInterface::GetWindowProperty(xAtomCbhmItem, &xAtomItemType, index));
-
- // Only return the text string if the Atom type is text (Do not return a text string/URL for images).
- if(!clipboardString.empty() &&
- (xAtomItemType == ECORE_X_ATOM_TEXT || xAtomItemType == ECORE_X_ATOM_COMPOUND_TEXT || xAtomItemType == ECORE_X_ATOM_STRING || xAtomItemType == ECORE_X_ATOM_UTF8_STRING))
- {
- Ecore_X_Atom xAtomCbhmError = ecore_x_atom_get(CBHM_ERROR);
- if(xAtomItemType != xAtomCbhmError)
- {
- // Call TextClipboardEventNotifier to notify event observe of retrieved string
- Dali::TextClipboardEventNotifier clipboardEventNotifier(TextClipboardEventNotifier::Get());
- if(clipboardEventNotifier)
- {
- TextClipboardEventNotifier& notifierImpl(TextClipboardEventNotifier::GetImplementation(clipboardEventNotifier));
-
- notifierImpl.SetContent(clipboardString);
- notifierImpl.EmitContentSelectedSignal();
- }
- }
- }
-}
-
-/*
- * Get number of items in clipboard
- */
-unsigned int TextClipboard::NumberOfItems()
-{
- Ecore_X_Atom xAtomCbhmCountGet = ecore_x_atom_get(CBHM_cCOUNT);
-
- std::string ret(ECore::WindowInterface::GetWindowProperty(xAtomCbhmCountGet, NULL, 0));
- int count = 0;
-
- if(!ret.empty())
- {
- count = atoi(ret.c_str());
- }
-
- return count;
-}
-
-/**
- * Show clipboard window
- * Function to send message to show the Clipboard (cbhm) as no direct API available
- * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c
- */
-void TextClipboard::ShowClipboard()
-{
- // Claim the ownership of the SECONDARY selection.
- ecore_x_selection_secondary_set(mImpl->mApplicationWindow, "", 1);
- Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow();
-
- // Launch the clipboard window
- Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get(CBHM_MSG);
- ECore::WindowInterface::SendXEvent(ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, SHOW);
-}
-
-void TextClipboard::HideClipboard(bool skipFirstHide)
-{
- Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow();
- // Launch the clipboard window
- Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get(CBHM_MSG);
- ECore::WindowInterface::SendXEvent(ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, HIDE);
-
- // release the ownership of SECONDARY selection
- ecore_x_selection_secondary_clear();
-}
-
-bool TextClipboard::IsVisible() const
-{
- return false;
-}
-
-void TextClipboard::ExcuteSend(void* event)
-{
-}
-
-void TextClipboard::ExcuteReceive(void* event, char*& data, int& length)
-{
- // Receive
- Ecore_X_Event_Selection_Notify* selectionNotifyEvent = static_cast<Ecore_X_Event_Selection_Notify*>(event);
-
- Ecore_X_Selection_Data* selectionData = static_cast<Ecore_X_Selection_Data*>(selectionNotifyEvent->data);
- if(selectionData->data)
- {
- if(selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY)
- {
- // Claim the ownership of the SECONDARY selection.
- ecore_x_selection_secondary_set(mImpl->mApplicationWindow, "", 1);
- data = reinterpret_cast<char*>(selectionData->data);
- length = selectionData->length;
- }
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
#include <dali/public-api/events/wheel-event.h>
// INTERNAL INCLUDES
-#include <dali/internal/text-clipboard/common/text-clipboard-impl.h>
+#include <dali/internal/clipboard/common/clipboard-impl.h>
#include <dali/internal/styling/common/style-monitor-impl.h>
#include <dali/internal/window-system/common/window-render-surface.h>
EventHandler::EventHandler(WindowBase* windowBase, DamageObserver& damageObserver)
: mStyleMonitor(StyleMonitor::Get()),
mDamageObserver(damageObserver),
- mClipboardEventNotifier(),
mPaused(false)
{
// Connect signals
void EventHandler::OnFocusChanged(bool focusIn)
{
// If the window gains focus and we hid the keyboard then show it again.
- if(TextClipboard::IsAvailable())
+ if(Clipboard::IsAvailable())
{
if(focusIn)
{
- Dali::TextClipboard clipboard = TextClipboard::Get();
+ 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::TextClipboard clipboard = TextClipboard::Get();
+ Dali::Clipboard clipboard = Clipboard::Get();
if(clipboard)
{
- TextClipboard& clipBoardImpl(GetImplementation(clipboard));
+ Clipboard& clipBoardImpl(GetImplementation(clipboard));
clipBoardImpl.HideClipboard(true);
}
}
void EventHandler::OnSelectionDataSend(void* event)
{
- Dali::TextClipboard clipboard = TextClipboard::Get();
- if(clipboard)
- {
- TextClipboard& clipBoardImpl(GetImplementation(clipboard));
- clipBoardImpl.ExcuteSend(event);
- }
+ // Note that the clipboard-related operstions previously available have been moved to Clipboard class.
+ // It is advised not to handle any clipboard-specific works within this context.
+ // There are currently no immediate works required in this callback.
+ // But this function is retained for the purpose of handling the event at the window level, if needed.
}
void EventHandler::OnSelectionDataReceived(void* event)
{
- // We have got the selected content, inform the clipboard event listener (if we have one).
- Dali::TextClipboard clipboard = TextClipboard::Get();
- char* selectionData = NULL;
- size_t dataLength = 0u;
-
- if(clipboard)
- {
- int len = 0;
- TextClipboard& clipBoardImpl(GetImplementation(clipboard));
- clipBoardImpl.ExcuteReceive(event, selectionData, len);
- dataLength = static_cast<size_t>(len);
- }
-
- if(!mClipboardEventNotifier)
- {
- mClipboardEventNotifier = TextClipboardEventNotifier::Get();
- }
-
- if(selectionData && mClipboardEventNotifier && dataLength > 0)
- {
- TextClipboardEventNotifier& clipboardEventNotifier(TextClipboardEventNotifier::GetImplementation(mClipboardEventNotifier));
- std::string content;
- size_t stringLength = strlen(selectionData);
-
- if(stringLength < dataLength)
- {
- content.append(selectionData, stringLength);
- }
- else
- {
- content.append(selectionData, dataLength);
- }
-
- clipboardEventNotifier.SetContent(content);
- clipboardEventNotifier.EmitContentSelectedSignal();
-
- DALI_LOG_INFO(gSelectionEventLogFilter, Debug::General, "EcoreEventSelectionNotify: Content(%s) strlen(%d) dataLength(%d)\n", selectionData, strlen(selectionData), dataLength);
- }
+ // Note that the clipboard-related operstions previously available have been moved to Clipboard class.
+ // It is advised not to handle any clipboard-specific works within this context.
+ // There are currently no immediate works required in this callback.
+ // But this function is retained for the purpose of handling the event at the window level, if needed.
}
void EventHandler::OnStyleChanged(StyleChange::Type styleChange)
#include <dali/public-api/common/intrusive-ptr.h>
#include <cstdint> // uint32_t
-#include <dali/devel-api/adaptor-framework/text-clipboard.h>
+#include <dali/devel-api/adaptor-framework/clipboard.h>
#include <dali/devel-api/adaptor-framework/style-monitor.h>
// INTERNAL INCLUDES
-#include <dali/internal/text-clipboard/common/text-clipboard-event-notifier-impl.h>
#include <dali/internal/window-system/common/damage-observer.h>
#include <dali/internal/window-system/common/window-base.h>
Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
- Dali::TextClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
-
using ObserverContainer = std::vector<Observer*>;
ObserverContainer mObservers; ///< A list of event observer pointers