diff --git a/build/gn/BUILD.gn b/build/gn/BUILD.gn
index 7ad5278e3e0550c7a0acda3b52fa486e3a3c2937..aa643279a971d9396bb3d8369dbf231089097d83 100644
--- a/build/gn/BUILD.gn
+++ b/build/gn/BUILD.gn
@@ -27,13 +27,6 @@ group("ft_window_manager") {
]
}
-group("ft_wayland_adapter") {
- deps = [
- "//wayland_adapter:libwayland_adapter",
- "//wayland_adapter/test:wayland_demo",
- ]
-}
-
group("samples") {
deps = [
"//samples:clock",
diff --git a/build/prebuild.sh b/build/prebuild.sh
index 33442d364d1ba7776c23fa41148285c8dfd0cf44..0c8ead31ace7625fb0f0da2fba746ce3664709ac 100755
--- a/build/prebuild.sh
+++ b/build/prebuild.sh
@@ -105,7 +105,6 @@ cd ${PROJECT_DIR}
# copy FT sa file to /usr/local/share/ft/
sudo mkdir -p /usr/local/share/ft
sudo cp -fr ${PROJECT_DIR}/etc/ft.xml /usr/local/share/ft/
-sudo cp -fr ${PROJECT_DIR}/etc/ft_wl.xml /usr/local/share/ft/
sudo cp -fr ${PROJECT_DIR}/etc/icon /usr/local/share/ft/
sudo cp -fr ${PROJECT_DIR}/etc/desktop /usr/local/share/ft/
diff --git a/etc/ft_wl.xml b/etc/ft_wl.xml
deleted file mode 100644
index a8f6fb84dc1ebbb78539d55a1c5786488fbf51e7..0000000000000000000000000000000000000000
--- a/etc/ft_wl.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
- ft_wl
-
- /usr/lib64/libwayland_adapter.so
-
-
-
- 4600
- /usr/lib64/libwayland_adapter.so
- true
- false
- 1
-
-
diff --git a/runFT_wayland.sh b/runFT_wayland.sh
deleted file mode 100755
index 4f81625dee3425a9504858133d9916c2b42d00ec..0000000000000000000000000000000000000000
--- a/runFT_wayland.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (c) 2023 Huawei Technologies 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.
-
-
-sa_main /usr/local/share/ft/ft_wl.xml
diff --git a/wayland_adapter/BUILD.gn b/wayland_adapter/BUILD.gn
deleted file mode 100644
index 1eca5ddfd8d6459e18117a242bcfcba93fd4d1ab..0000000000000000000000000000000000000000
--- a/wayland_adapter/BUILD.gn
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright (c) 2023 Huawei Technologies 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.
-
-import("//build/gn/fangtian.gni")
-import("//config.gni")
-
-config("libwayland_adapter_config") {
- visibility = [ ":*" ]
-
- cflags = [
- "-Wno-c++11-narrowing",
- "-Wno-c++20-extensions",
- ]
-
- include_dirs = [
- "utils",
- "/usr/include",
- ]
-}
-
-ft_shared_library("libwayland_adapter") {
- defines = ft_defines
-
- sources = [ "wayland_server.cpp" ]
-
- configs = [ ":libwayland_adapter_config" ]
-
- libs = [ "wayland-server" ]
-
- deps = [
- "//build/gn/configs/system_libs:hilog",
- "//build/gn/configs/system_libs:safwk",
- "//display_server/drivers/hal/base:ft_event_loop",
- "//wayland_adapter/framework:wayland_framewok_sources",
- "//wayland_adapter/utils:wayland_adapter_utils_sources",
- "//wayland_adapter/wayland_protocols:wayland_protocols_sources",
- ]
-}
diff --git a/wayland_adapter/framework/BUILD.gn b/wayland_adapter/framework/BUILD.gn
deleted file mode 100644
index cd729989e9ef5a4f8407c9f4d2ad996669659d54..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/BUILD.gn
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright (c) 2023 Huawei Technologies 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.
-
-import("//build/gn/fangtian.gni")
-import("//config.gni")
-import("//display_server/ft_build/ds_config.gni")
-
-config("wayland_framework_public_config") {
- include_dirs = [
- "core",
- "stable",
- "unstable",
- ]
-}
-
-ft_source_set("wayland_framewok_sources") {
- sources = [
- "core/wayland_compositor.cpp",
- "core/wayland_seat.cpp",
- "core/wayland_surface.cpp",
- "core/wayland_region.cpp",
- "core/wayland_pointer.cpp",
- "core/wayland_keyboard.cpp",
- "core/wayland_output.cpp",
- "core/wayland_subcompositor.cpp",
- "core/wayland_subsurface.cpp",
- "core/wayland_data_device_manager.cpp",
- "core/wayland_data_device.cpp",
- "core/wayland_data_source.cpp",
- "core/wayland_data_offer.cpp",
- ]
-
- sources += [
- "stable/wayland_xdg_surface.cpp",
- "stable/wayland_xdg_toplevel.cpp",
- "stable/wayland_xdg_wm_base.cpp",
- "stable/wayland_xdg_popup.cpp",
- "stable/wayland_xdg_positioner.cpp",
- ]
-
- sources += [
- "unstable/wayland_zxdg_output_manager_v1.cpp",
- "unstable/wayland_zxdg_output_v1.cpp",
- ]
-
- public_configs = [ ":wayland_framework_public_config" ]
-
- if (ds_enable_gpu) {
- defines = [ "ENABLE_GPU" ]
- }
-
- deps = [
- "$window_manager_path/dm/ft_build:libdm",
- "$window_manager_path/wm/ft_build:libwm",
- "$display_server_root/rosen/modules/render_service_base/ft_build:librender_service_base",
- "$display_server_root/rosen/modules/render_service_client/ft_build:librender_service_client",
- "//build/gn/configs/system_libs:hilog",
- "//build/gn/configs/system_libs:image",
- "//build/gn/configs/system_libs:mmi",
- "//display_server/drivers/hal/base:ft_event_loop",
- "//wayland_adapter/utils:wayland_adapter_utils_sources",
- "//wayland_adapter/wayland_protocols:wayland_protocols_sources",
- ]
-}
diff --git a/wayland_adapter/framework/core/wayland_compositor.cpp b/wayland_adapter/framework/core/wayland_compositor.cpp
deleted file mode 100644
index 8772b0f2995e91fc4165d0450f90cec38d3cd271..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_compositor.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include "wayland_compositor.h"
-
-#include "wayland_surface.h"
-#include "wayland_objects_pool.h"
-#include "version.h"
-#include "wayland_region.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandCompositor"};
-}
-
-struct wl_compositor_interface IWaylandCompositor::impl_ = {
- .create_surface = CreateSurface,
- .create_region = CreateRegion};
-
-void IWaylandCompositor::CreateSurface(struct wl_client *client, struct wl_resource *resource, uint32_t id)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandCompositorObject, resource,
- "IWaylandCompositor::CreateSurface: failed to find object.", CreateSurface, client, resource, id);
-}
-
-void IWaylandCompositor::CreateRegion(struct wl_client *client, struct wl_resource *resource, uint32_t id)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandCompositorObject, resource,
- "IWaylandCompositor::CreateRegion: failed to find object.", CreateRegion, client, resource, id);
-}
-
-OHOS::sptr WaylandCompositor::Create(struct wl_display *display)
-{
- if (display == nullptr) {
- LOG_ERROR("display is nullptr");
- return nullptr;
- }
-
- return OHOS::sptr(new WaylandCompositor(display));
-}
-
-WaylandCompositor::WaylandCompositor(struct wl_display *display)
- : WaylandGlobal(display, &wl_compositor_interface, WL_COMPOSITOR_MAX_VERSION) {}
-
-WaylandCompositor::~WaylandCompositor() noexcept {}
-
-void WaylandCompositor::Bind(struct wl_client *client, uint32_t version, uint32_t id)
-{
- auto object = OHOS::sptr(new WaylandCompositorObject(client, version, id));
- if (object == nullptr) {
- LOG_ERROR("no memory");
- return;
- }
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(object->WlClient(), object->Id()), object);
-}
-
-WaylandCompositorObject::WaylandCompositorObject(struct wl_client *client, uint32_t version, uint32_t id)
- : WaylandResourceObject(client, &wl_compositor_interface, version, id, &IWaylandCompositor::impl_) {}
-
-WaylandCompositorObject::~WaylandCompositorObject() noexcept {}
-
-void WaylandCompositorObject::CreateSurface(struct wl_client *client, struct wl_resource *resource, uint32_t id)
-{
- auto surface = WaylandSurface::Create(client, resource, wl_resource_get_version(resource), id);
- if (surface == nullptr) {
- LOG_ERROR("no memory");
- return;
- }
-}
-
-void WaylandCompositorObject::CreateRegion(struct wl_client *client, struct wl_resource *resource, uint32_t id)
-{
- auto region = WaylandRegion::Create(client, resource, wl_resource_get_version(resource), id);
- if (region == nullptr) {
- LOG_ERROR("no memory");
- return;
- }
-}
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_compositor.h b/wayland_adapter/framework/core/wayland_compositor.h
deleted file mode 100644
index 29e66e4cd3559997197d478436ef268c12c16fe4..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_compositor.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include "wayland_global.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandCompositor {
- static void CreateSurface(struct wl_client *client, struct wl_resource *resource, uint32_t id);
- static void CreateRegion(struct wl_client *client, struct wl_resource *resource, uint32_t id);
- static struct wl_compositor_interface impl_;
-};
-
-class WaylandCompositor final : public WaylandGlobal {
- friend struct IWaylandCompositor;
-
-public:
- static OHOS::sptr Create(struct wl_display *display);
- ~WaylandCompositor() noexcept override;
-
-private:
- WaylandCompositor(struct wl_display *display);
- void Bind(struct wl_client *client, uint32_t version, uint32_t id) override;
-};
-
-class WaylandCompositorObject final : public WaylandResourceObject {
- friend struct IWaylandCompositor;
-
-public:
- WaylandCompositorObject(struct wl_client *client, uint32_t version, uint32_t id);
- ~WaylandCompositorObject() noexcept;
-
-private:
- void CreateSurface(struct wl_client *client, struct wl_resource *resource, uint32_t id);
- void CreateRegion(struct wl_client *client, struct wl_resource *resource, uint32_t id);
-};
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_data_device.cpp b/wayland_adapter/framework/core/wayland_data_device.cpp
deleted file mode 100644
index d5ab3e9f83a9c428ee189a61439d01aa58218b57..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_data_device.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include "wayland_data_device.h"
-#include "wayland_objects_pool.h"
-#include "wayland_data_source.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandDataDevice"};
-}
-struct wl_data_device_interface IWaylandDataDeviceInterface::impl_ = {
- .start_drag = StartDrag,
- .set_selection = SetSelection,
- .release = Release,
-};
-
-void IWaylandDataDeviceInterface::StartDrag(
- struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *source,
- struct wl_resource *origin,
- struct wl_resource *icon,
- uint32_t serial)
-{
- LOG_DEBUG(" Request: wl_data_device-->start_drag.");
- UNUSED(client);
- CAST_OBJECT_AND_CALL_FUNC(
- WaylandDataDevice,
- resource,
- "IWaylandDataDeviceInterface::StartDrag: failed to find object.",
- StartDrag,
- source,
- origin,
- icon,
- serial);
-}
-
-void IWaylandDataDeviceInterface::SetSelection(
- struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *source,
- uint32_t serial)
-{
- LOG_DEBUG("Request: wl_data_device-->set_selection.");
- UNUSED(client);
- CAST_OBJECT_AND_CALL_FUNC(
- WaylandDataDevice,
- resource,
- "IWaylandDataDeviceInterface::SetSelection: failed to find object.",
- SetSelection,
- source,
- serial);
-}
-
-void IWaylandDataDeviceInterface::Release(struct wl_client *client, struct wl_resource *resource)
-{
- LOG_DEBUG("Request: wl_data_device-->release.");
- UNUSED(client);
- CAST_OBJECT_AND_CALL_FUNC(
- WaylandDataDevice, resource, "IWaylandDataDeviceInterface::Release: failed to find object.", Release);
-}
-
-OHOS::sptr WaylandDataDevice::Create(
- struct wl_client *client,
- uint32_t version,
- uint32_t id,
- struct wl_resource *seat)
-{
- if (client == nullptr) {
- return nullptr;
- }
-
- auto dataDevice = OHOS::sptr(new WaylandDataDevice(client, version, id, seat));
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(dataDevice->WlClient(), dataDevice->Id()), dataDevice);
- return dataDevice;
-}
-
-WaylandDataDevice::WaylandDataDevice(struct wl_client *client, uint32_t version, uint32_t id, struct wl_resource *seat)
- : WaylandResourceObject(client, &wl_data_device_interface, version, id, &IWaylandDataDeviceInterface::impl_),
- seatResource_(seat)
-{
- LOG_DEBUG("WaylandDataSource ctor.");
-}
-
-WaylandDataDevice::~WaylandDataDevice() noexcept
-{
- LOG_DEBUG("WaylandDataDevice dtor.");
-}
-
-void WaylandDataDevice::StartDrag(
- struct wl_resource *source,
- struct wl_resource *origin,
- struct wl_resource *icon,
- uint32_t serial)
-{
- LOG_DEBUG("WaylandDataDevice StartDrag.");
-}
-
-int32_t WaylandDataDevice::PointerStartDrag(
- OHOS::sptr pointer,
- OHOS::sptr dataSource,
- OHOS::sptr iconSurface,
- uint32_t serial)
-{
- // pointer clear focus
- wl_pointer_send_leave(pointer->WlResource(), serial, iconSurface->WlResource());
- if (wl_resource_get_version(pointer->WlResource()) >= WL_POINTER_FRAME_SINCE_VERSION) {
- wl_pointer_send_frame(pointer->WlResource());
- }
- auto seatResource = CastFromResource((seatResource_));
- if (seatResource) {
- std::list> KeyboardList;
- seatResource->GetChildKeyboard(KeyboardList);
- for (auto& keyboardResourceItem : KeyboardList) {
- wl_keyboard_send_leave(keyboardResourceItem->WlResource(), serial, iconSurface->WlResource());
- }
- }
-
- return 0;
-}
-
-void WaylandDataDevice::SetSelection(struct wl_resource *source, uint32_t serial)
-{
- LOG_DEBUG("WaylandDataDevice SetSelection.");
-}
-
-OHOS::sptr WaylandDataDevice::DataSourceSendOffer(OHOS::sptr source, struct wl_resource *target)
-{
- auto dataOffer = WaylandDataOffer::Create(wl_resource_get_client(target), wl_resource_get_version(target), 0);
- if (dataOffer == nullptr) {
- LOG_ERROR("WaylandDataDevice DataSourceSendOffer failed");
- return nullptr;
- }
- dataOffer->inAsk_ = false;
- dataOffer->dndActions_ = 0;
- dataOffer->preferredDndAction_ = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
- dataOffer->dataSource_ = source;
- wl_data_device_send_data_offer(target, dataOffer->WlResource());
- source->accepted_ = false;
- return dataOffer;
-}
-
-void WaylandDataDevice::Release()
-{
- LOG_DEBUG ("WaylandDataDevice::Release.");
-}
-} // namespace wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_data_device.h b/wayland_adapter/framework/core/wayland_data_device.h
deleted file mode 100644
index 6f0c718fc1940562f04fbeacd89ea2bb5ff77e48..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_data_device.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include
-#include "wayland_resource_object.h"
-#include "wayalnd_utils.h"
-#include "wayland_data_offer.h"
-#include "wayland_pointer.h"
-#include "wayland_surface.h"
-#include "wayland_seat.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandDataDeviceInterface {
- /**
- * start drag-and-drop operation
- *
- * @param source data source for the eventual transfer
- * @param origin surface where the drag originates
- * @param icon drag-and-drop icon surface
- * @param serial serial number of the implicit grab on the origin
- */
- static void StartDrag(
- struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *source,
- struct wl_resource *origin,
- struct wl_resource *icon,
- uint32_t serial);
-
- /**
- * copy data to the selection
- *
- * @param source data source for the selection
- * @param serial serial number of the event that triggered this request
- */
- static void SetSelection(
- struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *source,
- uint32_t serial);
- /**
- * destroy data device
- *
- * @since 2
- */
- static void Release(struct wl_client *client, struct wl_resource *resource);
- static struct wl_data_device_interface impl_;
-};
-
-class WaylandDataDevice final : public WaylandResourceObject {
-public:
- static OHOS::sptr Create(struct wl_client *client, uint32_t version, uint32_t id, struct wl_resource *seat);
- ~WaylandDataDevice() noexcept override;
-
- friend struct IWaylandDataDeviceInterface;
- // IWaylandDataDeviceInterface will call these member functions.
- void StartDrag(struct wl_resource *source, struct wl_resource *origin, struct wl_resource *icon, uint32_t serial);
- void SetSelection(struct wl_resource *source, uint32_t serial);
- void Release();
-
-private:
- WaylandDataDevice(struct wl_client *client, uint32_t version, uint32_t id, struct wl_resource *seat);
- OHOS::sptr DataSourceSendOffer(OHOS::sptr source, struct wl_resource *target);
- int32_t PointerStartDrag(
- OHOS::sptr pointer,
- OHOS::sptr dataSource,
- OHOS::sptr iconSurface,
- uint32_t serial);
- struct wl_resource *seatResource_ = nullptr;
-};
-} // namespace wayland
-} // namespace FT
-
diff --git a/wayland_adapter/framework/core/wayland_data_device_manager.cpp b/wayland_adapter/framework/core/wayland_data_device_manager.cpp
deleted file mode 100644
index 04ab686720bdf4d8ae267da9a6f3acaf7005825d..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_data_device_manager.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include "wayland_data_device_manager.h"
-#include "wayland_objects_pool.h"
-#include "version.h"
-#include "wayland_data_source.h"
-#include "wayland_data_device.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandDataDeviceManager"};
-}
-struct wl_data_device_manager_interface IWaylandDataDeviceManagerInterface::impl_ = {
- .create_data_source = CreateDataSource,
- .get_data_device = GetDataDevice};
-
-void IWaylandDataDeviceManagerInterface::CreateDataSource(struct wl_client *client, struct wl_resource *resource, uint32_t id)
-{
- LOG_DEBUG("Request: wl_data_device_manager-->create_data_source.");
- CAST_OBJECT_AND_CALL_FUNC(
- WaylandDataDeviceManager::WaylandDataDeviceManagerResourceObject,
- resource,
- "IWaylandDataDeviceManagerInterface::CreateDataSource: failed to find object.",
- CreateDataSource,
- client,
- resource,
- id);
-}
-
-void IWaylandDataDeviceManagerInterface::GetDataDevice(
- struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id,
- struct wl_resource *seat)
-{
- LOG_DEBUG("Request: wl_data_device_manager-->get_data_device.");
- CAST_OBJECT_AND_CALL_FUNC(
- WaylandDataDeviceManager::WaylandDataDeviceManagerResourceObject,
- resource,
- "IWaylandDataDeviceManagerInterface::GetDataDevice: failed to find object.",
- GetDataDevice,
- client,
- resource,
- id,
- seat);
-}
-
-OHOS::sptr WaylandDataDeviceManager::Create(struct wl_display *display)
-{
- if (display == nullptr) {
- LOG_ERROR("WaylandDataDeviceManager::Create failed: wl_display is nullptr.");
- return nullptr;
- }
-
- return OHOS::sptr(new WaylandDataDeviceManager(display));
-}
-
-WaylandDataDeviceManager::WaylandDataDeviceManager(struct wl_display *display)
- : WaylandGlobal(display, &wl_data_device_manager_interface, WL_DATA_DEVICE_MANAGER_MAX_VERSION)
-{
- LOG_DEBUG("WaylandDataDeviceManager ctor.");
-}
-
-WaylandDataDeviceManager::~WaylandDataDeviceManager() noexcept
-{
- LOG_DEBUG("WaylandDataDeviceManager dtor.");
-}
-
-void WaylandDataDeviceManager::Bind(struct wl_client *client, uint32_t version, uint32_t id)
-{
- auto object = OHOS::sptr(new WaylandDataDeviceManagerResourceObject(client, version, id));
- if (object == nullptr) {
- LOG_ERROR("WaylandDataDeviceManager Bind failed.");
- return;
- }
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(object->WlClient(), object->Id()), object);
-}
-
-WaylandDataDeviceManager::WaylandDataDeviceManagerResourceObject::WaylandDataDeviceManagerResourceObject(
- struct wl_client *client,
- uint32_t version,
- uint32_t id)
- : WaylandResourceObject(client, &wl_data_device_manager_interface, version, id, &IWaylandDataDeviceManagerInterface::impl_)
-{
- LOG_DEBUG("WaylandDataDeviceManagerResourceObject ctor.");
-}
-
-WaylandDataDeviceManager::WaylandDataDeviceManagerResourceObject::~WaylandDataDeviceManagerResourceObject() noexcept
-{
- LOG_DEBUG("WaylandDataDeviceManagerResourceObject dtor.");
-}
-
-void WaylandDataDeviceManager::WaylandDataDeviceManagerResourceObject::CreateDataSource(
- struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id)
-{
- LOG_DEBUG("CreateDataSource.");
- auto dataSource = WaylandDataSource::Create(client, wl_resource_get_version(resource), id);
- if (dataSource == nullptr) {
- LOG_ERROR("CreateDataSource failed.");
- return;
- }
-}
-
-void WaylandDataDeviceManager::WaylandDataDeviceManagerResourceObject::GetDataDevice(
- struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id,
- struct wl_resource *seat)
-{
- LOG_DEBUG("GetDataDevice.");
- auto dataDevice = WaylandDataDevice::Create(client, wl_resource_get_version(resource), id, seat);
- if (dataDevice == nullptr) {
- LOG_DEBUG("GetDataDevice failed.");
- return;
- }
- if (seat) {
- // auto seatResource = CastFromResource((seat));
- // wl_list_insert(&seatResource->dragResourceList_, wl_resource_get_link(dataDevice->WlResource()));
- } else {
- wl_list_init(wl_resource_get_link(dataDevice->WlResource()));
- }
-}
-} // namespace wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_data_device_manager.h b/wayland_adapter/framework/core/wayland_data_device_manager.h
deleted file mode 100644
index 467ca50c09eadce70c4b535ee3ba19d09aec8ac9..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_data_device_manager.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-
-#include
-#include "wayland_global.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandDataDeviceManagerInterface {
- /**
- * create a new data source
- *
- * Create a new data source.
- * @param id data source to create
- */
- static void CreateDataSource(struct wl_client *client, struct wl_resource *resource, uint32_t id);
- /**
- * create a new data device
- *
- * Create a new data device for a given seat.
- * @param id data device to create
- * @param seat seat associated with the data device
- */
- static void GetDataDevice(
- struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id,
- struct wl_resource *seat);
-
- static struct wl_data_device_manager_interface impl_;
-};
-
-class WaylandDataDeviceManager final : public WaylandGlobal {
-public:
- static OHOS::sptr Create(struct wl_display *display);
- ~WaylandDataDeviceManager() noexcept override;
-
-private:
- WaylandDataDeviceManager(struct wl_display *display);
- class WaylandDataDeviceManagerResourceObject final : public WaylandResourceObject {
- public:
- WaylandDataDeviceManagerResourceObject(struct wl_client *client, uint32_t version, uint32_t id);
- ~WaylandDataDeviceManagerResourceObject() noexcept;
-
- private:
- friend struct IWaylandDataDeviceManagerInterface;
- // IWaylandDataDeviceManagerInterface will call these member functions.
- void CreateDataSource(struct wl_client *client, struct wl_resource *resource, uint32_t id);
- void GetDataDevice(
- struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id,
- struct wl_resource *seat);
- };
- friend struct IWaylandDataDeviceManagerInterface;
-
- void Bind(struct wl_client *client, uint32_t version, uint32_t id) override;
-};
-} // namespace wayland
-} // namespace FT
-
diff --git a/wayland_adapter/framework/core/wayland_data_offer.cpp b/wayland_adapter/framework/core/wayland_data_offer.cpp
deleted file mode 100644
index f7fc60439db5d6e58721e82744a6fc710372495b..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_data_offer.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include "wayland_data_offer.h"
-#include "wayland_objects_pool.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandDataOffer"};
-}
-struct wl_data_offer_interface IWaylandDataOfferInterface::impl_ = {
- .accept = Accept,
- .receive = Receive,
- .destroy = &WaylandResourceObject::DefaultDestroyResource,
- .finish = Finish,
- .set_actions = SetActions,
-};
-
-void IWaylandDataOfferInterface::Accept(
- struct wl_client *client,
- struct wl_resource *resource,
- uint32_t serial,
- const char *mimeType)
-{
- LOG_DEBUG("Request: wl_data_offer-->Accept");
- UNUSED(client);
- CAST_OBJECT_AND_CALL_FUNC(
- WaylandDataOffer, resource, "IWaylandDataOfferInterface::Accept: failed to find object.", Accept, serial, mimeType);
-}
-
-void IWaylandDataOfferInterface::Receive(
- struct wl_client *client,
- struct wl_resource *resource,
- const char *mimeType,
- int32_t fd)
-{
- LOG_DEBUG("Request: wl_data_offer-->Receive");
- UNUSED(client);
- CAST_OBJECT_AND_CALL_FUNC(
- WaylandDataOffer, resource, "IWaylandDataOfferInterface::Receive: failed to find object.", Receive, mimeType, fd);
-}
-
-void IWaylandDataOfferInterface::Finish(struct wl_client *client, struct wl_resource *resource)
-{
- LOG_DEBUG("Request: wl_data_offer-->Finish");
- UNUSED(client);
- CAST_OBJECT_AND_CALL_FUNC(WaylandDataOffer, resource, "IWaylandDataOfferInterface::Finish: failed to find object.", Finish);
-}
-
-void IWaylandDataOfferInterface::SetActions(
- struct wl_client *client,
- struct wl_resource *resource,
- uint32_t dndActions,
- uint32_t preferredAction)
-{
- LOG_DEBUG("Request: wl_data_offer-->SetActions");
- UNUSED(client);
- CAST_OBJECT_AND_CALL_FUNC(
- WaylandDataOffer,
- resource,
- "IWaylandDataOfferInterface::SetActions: failed to find object.",
- SetActions,
- dndActions,
- preferredAction);
-}
-
-OHOS::sptr WaylandDataOffer::Create(struct wl_client *client, uint32_t version, uint32_t id)
-{
- if (client == nullptr) {
- return nullptr;
- }
- auto dataOffer = OHOS::sptr(new WaylandDataOffer(client, version, id));
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(dataOffer->WlClient(), dataOffer->Id()), dataOffer);
- return dataOffer;
-}
-
-WaylandDataOffer::WaylandDataOffer(struct wl_client *client, uint32_t version, uint32_t id)
- : WaylandResourceObject(client, &wl_data_offer_interface, version, id, &IWaylandDataOfferInterface::impl_)
-{
- LOG_DEBUG("WaylandDataOffer ctor.");
-}
-
-WaylandDataOffer::~WaylandDataOffer() noexcept
-{
- LOG_DEBUG("WaylandDataOffer dtor.");
-}
-
-void WaylandDataOffer::Accept(uint32_t serial, const char *mimeType) {}
-
-void WaylandDataOffer::Receive(const char *mimeType, int32_t fd) {}
-
-void WaylandDataOffer::Finish() {}
-
-void WaylandDataOffer::SetActions(uint32_t dndActions, uint32_t preferredAction) {}
-} // namespace wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_data_offer.h b/wayland_adapter/framework/core/wayland_data_offer.h
deleted file mode 100644
index 01291cdbd40e32079b7af46f1dfe859e8ca88c1c..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_data_offer.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include
-#include "wayland_resource_object.h"
-#include "wayalnd_utils.h"
-#include "wayland_data_source.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandDataOfferInterface {
- /**
- *@brief accept one of the offered mime types
- *
- * @param client
- * @param resource
- * @param serial serial number of the accept request
- * @param mimeType mime type accepted by the client
- */
- static void Accept(struct wl_client *client, struct wl_resource *resource, uint32_t serial, const char *mimeType);
- /**
- *@brief request that the data is transferred
- *
- * @param client
- * @param resource
- * @param mimeType mime type desired by receiver
- * @param fd file descriptor for data transfer
- */
- static void Receive(struct wl_client *client, struct wl_resource *resource, const char *mimeType, int32_t fd);
- /**
- * the offer will no longer be used
- *
- * @param client
- * @param resource
- */
- static void Finish(struct wl_client *client, struct wl_resource *resource);
- /**
- * set the available/preferred drag-and-drop actions
- *
- * @param client
- * @param resource
- * @param dndActions actions supported by the destination client
- * @param preferredAction action preferred by the destination client
- */
- static void SetActions(
- struct wl_client *client,
- struct wl_resource *resource,
- uint32_t dndActions,
- uint32_t preferredAction);
- static struct wl_data_offer_interface impl_;
-};
-
-class WaylandDataOffer final : public WaylandResourceObject {
-public:
- static OHOS::sptr Create(struct wl_client *client, uint32_t version, uint32_t id);
- ~WaylandDataOffer() noexcept override;
- friend struct IWaylandDataOfferInterface;
- // IWaylandDataOfferInterface will call these member functions.
- void Accept(uint32_t serial, const char *mimeType);
- void Receive(const char *mimeType, int32_t fd);
- void Finish();
- void SetActions(uint32_t dndActions, uint32_t preferredAction);
-
- OHOS::sptr dataSource_;
- uint32_t dndActions_;
- wl_data_device_manager_dnd_action preferredDndAction_;
- bool inAsk_;
-
-private:
- WaylandDataOffer(struct wl_client *client, uint32_t version, uint32_t id);
-};
-} // namespace wayland
-} // namespace FT
-
diff --git a/wayland_adapter/framework/core/wayland_data_source.cpp b/wayland_adapter/framework/core/wayland_data_source.cpp
deleted file mode 100644
index 3267d0884f47d24efd3b47efc629f8b8b846041c..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_data_source.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include "wayland_data_source.h"
-#include "wayland_objects_pool.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandDataSource"};
-}
-static uint32_t const ALL_ACTIONS =
- (WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY | WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE |
- WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK);
-struct wl_data_source_interface IWaylandDataSourceInterface::impl_ = {
- .offer = Offer,
- .destroy = &WaylandResourceObject::DefaultDestroyResource,
- .set_actions = SetActions,
-};
-
-void IWaylandDataSourceInterface::Offer(struct wl_client *client, struct wl_resource *resource, const char *mimeType)
-{
- LOG_DEBUG("Request: wl_data_source-->Offer.");
- UNUSED(client);
- CAST_OBJECT_AND_CALL_FUNC(
- WaylandDataSource, resource, "IWaylandDataSourceInterface::Offer: failed to find object.", Offer, mimeType);
-}
-
-void IWaylandDataSourceInterface::SetActions(struct wl_client *client, struct wl_resource *resource, uint32_t dndAction)
-{
- LOG_DEBUG("Request: wl_data_source-->SetActions.");
- UNUSED(client);
- CAST_OBJECT_AND_CALL_FUNC(
- WaylandDataSource, resource, "IWaylandDataSourceInterface::SetActions: failed to find object.", SetActions, dndAction);
-}
-
-OHOS::sptr WaylandDataSource::Create(struct wl_client *client, uint32_t version, uint32_t id)
-{
- if (client == nullptr) {
- return nullptr;
- }
-
- auto dataSource = OHOS::sptr(new WaylandDataSource(client, version, id));
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(dataSource->WlClient(), dataSource->Id()), dataSource);
- return dataSource;
-}
-
-WaylandDataSource::WaylandDataSource(struct wl_client *client, uint32_t version, uint32_t id)
- : WaylandResourceObject(client, &wl_data_source_interface, version, id, &IWaylandDataSourceInterface::impl_)
-{
- LOG_DEBUG("WaylandDataSource ctor.");
- actionsSet_ = false;
- selectionSet_ = false;
- dndActions_ = 0;
- currentAndAction_ = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
- compositorAction_ = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
-
- wl_array_init(&mimeTypes_);
-}
-
-WaylandDataSource::~WaylandDataSource() noexcept
-{
- LOG_DEBUG("WaylandDataSource dtor.");
-}
-
-void WaylandDataSource::Offer(const char *mimeType)
-{
- char **p;
- p = static_cast(wl_array_add(&mimeTypes_, sizeof(*p)));
- if (p) {
- *p = strdup(mimeType);
- }
- if (!p || !*p) {
- LOG_DEBUG("WaylandDataSource::Offer nullptr.");
- }
-}
-
-void WaylandDataSource::SetActions(uint32_t dndAction)
-{
- if (actionsSet_) {
- LOG_DEBUG("WaylandDataSource::SetActions: cannot set actions more than once.");
- return;
- }
- if (dndAction & ~ALL_ACTIONS) {
- LOG_DEBUG("WaylandDataSource::SetActions: cannot invalid action mask.");
- }
- dndActions_ = dndAction;
- actionsSet_ = true;
-}
-
-void WaylandDataSource::SetSelectionSet(bool selectionSet)
-{
- selectionSet_ = selectionSet;
-}
-} // namespace wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_data_source.h b/wayland_adapter/framework/core/wayland_data_source.h
deleted file mode 100644
index 3e620ab421d0ba4dc0211cdf14b8cb187d91cdd2..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_data_source.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include
-#include "wayland_resource_object.h"
-#include "wayalnd_utils.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandDataSourceInterface {
- /**
- *@brief Add an offered mime type
- *
- * @param client
- * @param resource
- * @param mimeType mime type offered by the data source
- */
- static void Offer(struct wl_client *client, struct wl_resource *resource, const char *mimeType);
-
- /**
- *@brief Set the available drag-and-drop actions
- *
- * @param client
- * @param resource
- * @param dnd_actions actions supported by the data source
- * @since 3
- */
- static void SetActions(struct wl_client *client, struct wl_resource *resource, uint32_t dndAction);
- static struct wl_data_source_interface impl_;
-};
-
-class WaylandDataSource final : public WaylandResourceObject {
-public:
- static OHOS::sptr Create(struct wl_client *client, uint32_t version, uint32_t id);
- ~WaylandDataSource() noexcept override;
-
- friend struct IWaylandDataSourceInterface;
- // IWaylandDataSourceInterface will call these member functions.
- void Offer(const char *mimeType);
- void SetActions(uint32_t dndAction);
- bool GetActionsSet() const
- {
- return actionsSet_;
- }
- void SetSelectionSet(bool selectionSet);
- bool GetSelectionSet() const
- {
- return selectionSet_;
- }
- struct wl_array mimeTypes_;
- bool accepted_;
- // OHOS::sptr dataOffer_;
-
-private:
- WaylandDataSource(struct wl_client *client, uint32_t version, uint32_t id);
-
- bool actionsSet_;
- bool selectionSet_;
- uint32_t dndActions_;
- enum wl_data_device_manager_dnd_action currentAndAction_;
- enum wl_data_device_manager_dnd_action compositorAction_;
-};
-} // namespace wayland
-} // namespace FT
-
diff --git a/wayland_adapter/framework/core/wayland_keyboard.cpp b/wayland_adapter/framework/core/wayland_keyboard.cpp
deleted file mode 100644
index d0167597118232cad4bd0443a24f8870ac725032..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_keyboard.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include "wayland_keyboard.h"
-
-#include "version.h"
-#include "wayland_objects_pool.h"
-#include "wayland_keycode_trans.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandKeyboard"};
-}
-
-struct wl_keyboard_interface IWaylandKeyboard::impl_ = {
- .release = WaylandResourceObject::DefaultDestroyResource,
-};
-
-OHOS::sptr WaylandKeyboard::Create(struct wl_client *client, uint32_t version, uint32_t id)
-{
- if (client == nullptr) {
- return nullptr;
- }
-
- auto keyboard = OHOS::sptr(new WaylandKeyboard(client, version, id));
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(keyboard->WlClient(), keyboard->Id()), keyboard);
-
- return keyboard;
-}
-
-void WaylandKeyboard::OnKeyboardKey(int32_t key, int32_t state, uint32_t time)
-{
- wl_resource *keyboard = WlResource();
- if (keyboard == nullptr) {
- return;
- }
- wl_display *display = WlDisplay();
- if (display == nullptr) {
- return;
- }
- uint32_t serial = wl_display_next_serial(display);
- int32_t newKey = TransferKeyValue(key);
- if (newKey == -1) {
- LOG_ERROR("unknow keycode: %{public}u", key);
- return;
- }
- wl_keyboard_send_key(keyboard, serial, time, newKey, state);
-}
-
-void WaylandKeyboard::OnKeyboardEnter(struct wl_resource *surface_resource)
-{
- wl_display *display = WlDisplay();
- if (display == nullptr) {
- return;
- }
- uint32_t serial = wl_display_next_serial(display);
- wl_resource *keyboard = WlResource();
- if (keyboard == nullptr) {
- return;
- }
- struct wl_array keys = {};
- wl_keyboard_send_enter(keyboard, serial, surface_resource, &keys);
-}
-
-void WaylandKeyboard::OnKeyboardLeave(struct wl_resource *surface_resource)
-{
- wl_display *display = WlDisplay();
- if (display == nullptr) {
- return;
- }
- uint32_t serial = wl_display_next_serial(display);
- wl_resource *keyboard = WlResource();
- if (keyboard == nullptr) {
- return;
- }
- wl_keyboard_send_leave(keyboard, serial, surface_resource);
-}
-
-WaylandKeyboard::WaylandKeyboard(struct wl_client *client, uint32_t version, uint32_t id)
- : WaylandResourceObject(client, &wl_keyboard_interface, version, id, &IWaylandKeyboard::impl_)
-{
- LOG_DEBUG("WaylandKeyboard create, this=%{public}p", this);
-}
-
-WaylandKeyboard::~WaylandKeyboard() noexcept
-{
- LOG_DEBUG("WaylandKeyboard release, this=%{public}p", this);
-}
-} // namespace Wayland
-} // namespace FT
\ No newline at end of file
diff --git a/wayland_adapter/framework/core/wayland_keyboard.h b/wayland_adapter/framework/core/wayland_keyboard.h
deleted file mode 100644
index b9fced1bacf87cd155a53877f4b5ecaf1abca385..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_keyboard.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include "wayland_resource_object.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandKeyboard {
- static struct wl_keyboard_interface impl_;
-};
-
-class WaylandKeyboard final : public WaylandResourceObject {
- friend struct IWaylandKeyboard;
-
-public:
- static OHOS::sptr Create(struct wl_client *client, uint32_t version, uint32_t id);
- ~WaylandKeyboard() noexcept override;
-
- void OnKeyboardKey(int32_t key, int32_t state, uint32_t time);
- void OnKeyboardEnter(struct wl_resource *surface_resource);
- void OnKeyboardLeave(struct wl_resource *surface_resource);
-
-
-private:
- WaylandKeyboard(struct wl_client *client, uint32_t version, uint32_t id);
-};
-} // namespace Wayland
-} // namespace FT
\ No newline at end of file
diff --git a/wayland_adapter/framework/core/wayland_output.cpp b/wayland_adapter/framework/core/wayland_output.cpp
deleted file mode 100644
index 9bbd8a3a9b2a849d8bd27a6d5968db28a6601391..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_output.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-#include "wayland_output.h"
-#include "wayland_objects_pool.h"
-#include "version.h"
-#include "display_manager.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandOutput"};
-}
-struct wl_output_interface IWaylandOutput::impl_ = {.release = &WaylandResourceObject::DefaultDestroyResource};
-
-OHOS::sptr WaylandOutput::Create(struct wl_display *display)
-{
- if (display == nullptr) {
- LOG_ERROR("display nullptr");
- return nullptr;
- }
-
- return OHOS::sptr(new WaylandOutput(display));
-}
-
-WaylandOutput::WaylandOutput(struct wl_display *display)
- : WaylandGlobal(display, &wl_output_interface, WL_OUTPUT_MAX_VERSION)
-{
-}
-
-WaylandOutput::~WaylandOutput() noexcept
-{
-}
-
-void WaylandOutput::Send(const OHOS::sptr &output)
-{
- if (output == nullptr) {
- return;
- }
- wl_output_send_geometry(
- output->WlResource(), 0, 0, 0, 0, 0, "fangtian", "unknown", 0);
-
- wl_output_send_scale(output->WlResource(), 1);
- auto defaultDisplay = OHOS::Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
- auto displays = OHOS::Rosen::DisplayManager::GetInstance().GetAllDisplays();
- for (auto &dis : displays) {
- if (dis == nullptr) {
- continue;
- }
- uint32_t flags = 0;
- if (dis == defaultDisplay) {
- flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
- }
- constexpr int32_t rateFactor = 1000;
- wl_output_send_mode(output->WlResource(), flags, dis->GetWidth(), dis->GetHeight(),
- dis->GetRefreshRate() * rateFactor);
- }
- wl_output_send_done(output->WlResource());
-}
-
-void WaylandOutput::Bind(struct wl_client *client, uint32_t version, uint32_t id)
-{
- auto object = OHOS::sptr(new WaylandOutputObject(client, version, id));
- if (object == nullptr) {
- LOG_ERROR("no memory");
- return;
- }
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(object->WlClient(), object->Id()), object);
-
- Send(object);
-}
-
-WaylandOutputObject::WaylandOutputObject(struct wl_client *client, uint32_t version, uint32_t id)
- : WaylandResourceObject(client, &wl_output_interface, version, id, &IWaylandOutput::impl_)
-{
-}
-
-WaylandOutputObject::~WaylandOutputObject() noexcept
-{
-}
-
-} // Wayland
-} // FT
\ No newline at end of file
diff --git a/wayland_adapter/framework/core/wayland_output.h b/wayland_adapter/framework/core/wayland_output.h
deleted file mode 100644
index 309238e5c4ba93071341f668880d1ec3cd0d8b8e..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_output.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include "wayland_global.h"
-#include
-
-namespace FT {
-namespace Wayland {
-
-struct IWaylandOutput {
- static struct wl_output_interface impl_;
-};
-
-class WaylandOutput final : public WaylandGlobal {
-public:
- static OHOS::sptr Create(struct wl_display *display);
- ~WaylandOutput() noexcept override;
- void Send(const OHOS::sptr &output);
-
-private:
- WaylandOutput(struct wl_display *display);
- void Bind(struct wl_client *client, uint32_t version, uint32_t id) override;
-
-};
-
-class WaylandOutputObject final : public WaylandResourceObject {
-public:
- WaylandOutputObject(struct wl_client *client, uint32_t version, uint32_t id);
- ~WaylandOutputObject() noexcept;
-};
-} // namespace Wayland
-} // namespace FT
\ No newline at end of file
diff --git a/wayland_adapter/framework/core/wayland_pointer.cpp b/wayland_adapter/framework/core/wayland_pointer.cpp
deleted file mode 100644
index 94e0bbd1f31ca4082894b731458c19bec117b72e..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_pointer.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include "wayland_pointer.h"
-
-#include "version.h"
-#include "wayland_objects_pool.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandPointer"};
-}
-
-struct wl_pointer_interface IWaylandPointer::impl_ = {
- .set_cursor = SetCursor,
- .release = WaylandResourceObject::DefaultDestroyResource,
-};
-
-void IWaylandPointer::SetCursor(struct wl_client *client, struct wl_resource *resource,
- uint32_t serial, struct wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandPointer, resource, "IWaylandPointer::SetCursor: failed to find object.",
- SetCursor, serial, surface, hotspot_x, hotspot_y);
-}
-
-OHOS::sptr WaylandPointer::Create(struct wl_client *client, uint32_t version, uint32_t id)
-{
- if (client == nullptr) {
- return nullptr;
- }
-
- auto pointer = OHOS::sptr(new WaylandPointer(client, version, id));
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(pointer->WlClient(), pointer->Id()), pointer);
-
- return pointer;
-}
-
-WaylandPointer::WaylandPointer(struct wl_client *client, uint32_t version, uint32_t id)
- : WaylandResourceObject(client, &wl_pointer_interface, version, id, &IWaylandPointer::impl_)
-{
- LOG_DEBUG("WaylandPointer create, this=%{public}p", this);
-}
-
-WaylandPointer::~WaylandPointer() noexcept
-{
- LOG_DEBUG("WaylandPointer release, this=%{public}p", this);
-}
-
-void WaylandPointer::OnPointerButton(uint32_t time, uint32_t button, bool isPressed)
-{
- wl_resource *pointer = WlResource();
- if (pointer == nullptr) {
- return;
- }
- wl_display *display = WlDisplay();
- if (display == nullptr) {
- return;
- }
- uint32_t serial = wl_display_next_serial(display);
- uint32_t state = isPressed ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED;
- wl_pointer_send_button(pointer, serial, time, button, state);
- wl_pointer_send_frame(pointer);
-}
-
-void WaylandPointer::OnPointerMotionAbsolute(uint32_t time, int32_t posX, int32_t posY)
-{
- wl_fixed_t posFixedX = wl_fixed_from_int(posX);
- wl_fixed_t posFixedY = wl_fixed_from_int(posY);
- wl_resource *pointer = WlResource();
- if (pointer == nullptr) {
- return;
- }
-
- wl_pointer_send_motion(pointer, time, posFixedX, posFixedY);
- wl_pointer_send_frame(pointer);
-}
-
-void WaylandPointer::OnPointerLeave(struct wl_resource *surface_resource)
-{
- wl_display *display = WlDisplay();
- if (display == nullptr) {
- return;
- }
- uint32_t serial = wl_display_next_serial(display);
- wl_resource *pointer = WlResource();
- if (pointer == nullptr) {
- return;
- }
- wl_pointer_send_leave(pointer, serial, surface_resource);
- wl_pointer_send_frame(pointer);
-}
-
-void WaylandPointer::OnPointerEnter(int32_t posX, int32_t posY, struct wl_resource *surface_resource)
-{
- wl_fixed_t posFixedX = wl_fixed_from_int(posX);
- wl_fixed_t posFixedY = wl_fixed_from_int(posY);
- wl_resource *pointer = WlResource();
- if (pointer == nullptr) {
- return;
- }
- wl_display *display = WlDisplay();
- if (display == nullptr) {
- return;
- }
- uint32_t serial = wl_display_next_serial(display);
- wl_pointer_send_enter(pointer, serial, surface_resource, posFixedX, posFixedY);
- wl_pointer_send_frame(pointer);
-}
-
-void WaylandPointer::SetCursor(uint32_t serial, struct wl_resource *surface, int32_t hotsPotx, int32_t hotsPoty)
-{
- std::lock_guard lock(mutex_);
- cursorSurface_ = surface;
-}
-
-bool WaylandPointer::IsCursorSurface(struct wl_resource *surface)
-{
- std::lock_guard lock(mutex_);
- if (cursorSurface_ == nullptr || surface == nullptr) {
- return false;
- }
- return cursorSurface_ == surface ? true : false;
-}
-
-} // namespace Wayland
-} // namespace FT
\ No newline at end of file
diff --git a/wayland_adapter/framework/core/wayland_pointer.h b/wayland_adapter/framework/core/wayland_pointer.h
deleted file mode 100644
index 901026f66193a5d3e7de81ab6bff9dcd79c6d78b..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_pointer.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include
-#include "wayland_resource_object.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandPointer {
- static void SetCursor(struct wl_client *client, struct wl_resource *resource,
- uint32_t serial, struct wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y);
- static struct wl_pointer_interface impl_;
-};
-
-class WaylandPointer final : public WaylandResourceObject {
- friend struct IWaylandPointer;
-
-public:
- static OHOS::sptr Create(struct wl_client *client, uint32_t version, uint32_t id);
- ~WaylandPointer() noexcept override;
-
- void OnPointerLeave(struct wl_resource *surface_resource);
- void OnPointerEnter(int32_t posX, int32_t posY, struct wl_resource *surface_resource);
- void OnPointerButton(uint32_t time, uint32_t button, bool isPressed);
- void OnPointerMotionAbsolute(uint32_t time, int32_t posX, int32_t posY);
- bool IsCursorSurface(struct wl_resource *surface);
-
-private:
- WaylandPointer(struct wl_client *client, uint32_t version, uint32_t id);
- void SetCursor(uint32_t serial, struct wl_resource *surface, int32_t hotsPotx, int32_t hotsPoty);
- struct wl_resource *cursorSurface_ = nullptr;
- mutable std::mutex mutex_;
-};
-} // namespace Wayland
-} // namespace FT
\ No newline at end of file
diff --git a/wayland_adapter/framework/core/wayland_region.cpp b/wayland_adapter/framework/core/wayland_region.cpp
deleted file mode 100644
index 0cf3b5d5ff5e30fce830363871f37f2e0e45fad5..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_region.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include "wayland_region.h"
-#include "wayland_objects_pool.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandRegion"};
-}
-
-struct wl_region_interface IWaylandRegion::impl_ = {
- .destroy = &WaylandResourceObject::DefaultDestroyResource,
- .add = Add,
- .subtract = Subtract};
-
-void IWaylandRegion::Add(struct wl_client *client, struct wl_resource *resource,
- int32_t x, int32_t y, int32_t width, int32_t height)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandRegion, resource,
- "IWaylandRegion::Add: failed to find object.", Add, x, y, width, height);
-}
-
-void IWaylandRegion::Subtract(struct wl_client *client, struct wl_resource *resource,
- int32_t x, int32_t y, int32_t width, int32_t height)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandRegion, resource,
- "IWaylandRegion::Subtract: failed to find object.", Subtract, x, y, width, height);
-}
-
-OHOS::sptr WaylandRegion::Create(struct wl_client *client,
- struct wl_resource *parent, uint32_t version, uint32_t id)
-{
- if (client == nullptr) {
- return nullptr;
- }
-
- auto region = OHOS::sptr(new WaylandRegion(client, parent, version, id));
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(region->WlClient(), region->Id()), region);
- return region;
-}
-
-WaylandRegion::WaylandRegion(struct wl_client *client, struct wl_resource *parent, uint32_t version, uint32_t id)
- : WaylandResourceObject(client, &wl_region_interface, version, id, &IWaylandRegion::impl_),
- parent_(parent) {}
-
-WaylandRegion::~WaylandRegion() noexcept {}
-
-void WaylandRegion::Add(int32_t x, int32_t y, int32_t width, int32_t height)
-{
- LOG_DEBUG("WaylandRegion::Add, cover");
- rect_.x = x;
- rect_.y = y;
- rect_.width = width;
- rect_.height = height;
-}
-
-void WaylandRegion::Subtract(int32_t x, int32_t y, int32_t width, int32_t height)
-{
- LOG_DEBUG("WaylandRegion::Subtract, ignore");
-}
-
-Rect WaylandRegion::GetRect()
-{
- return rect_;
-}
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_region.h b/wayland_adapter/framework/core/wayland_region.h
deleted file mode 100644
index 270795eae3e9cb9870072aeb155a4966aefef853..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_region.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include
-#include
-#include "wayland_resource_object.h"
-#include "wayalnd_utils.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandRegion {
- static void Destroy(struct wl_client *client, struct wl_resource *resource);
- static void Add(struct wl_client *client, struct wl_resource *resource,
- int32_t x, int32_t y, int32_t width, int32_t height);
- static void Subtract(struct wl_client *client, struct wl_resource *resource,
- int32_t x, int32_t y, int32_t width, int32_t height);
- static struct wl_region_interface impl_;
-};
-
-class WaylandRegion final : public WaylandResourceObject {
- friend struct IWaylandRegion;
-
-public:
- static OHOS::sptr Create(struct wl_client *client, struct wl_resource *parent,
- uint32_t version, uint32_t id);
- ~WaylandRegion() noexcept override;
-
- Rect GetRect();
-
-private:
- WaylandRegion(struct wl_client *client, struct wl_resource *parent, uint32_t version, uint32_t id);
-
- void Destroy(struct wl_client *client, struct wl_resource *resource);
- void Add(int32_t x, int32_t y, int32_t width, int32_t height);
- void Subtract(int32_t x, int32_t y, int32_t width, int32_t height);
-
- struct wl_resource *parent_ = nullptr;
- Rect rect_;
-};
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_seat.cpp b/wayland_adapter/framework/core/wayland_seat.cpp
deleted file mode 100644
index 1b45c473de6d451729f75a14fc2659aa82fc7ecf..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_seat.cpp
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include
-#include "wayland_seat.h"
-
-#include "wayland_objects_pool.h"
-#include "version.h"
-#include "input_manager.h"
-#include
-
-using namespace OHOS::MMI;
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandSeat"};
-}
-
-static OHOS::sptr wl_seat_global = nullptr;
-std::mutex wl_seat_global_mutex_;
-
-struct wl_seat_interface IWaylandSeat::impl_ = {
- .get_pointer = GetPointer,
- .get_keyboard = GetKeyboard,
- .get_touch = GetTouch,
- .release = WaylandResourceObject::DefaultDestroyResource,};
-
-void IWaylandSeat::GetPointer(struct wl_client *client, struct wl_resource *resource, uint32_t id)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSeatObject, resource,
- "IWaylandSeat::GetPointer: failed to find object.", GetPointer, id);
-}
-
-void IWaylandSeat::GetKeyboard(struct wl_client *client, struct wl_resource *resource, uint32_t id)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSeatObject, resource,
- "IWaylandSeat::GetKeyboard: failed to find object.", GetKeyboard, id);
-}
-
-void IWaylandSeat::GetTouch(struct wl_client *client, struct wl_resource *resource, uint32_t id)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSeatObject, resource,
- "IWaylandSeat::GetTouch: failed to find object.", GetTouch, id);
-}
-
-OHOS::sptr WaylandSeat::Create(struct wl_display *display)
-{
- std::lock_guard lock(wl_seat_global_mutex_);
- if (display == nullptr) {
- LOG_ERROR("display is nullptr");
- return nullptr;
- }
-
- if (wl_seat_global != nullptr) {
- return wl_seat_global;
- }
-
- wl_seat_global = OHOS::sptr(new WaylandSeat(display));
- return wl_seat_global;
-}
-
-OHOS::sptr WaylandSeat::GetWaylandSeatGlobal()
-{
- std::lock_guard lock(wl_seat_global_mutex_);
- return wl_seat_global;
-}
-
-void WaylandSeat::FreeSeatResource(struct wl_client *client, struct wl_resource *resource)
-{
- std::lock_guard lock(seatResourcesMutex_);
- auto iter = seatResourcesMap_.find(client);
- if (iter == seatResourcesMap_.end()) {
- return;
- }
-
- auto seatObjectList = &iter->second;
- for (auto itr = seatObjectList->begin(); itr != seatObjectList->end(); itr++) {
- if ((*itr)->WlResource() == resource) {
- seatObjectList->erase(itr);
- break;
- }
- }
- if (seatResourcesMap_[client].empty()) {
- seatResourcesMap_.erase(client);
- }
-}
-
-WaylandSeat::WaylandSeat(struct wl_display *display)
- : WaylandGlobal(display, &wl_seat_interface, WL_SEAT_MAX_VERSION) {}
-
-WaylandSeat::~WaylandSeat() noexcept
-{
- if (thread_ != nullptr) {
- if (thread_->joinable()) {
- thread_->join();
- }
- thread_ = nullptr;
- }
-}
-
-void WaylandSeat::Bind(struct wl_client *client, uint32_t version, uint32_t id)
-{
- auto object = OHOS::sptr(new WaylandSeatObject(client, version, id));
- if (object == nullptr) {
- LOG_ERROR("no memory");
- return;
- }
-
- std::lock_guard lock(seatResourcesMutex_);
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(object->WlClient(), object->Id()), object);
- seatResourcesMap_[client].emplace_back(object);
-
- if (thread_ != nullptr) {
- if (thread_->joinable()) {
- thread_->join();
- }
- thread_ = nullptr;
- }
- thread_ = std::make_unique(&WaylandSeat::UpdateCapabilities, object->WlResource());
-}
-
-void WaylandSeat::GetKeyboardResource(struct wl_client *client, std::list>& list)
-{
- std::lock_guard lock(seatResourcesMutex_);
- auto iter = seatResourcesMap_.find(client);
- if (iter == seatResourcesMap_.end()) {
- return;
- }
-
- /* A wl_client object maybe has many seatResourceObjects, each seatResourceObject maybe has many keyboardResourceObjects
- * so we need get all keyboardResourceObjects in this wl_client object.
- */
- auto seatList = iter->second;
- for (auto& seatResourceItem : seatList) {
- std::list> KeyboardList;
- seatResourceItem->GetChildKeyboard(KeyboardList);
- if (KeyboardList.empty()) {
- continue;
- }
- for (auto& keyboardResourceItem : KeyboardList) {
- list.emplace_back(keyboardResourceItem);
- }
- }
-}
-
-void WaylandSeat::GetPointerResource(struct wl_client *client, std::list>& list)
-{
- std::lock_guard lock(seatResourcesMutex_);
- auto iter = seatResourcesMap_.find(client);
- if (iter == seatResourcesMap_.end()) {
- return;
- }
-
- /* A wl_client object maybe has many seatResourceObjects, each seatResourceObject maybe has many pointerResourceObjects
- * so we need get all pointerResourceObjects in this wl_client object.
- */
- auto seatList = iter->second;
- for (auto& seatResourceItem : seatList) {
- std::list> pointerList;
- seatResourceItem->GetChildPointer(pointerList);
- if (pointerList.empty()) {
- continue;
- }
- for (auto& pointerResourceItem : pointerList) {
- list.emplace_back(pointerResourceItem);
- }
- }
-}
-
-void WaylandSeat::UpdateCapabilities(struct wl_resource *resource)
-{
- LOG_INFO("UpdateCapabilities in");
- uint32_t cap = 0;
- int32_t DevNums = 0;
- int32_t hasGetDevNums = 0;
- bool isGetIds = false;
- int32_t wait_count = 0;
-
- auto GetDeviceCb = [&hasGetDevNums, &cap](std::shared_ptr inputDevice) {
- LOG_INFO("Get device success, id=%{public}d, name=%{public}s, type=%{public}d",
- inputDevice->GetId(), inputDevice->GetName().c_str(), inputDevice->GetType());
- if (inputDevice->GetType() == (int32_t)DEVICE_TYPE_MOUSE) {
- cap |= WL_SEAT_CAPABILITY_POINTER;
- } else if (inputDevice->GetType() == (int32_t)DEVICE_TYPE_KEYBOARD) {
- cap |= WL_SEAT_CAPABILITY_KEYBOARD;
- }
- hasGetDevNums++;
- };
- auto GetDeviceIdsCb = [&DevNums, &isGetIds](std::vector ids) {
- DevNums = ids.size();
- isGetIds = true;
- };
- (void)InputManager::GetInstance()->GetDeviceIds(GetDeviceIdsCb);
- while (!isGetIds && wait_count < 100) {
- usleep(3 * 1000); // wait for GetDeviceIdsCb finish
- wait_count++;
- }
-
- for (int32_t i = 0; i < DevNums; i++) {
- InputManager::GetInstance()->GetDevice(i, GetDeviceCb);
- }
-
- wait_count = 0;
- while (hasGetDevNums != DevNums && wait_count < 100) {
- usleep(3 * 1000); // wait for GetDeviceCb finish
- wait_count++;
- }
- wl_seat_send_capabilities(resource, cap);
-}
-
-WaylandSeatObject::WaylandSeatObject(struct wl_client *client, uint32_t version, uint32_t id)
- : WaylandResourceObject(client, &wl_seat_interface, version, id, &IWaylandSeat::impl_)
-{
- LOG_DEBUG("WaylandSeatObject create, this=%{public}p, id=%{public}u", this, id);
-}
-
-void WaylandSeatObject::OnResourceDestroy()
-{
- // free pointer
- auto pointerIter = pointerResourcesMap_.find(WlClient());
- if (pointerIter != pointerResourcesMap_.end()) {
- pointerIter->second.clear();
- }
-
- // free keyboard
- auto keyboardIter = keyboardResourcesMap_.find(WlClient());
- if (keyboardIter != keyboardResourcesMap_.end()) {
- keyboardIter->second.clear();
- }
-
- OHOS::sptr wlSeat = WaylandSeat::GetWaylandSeatGlobal();
- if (wlSeat == nullptr) {
- return;
- }
- wlSeat->FreeSeatResource(WlClient(), WlResource());
-}
-
-WaylandSeatObject::~WaylandSeatObject() noexcept
-{
- LOG_DEBUG("WaylandSeatObject release, this=%{public}p", this);
-}
-
-void WaylandSeatObject::GetChildPointer(std::list> &list)
-{
- auto iter = pointerResourcesMap_.find(WlClient());
- if (iter == pointerResourcesMap_.end()) {
- return;
- }
- list = iter->second;
-}
-
-void WaylandSeatObject::GetChildKeyboard(std::list> &list)
-{
- auto iter = keyboardResourcesMap_.find(WlClient());
- if (iter == keyboardResourcesMap_.end()) {
- return;
- }
- list = iter->second;
-}
-
-void WaylandSeatObject::GetPointer(uint32_t id)
-{
- auto pointer = WaylandPointer::Create(WlClient(), wl_resource_get_version(WlResource()), id);
- if (pointer == nullptr) {
- LOG_ERROR("no memory");
- return;
- }
-
- pointerResourcesMap_[WlClient()].emplace_back(pointer);
-}
-
-void WaylandSeatObject::GetKeyboard(uint32_t id)
-{
- auto keyboard = WaylandKeyboard::Create(WlClient(), wl_resource_get_version(WlResource()), id);
- if (keyboard == nullptr) {
- LOG_ERROR("no memory");
- return;
- }
- keyboardResourcesMap_[WlClient()].emplace_back(keyboard);
-}
-
-void WaylandSeatObject::GetTouch(uint32_t id)
-{
-}
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_seat.h b/wayland_adapter/framework/core/wayland_seat.h
deleted file mode 100644
index 09d64007acf2f14d9d8cd0b97b8fdcd468144141..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_seat.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include
-#include
-#include "wayland_global.h"
-#include "wayland_pointer.h"
-#include "wayland_keyboard.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandSeat {
- static void GetPointer(struct wl_client *client, struct wl_resource *resource, uint32_t id);
- static void GetKeyboard(struct wl_client *client, struct wl_resource *resource, uint32_t id);
- static void GetTouch(struct wl_client *client, struct wl_resource *resource, uint32_t id);
- static struct wl_seat_interface impl_;
-};
-
-
-class WaylandSeatObject;
-
-class WaylandSeat final : public WaylandGlobal {
- friend struct IWaylandSeat;
-
-public:
- static OHOS::sptr Create(struct wl_display *display);
- static OHOS::sptr GetWaylandSeatGlobal();
- void GetPointerResource(struct wl_client *client, std::list> &list);
- void GetKeyboardResource(struct wl_client *client, std::list> &list);
- ~WaylandSeat() noexcept override;
- void FreeSeatResource(struct wl_client *client, struct wl_resource *resource);
-
-private:
- WaylandSeat(struct wl_display *display);
- void Bind(struct wl_client *client, uint32_t version, uint32_t id) override;
- static void UpdateCapabilities(struct wl_resource *resource);
- std::unordered_map>> seatResourcesMap_;
- std::unique_ptr thread_ = nullptr;
- mutable std::mutex seatResourcesMutex_;
-};
-
-class WaylandSeatObject final : public WaylandResourceObject {
- friend struct IWaylandSeat;
-
-public:
- WaylandSeatObject(struct wl_client *client, uint32_t version, uint32_t id);
- ~WaylandSeatObject() noexcept;
- void GetChildPointer(std::list> &list);
- void GetChildKeyboard(std::list> &list);
- void OnResourceDestroy() override;
-
-private:
- void GetPointer(uint32_t id);
- void GetKeyboard(uint32_t id);
- void GetTouch(uint32_t id);
- std::unordered_map>> pointerResourcesMap_;
- std::unordered_map>> keyboardResourcesMap_;
-};
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_subcompositor.cpp b/wayland_adapter/framework/core/wayland_subcompositor.cpp
deleted file mode 100644
index 70c4ec5351d53551f999d2ee0dd1cb74b6cca151..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_subcompositor.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include "wayland_subcompositor.h"
-
-#include "wayland_subsurface.h"
-#include "wayland_objects_pool.h"
-#include "version.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandSubCompositor"};
-}
-
-struct wl_subcompositor_interface IWaylandSubCompositor::impl_ = {
- .destroy = WaylandResourceObject::DefaultDestroyResource,
- .get_subsurface = IWaylandSubCompositor::GetSubSurface};
-
-void IWaylandSubCompositor::GetSubSurface(struct wl_client *client, struct wl_resource *resource,
- uint32_t id, struct wl_resource *surface, struct wl_resource *parent)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSubCompositorObject, resource,
- "OECompositorInterface::CreateRegion: failed to find object.", CreateSubSurface, id, surface, parent);
-}
-
-OHOS::sptr WaylandSubCompositor::Create(struct wl_display *display)
-{
- if (display == nullptr) {
- LOG_ERROR("display is nullptr");
- return nullptr;
- }
-
- return OHOS::sptr(new WaylandSubCompositor(display));
-}
-
-WaylandSubCompositor::WaylandSubCompositor(struct wl_display *display)
- : WaylandGlobal(display, &wl_subcompositor_interface, WL_SUBCOMPOSITOR_MAX_VERSION) {}
-
-WaylandSubCompositor::~WaylandSubCompositor() noexcept {}
-
-void WaylandSubCompositor::Bind(struct wl_client *client, uint32_t version, uint32_t id)
-{
- auto object = OHOS::sptr(new WaylandSubCompositorObject(client, version, id));
- if (object == nullptr) {
- LOG_ERROR("no memory");
- return;
- }
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(object->WlClient(), object->Id()), object);
-}
-
-WaylandSubCompositorObject::WaylandSubCompositorObject(struct wl_client *client,
- uint32_t version, uint32_t id)
- : WaylandResourceObject(client, &wl_subcompositor_interface, version, id, &IWaylandSubCompositor::impl_) {}
-
-WaylandSubCompositorObject::~WaylandSubCompositorObject() noexcept {}
-
-void WaylandSubCompositorObject::CreateSubSurface(uint32_t id, struct wl_resource *surface, struct wl_resource *parent)
-{
- auto subSurface = WaylandSubSurface::Create(WlClient(), wl_resource_get_version(WlResource()), id, surface, parent);
- if (subSurface == nullptr) {
- LOG_ERROR("no memory");
- return;
- }
-}
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_subcompositor.h b/wayland_adapter/framework/core/wayland_subcompositor.h
deleted file mode 100644
index 2925beba8a943f7f0e527dd6fe1282f05966e020..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_subcompositor.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include "wayland_global.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandSubCompositor {
- static void GetSubSurface(struct wl_client *client, struct wl_resource *resource,
- uint32_t id, struct wl_resource *surface, struct wl_resource *parent);
- static struct wl_subcompositor_interface impl_;
-};
-
-class WaylandSubCompositor final : public WaylandGlobal {
- friend struct IWaylandSubCompositor;
-
-public:
- static OHOS::sptr Create(struct wl_display *display);
- ~WaylandSubCompositor() noexcept override;
-
-private:
- WaylandSubCompositor(struct wl_display *display);
- void Bind(struct wl_client *client, uint32_t version, uint32_t id) override;
-};
-
-class WaylandSubCompositorObject final : public WaylandResourceObject {
- friend struct IWaylandSubCompositor;
-
-public:
- WaylandSubCompositorObject(struct wl_client *client, uint32_t version, uint32_t id);
- ~WaylandSubCompositorObject() noexcept;
-
-private:
- void CreateSubSurface(uint32_t id, struct wl_resource *surface, struct wl_resource *parent);
-};
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_subsurface.cpp b/wayland_adapter/framework/core/wayland_subsurface.cpp
deleted file mode 100644
index e12ce9fe9a33edad944b4910c43cb69fb9d4ff9a..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_subsurface.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include "wayland_subsurface.h"
-
-#include "wayland_objects_pool.h"
-#include "wayland_surface.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandSubSurface"};
-}
-
-struct wl_subsurface_interface IWaylandSubSurface::impl_ = {
- .destroy = WaylandResourceObject::DefaultDestroyResource,
- .set_position = IWaylandSubSurface::SetPosition,
- .place_above = IWaylandSubSurface::PlaceAbove,
- .place_below = IWaylandSubSurface::PlaceBelow,
- .set_sync = IWaylandSubSurface::SetSync,
- .set_desync = IWaylandSubSurface::SetDesync,
-};
-
-void IWaylandSubSurface::SetPosition(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSubSurface, resource,
- "IWaylandSubSurface::SetPosition: failed to find object.", SetPosition, resource, x, y);
-}
-
-void IWaylandSubSurface::PlaceAbove(struct wl_client *client, struct wl_resource *resource,
- struct wl_resource *sibling) {}
-
-void IWaylandSubSurface::PlaceBelow(struct wl_client *client, struct wl_resource *resource,
- struct wl_resource *sibling) {}
-
-void IWaylandSubSurface::SetSync(struct wl_client *client, struct wl_resource *resource) {}
-
-void IWaylandSubSurface::SetDesync(struct wl_client *client, struct wl_resource *resource) {}
-
-OHOS::sptr WaylandSubSurface::Create(struct wl_client *client, uint32_t version,
- uint32_t id, struct wl_resource *surface, struct wl_resource *parent)
-{
- if (client == nullptr) {
- return nullptr;
- }
-
- auto subSurface = OHOS::sptr(new WaylandSubSurface(client, version, id, surface, parent));
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(subSurface->WlClient(), subSurface->Id()), subSurface);
- return subSurface;
-}
-
-WaylandSubSurface::WaylandSubSurface(struct wl_client *client, uint32_t version, uint32_t id,
- struct wl_resource *surface, struct wl_resource *parent)
- : WaylandResourceObject(client, &wl_subsurface_interface, version, id, &IWaylandSubSurface::impl_)
-{
- parentSurfaceRes_ = parent;
- childSurfaceRes_ = surface;
-}
-
-void WaylandSubSurface::SetPosition(struct wl_resource *resource, int32_t x, int32_t y)
-{
- if ((positionX_ != x) || (positionY_ != y)) {
- LOG_INFO("SetPosition X:%{public}d, Y:%{public}d", x, y);
- auto surfaceParent = CastFromResource(parentSurfaceRes_);
- auto surfaceChild = CastFromResource(childSurfaceRes_);
- surfaceParent->AddChild(childSurfaceRes_, x, y);
- surfaceChild->AddParent(parentSurfaceRes_);
- positionX_ = x;
- positionY_ = y;
- }
-}
-
-WaylandSubSurface::~WaylandSubSurface() noexcept {}
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_subsurface.h b/wayland_adapter/framework/core/wayland_subsurface.h
deleted file mode 100644
index 71048a24749f0c6f696d52dec3c4e2fb352a1389..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_subsurface.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include "wayland_resource_object.h"
-
-namespace FT {
-namespace Wayland {
-struct IWaylandSubSurface {
- static void SetPosition(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y);
- static void PlaceAbove(struct wl_client *client, struct wl_resource *resource, struct wl_resource *sibling);
- static void PlaceBelow(struct wl_client *client, struct wl_resource *resource, struct wl_resource *sibling);
- static void SetSync(struct wl_client *client, struct wl_resource *resource);
- static void SetDesync(struct wl_client *client, struct wl_resource *resource);
- static struct wl_subsurface_interface impl_;
-};
-
-class WaylandSubSurface : public WaylandResourceObject {
-public:
- static OHOS::sptr Create(struct wl_client *client, uint32_t version, uint32_t id,
- struct wl_resource *surface, struct wl_resource *parent);
- ~WaylandSubSurface() noexcept override;
- void SetPosition(struct wl_resource *resource, int32_t x, int32_t y);
-
-private:
- WaylandSubSurface(struct wl_client *client, uint32_t version, uint32_t id,
- struct wl_resource *surface, struct wl_resource *parent);
-
- struct wl_resource *parentSurfaceRes_;
- struct wl_resource *childSurfaceRes_;
- int32_t positionX_ = -1;
- int32_t positionY_ = -1;
-};
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_surface.cpp b/wayland_adapter/framework/core/wayland_surface.cpp
deleted file mode 100644
index 2bc67f40cfed4079918583648c7d9eaf710ff495..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_surface.cpp
+++ /dev/null
@@ -1,725 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#include
-#include "wayland_surface.h"
-
-#include "wayland_objects_pool.h"
-#include "wayland_event_loop.h"
-#include "ui/rs_surface_extractor.h"
-#include "wayland_region.h"
-#include "wayland_seat.h"
-#include "input_manager.h"
-
-namespace FT {
-namespace Wayland {
-namespace {
- constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandSurface"};
- constexpr uint32_t US_TO_MS = 1000;
-}
-
-class InputEventConsumer : public OHOS::Rosen::IInputEventConsumer
-{
-public:
- InputEventConsumer(OHOS::sptr wlSurface)
- {
- wlSurface_ = wlSurface;
- }
-
- bool OnInputEvent(const std::shared_ptr& keyEvent) const override;
- bool OnInputEvent(const std::shared_ptr& axisEvent) const override;
- bool OnInputEvent(const std::shared_ptr& pointerEvent) const override;
-private:
- OHOS::sptr wlSurface_ = nullptr;
- int32_t MapPointerActionButton(int32_t PointerActionButtonType) const;
- int32_t MapKeyAction(int32_t keyAction) const;
- const std::map ptrActionMap_ = {
- {OHOS::MMI::PointerEvent::MOUSE_BUTTON_LEFT, BTN_LEFT},
- {OHOS::MMI::PointerEvent::MOUSE_BUTTON_RIGHT, BTN_RIGHT},
- };
- const std::map keyActionMap_ = {
- {OHOS::MMI::KeyEvent::KEY_ACTION_UP, WL_KEYBOARD_KEY_STATE_RELEASED},
- {OHOS::MMI::KeyEvent::KEY_ACTION_DOWN, WL_KEYBOARD_KEY_STATE_PRESSED},
- };
- const int32_t INVALID_KEYACTION = -1;
-};
-
-int32_t InputEventConsumer::MapKeyAction(int32_t keyAction) const
-{
- auto it = keyActionMap_.find(keyAction);
- if (it == keyActionMap_.end()) {
- return INVALID_KEYACTION;
- }
- return it->second;
-}
-
-int32_t InputEventConsumer::MapPointerActionButton(int32_t PointerActionButtonType) const
-{
- auto it = ptrActionMap_.find(PointerActionButtonType);
- if (it == ptrActionMap_.end()) {
- return OHOS::MMI::PointerEvent::BUTTON_NONE;
- }
- return it->second;
-}
-
-bool InputEventConsumer::OnInputEvent(const std::shared_ptr& keyEvent) const
-{
- keyEvent->MarkProcessed();
- WaylandEventLoop::GetInstance().QueueToLoop([this, keyEvent]{
- OHOS::sptr wlSeat = WaylandSeat::GetWaylandSeatGlobal();
- if (wlSeat == nullptr) {
- return;
- }
- std::list> keyboardList;
- wlSeat->GetKeyboardResource(wlSurface_->WlClient(), keyboardList);
- int32_t keyAction = MapKeyAction(keyEvent->GetKeyAction());
- if (keyAction == INVALID_KEYACTION) {
- return;
- }
-
- for (auto &keyboard : keyboardList) {
- keyboard->OnKeyboardKey(keyEvent->GetKeyCode(), keyAction, keyEvent->GetActionTime() / US_TO_MS);
- }
- wl_display_flush_clients(wlSurface_->WlDisplay());
- });
-
- return true;
-}
-
-bool InputEventConsumer::OnInputEvent(const std::shared_ptr& axisEvent) const
-{
- axisEvent->MarkProcessed();
- return true;
-}
-
-bool InputEventConsumer::OnInputEvent(const std::shared_ptr& pointerEvent) const
-{
- pointerEvent->MarkProcessed();
- WaylandEventLoop::GetInstance().QueueToLoop([this, pointerEvent]{
- OHOS::sptr wlSeat = WaylandSeat::GetWaylandSeatGlobal();
- if (wlSeat == nullptr) {
- return;
- }
- std::list> pointerList;
- std::list> keyboardList;
- wlSeat->GetPointerResource(wlSurface_->WlClient(), pointerList);
- wlSeat->GetKeyboardResource(wlSurface_->WlClient(), keyboardList);
-
- OHOS::MMI::PointerEvent::PointerItem pointerItem;
- int32_t pointId = pointerEvent->GetPointerId();
- if (!pointerEvent->GetPointerItem(pointId, pointerItem)) {
- LOG_WARN("GetPointerItem fail");
- return;
- }
-
- Rect rect = wlSurface_->GetWindowGeometry();
- if (rect.x >= 0 && rect.y >= 0 && rect.width > 0 && rect.height > 0) {
- pointerItem.SetWindowX(pointerItem.GetWindowX() + rect.x);
- pointerItem.SetWindowY(pointerItem.GetWindowY() + rect.y);
- }
- if (pointerEvent->GetPointerAction() == OHOS::MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW) {
- for (auto &pointer : pointerList) {
- pointer->OnPointerEnter(pointerItem.GetWindowX(), pointerItem.GetWindowY(), wlSurface_->WlResource());
- }
- for (auto &keyboard : keyboardList) {
- keyboard->OnKeyboardEnter(wlSurface_->WlResource());
- }
- } else if (pointerEvent->GetPointerAction() == OHOS::MMI::PointerEvent::POINTER_ACTION_LEAVE_WINDOW) {
- for (auto &pointer : pointerList) {
- pointer->OnPointerLeave(wlSurface_->WlResource());
- }
- for (auto &keyboard : keyboardList) {
- keyboard->OnKeyboardLeave(wlSurface_->WlResource());
- }
- } else if (pointerEvent->GetPointerAction() == OHOS::MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN ||
- pointerEvent->GetPointerAction() == OHOS::MMI::PointerEvent::POINTER_ACTION_BUTTON_UP) {
- int32_t buttonId = MapPointerActionButton(pointerEvent->GetButtonId());
- if (buttonId != OHOS::MMI::PointerEvent::BUTTON_NONE) {
- for (auto &pointer : pointerList) {
- pointer->OnPointerButton(pointerEvent->GetActionTime() / US_TO_MS, buttonId, pointerItem.IsPressed());
- }
- }
- } else if (pointerEvent->GetPointerAction() == OHOS::MMI::PointerEvent::POINTER_ACTION_MOVE) {
- for (auto &pointer : pointerList) {
- pointer->OnPointerMotionAbsolute(pointerEvent->GetActionTime() / US_TO_MS, pointerItem.GetWindowX(), pointerItem.GetWindowY());
- }
- }
- wl_display_flush_clients(wlSurface_->WlDisplay());
- });
- return true;
-}
-
-
-struct wl_surface_interface IWaylandSurface::impl_ = {
- .destroy = &WaylandResourceObject::DefaultDestroyResource,
- .attach = Attach,
- .damage = Damage,
- .frame = Frame,
- .set_opaque_region = SetOpaqueRegion,
- .set_input_region = SetInputRegion,
- .commit = Commit,
- .set_buffer_transform = SetBufferTransform,
- .set_buffer_scale = SetBufferScale,
- .damage_buffer = DamageBuffer,
- .offset = Offset};
-
-void IWaylandSurface::Attach(struct wl_client *client, struct wl_resource *surfaceResource,
- struct wl_resource *bufferResource, int32_t x, int32_t y)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSurface, surfaceResource,
- "IWaylandSurface::Attach: failed to find object.", Attach, bufferResource, x, y);
-}
-
-void IWaylandSurface::Damage(struct wl_client *client, struct wl_resource *resource,
- int32_t x, int32_t y, int32_t width, int32_t height)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSurface, resource,
- "IWaylandSurface::Damage: failed to find object.", Damage, x, y, width, height);
-}
-
-void IWaylandSurface::Frame(struct wl_client *client, struct wl_resource *resource, uint32_t callback)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSurface, resource,
- "IWaylandSurface::Frame: failed to find object.", Frame, callback);
-}
-
-void IWaylandSurface::SetOpaqueRegion(struct wl_client *client,
- struct wl_resource *surfaceResource, struct wl_resource *regionResource)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSurface, surfaceResource,
- "IWaylandSurface::SetOpaqueRegion: failed to find object.", SetOpaqueRegion, regionResource);
-}
-
-void IWaylandSurface::SetInputRegion(struct wl_client *client,
- struct wl_resource *surfaceResource, struct wl_resource *regionResource)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSurface, surfaceResource,
- "IWaylandSurface::SetInputRegion: failed to find object.", SetInputRegion, regionResource);
-}
-
-void IWaylandSurface::Commit(struct wl_client *client, struct wl_resource *resource)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSurface, resource, "IWaylandSurface::Commit: failed to find object.", Commit);
-}
-
-void IWaylandSurface::SetBufferTransform(struct wl_client *client, struct wl_resource *resource, int32_t transform)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSurface, resource,
- "IWaylandSurface::SetBufferTransform: failed to find object.", SetBufferTransform, transform);
-}
-
-void IWaylandSurface::SetBufferScale(struct wl_client *client, struct wl_resource *resource, int32_t scale)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSurface, resource,
- "IWaylandSurface::SetBufferScale: failed to find object.", SetBufferScale, scale);
-}
-
-void IWaylandSurface::DamageBuffer(struct wl_client *client, struct wl_resource *resource,
- int32_t x, int32_t y, int32_t width, int32_t height)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSurface, resource,
- "IWaylandSurface::DamageBuffer: failed to find object.", DamageBuffer, x, y, width, height);
-}
-
-void IWaylandSurface::Offset(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y)
-{
- CAST_OBJECT_AND_CALL_FUNC(WaylandSurface, resource,
- "IWaylandSurface::Offset: failed to find object.", Offset, x, y);
-}
-
-OHOS::sptr WaylandSurface::Create(struct wl_client *client,
- struct wl_resource *parent, uint32_t version, uint32_t id)
-{
- if (client == nullptr) {
- LOG_ERROR("Invalid client parameter");
- return nullptr;
- }
-
- auto surface = OHOS::sptr(new WaylandSurface(client, parent, version, id));
- if (surface == nullptr) {
- LOG_ERROR("Failed to create WaylandSurface");
- return nullptr;
- }
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(surface->WlClient(), surface->Id()), surface);
- return surface;
-}
-
-class WaylandWindowListener : public OHOS::Rosen::IWindowChangeListener {
-public:
- WaylandWindowListener(OHOS::sptr wlSurface) : wlSurface_(wlSurface) {}
- ~WaylandWindowListener() = default;
- void OnSizeChange(OHOS::Rosen::Rect rect, OHOS::Rosen::WindowSizeChangeReason reason) override;
- void OnModeChange(OHOS::Rosen::WindowMode mode) override;
-
-private:
- OHOS::sptr wlSurface_ = nullptr;
-};
-
-void WaylandWindowListener::OnSizeChange(OHOS::Rosen::Rect rect, OHOS::Rosen::WindowSizeChangeReason reason)
-{
- if (wlSurface_ != nullptr) {
- wlSurface_->OnSizeChange(rect, reason);
- }
-}
-
-void WaylandWindowListener::OnModeChange(OHOS::Rosen::WindowMode mode)
-{
- if (wlSurface_ != nullptr) {
- wlSurface_->OnModeChange(mode);
- }
-}
-
-WaylandSurface::WaylandSurface(struct wl_client *client, struct wl_resource *parent, uint32_t version, uint32_t id)
- : WaylandResourceObject(client, &wl_surface_interface, version, id, &IWaylandSurface::impl_),
- parent_(parent)
-{
- windowTitle_ = std::to_string((long)((void *)this)) + std::string("-Untitled");
- windowOptionExt_ = std::make_shared();
- windowOption_ = new OHOS::Rosen::WindowOption();
- windowOption_->SetWindowType(OHOS::Rosen::WindowType::APP_WINDOW_BASE);
- windowOption_->SetWindowMode(OHOS::Rosen::WindowMode::WINDOW_MODE_FLOATING);
- windowOption_->SetMainHandlerAvailable(false);
- LOG_DEBUG("enter : %{public}s.", windowTitle_.c_str());
-}
-
-WaylandSurface::~WaylandSurface() noexcept
-{
- LOG_DEBUG("exit : %{public}s.", windowTitle_.c_str());
-}
-
-void WaylandSurface::AddCommitCallback(SurfaceCommitCallback callback)
-{
- commitCallbacks_.push_back(std::move(callback));
-}
-
-void WaylandSurface::AddRectCallback(SurfaceRectCallback callback)
-{
- rectCallbacks_.push_back(std::move(callback));
-}
-
-void WaylandSurface::AddWindowCreateCallback(WindowCreateCallback callback)
-{
- windowCreatebacks_.push_back(std::move(callback));
-}
-
-void WaylandSurface::Attach(struct wl_resource *bufferResource, int32_t x, int32_t y)
-{
- if (new_.buffer != nullptr) {
- wl_callback_send_done(new_.buffer, 0);
- }
-
- new_.buffer = bufferResource;
- new_.offsetX = x;
- new_.offsetY = y;
-}
-
-void WaylandSurface::Damage(int32_t x, int32_t y, int32_t width, int32_t height)
-{
- new_.damage.x = x;
- new_.damage.y = y;
- new_.damage.width = static_cast(width);
- new_.damage.height = static_cast(height);
-}
-
-void WaylandSurface::Frame(uint32_t callback)
-{
- bool pending = false;
- if (new_.cb != nullptr) {
- pending = true;
- LOG_WARN("duplicate frame request");
- }
-
- auto cb = FrameCallback::Create(WlClient(), WAYLAND_VERSION_MAJOR, callback);
- if (cb == nullptr) {
- LOG_ERROR("no memory");
- return;
- }
-
- WaylandObjectsPool::GetInstance().AddObject(ObjectId(cb->WlClient(), cb->Id()), cb);
- if (pending) {
- pengindCb_.push_back(cb);
- return;
- }
- new_.cb = cb;
-}
-
-void WaylandSurface::SetOpaqueRegion(struct wl_resource *regionResource)
-{
- if (regionResource == nullptr) {
- LOG_ERROR("regionResource is nullptr");
- return;
- }
-
- auto region = CastFromResource(regionResource);
- if (region == nullptr) {
- LOG_ERROR("failed to cast WaylandRegion from regionResource, maybe resource is not valid.");
- return;
- }
-
- new_.opaqueRegion = region->GetRect();
- LOG_DEBUG("SetOpaqueRegion, rect: x %{public}d, y %{public}d, width %{public}d, height %{public}d.",
- new_.opaqueRegion.x, new_.opaqueRegion.y, new_.opaqueRegion.width, new_.opaqueRegion.height);
-}
-
-void WaylandSurface::SetInputRegion(struct wl_resource *regionResource)
-{
- if (regionResource == nullptr) {
- LOG_ERROR("regionResource is nullptr");
- return;
- }
-
- auto region = CastFromResource(regionResource);
- if (region == nullptr) {
- LOG_ERROR("failed to cast WaylandRegion from regionResource, maybe resource is not valid.");
- return;
- }
-
- new_.inputRegion = region->GetRect();
- LOG_DEBUG("SetInputRegion, rect: x %{public}d, y %{public}d, width %{public}d, height %{public}d.",
- new_.inputRegion.x, new_.inputRegion.y, new_.inputRegion.width, new_.inputRegion.height);
-}
-
-void WaylandSurface::Commit()
-{
- if (isPointerSurface_) {
- return; // it is pointer surface, we do not handle commit!
- }
-
- if (withTopLevel_ && window_ == nullptr) {
- CreateWindow();
- }
-
- {
- HandleCommit();
- LOG_DEBUG("withTopLevel_ %{public}d", withTopLevel_);
- }
-
- for (auto &cb : commitCallbacks_) {
- cb();
- }
-}
-
-void WaylandSurface::SetBufferTransform(int32_t transform)
-{
- new_.transform = static_cast(transform);
-}
-
-void WaylandSurface::SetBufferScale(int32_t scale)
-{
- new_.scale = scale;
-}
-
-void WaylandSurface::DamageBuffer(int32_t x, int32_t y, int32_t width, int32_t height)
-{
- new_.damageBuffer.x = x;
- new_.damageBuffer.y = y;
- new_.damageBuffer.width = static_cast(width);
- new_.damageBuffer.height = static_cast(height);
-}
-
-void WaylandSurface::Offset(int32_t x, int32_t y)
-{
- new_.offsetX = x;
- new_.offsetY = y;
-}
-
-void WaylandSurface::HandleCommit() {
- int32_t timeMs = 0;
- struct timespec ts = { 0, 0 };
- if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
- timeMs = (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
- } else {
- LOG_ERROR("failed to clock_gettime");
- }
-
- if (new_.buffer != nullptr) {
- wl_shm_buffer *shm = wl_shm_buffer_get(new_.buffer);
- if (shm == nullptr) {
- LOG_ERROR("wl_shm_buffer_get fail");
- wl_callback_send_done(new_.buffer, 0);
- return;
- }
-
- wl_shm_buffer_begin_access(shm);
- CopyBuffer(shm);
- wl_shm_buffer_end_access(shm);
-
- wl_callback_send_done(new_.buffer, timeMs);
- new_.buffer = nullptr;
- }
-
- if (new_.cb != nullptr) {
- wl_callback_send_done(new_.cb->WlResource(), timeMs);
- wl_resource_destroy(new_.cb->WlResource());
- new_.cb = nullptr;
- for (auto &cb : pengindCb_) {
- wl_callback_send_done(cb->WlResource(), timeMs);
- wl_resource_destroy(cb->WlResource());
- }
- pengindCb_.clear();
- }
-
- old_ = new_;
- new_.Reset();
-}
-
-void WaylandSurface::CheckIsPointerSurface()
-{
- OHOS::sptr wlSeat = WaylandSeat::GetWaylandSeatGlobal();
- if (wlSeat == nullptr) {
- return;
- }
-
- std::list> pointerList;
- wlSeat->GetPointerResource(WlClient(), pointerList);
- for (auto &pointer : pointerList) {
- isPointerSurface_ = pointer->IsCursorSurface(WlResource());
- if (isPointerSurface_) {
- break;
- }
- }
-
- LOG_DEBUG("this surface Pointer Surface: %{public}d", isPointerSurface_);
-}
-
-void WaylandSurface::CreateWindow()
-{
- CheckIsPointerSurface();
- if (isPointerSurface_) {
- return;
- }
-
- static int count = 0;
- std::string windowName = "WaylandWindow" + std::to_string(count++);
- window_ = OHOS::Rosen::Window::Create(windowName, windowOption_);
- if (window_ == nullptr) {
- LOG_ERROR("Window::Create failed");
- return;
- }
- LOG_DEBUG("Window::Create success, Title %{public}s.", windowTitle_.c_str());
- auto listener = std::make_shared(this);
- window_->SetInputEventConsumer(listener);
- window_->SetAPPWindowLabel(windowOptionExt_->title);
- window_->Show();
-
- OHOS::sptr waylandWindowListener = new WaylandWindowListener(this);
- window_->RegisterWindowChangeListener(waylandWindowListener);
-
- surfaceNode_ = window_->GetSurfaceNode();
- if (surfaceNode_ == nullptr) {
- LOG_ERROR("GetSurfaceNode failed");
- return;
- }
-
- rsSurface_ = OHOS::Rosen::RSSurfaceExtractor::ExtractRSSurface(surfaceNode_);
- if (rsSurface_ == nullptr) {
- LOG_ERROR("ExtractRSSurface failed");
- return;
- }
-
-#ifdef ENABLE_GPU
- renderContext_ = std::make_unique();
- renderContext_->InitializeEglContext();
- rsSurface_->SetRenderContext(renderContext_.get());
-#endif
-
- for (auto &cb : windowCreatebacks_) {
- cb(window_);
- }
-
- OHOS::Rosen::Rect rect = window_->GetRect();
- rect_.width = rect.width_;
- rect_.height = rect.height_;
-
- for (auto &cb : rectCallbacks_) {
- cb(rect_);
- }
-
- if (windowOptionExt_->maximizeAfterShow) {
- window_->Maximize();
- } else if (windowOptionExt_->fullscreenAfterShow) {
- window_->SetFullScreen(true);
- } else if (windowOptionExt_->minimizeAfterShow) {
- window_->Minimize();
- }
-}
-
-void WaylandSurface::CopyBuffer(struct wl_shm_buffer *shm)
-{
- SkColorType format = ShmFormatToSkia(wl_shm_buffer_get_format(shm));
- if (format == SkColorType::kUnknown_SkColorType) {
- LOG_ERROR("unsupported format %{public}d", wl_shm_buffer_get_format(shm));
- return;
- }
-
- int32_t stride = wl_shm_buffer_get_stride(shm);
- int32_t width = wl_shm_buffer_get_width(shm);
- int32_t height = wl_shm_buffer_get_height(shm);
- if (stride <= 0 || width <= 0 || height <= 0) {
- LOG_ERROR("invalid, stride:%{public}d width:%{public}d height:%{public}d", stride, width, height);
- return;
- }
-
- void *data = wl_shm_buffer_get_data(shm);
- if (data == nullptr) {
- LOG_ERROR("wl_shm_buffer_get_data fail");
- return;
- }
- SkImageInfo imageInfo = SkImageInfo::Make(width, height, format, kUnpremul_SkAlphaType);
- SkPixmap srcPixmap(imageInfo, data, stride);
- {
- std::lock_guard lg(bitmapMutex_);
- srcBitmap_.installPixels(srcPixmap);
- }
-
- if (!withTopLevel_) {
- auto surfaceParent = CastFromResource(parentSurfaceRes_);
- if (parentSurfaceRes_ != nullptr) {
- surfaceParent->TriggerInnerCompose();
- }
- LOG_DEBUG("return because without toplevel");
- return;
- }
- TriggerInnerCompose();
-}
-
-void WaylandSurface::OnSizeChange(const OHOS::Rosen::Rect& rect, OHOS::Rosen::WindowSizeChangeReason reason)
-{
- rect_.x = rect.posX_;
- rect_.y = rect.posY_;
- rect_.width = rect.width_;
- rect_.height = rect.height_;
- for (auto &cb : rectCallbacks_) {
- cb(rect_);
- }
-}
-
-void WaylandSurface::OnModeChange(OHOS::Rosen::WindowMode mode)
-{
- LOG_DEBUG("OnModeChange, window mode is %{public}d, ignore", mode);
-}
-
-void WaylandSurface::SetWindowGeometry(Rect rect)
-{
- LOG_DEBUG("Window %{public}s. x:%{public}d y:%{public}d width:%{public}d height:%{public}d",
- windowTitle_.c_str(), rect.x, rect.y, rect.width, rect.height);
- geometryRect_ = rect;
-}
-
-Rect WaylandSurface::GetWindowGeometry()
-{
- return geometryRect_;
-}
-
-void WaylandSurface::WithTopLevel(bool toplevel)
-{
- withTopLevel_ = toplevel;
-}
-
-void WaylandSurface::AddChild(struct wl_resource *child, int32_t x, int32_t y)
-{
- if (child == nullptr) {
- LOG_ERROR("AddChild with nullptr resource");
- return;
- }
- if (childs_.count(child) > 0) {
- childs_[child].offsetX = x;
- childs_[child].offsetY = y;
- return;
- }
- SubSurfaceData data;
- data.surface = child;
- data.offsetX = x;
- data.offsetY = y;
- childs_[child] = data;
- for (auto &cb : rectCallbacks_) {
- cb(rect_);
- }
-}
-
-void WaylandSurface::AddParent(struct wl_resource *parent)
-{
- parentSurfaceRes_ = parent;
-}
-
-void WaylandSurface::ProcessSrcBitmap(SkCanvas* canvas, int32_t x, int32_t y)
-{
- std::lock_guard lg(bitmapMutex_);
- canvas->drawBitmap(srcBitmap_, x, y);
- LOG_DEBUG("draw child offsetx %{public}d, offsety %{public}d,", x, y);
-}
-
-void WaylandSurface::TriggerInnerCompose()
-{
- if (rsSurface_ == nullptr) {
- LOG_ERROR("rsSurface_ is nullptr");
- return;
- }
-
- if (srcBitmap_.width() == 0 || srcBitmap_.height() == 0) {
- LOG_DEBUG("srcBitmap_ is nullptr");
- return;
- }
- uint32_t width;
- uint32_t height;
- bool vailedGeometry = (geometryRect_.x >= 0 && geometryRect_.y >= 0 &&
- geometryRect_.width > 0 && geometryRect_.height > 0);
- if (vailedGeometry) {
- width = geometryRect_.width;
- height = geometryRect_.height;
- } else {
- width = srcBitmap_.width();
- height = srcBitmap_.height();
- }
- auto framePtr = rsSurface_->RequestFrame(width, height);
- if (framePtr == nullptr) {
- LOG_ERROR("RequestFrame failed");
- return;
- }
-
- auto canvas = framePtr->GetCanvas();
- if (canvas == nullptr) {
- LOG_ERROR("GetCanvas failed");
- return;
- }
- canvas->clear(SK_ColorTRANSPARENT);
- if (vailedGeometry) {
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kFill_Style);
- canvas->drawBitmapRect(srcBitmap_,
- SkRect::MakeXYWH(geometryRect_.x, geometryRect_.y, geometryRect_.width, geometryRect_.height),
- SkRect::MakeXYWH(0, 0, geometryRect_.width, geometryRect_.height),
- &paint);
- } else {
- canvas->drawBitmap(srcBitmap_, 0, 0);
- }
- for (auto &&[childKey, data] : childs_) {
- if (data.surface == nullptr) {
- continue;
- }
- LOG_DEBUG("Draw Child");
- auto surfaceChild = CastFromResource(data.surface);
- if (vailedGeometry) {
- surfaceChild->ProcessSrcBitmap(canvas, data.offsetX - geometryRect_.x, data.offsetY - geometryRect_.y);
- } else {
- surfaceChild->ProcessSrcBitmap(canvas, data.offsetX, data.offsetY);
- }
- }
- rsSurface_->FlushFrame(framePtr);
-}
-
-} // namespace Wayland
-} // namespace FT
diff --git a/wayland_adapter/framework/core/wayland_surface.h b/wayland_adapter/framework/core/wayland_surface.h
deleted file mode 100644
index 007f7fb52dc95702286984066b4475edf12468e7..0000000000000000000000000000000000000000
--- a/wayland_adapter/framework/core/wayland_surface.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2023 Huawei Technologies 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.
- */
-
-#pragma once
-
-#include
-#include
-#include