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 -#include -#include -#include "wayland_resource_object.h" -#include "wayalnd_utils.h" - -#include "ui/rs_surface_node.h" -#include "render_context/render_context.h" - -namespace FT { -namespace Wayland { -struct IWaylandSurface { - static void Attach(struct wl_client *client, struct wl_resource *surfaceResource, - struct wl_resource *bufferResource, int32_t x, int32_t y); - static void Damage(struct wl_client *client, struct wl_resource *resource, - int32_t x, int32_t y, int32_t width, int32_t height); - static void Frame(struct wl_client *client, struct wl_resource *resource, uint32_t callback); - static void SetOpaqueRegion(struct wl_client *client, struct wl_resource *surfaceResource, - struct wl_resource *regionResource); - static void SetInputRegion(struct wl_client *client, struct wl_resource *surfaceResource, - struct wl_resource *regionResource); - static void Commit(struct wl_client *client, struct wl_resource *resource); - static void SetBufferTransform(struct wl_client *client, struct wl_resource *resource, int32_t transform); - static void SetBufferScale(struct wl_client *client, struct wl_resource *resource, int32_t scale); - static void DamageBuffer(struct wl_client *client, struct wl_resource *resource, - int32_t x, int32_t y, int32_t width, int32_t height); - static void Offset(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y); - static struct wl_surface_interface impl_; -}; - - -class WaylandSurface final : public WaylandResourceObject { - friend struct IWaylandSurface; - -public: - static OHOS::sptr Create(struct wl_client *client, struct wl_resource *parent, - uint32_t version, uint32_t id); - ~WaylandSurface() noexcept override; - - void AddCommitCallback(SurfaceCommitCallback callback); - void AddRectCallback(SurfaceRectCallback callback); - void AddWindowCreateCallback(WindowCreateCallback callback); - void OnSizeChange(const OHOS::Rosen::Rect& rect, OHOS::Rosen::WindowSizeChangeReason reason); - void OnModeChange(OHOS::Rosen::WindowMode mode); - - // form xdgsruface - void SetWindowGeometry(Rect rect); - Rect GetWindowGeometry(); - - void WithTopLevel(bool toplevel); - void AddChild(struct wl_resource *child, int32_t x, int32_t y); - void AddParent(struct wl_resource *parent); - void ProcessSrcBitmap(SkCanvas* canvas, int32_t x, int32_t y); - void TriggerInnerCompose(); - OHOS::sptr GetWindowOption() - { - return windowOption_; - } - std::shared_ptr GetWindowOptionExt() - { - return windowOptionExt_; - } - -private: - WaylandSurface(struct wl_client *client, struct wl_resource *parent, uint32_t version, uint32_t id); - - void Attach(struct wl_resource *bufferResource, int32_t x, int32_t y); - void Damage(int32_t x, int32_t y, int32_t width, int32_t height); - void Frame(uint32_t callback); - void SetOpaqueRegion(struct wl_resource *regionResource); - void SetInputRegion(struct wl_resource *regionResource); - void Commit(); - void SetBufferTransform(int32_t transform); - void SetBufferScale(int32_t scale); - void DamageBuffer(int32_t x, int32_t y, int32_t width, int32_t height); - void Offset(int32_t x, int32_t y); - void HandleCommit(); - void CreateWindow(); - void CopyBuffer(struct wl_shm_buffer *shm); - void CheckIsPointerSurface(); - - struct wl_resource *parent_ = nullptr; - std::list commitCallbacks_; - std::list rectCallbacks_; - std::list windowCreatebacks_; - Rect rect_; - Rect geometryRect_ = {0}; - SurfaceState old_; - SurfaceState new_; - bool isPointerSurface_ = false; - -#ifdef ENABLE_GPU - std::unique_ptr renderContext_; -#endif - OHOS::sptr window_; - OHOS::sptr windowOption_; - std::shared_ptr windowOptionExt_; - std::shared_ptr surfaceNode_; - std::shared_ptr rsSurface_; - std::string windowTitle_; - bool withTopLevel_ = false; - std::map childs_; - struct wl_resource *parentSurfaceRes_ = nullptr; - std::mutex bitmapMutex_; - SkBitmap srcBitmap_; - std::vector> pengindCb_; -}; -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_popup.cpp b/wayland_adapter/framework/stable/wayland_xdg_popup.cpp deleted file mode 100644 index d046d904494edc156b688af90777a58035d613ed..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/stable/wayland_xdg_popup.cpp +++ /dev/null @@ -1,116 +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_xdg_popup.h" - -#include "wayland_objects_pool.h" -#include "wayland_xdg_toplevel.h" -#include "wayland_xdg_wm_base.h" - -namespace FT { -namespace Wayland { -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandXdgPopup"}; -} - -struct xdg_popup_interface WaylandXdgPopupInterface::impl_ = { - .destroy = WaylandResourceObject::DefaultDestroyResource, - .grab = WaylandXdgPopupInterface::Grab, - .reposition = WaylandXdgPopupInterface::Reposition}; - -void WaylandXdgPopupInterface::Grab( - struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial) -{} - -void WaylandXdgPopupInterface::Reposition( - struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *positioner, - uint32_t token) -{} - -OHOS::sptr WaylandXdgPopup::Create( - const OHOS::sptr &xdgSurface, - const OHOS::sptr &parentXdgSurface, - const OHOS::sptr &positioner, - uint32_t id) -{ - if (xdgSurface == nullptr) { - LOG_ERROR("WaylandXdgPopup::Create: xdgSurface is nullptr."); - return nullptr; - } - - if (parentXdgSurface == nullptr) { - LOG_ERROR("WaylandXdgPopup::Create: parentXdgSurface is nullptr."); - return nullptr; - } - - if (positioner == nullptr) { - LOG_ERROR("WaylandXdgPopup::Create: positioner is nullptr."); - return nullptr; - } - - auto xdgPopUp = OHOS::sptr(new WaylandXdgPopup(xdgSurface, parentXdgSurface, positioner, id)); - WaylandObjectsPool::GetInstance().AddObject(ObjectId(xdgPopUp->WlClient(), xdgPopUp->Id()), xdgPopUp); - return xdgPopUp; -} - -WaylandXdgPopup::WaylandXdgPopup( - const OHOS::sptr &xdgSurface, - const OHOS::sptr &parentXdgSurface, - const OHOS::sptr &positioner, - uint32_t id) - : WaylandResourceObject( - xdgSurface->WlClient(), - &xdg_popup_interface, - xdgSurface->Version(), - id, - &WaylandXdgPopupInterface::impl_), - xdgSurface_(xdgSurface), - parentXdgSurface_(parentXdgSurface) -{ - // TODO: get information from positioner. - LOG_DEBUG("WaylandXdgPopup ctor."); -} - -WaylandXdgPopup::~WaylandXdgPopup() noexcept -{ - LOG_DEBUG("WaylandXdgPopup dtor."); -} - -void WaylandXdgPopup::OnSurfaceCommitted() {} - -void WaylandXdgPopup::Grab(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat, uint32_t serial) -{} - -void WaylandXdgPopup::Reposition( - struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *positioner, - uint32_t token) -{} - -void WaylandXdgPopup::UpdateSize(int32_t x, int32_t y, uint32_t width, uint32_t height) -{ -} - -void WaylandXdgPopup::SetGeometry(int32_t x, int32_t y, uint32_t width, uint32_t height) -{ -} -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_popup.h b/wayland_adapter/framework/stable/wayland_xdg_popup.h deleted file mode 100644 index b68615bc538eadc94c1b04e3f9576e86b36e3f6e..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/stable/wayland_xdg_popup.h +++ /dev/null @@ -1,154 +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 "wayland_xdg_positioner.h" -#include "wayalnd_utils.h" - -namespace FT { -namespace Wayland { -class WaylandXdgSurface; - -struct WaylandXdgPopupInterface { - /** - * make the popup take an explicit grab - * - * This request makes the created popup take an explicit grab. An - * explicit grab will be dismissed when the user dismisses the - * popup, or when the client destroys the xdg_popup. This can be - * done by the user clicking outside the surface, using the - * keyboard, or even locking the screen through closing the lid or - * a timeout. - * - * If the compositor denies the grab, the popup will be immediately - * dismissed. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. The - * serial number of the event should be passed as 'serial'. - * - * The parent of a grabbing popup must either be an xdg_toplevel - * surface or another xdg_popup with an explicit grab. If the - * parent is another xdg_popup it means that the popups are nested, - * with this popup now being the topmost popup. - * - * Nested popups must be destroyed in the reverse order they were - * created in, e.g. the only popup you are allowed to destroy at - * all times is the topmost one. - * - * When compositors choose to dismiss a popup, they may dismiss - * every nested grabbing popup as well. When a compositor dismisses - * popups, it will follow the same dismissing order as required - * from the client. - * - * The parent of a grabbing popup must either be another xdg_popup - * with an active explicit grab, or an xdg_popup or xdg_toplevel, - * if there are no explicit grabs already taken. - * - * If the topmost grabbing popup is destroyed, the grab will be - * returned to the parent of the popup, if that parent previously - * had an explicit grab. - * - * If the parent is a grabbing popup which has already been - * dismissed, this popup will be immediately dismissed. If the - * parent is a popup that did not take an explicit grab, an error - * will be raised. - * - * During a popup grab, the client owning the grab will receive - * pointer and touch events for all their surfaces as normal - * (similar to an "owner-events" grab in X11 parlance), while the - * top most grabbing popup will always have keyboard focus. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - */ - static void Grab(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat, uint32_t serial); - /** - * recalculate the popup's location - * - * Reposition an already-mapped popup. The popup will be placed - * given the details in the passed xdg_positioner object, and a - * xdg_popup.repositioned followed by xdg_popup.configure and - * xdg_surface.configure will be emitted in response. Any - * parameters set by the previous positioner will be discarded. - * - * The passed token will be sent in the corresponding - * xdg_popup.repositioned event. The new popup position will not - * take effect until the corresponding configure event is - * acknowledged by the client. See xdg_popup.repositioned for - * details. The token itself is opaque, and has no other special - * meaning. - * - * If multiple reposition requests are sent, the compositor may - * skip all but the last one. - * - * If the popup is repositioned in response to a configure event - * for its parent, the client should send an - * xdg_positioner.set_parent_configure and possibly an - * xdg_positioner.set_parent_size request to allow the compositor - * to properly constrain the popup. - * - * If the popup is repositioned together with a parent that is - * being resized, but not in response to a configure event, the - * client should send an xdg_positioner.set_parent_size request. - * @param token reposition request token - * @since 3 - */ - static void Reposition( - struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *positioner, - uint32_t token); - - static struct xdg_popup_interface impl_; -}; - -class WaylandXdgPopup : public WaylandResourceObject { -public: - static OHOS::sptr Create( - const OHOS::sptr &xdgSurface, - const OHOS::sptr &parentXdgSurface, - const OHOS::sptr &positioner, - uint32_t id); - ~WaylandXdgPopup() noexcept; - void OnSurfaceCommitted(); - void UpdateSize(int32_t x, int32_t y, uint32_t width, uint32_t height); - void SetGeometry(int32_t x, int32_t y, uint32_t width, uint32_t height); - -private: - WaylandXdgPopup( - const OHOS::sptr &xdgSurface, - const OHOS::sptr &parentXdgSurface, - const OHOS::sptr &positioner, - uint32_t id); - - friend struct WaylandXdgPopupInterface; - - void Grab(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat, uint32_t serial); - - void Reposition( - struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *positioner, - uint32_t token); - -private: - OHOS::wptr xdgSurface_; - OHOS::wptr parentXdgSurface_; -}; -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_positioner.cpp b/wayland_adapter/framework/stable/wayland_xdg_positioner.cpp deleted file mode 100644 index 543109607b886da73217dbfda736a5b5fb572158..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/stable/wayland_xdg_positioner.cpp +++ /dev/null @@ -1,288 +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_xdg_positioner.h" - -#include "wayland_objects_pool.h" -#include "wayland_xdg_surface.h" - -namespace FT { -namespace Wayland { -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandXdgPositioner"}; -} -struct xdg_positioner_interface WaylandXdgPositionerInterface::impl_ = { - .destroy = WaylandResourceObject::DefaultDestroyResource, - .set_size = WaylandXdgPositionerInterface::SetSize, - .set_anchor_rect = WaylandXdgPositionerInterface::SetAnchorRect, - .set_anchor = WaylandXdgPositionerInterface::SetAnchor, - .set_gravity = WaylandXdgPositionerInterface::SetGravity, - .set_constraint_adjustment = WaylandXdgPositionerInterface::SetConstraintAdjustment, - .set_offset = WaylandXdgPositionerInterface::SetOffset, - .set_reactive = WaylandXdgPositionerInterface::SetReactive, - .set_parent_size = WaylandXdgPositionerInterface::SetParentSize, - .set_parent_configure = WaylandXdgPositionerInterface::SetParentConfigure}; - -void WaylandXdgPositionerInterface::SetSize( - struct wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) -{ - LOG_DEBUG("Request: xdg_positioner-->set_size."); - UNUSED(client); - CAST_OBJECT_AND_CALL_FUNC( - WaylandXdgPositioner, resource, "WaylandXdgPositioner::SetSize: failed to find object.", SetSize, width, height); -} - -void WaylandXdgPositionerInterface::SetAnchorRect( - struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) -{ - LOG_DEBUG("Request: xdg_positioner-->set_anchor_rect."); - UNUSED(client); - CAST_OBJECT_AND_CALL_FUNC( - WaylandXdgPositioner, - resource, - "WaylandXdgPositioner::SetAnchorRect: failed to find object.", - SetAnchorRect, - x, - y, - width, - height); -} - -void WaylandXdgPositionerInterface::SetAnchor(struct wl_client *client, struct wl_resource *resource, uint32_t anchor) -{ - LOG_DEBUG("Request: xdg_positioner-->set_anchor."); - UNUSED(client); - CAST_OBJECT_AND_CALL_FUNC( - WaylandXdgPositioner, resource, "WaylandXdgPositioner::SetAnchor: failed to find object.", SetAnchor, anchor); -} - -void WaylandXdgPositionerInterface::SetGravity(struct wl_client *client, struct wl_resource *resource, uint32_t gravity) -{ - LOG_DEBUG("Request: xdg_positioner-->set_gravity."); - UNUSED(client); - CAST_OBJECT_AND_CALL_FUNC( - WaylandXdgPositioner, resource, "WaylandXdgPositioner::SetGravity: failed to find object.", SetGravity, gravity); -} - -void WaylandXdgPositionerInterface::SetConstraintAdjustment( - struct wl_client *client, - struct wl_resource *resource, - uint32_t constraintAdjustment) -{ - LOG_DEBUG("Request: xdg_positioner-->set_constraint_adjustment."); - UNUSED(client); - CAST_OBJECT_AND_CALL_FUNC( - WaylandXdgPositioner, - resource, - "WaylandXdgPositioner::SetConstraintAdjustment: failed to find object.", - SetConstraintAdjustment, - constraintAdjustment); -} - -void WaylandXdgPositionerInterface::SetOffset(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y) -{ - LOG_DEBUG("Request: xdg_positioner-->set_offset."); - UNUSED(client); - CAST_OBJECT_AND_CALL_FUNC( - WaylandXdgPositioner, resource, "WaylandXdgPositioner::SetOffset: failed to find object.", SetOffset, x, y); -} - -void WaylandXdgPositionerInterface::SetReactive(struct wl_client *client, struct wl_resource *resource) -{ - LOG_DEBUG("Request: xdg_positioner-->set_reactive."); - UNUSED(client); - CAST_OBJECT_AND_CALL_FUNC( - WaylandXdgPositioner, resource, "WaylandXdgPositioner::SetReactive: failed to find object.", SetReactive); -} - -void WaylandXdgPositionerInterface::SetParentSize( - struct wl_client *client, - struct wl_resource *resource, - int32_t parentWidth, - int32_t parentHeight) -{ - LOG_DEBUG("Request: xdg_positioner-->set_parent_size."); - UNUSED(client); - CAST_OBJECT_AND_CALL_FUNC( - WaylandXdgPositioner, - resource, - "WaylandXdgPositioner::SetParentSize: failed to find object.", - SetParentSize, - parentWidth, - parentHeight); -} - -void WaylandXdgPositionerInterface::SetParentConfigure( - struct wl_client *client, - struct wl_resource *resource, - uint32_t serial) -{ - LOG_DEBUG("Request: xdg_positioner-->set_parent_configure."); - UNUSED(client); - CAST_OBJECT_AND_CALL_FUNC( - WaylandXdgPositioner, - resource, - "WaylandXdgPositioner::SetParentConfigure: failed to find object.", - SetParentConfigure, - serial); -} - -OHOS::sptr WaylandXdgPositioner::Create(struct wl_client *client, uint32_t version, uint32_t id) -{ - // check - if (client == nullptr) { - LOG_WARN("WaylandXdgPositioner::Create failed: client is nullptr."); - return nullptr; - } - - auto xdgPositioner = OHOS::sptr(new WaylandXdgPositioner(client, version, id)); - WaylandObjectsPool::GetInstance().AddObject(ObjectId(xdgPositioner->WlClient(), xdgPositioner->Id()), xdgPositioner); - return xdgPositioner; -} - -WaylandXdgPositioner::WaylandXdgPositioner(struct wl_client *client, uint32_t version, uint32_t id) - : WaylandResourceObject(client, &xdg_positioner_interface, version, id, &WaylandXdgPositionerInterface::impl_) -{ - LOG_DEBUG("WaylandXdgPositioner ctor."); -} - -WaylandXdgPositioner::~WaylandXdgPositioner() noexcept -{ - LOG_DEBUG("WaylandXdgPositioner dtor."); -} - -void WaylandXdgPositioner::SetSize(int32_t width, int32_t height) -{ - if (width < 1 || height < 1) { - wl_resource_post_error( - WlResource(), XDG_POSITIONER_ERROR_INVALID_INPUT, "width and height must be positives and non-zero"); - return; - } - - size_.width = width; - size_.height = height; -} - -void WaylandXdgPositioner::SetAnchorRect(int32_t x, int32_t y, int32_t width, int32_t height) -{ - if (width < 0 || height < 0) { - wl_resource_post_error( - WlResource(), XDG_POSITIONER_ERROR_INVALID_INPUT, "width and height must be non-negative"); - return; - } - - anchorRect_.x = x; - anchorRect_.y = y; - anchorRect_.width = width; - anchorRect_.height = height; -} - -void WaylandXdgPositioner::SetAnchor(uint32_t anchor) -{ - auto newAnchor = static_cast(anchor); - switch (newAnchor) { - case XDG_POSITIONER_ANCHOR_NONE: - case XDG_POSITIONER_ANCHOR_TOP: - case XDG_POSITIONER_ANCHOR_BOTTOM: - case XDG_POSITIONER_ANCHOR_LEFT: - case XDG_POSITIONER_ANCHOR_RIGHT: - case XDG_POSITIONER_ANCHOR_TOP_LEFT: - case XDG_POSITIONER_ANCHOR_BOTTOM_LEFT: - case XDG_POSITIONER_ANCHOR_TOP_RIGHT: - case XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT: - anchor_ = newAnchor; - break; - default: - break; - } -} - -void WaylandXdgPositioner::SetGravity(uint32_t gravity) -{ - auto newGravity = static_cast(gravity); - switch (newGravity) { - case XDG_POSITIONER_GRAVITY_NONE: - case XDG_POSITIONER_GRAVITY_TOP: - case XDG_POSITIONER_GRAVITY_BOTTOM: - case XDG_POSITIONER_GRAVITY_LEFT: - case XDG_POSITIONER_GRAVITY_RIGHT: - case XDG_POSITIONER_GRAVITY_TOP_LEFT: - case XDG_POSITIONER_GRAVITY_BOTTOM_LEFT: - case XDG_POSITIONER_GRAVITY_TOP_RIGHT: - case XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT: - gravity_ = newGravity; - break; - default: - break; - } -} - -void WaylandXdgPositioner::SetConstraintAdjustment(uint32_t constraintAdjustment) -{ - auto newConstraintAdjustment = static_cast(constraintAdjustment); - switch (newConstraintAdjustment) { - case XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE: - case XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X: - case XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y: - case XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X: - case XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y: - case XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X: - case XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y: - constraintAdjustment_ = newConstraintAdjustment; - break; - default: - break; - } -} - -void WaylandXdgPositioner::SetOffset(int32_t x, int32_t y) -{ - offset_.x = x; - offset_.y = y; -} - -void WaylandXdgPositioner::SetReactive() -{ - reactive_ = true; -} - -void WaylandXdgPositioner::SetParentSize(int32_t parentWidth, int32_t parentHeight) -{ - if (parentWidth < 1 || parentHeight < 1) { - wl_resource_post_error( - WlResource(), - XDG_POSITIONER_ERROR_INVALID_INPUT, - "positioner parent width and height must be positives and non-zero"); - return; - } - - parentSize_.width = parentWidth; - parentSize_.height = parentHeight; -} - -void WaylandXdgPositioner::SetParentConfigure(uint32_t serial) -{ - parentConfigureSerial_ = serial; -} -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_positioner.h b/wayland_adapter/framework/stable/wayland_xdg_positioner.h deleted file mode 100644 index 3aed8a5a9dd070f35a52da714904dd7d7ad52ff6..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/stable/wayland_xdg_positioner.h +++ /dev/null @@ -1,292 +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 WaylandXdgPositionerInterface { - /** - * set the size of the to-be positioned rectangle - * - * Set the size of the surface that is to be positioned with the - * positioner object. The size is in surface-local coordinates and - * corresponds to the window geometry. See - * xdg_surface.set_window_geometry. - * - * If a zero or negative size is set the invalid_input error is - * raised. - * @param width width of positioned rectangle - * @param height height of positioned rectangle - */ - static void SetSize(struct wl_client *client, struct wl_resource *resource, int32_t width, int32_t height); - /** - * set the anchor rectangle within the parent surface - * - * Specify the anchor rectangle within the parent surface that - * the child surface will be placed relative to. The rectangle is - * relative to the window geometry as defined by - * xdg_surface.set_window_geometry of the parent surface. - * - * When the xdg_positioner object is used to position a child - * surface, the anchor rectangle may not extend outside the window - * geometry of the positioned child's parent surface. - * - * If a negative size is set the invalid_input error is raised. - * @param x x position of anchor rectangle - * @param y y position of anchor rectangle - * @param width width of anchor rectangle - * @param height height of anchor rectangle - */ - static void SetAnchorRect( - struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - /** - * set anchor rectangle anchor - * - * Defines the anchor point for the anchor rectangle. The - * specified anchor is used derive an anchor point that the child - * surface will be positioned relative to. If a corner anchor is - * set (e.g. 'top_left' or 'bottom_right'), the anchor point will - * be at the specified corner; otherwise, the derived anchor point - * will be centered on the specified edge, or in the center of the - * anchor rectangle if no edge is specified. - * @param anchor anchor - */ - static void SetAnchor(struct wl_client *client, struct wl_resource *resource, uint32_t anchor); - /** - * set child surface gravity - * - * Defines in what direction a surface should be positioned, - * relative to the anchor point of the parent surface. If a corner - * gravity is specified (e.g. 'bottom_right' or 'top_left'), then - * the child surface will be placed towards the specified gravity; - * otherwise, the child surface will be centered over the anchor - * point on any axis that had no gravity specified. - * @param gravity gravity direction - */ - static void SetGravity(struct wl_client *client, struct wl_resource *resource, uint32_t gravity); - /** - * set the adjustment to be done when constrained - * - * Specify how the window should be positioned if the originally - * intended position caused the surface to be constrained, meaning - * at least partially outside positioning boundaries set by the - * compositor. The adjustment is set by constructing a bitmask - * describing the adjustment to be made when the surface is - * constrained on that axis. - * - * If no bit for one axis is set, the compositor will assume that - * the child surface should not change its position on that axis - * when constrained. - * - * If more than one bit for one axis is set, the order of how - * adjustments are applied is specified in the corresponding - * adjustment descriptions. - * - * The default adjustment is none. - * @param constraintAdjustment bit mask of constraint adjustments - */ - static void SetConstraintAdjustment( - struct wl_client *client, - struct wl_resource *resource, - uint32_t constraintAdjustment); - /** - * set surface position offset - * - * Specify the surface position offset relative to the position - * of the anchor on the anchor rectangle and the anchor on the - * surface. For example if the anchor of the anchor rectangle is at - * (x, y), the surface has the gravity bottom|right, and the offset - * is (ox, oy), the calculated surface position will be (x + ox, y - * + oy). The offset position of the surface is the one used for - * constraint testing. See set_constraint_adjustment. - * - * An example use case is placing a popup menu on top of a user - * interface element, while aligning the user interface element of - * the parent surface with some user interface element placed - * somewhere in the popup surface. - * @param x surface position x offset - * @param y surface position y offset - */ - static void SetOffset(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y); - /** - * continuously reconstrain the surface - * - * When set reactive, the surface is reconstrained if the - * conditions used for constraining changed, e.g. the parent window - * moved. - * - * If the conditions changed and the popup was reconstrained, an - * xdg_popup.configure event is sent with updated geometry, - * followed by an xdg_surface.configure event. - * @since 3 - */ - static void SetReactive(struct wl_client *client, struct wl_resource *resource); - /** - * - * - * Set the parent window geometry the compositor should use when - * positioning the popup. The compositor may use this information - * to determine the future state the popup should be constrained - * using. If this doesn't match the dimension of the parent the - * popup is eventually positioned against, the behavior is - * undefined. - * - * The arguments are given in the surface-local coordinate space. - * @param parentWidth future window geometry width of parent - * @param parentHeight future window geometry height of parent - * @since 3 - */ - static void SetParentSize( - struct wl_client *client, - struct wl_resource *resource, - int32_t parentWidth, - int32_t parentHeight); - /** - * set parent configure this is a response to - * - * Set the serial of an xdg_surface.configure event this - * positioner will be used in response to. The compositor may use - * this information together with set_parent_size to determine what - * future state the popup should be constrained using. - * @param serial serial of parent configure event - * @since 3 - */ - static void SetParentConfigure(struct wl_client *client, struct wl_resource *resource, uint32_t serial); - - static struct xdg_positioner_interface impl_; -}; - -class WaylandXdgPositioner final : public WaylandResourceObject { -public: - /** - * @brief Create XdgOutput resource by XdgOutputManager - * - * @param client - * @param manager - * @param version - * @param id - * @param output - * @return OHOS::sptr - */ - static OHOS::sptr Create(struct wl_client *client, uint32_t version, uint32_t id); - ~WaylandXdgPositioner() noexcept override; - - Size GetSize() const - { - return size_; - } - Rect GetAnchorRect() const - { - return anchorRect_; - } - enum xdg_positioner_anchor GetAnchor() const - { - return anchor_; - } - enum xdg_positioner_gravity GetGravity() const - { - return gravity_; - } - enum xdg_positioner_constraint_adjustment GetConstraintAdjustment() const - { - return constraintAdjustment_; - } - Offset GetOffset() const - { - return offset_; - } - bool GetReactive() const - { - return reactive_; - } - Size GetParentSize() const - { - return parentSize_; - } - uint32_t GetParentConfigureSerial() const - { - return parentConfigureSerial_; - } - -private: - WaylandXdgPositioner(struct wl_client *client, uint32_t version, uint32_t id); - -private: - friend struct WaylandXdgPositionerInterface; - // WaylandXdgPositionerInterface will call these member functions. - void SetSize(int32_t width, int32_t height); - void SetAnchorRect(int32_t x, int32_t y, int32_t width, int32_t height); - // enum xdg_positioner_anchor { - // XDG_POSITIONER_ANCHOR_NONE = 0, - // XDG_POSITIONER_ANCHOR_TOP = 1, - // XDG_POSITIONER_ANCHOR_BOTTOM = 2, - // XDG_POSITIONER_ANCHOR_LEFT = 3, - // XDG_POSITIONER_ANCHOR_RIGHT = 4, - // XDG_POSITIONER_ANCHOR_TOP_LEFT = 5, - // XDG_POSITIONER_ANCHOR_BOTTOM_LEFT = 6, - // XDG_POSITIONER_ANCHOR_TOP_RIGHT = 7, - // XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT = 8, - // }; - void SetAnchor(uint32_t anchor); - // enum xdg_positioner_gravity { - // XDG_POSITIONER_GRAVITY_NONE = 0, - // XDG_POSITIONER_GRAVITY_TOP = 1, - // XDG_POSITIONER_GRAVITY_BOTTOM = 2, - // XDG_POSITIONER_GRAVITY_LEFT = 3, - // XDG_POSITIONER_GRAVITY_RIGHT = 4, - // XDG_POSITIONER_GRAVITY_TOP_LEFT = 5, - // XDG_POSITIONER_GRAVITY_BOTTOM_LEFT = 6, - // XDG_POSITIONER_GRAVITY_TOP_RIGHT = 7, - // XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT = 8, - // }; - void SetGravity(uint32_t gravity); - // enum xdg_positioner_constraint_adjustment { - // XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE = 0, - // XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1, - // XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2, - // XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X = 4, - // XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8, - // XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16, - // XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32, - // }; - void SetConstraintAdjustment(uint32_t constraintAdjustment); - void SetOffset(int32_t x, int32_t y); - void SetReactive(); - void SetParentSize(int32_t parentWidth, int32_t parentHeight); - void SetParentConfigure(uint32_t serial); - -private: - Size size_; - Rect anchorRect_; - enum xdg_positioner_anchor anchor_ = XDG_POSITIONER_ANCHOR_NONE; - enum xdg_positioner_gravity gravity_ = XDG_POSITIONER_GRAVITY_NONE; - enum xdg_positioner_constraint_adjustment constraintAdjustment_ = XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE; - Offset offset_; - bool reactive_ = false; - Size parentSize_; - uint32_t parentConfigureSerial_ = 0; -}; -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_surface.cpp b/wayland_adapter/framework/stable/wayland_xdg_surface.cpp deleted file mode 100644 index c00c6499d0e085873c87ab04230cbf83927f26eb..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/stable/wayland_xdg_surface.cpp +++ /dev/null @@ -1,189 +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_xdg_surface.h" - -#include "wayland_objects_pool.h" -#include "wayland_xdg_toplevel.h" -#include "wayland_xdg_wm_base.h" - -namespace FT { -namespace Wayland { -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandXdgSurface"}; -} - -struct xdg_surface_interface IWaylandXdgSurface::impl_ = { - .destroy = &WaylandResourceObject::DefaultDestroyResource, - .get_toplevel = GetToplevel, - .get_popup = GetPopup, - .set_window_geometry = SetWindowGeometry, - .ack_configure = AckConfigure}; - -void IWaylandXdgSurface::GetToplevel(struct wl_client *client, struct wl_resource *resource, uint32_t id) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgSurface, resource, - "WaylandXdgSurface::GetToplevel: failed to find object.", GetToplevel, id); -} - -void IWaylandXdgSurface::GetPopup(struct wl_client *client, struct wl_resource *resource, - uint32_t id, struct wl_resource *parent, struct wl_resource *positioner) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgSurface, resource, - "WaylandXdgSurface::GetPopup: failed to find object.", GetPopup, id, parent, positioner); -} - -void IWaylandXdgSurface::SetWindowGeometry(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(WaylandXdgSurface, resource, - "WaylandXdgSurface::SetWindowGeometry: failed to find object.", SetWindowGeometry, x, y, width, height); -} - -void IWaylandXdgSurface::AckConfigure(struct wl_client *client, struct wl_resource *resource, uint32_t serial) -{ -} - -OHOS::sptr WaylandXdgSurface::Create(const OHOS::sptr &xdgWm, - const OHOS::sptr &surface, uint32_t id) -{ - if (xdgWm == nullptr) { - LOG_WARN("xdgWm is nullptr"); - return nullptr; - } - if (surface == nullptr) { - LOG_WARN("surface is nullptr"); - return nullptr; - } - - auto xdgSurface = OHOS::sptr(new WaylandXdgSurface(xdgWm, surface, id)); - WaylandObjectsPool::GetInstance().AddObject(ObjectId(xdgSurface->WlClient(), xdgSurface->Id()), xdgSurface); - xdgSurface->windowOption_ = surface->GetWindowOption(); - xdgSurface->windowOptionExt_ = surface->GetWindowOptionExt(); - - return xdgSurface; -} - -WaylandXdgSurface::WaylandXdgSurface(const OHOS::sptr &xdgWm, - const OHOS::sptr &surface, uint32_t id) - : WaylandResourceObject(xdgWm->WlClient(), &xdg_surface_interface, xdgWm->Version(), - id, &IWaylandXdgSurface::impl_), - xdgWm_(xdgWm), - surface_(surface) -{ - surface->AddCommitCallback([this]() { OnSurfaceCommit(); }); - surface->AddRectCallback([this](Rect rect) { OnSurfaceRect(rect); }); - surface->AddWindowCreateCallback([this](OHOS::sptr window) { OnWindowCreate(window); }); - windowTitle_ = std::to_string((long)((void *)this)) + std::string("-Untitled"); - LOG_DEBUG("enter : %{public}s.", windowTitle_.c_str()); -} - -WaylandXdgSurface::~WaylandXdgSurface() noexcept -{ - LOG_DEBUG("exit : %{public}s.", windowTitle_.c_str()); - if (window_ != nullptr) { - window_->Close(); - } -} - -void WaylandXdgSurface::GetToplevel(uint32_t id) -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); - toplevel_ = WaylandXdgToplevel::Create(this, id, windowOption_, windowOptionExt_); - if (toplevel_ == nullptr) { - LOG_ERROR("no memory"); - return; - } - - role_ = SurfaceRole::XDG_TOPLEVEL; - surface_->WithTopLevel(true); -} - -void WaylandXdgSurface::GetPopup(uint32_t id, struct wl_resource *parent, struct wl_resource *positioner) -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); - auto parentXdgSurface = CastFromResource(parent); - if (parentXdgSurface == nullptr) { - LOG_ERROR("parentXdgSurface is nullptr."); - return; - } - - auto xdgPositioner = CastFromResource(positioner); - if (xdgPositioner == nullptr) { - LOG_ERROR("xdgPositioner is nullptr."); - return; - } - - auto popUp = WaylandXdgPopup::Create(this, parentXdgSurface, xdgPositioner, id); - if (popUp == nullptr) { - LOG_ERROR("no memory"); - return; - } - popUp_ = popUp; - popUp_->UpdateSize(0, 0, xdgPositioner->GetSize().width, xdgPositioner->GetSize().height); - role_ = SurfaceRole::XDG_POPUP; -} - -void WaylandXdgSurface::SetWindowGeometry(int32_t x, int32_t y, int32_t width, int32_t height) -{ - LOG_DEBUG("Window %{public}s. x:%{public}d y:%{public}d width:%{public}d height:%{public}d", - windowTitle_.c_str(), x, y, width, height); - auto surface = surface_.promote(); - if (surface != nullptr) { - Rect rect = {x, y, static_cast(width), static_cast(height)}; - surface->SetWindowGeometry(rect); - } -} - -void WaylandXdgSurface::AckConfigure(uint32_t serial) -{ -} - -void WaylandXdgSurface::OnSurfaceCommit() -{ - if (role_ == SurfaceRole::XDG_TOPLEVEL) { - auto topLevel = toplevel_.promote(); - if (topLevel != nullptr) { - topLevel->HandleCommit(); - } - } - - xdg_surface_send_configure(WlResource(), wl_display_next_serial(WlDisplay())); -} - -void WaylandXdgSurface::OnSurfaceRect(Rect rect) -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); - if (role_ == SurfaceRole::XDG_TOPLEVEL) { - auto topLevel = toplevel_.promote(); - if (topLevel != nullptr) { - topLevel->SetRect(rect); - xdg_surface_send_configure(WlResource(), wl_display_next_serial(WlDisplay())); - } - } -} - -void WaylandXdgSurface::OnWindowCreate(OHOS::sptr window) -{ - window_ = window; - if (role_ == SurfaceRole::XDG_TOPLEVEL) { - auto topLevel = toplevel_.promote(); - if (topLevel != nullptr) { - topLevel->SetWindow(window); - } - } -} -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_surface.h b/wayland_adapter/framework/stable/wayland_xdg_surface.h deleted file mode 100644 index 1de48e63d28c0a8cc912966cbaee1c3dc7549ac6..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/stable/wayland_xdg_surface.h +++ /dev/null @@ -1,67 +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 "wayland_surface.h" -#include "wayalnd_utils.h" -#include "wayland_xdg_popup.h" - -namespace FT { -namespace Wayland { -class WaylandXdgWmObject; -class WaylandXdgToplevel; -struct IWaylandXdgSurface { - static void GetToplevel(struct wl_client *client, struct wl_resource *resource, uint32_t id); - static void GetPopup(struct wl_client *client, struct wl_resource *resource, - uint32_t id, struct wl_resource *parent, struct wl_resource *positioner); - static void SetWindowGeometry(struct wl_client *client, struct wl_resource *resource, - int32_t x, int32_t y, int32_t width, int32_t height); - static void AckConfigure(struct wl_client *client, struct wl_resource *resource, uint32_t serial); - static struct xdg_surface_interface impl_; -}; - -class WaylandXdgSurface : public WaylandResourceObject { -public: - static OHOS::sptr Create(const OHOS::sptr &xdgWm, - const OHOS::sptr &surface, uint32_t id); - WaylandXdgSurface(const OHOS::sptr &xdgWm, const OHOS::sptr &surface, uint32_t id); - ~WaylandXdgSurface() noexcept override; - -private: - friend struct IWaylandXdgSurface; - - void GetToplevel(uint32_t id); - void GetPopup(uint32_t id, struct wl_resource *parent, struct wl_resource *positioner); - void SetWindowGeometry(int32_t x, int32_t y, int32_t width, int32_t height); - void AckConfigure(uint32_t serial); - void OnSurfaceCommit(); - void OnSurfaceRect(Rect rect); - void OnWindowCreate(OHOS::sptr window); - - SurfaceRole role_ = SurfaceRole::NONE; - OHOS::wptr xdgWm_; - OHOS::wptr surface_; - OHOS::wptr toplevel_; - OHOS::wptr popUp_; - std::string windowTitle_ = "unknow"; - OHOS::sptr window_; - OHOS::sptr windowOption_; - std::shared_ptr windowOptionExt_; -}; -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_toplevel.cpp b/wayland_adapter/framework/stable/wayland_xdg_toplevel.cpp deleted file mode 100644 index 8d5503e5e0204693fb88fdb533b99469917704c7..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/stable/wayland_xdg_toplevel.cpp +++ /dev/null @@ -1,303 +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_xdg_toplevel.h" - -#include "wayland_objects_pool.h" - -namespace FT { -namespace Wayland { -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandXdgToplevel"}; -} - -struct xdg_toplevel_interface IWaylandXdgToplevel::impl_ = { - .destroy = DestroyResource, - .set_parent = SetParent, - .set_title = SetTitle, - .set_app_id = SetAppId, - .show_window_menu = ShowWindowMenu, - .move = Move, - .resize = Resize, - .set_max_size = SetMaxSize, - .set_min_size = SetMinSize, - .set_maximized = SetMaximized, - .unset_maximized = UnsetMaximized, - .set_fullscreen = SetFullscreen, - .unset_fullscreen = UnsetFullscreen, - .set_minimized = SetMinimized}; - -void IWaylandXdgToplevel::SetParent(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *parent) {} - -void IWaylandXdgToplevel::SetTitle(struct wl_client *client, struct wl_resource *resource, const char *title) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::SetTitle: failed to find object.", SetTitle, title); -} - -void IWaylandXdgToplevel::SetAppId(struct wl_client *client, struct wl_resource *resource, const char *app_id) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::SetTitle: failed to find object.", SetAppId, app_id); -} - -void IWaylandXdgToplevel::ShowWindowMenu(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *seat, uint32_t serial, int32_t x, int32_t y) {} - -void IWaylandXdgToplevel::Move(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *seat, uint32_t serial) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::Move: failed to find object.", Move, serial); -} - -void IWaylandXdgToplevel::Resize(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *seat, uint32_t serial, uint32_t edges) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::Resize: failed to find object.", Resize, serial, edges); -} - -void IWaylandXdgToplevel::SetMaxSize(struct wl_client *client, struct wl_resource *resource, - int32_t width, int32_t height) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::SetMaxSize: failed to find object.", SetMaxSize, width, height); -} - -void IWaylandXdgToplevel::SetMinSize(struct wl_client *client, struct wl_resource *resource, - int32_t width, int32_t height) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::SetMinSize: failed to find object.", SetMinSize, width, height); -} - -void IWaylandXdgToplevel::SetMaximized(struct wl_client *client, struct wl_resource *resource) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::SetMaximized: failed to find object.", SetMaximized); -} - -void IWaylandXdgToplevel::UnsetMaximized(struct wl_client *client, struct wl_resource *resource) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::UnsetMaximized: failed to find object.", UnSetMaximized); -} - -void IWaylandXdgToplevel::SetFullscreen(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *output) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::SetFullscreen: failed to find object.", SetFullscreen); -} - -void IWaylandXdgToplevel::UnsetFullscreen(struct wl_client *client, struct wl_resource *resource) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::UnsetFullscreen: failed to find object.", UnSetFullscreen); -} - -void IWaylandXdgToplevel::SetMinimized(struct wl_client *client, struct wl_resource *resource) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::SetMinimized: failed to find object.", SetMinimized); -} - -void IWaylandXdgToplevel::DestroyResource(struct wl_client *client, struct wl_resource *resource) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgToplevel, resource, - "IWaylandXdgToplevel::DestroyResource: failed to find object.", DestroyResource, client, resource); -} - -void WaylandXdgToplevel::DestroyResource(struct wl_client *client, struct wl_resource *resource) -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); - WaylandResourceObject::DefaultDestroyResource(client, resource); -} - -OHOS::sptr WaylandXdgToplevel::Create(const OHOS::sptr &xdgSurface, uint32_t id, - OHOS::sptr windowOption, std::shared_ptr windowOptionExt) -{ - if (xdgSurface == nullptr) { - LOG_WARN("xdgSurface is nullptr"); - return nullptr; - } - - auto xdgTopLevel = OHOS::sptr(new WaylandXdgToplevel(xdgSurface, id)); - WaylandObjectsPool::GetInstance().AddObject(ObjectId(xdgTopLevel->WlClient(), xdgTopLevel->Id()), xdgTopLevel); - xdgTopLevel->windowOption_ = windowOption; - xdgTopLevel->windowOptionExt_ = windowOptionExt; - - return xdgTopLevel; -} - -WaylandXdgToplevel::WaylandXdgToplevel(const OHOS::sptr &xdgSurface, uint32_t id) - : WaylandResourceObject(xdgSurface->WlClient(), &xdg_toplevel_interface, xdgSurface->Version(), - id, &IWaylandXdgToplevel::impl_), - xdgSurface_(xdgSurface) -{ - windowTitle_ = std::to_string((long)((void *)this)) + std::string("-Untitled"); - LOG_DEBUG("enter : %{public}s.", windowTitle_.c_str()); -} - -WaylandXdgToplevel::~WaylandXdgToplevel() noexcept -{ - LOG_DEBUG("exit : %{public}s.", windowTitle_.c_str()); -} - -void WaylandXdgToplevel::SetTitle(const char *title) -{ - LOG_DEBUG("Window %{public}s, set Title %{public}s.", windowTitle_.c_str(), title); - windowTitle_ = std::to_string((long)((void *)this)) + std::string("-") + std::string(title); - if (window_ != nullptr) { - window_->SetAPPWindowLabel(title); - } else { - windowOptionExt_->title = title; - } -} - -void WaylandXdgToplevel::Move(uint32_t serial) -{ - if (window_ != nullptr) { - window_->StartMove(); - } -} - -void WaylandXdgToplevel::Resize(uint32_t serial, uint32_t edges) -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); -} - -void WaylandXdgToplevel::SetAppId(const char *appId) -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); - if (strstr(appId, "desktop") != nullptr && windowOption_ != nullptr) { - windowOption_->SetWindowMode(OHOS::Rosen::WindowMode::WINDOW_MODE_FULLSCREEN); - windowOption_->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_DESKTOP); - } -} - -void WaylandXdgToplevel::SetMaxSize(int32_t width, int32_t height) -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); -} - -void WaylandXdgToplevel::SetMinSize(int32_t width, int32_t height) -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); -} - -void WaylandXdgToplevel::SetMaximized() -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); - if (state_.maximized) { - LOG_DEBUG("Window %{public}s already Maximized.", windowTitle_.c_str()); - return UnSetMaximized(); - } - state_.maximized = true; - if (window_ != nullptr) { - window_->Maximize(); - } else { - windowOptionExt_->maximizeAfterShow = true; - windowOptionExt_->fullscreenAfterShow = false; - windowOptionExt_->minimizeAfterShow = false; - } -} - -void WaylandXdgToplevel::UnSetMaximized() -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); - state_.maximized = false; - if (window_ != nullptr) { - window_->Recover(); - } -} - -void WaylandXdgToplevel::SetFullscreen() -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); - state_.fullscreen = true; - if (window_ != nullptr) { - window_->SetFullScreen(true); - } else { - windowOptionExt_->maximizeAfterShow = false; - windowOptionExt_->fullscreenAfterShow = true; - windowOptionExt_->minimizeAfterShow = false; - } -} - -void WaylandXdgToplevel::UnSetFullscreen() -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); - state_.fullscreen = false; - if (window_ != nullptr) { - window_->SetFullScreen(false); - } -} - -void WaylandXdgToplevel::SetMinimized() -{ - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); - state_.minimized = true; - if (window_ != nullptr) { - window_->Minimize(); - } else { - windowOptionExt_->maximizeAfterShow = false; - windowOptionExt_->fullscreenAfterShow = false; - windowOptionExt_->minimizeAfterShow = true; - } -} - -void WaylandXdgToplevel::SendConfigure() -{ - SetRect(rect_); -} - -void WaylandXdgToplevel::HandleCommit() -{ - SendConfigure(); -} - -void WaylandXdgToplevel::SetRect(Rect rect) -{ - rect_ = rect; - struct wl_array states; - uint32_t *s; - wl_array_init(&states); - if (state_.maximized) { - s = static_cast(wl_array_add(&states, sizeof(uint32_t))); - *s = XDG_TOPLEVEL_STATE_MAXIMIZED; - } - if (state_.fullscreen) { - s = static_cast(wl_array_add(&states, sizeof(uint32_t))); - *s = XDG_TOPLEVEL_STATE_FULLSCREEN; - } - if (state_.resizing) { - s = static_cast(wl_array_add(&states, sizeof(uint32_t))); - *s = XDG_TOPLEVEL_STATE_RESIZING; - } - s = static_cast(wl_array_add(&states, sizeof(uint32_t))); - *s = XDG_TOPLEVEL_STATE_ACTIVATED; - xdg_toplevel_send_configure(WlResource(), rect.width, rect.height, &states); - wl_array_release(&states); -} - -void WaylandXdgToplevel::SetWindow(OHOS::sptr window) -{ - window_ = window; -} -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_toplevel.h b/wayland_adapter/framework/stable/wayland_xdg_toplevel.h deleted file mode 100644 index 8b9eaffcce1786d913556832e160473aaa2f76e8..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/stable/wayland_xdg_toplevel.h +++ /dev/null @@ -1,86 +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_xdg_surface.h" - -namespace FT { -namespace Wayland { -struct IWaylandXdgToplevel { - static void DestroyResource(struct wl_client *client, struct wl_resource *resource); - static void SetParent(struct wl_client *client, struct wl_resource *resource, struct wl_resource *parent); - static void SetTitle(struct wl_client *client, struct wl_resource *resource, const char *title); - static void SetAppId(struct wl_client *client, struct wl_resource *resource, const char *app_id); - static void ShowWindowMenu(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *seat, uint32_t serial, int32_t x, int32_t y); - static void Move(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *seat, uint32_t serial); - static void Resize(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *seat, uint32_t serial, uint32_t edges); - static void SetMaxSize(struct wl_client *client, struct wl_resource *resource, int32_t width, int32_t height); - static void SetMinSize(struct wl_client *client, struct wl_resource *resource, int32_t width, int32_t height); - static void SetMaximized(struct wl_client *client, struct wl_resource *resource); - static void UnsetMaximized(struct wl_client *client, struct wl_resource *resource); - static void SetFullscreen(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output); - static void UnsetFullscreen(struct wl_client *client, struct wl_resource *resource); - static void SetMinimized(struct wl_client *client, struct wl_resource *resource); - static struct xdg_toplevel_interface impl_; -}; - -class WaylandXdgToplevel final : public WaylandResourceObject { -public: - static OHOS::sptr Create(const OHOS::sptr &xdgSurface, uint32_t id, - OHOS::sptr windowOption, std::shared_ptr windowOptionExt); - ~WaylandXdgToplevel() noexcept override; - - void DestroyResource(struct wl_client *client, struct wl_resource *resource); - void SetTitle(const char *title); - void SetAppId(const char *appId); - void SetMaxSize(int32_t width, int32_t height); - void SetMinSize(int32_t width, int32_t height); - void SetMaximized(); - void UnSetMaximized(); - void SetFullscreen(); - void UnSetFullscreen(); - void SetMinimized(); - void Move(uint32_t serial); - void Resize(uint32_t serial, uint32_t edges); - void SendConfigure(); - void HandleCommit(); - void SetRect(Rect rect); - void SetWindow(OHOS::sptr window); - -private: - WaylandXdgToplevel(const OHOS::sptr &xdgSurface, uint32_t id); - friend struct IWaylandXdgToplevel; - - OHOS::wptr xdgSurface_; - std::string windowTitle_ = "unknow"; - Rect rect_; - OHOS::sptr window_; - OHOS::sptr windowOption_; - std::shared_ptr windowOptionExt_; - - struct { - bool maximized = false; - bool minimized = false; - bool fullscreen = false; - bool resizing = true; - } state_; -}; -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_wm_base.cpp b/wayland_adapter/framework/stable/wayland_xdg_wm_base.cpp deleted file mode 100644 index 705c3c39501c339a56f99863ab2b26bf16c0905e..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/stable/wayland_xdg_wm_base.cpp +++ /dev/null @@ -1,134 +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_xdg_wm_base.h" - -#include "wayland_objects_pool.h" -#include "wayland_xdg_surface.h" -#include "wayland_xdg_positioner.h" -#include "version.h" - -namespace FT { -namespace Wayland { -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandXdgWmBase"}; -} - -struct xdg_wm_base_interface IWaylandXdgWmBase::impl_ = { - .destroy = &WaylandResourceObject::DefaultDestroyResource, - .create_positioner = CreatePositioner, - .get_xdg_surface = GetXdgSurface, - .pong = Pong, -}; - -void IWaylandXdgWmBase::CreatePositioner(struct wl_client *client, struct wl_resource *resource, uint32_t id) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgWmObject, resource, - "IWaylandXdgWmBase::CreatePositioner: failed to find object.", - CreatePositioner, client, id); -} - -void IWaylandXdgWmBase::GetXdgSurface(struct wl_client *client, struct wl_resource *xdgWmBaseResource, - uint32_t id, struct wl_resource *surfaceResource) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgWmObject, xdgWmBaseResource, - "IWaylandXdgWmBase::GetXdgSurface: failed to find object.", - GetXdgSurface, client, xdgWmBaseResource, id, surfaceResource); -} - -void IWaylandXdgWmBase::Pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandXdgWmObject, resource, - "IWaylandXdgWmBase::Pong: failed to find object.", Pong, client, resource, serial); -} - -OHOS::sptr WaylandXdgWmObject::Create(struct wl_client *client, uint32_t version, uint32_t id) -{ - if (client == nullptr) { - LOG_WARN("client is nullptr"); - return nullptr; - } - - auto xdgWm = OHOS::sptr(new WaylandXdgWmObject(client, version, id)); - WaylandObjectsPool::GetInstance().AddObject(ObjectId(xdgWm->WlClient(), xdgWm->Id()), xdgWm); - return xdgWm; -} - -WaylandXdgWmObject::WaylandXdgWmObject(struct wl_client *client, uint32_t version, uint32_t id) - : WaylandResourceObject(client, &xdg_wm_base_interface, version, id, &IWaylandXdgWmBase::impl_) {} - -WaylandXdgWmObject::~WaylandXdgWmObject() noexcept {} - -void WaylandXdgWmObject::CreatePositioner(struct wl_client *client, uint32_t id) -{ - if (client != client_) { - LOG_WARN("client conflict"); - return; - } - - auto xdgPositioner = WaylandXdgPositioner::Create(client, Version(), id); - if (xdgPositioner == nullptr) { - LOG_ERROR("no memory"); - return; - } -} - -void WaylandXdgWmObject::GetXdgSurface(struct wl_client *client, struct wl_resource *xdgWmBaseResource, - uint32_t id, struct wl_resource *surfaceResource) -{ - if (client != client_) { - LOG_WARN("client conflict"); - return; - } - - auto surface = CastFromResource(surfaceResource); - if (surface == nullptr) { - LOG_WARN("waylandSurface is nullptr"); - return; - } - - auto xdgSurface = WaylandXdgSurface::Create(this, surface, id); - if (xdgSurface == nullptr) { - LOG_ERROR("no memory"); - return; - } -} - -void WaylandXdgWmObject::Pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial) {} - -OHOS::sptr WaylandXdgWmBase::Create(struct wl_display *display) -{ - if (display == nullptr) { - LOG_ERROR("display is nullptr"); - return nullptr; - } - - return OHOS::sptr(new WaylandXdgWmBase(display)); -} - -WaylandXdgWmBase::WaylandXdgWmBase(struct wl_display *display) - : WaylandGlobal(display, &xdg_wm_base_interface, XDG_WM_BASE_MAX_VERSION) {} - -WaylandXdgWmBase::~WaylandXdgWmBase() noexcept {} - -void WaylandXdgWmBase::Bind(struct wl_client *client, uint32_t version, uint32_t id) -{ - auto xdgWm = WaylandXdgWmObject::Create(client, version, id); - if (xdgWm == nullptr) { - LOG_ERROR("no memory"); - } -} -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_wm_base.h b/wayland_adapter/framework/stable/wayland_xdg_wm_base.h deleted file mode 100644 index 20c449245f851ccfc254ed400068773b8a9a2432..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/stable/wayland_xdg_wm_base.h +++ /dev/null @@ -1,59 +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 -#include "wayland_global.h" - -namespace FT { -namespace Wayland { -struct IWaylandXdgWmBase { - static void CreatePositioner(struct wl_client *client, struct wl_resource *resource, uint32_t id); - static void GetXdgSurface(struct wl_client *client, struct wl_resource *xdgWmBaseResource, - uint32_t id, struct wl_resource *surfaceResource); - static void Pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial); - static struct xdg_wm_base_interface impl_; -}; - -class WaylandXdgWmBase final : public WaylandGlobal { -public: - static OHOS::sptr Create(struct wl_display *display); - ~WaylandXdgWmBase() noexcept override; - -private: - WaylandXdgWmBase(struct wl_display *display); - void Bind(struct wl_client *client, uint32_t version, uint32_t id) override; -}; - -class WaylandXdgWmObject final : public WaylandResourceObject { -public: - static OHOS::sptr Create(struct wl_client *client, uint32_t version, uint32_t id); - ~WaylandXdgWmObject() noexcept override; - -private: - WaylandXdgWmObject(struct wl_client *client, uint32_t version, uint32_t id); - friend struct IWaylandXdgWmBase; - - void CreatePositioner(struct wl_client *client, uint32_t id); - void GetXdgSurface(struct wl_client *client, struct wl_resource *xdgWmBaseResource, - uint32_t id, struct wl_resource *surfaceResource); - void Pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial); -}; -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/unstable/wayland_zxdg_output_manager_v1.cpp b/wayland_adapter/framework/unstable/wayland_zxdg_output_manager_v1.cpp deleted file mode 100644 index 78f16da385a1488159525f90862511f24f23cfcb..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/unstable/wayland_zxdg_output_manager_v1.cpp +++ /dev/null @@ -1,105 +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_zxdg_output_manager_v1.h" -#include "display_manager.h" -#include "version.h" -#include "wayland_objects_pool.h" - -namespace FT { -namespace Wayland { -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandZxdgOutputMgr"}; -} - -struct zxdg_output_manager_v1_interface IWaylandZxdgOutputManagerV1::impl_ = { - .destroy = &WaylandResourceObject::DefaultDestroyResource, - .get_xdg_output = IWaylandZxdgOutputManagerV1::GetZxdgOutput, -}; - -void IWaylandZxdgOutputManagerV1::GetZxdgOutput( - struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *output) -{ - CAST_OBJECT_AND_CALL_FUNC(WaylandZxdgOutputManagerObject, resource, - "WaylandZxdgOutputManagerObject::GetZxdgOutput: failed to find object.", GetZxdgOutput, client, resource, id, output); -} - -OHOS::sptr WaylandZxdgOutputManagerV1::Create(struct wl_display *display) -{ - if (display == nullptr) { - LOG_ERROR("display is nullptr"); - return nullptr; - } - - return OHOS::sptr(new WaylandZxdgOutputManagerV1(display)); -} - -WaylandZxdgOutputManagerV1::WaylandZxdgOutputManagerV1(struct wl_display *display) - : WaylandGlobal(display, &zxdg_output_manager_v1_interface, ZXDG_OUTPUT_MANAGER_V1_MAX_VERSION) -{ -} - -WaylandZxdgOutputManagerV1::~WaylandZxdgOutputManagerV1() noexcept -{ -} - -void WaylandZxdgOutputManagerV1::Bind(struct wl_client *client, uint32_t version, uint32_t id) -{ - auto object = OHOS::sptr(new WaylandZxdgOutputManagerObject(client, version, id)); - if (object == nullptr) { - LOG_ERROR("no memory"); - return; - } - WaylandObjectsPool::GetInstance().AddObject(ObjectId(object->WlClient(), object->Id()), object); -} - -WaylandZxdgOutputManagerObject::WaylandZxdgOutputManagerObject( - struct wl_client *client, uint32_t version, uint32_t id) - : WaylandResourceObject(client, &zxdg_output_manager_v1_interface, version, id, &IWaylandZxdgOutputManagerV1::impl_) -{ -} - -WaylandZxdgOutputManagerObject::~WaylandZxdgOutputManagerObject() noexcept -{ -} - -void WaylandZxdgOutputManagerObject::GetZxdgOutput(struct wl_client *client, struct wl_resource *resource, - uint32_t id, struct wl_resource *output) -{ - auto xdgOutput = WaylandZxdgOutputV1::Create(client, wl_resource_get_version(resource), id, output); - if (xdgOutput == nullptr) { - LOG_ERROR("WaylandZxdgOutputManagerObject GetZxdgOutput failed."); - return; - } - Send(xdgOutput); -} - -void WaylandZxdgOutputManagerObject::Send(const OHOS::sptr &xdgOutput) -{ - zxdg_output_v1_send_logical_position(xdgOutput->WlResource(), 0, 0); - auto defaultDisplay = OHOS::Rosen::DisplayManager::GetInstance().GetDefaultDisplay(); - if (defaultDisplay != nullptr) { - zxdg_output_v1_send_logical_size(xdgOutput->WlResource(), - defaultDisplay->GetWidth(), defaultDisplay->GetHeight()); - } - zxdg_output_v1_send_name(xdgOutput->WlResource(), "fangtian"); - zxdg_output_v1_send_done(xdgOutput->WlResource()); -} - -} // Wayland -} // FT \ No newline at end of file diff --git a/wayland_adapter/framework/unstable/wayland_zxdg_output_manager_v1.h b/wayland_adapter/framework/unstable/wayland_zxdg_output_manager_v1.h deleted file mode 100644 index ae553737e8843857bb39c7aee4b8471b27cd7d04..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/unstable/wayland_zxdg_output_manager_v1.h +++ /dev/null @@ -1,58 +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" -#include "wayland_zxdg_output_v1.h" - -namespace FT { -namespace Wayland { -struct IWaylandZxdgOutputManagerV1 { - static void GetZxdgOutput( - struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *output); - - static struct zxdg_output_manager_v1_interface impl_; -}; - -class WaylandZxdgOutputManagerV1 final : public WaylandGlobal { -public: - static OHOS::sptr Create(struct wl_display *display); - ~WaylandZxdgOutputManagerV1() noexcept override; - -private: - WaylandZxdgOutputManagerV1(struct wl_display *display); - void Bind(struct wl_client *client, uint32_t version, uint32_t id) override; -}; - -class WaylandZxdgOutputManagerObject final : public WaylandResourceObject { -public: - WaylandZxdgOutputManagerObject(struct wl_client *client, uint32_t version, uint32_t id); - ~WaylandZxdgOutputManagerObject() noexcept; - - void GetZxdgOutput( - struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *output); -private: - void Send(const OHOS::sptr &xdgOutput); -}; -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/framework/unstable/wayland_zxdg_output_v1.cpp b/wayland_adapter/framework/unstable/wayland_zxdg_output_v1.cpp deleted file mode 100644 index c803b0e41a3c186ad3eaf477f38a6bcd14dee9a0..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/unstable/wayland_zxdg_output_v1.cpp +++ /dev/null @@ -1,70 +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_zxdg_output_v1.h" -#include "wayland_objects_pool.h" - -namespace FT { -namespace Wayland { - -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandZxdgOutput"}; -} - -struct zxdg_output_v1_interface IWaylandZxdgOutputV1::impl_ = {.destroy = &WaylandResourceObject::DefaultDestroyResource}; - -OHOS::sptr WaylandZxdgOutputV1::Create( - struct wl_client *client, - uint32_t version, - uint32_t id, - struct wl_resource *outputResource) -{ - if (client == nullptr) { - LOG_ERROR("OEXdgOutput::Create failed: wl_client is nullptr."); - return nullptr; - } - - auto output = CastFromResource(outputResource); - if (output == nullptr) { - LOG_ERROR("OEXdgOutput::Create failed: outputResource is nullptr."); - return nullptr; - } - - auto zxdgOutput = OHOS::sptr(new WaylandZxdgOutputV1(client, version, id, output)); - WaylandObjectsPool::GetInstance().AddObject(ObjectId(zxdgOutput->WlClient(), zxdgOutput->Id()), zxdgOutput); - - return zxdgOutput; -} - -WaylandZxdgOutputV1::WaylandZxdgOutputV1( - struct wl_client *client, - uint32_t version, - uint32_t id, - const OHOS::sptr &output) - : WaylandResourceObject(client, &zxdg_output_v1_interface, version, id, &IWaylandZxdgOutputV1::impl_), wlOutput_(output) -{ -} - -WaylandZxdgOutputV1::~WaylandZxdgOutputV1() noexcept -{ -} - -OHOS::sptr WaylandZxdgOutputV1::GetOutput() const -{ - return wlOutput_.promote(); -} - -} // namespace Wayland -} // namespace FT \ No newline at end of file diff --git a/wayland_adapter/framework/unstable/wayland_zxdg_output_v1.h b/wayland_adapter/framework/unstable/wayland_zxdg_output_v1.h deleted file mode 100644 index 0d5511a4103938c04a4954704696995d639a2385..0000000000000000000000000000000000000000 --- a/wayland_adapter/framework/unstable/wayland_zxdg_output_v1.h +++ /dev/null @@ -1,43 +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_output.h" -#include - -namespace FT { -namespace Wayland { - -struct IWaylandZxdgOutputV1 { - static struct zxdg_output_v1_interface impl_; -}; - -class WaylandZxdgOutputV1 final : public WaylandResourceObject { -public: - static OHOS::sptr Create( - struct wl_client *client, - uint32_t version, - uint32_t id, - struct wl_resource *outputResource); - ~WaylandZxdgOutputV1() noexcept; - OHOS::sptr GetOutput() const; - -private: - WaylandZxdgOutputV1(struct wl_client *client, uint32_t version, uint32_t id, const OHOS::sptr &output); - - OHOS::wptr wlOutput_; -}; -} // namespace Wayland -} // namespace FT \ No newline at end of file diff --git a/wayland_adapter/test/BUILD.gn b/wayland_adapter/test/BUILD.gn deleted file mode 100644 index f49f21ccad36367309645c7e48673f75dc8cb317..0000000000000000000000000000000000000000 --- a/wayland_adapter/test/BUILD.gn +++ /dev/null @@ -1,29 +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") - -ft_executable("wayland_demo") { - sources = [ "wayland_demo.cpp" ] - - include_dirs = [ "." ] - - libs = [ "wayland-client" ] - - deps = [ - "//build/gn/configs/system_libs:skia", - "//display_server/drivers/hal/base:ft_event_loop", - "//wayland_adapter/wayland_protocols:wayland_protocols_sources", - ] -} diff --git a/wayland_adapter/test/wayland_demo.cpp b/wayland_adapter/test/wayland_demo.cpp deleted file mode 100644 index 0aaedcf4ece63e1717c2420f78c02523434aafa7..0000000000000000000000000000000000000000 --- a/wayland_adapter/test/wayland_demo.cpp +++ /dev/null @@ -1,810 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "timestamp.h" -#include "types.h" -#include "core/SkPaint.h" -#include "core/SkPath.h" -#include "xdg-shell-client-protocol.h" - -#include "core/SkBitmap.h" -#include "core/SkCanvas.h" -#include "core/SkColor.h" -#include "core/SkFont.h" -#include "core/SkImageEncoder.h" -#include "core/SkPoint.h" -#include "core/SkRect.h" -#include "core/SkScalar.h" -#include "core/SkStream.h" -#include "core/SkTextBlob.h" -#include "core/SkTypeface.h" - -constexpr int32_t WINDOW_WIDTH = 500; -constexpr int32_t WINDOW_HEIGHT = 400; -struct window; - -struct display { - struct wl_display *display; - struct wl_registry *registry; - struct wl_compositor *compositor; - struct xdg_wm_base *wm_base; - struct wl_shm *shm; - struct wl_seat *seat; - struct wl_pointer *pointer; - struct wl_keyboard *keyboard; - struct window *window; - bool has_rgba8888 = false; -}; - -struct buffer { - struct wl_buffer *buffer; - void *shm_data; - bool busy; - int32_t width, height; -}; - -struct window { - struct display *display; - int32_t width, height; - struct wl_surface *surface; - struct wl_region *region; - struct xdg_surface *xdg_surface; - struct xdg_toplevel *xdg_toplevel; - struct buffer buffers[2]; - struct buffer *prev_buffer; - struct wl_callback *callback; - bool wait_for_configure = true; -}; - -bool g_running = true; - -static void BufferRelease(void *data, struct wl_buffer *buffer) -{ - struct buffer *mybuf = (struct buffer *)data; - mybuf->busy = false; -} -struct wl_buffer_listener g_bufferListener = {BufferRelease}; - -static void Redraw(void *data, struct wl_callback *callback, uint32_t time); -struct wl_callback_listener g_frameListener = {Redraw}; - -static int32_t CloseFd(int32_t fd) -{ - if (fd == -1) { - close(fd); - return -1; - } - - auto flags = fcntl(fd, F_GETFD); - if (flags == -1) { - close(fd); - return -1; - } - - if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) { - close(fd); - return -1; - } - - return fd; -} - -static int32_t CreateTmpFile(char *tmpname) -{ - int32_t fd = mkstemp(tmpname); - if (fd >= 0) { - fd = CloseFd(fd); - unlink(tmpname); - } - - return fd; -} - -static int32_t CreateFile(off_t size) -{ - static const char suffix[] = "/weston-shared-XXXXXX"; - const char *path = getenv("XDG_RUNTIME_DIR"); - if (!path) { - errno = ENOENT; - return -1; - } - - char *name = static_cast(malloc(strlen(path) + sizeof(suffix))); - if (!name) { - return -1; - } - - strcpy(name, path); - strcat(name, suffix); - int32_t fd = CreateTmpFile(name); - free(name); - - if (fd < 0) { - return -1; - } - - int32_t ret = 0; - do { - ret = ftruncate(fd, size); - } while (ret < 0 && errno == EINTR); - - if (ret < 0) { - close(fd); - return -1; - } - - return fd; -} - -static int32_t CreateShmBuffer(struct display *display, struct buffer *buffer, int32_t width, int32_t height, uint32_t format) -{ - int32_t stride = width * 4; - int32_t size = stride * height; - int32_t fd = CreateFile(size); - if (fd < 0) { - fprintf(stderr, "creating a buffer file for %d B failed: %s\n", size, strerror(errno)); - return -1; - } - - void *data = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (data == MAP_FAILED) { - fprintf(stderr, "mmap failed: %s\n", strerror(errno)); - close(fd); - return -1; - } - - struct wl_shm_pool *pool = wl_shm_create_pool(display->shm, fd, size); - buffer->buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride, format); - buffer->width = width; - buffer->height = height; - wl_buffer_add_listener(buffer->buffer, &g_bufferListener, buffer); - wl_shm_pool_destroy(pool); - close(fd); - buffer->shm_data = data; - - return 0; -} - -static void HandleXdgSurfaceConfigure(void *data, struct xdg_surface *surface, uint32_t serial) -{ - struct window *window = static_cast(data); - - xdg_surface_ack_configure(surface, serial); - - if (window->wait_for_configure) { - Redraw(window, nullptr, 0); - window->wait_for_configure = false; - } -} -struct xdg_surface_listener g_xdgSurfaceListener = {HandleXdgSurfaceConfigure}; - -static void HandleXdgToplevelConfigure(void *data, struct xdg_toplevel *xdg_toplevel, - int32_t width, int32_t height, struct wl_array *state) { - - struct window *window = static_cast(data); - if (window->width != width || window->height != height) { - fprintf(stderr, "HandleXdgToplevelConfigure, width:%d, height:%d\n", width, height); - window->width = width; - window->height = height; - } -} -static void HandleXdgToplevelClose(void *data, struct xdg_toplevel *xdg_toplevel) -{ - g_running = false; -} -struct xdg_toplevel_listener g_xdgToplevelListener = {HandleXdgToplevelConfigure, HandleXdgToplevelClose}; - -static struct window *CreateWindow(struct display *display, int32_t width, int32_t height) -{ - struct window *pWindow = static_cast(malloc(sizeof(*pWindow))); - if (!pWindow) { - return nullptr; - } - memset_s(pWindow, sizeof(*pWindow), 0, sizeof(*pWindow)); - - pWindow->callback = nullptr; - pWindow->display = display; - pWindow->width = width; - pWindow->height = height; - pWindow->surface = wl_compositor_create_surface(display->compositor); - - if (display->wm_base) { - pWindow->xdg_surface = xdg_wm_base_get_xdg_surface(display->wm_base, pWindow->surface); - assert(pWindow->xdg_surface); - xdg_surface_add_listener(pWindow->xdg_surface, &g_xdgSurfaceListener, pWindow); - - pWindow->xdg_toplevel = xdg_surface_get_toplevel(pWindow->xdg_surface); - assert(pWindow->xdg_toplevel); - xdg_toplevel_add_listener(pWindow->xdg_toplevel, &g_xdgToplevelListener, pWindow); - - xdg_toplevel_set_title(pWindow->xdg_toplevel, "simple-shm"); - xdg_toplevel_set_app_id(pWindow->xdg_toplevel, "org.freedesktop.weston.simple-shm"); - - wl_surface_commit(pWindow->surface); - pWindow->wait_for_configure = true; - } else { - assert(0); - } - - // region test - pWindow->region = wl_compositor_create_region(display->compositor); - wl_region_add(pWindow->region, 0, 0, width, height); - wl_surface_set_opaque_region(pWindow->surface, pWindow->region); - wl_surface_set_input_region(pWindow->surface, pWindow->region); - wl_region_destroy(pWindow->region); - display->window = pWindow; - return pWindow; -} - -static void DestroyWindow(struct window *window) -{ - if (window->callback) { - wl_callback_destroy(window->callback); - } - - if (window->buffers[0].buffer) { - wl_buffer_destroy(window->buffers[0].buffer); - } - - if (window->buffers[1].buffer) { - wl_buffer_destroy(window->buffers[1].buffer); - } - - if (window->xdg_toplevel) { - xdg_toplevel_destroy(window->xdg_toplevel); - } - - if (window->xdg_surface) { - xdg_surface_destroy(window->xdg_surface); - } - - wl_surface_destroy(window->surface); - free(window); -} - -static struct buffer *WindowNextBuffer(struct window *window) -{ - struct buffer *buffer; - if (!window->buffers[0].busy) { - buffer = &window->buffers[0]; - } else if (!window->buffers[1].busy) { - buffer = &window->buffers[1]; - } else { - return nullptr; - } - - if (buffer->buffer && (buffer->width != window->width || buffer->height != window->height)) { - wl_buffer_destroy(buffer->buffer); - buffer->buffer = nullptr; - } - - if (!buffer->buffer) { - int32_t ret = CreateShmBuffer(window->display, buffer, window->width, window->height, WL_SHM_FORMAT_RGBA8888); - if (ret < 0) { - return nullptr; - } - memset(buffer->shm_data, 0xff, window->width * window->height * 4); - } - - return buffer; -} - -struct DrawClock { -public: - DrawClock(SkCanvas *canvas, uint32_t width, uint32_t height) - : canvas_(canvas), - width_(width), - height_(height), - now_(FT::TimeStamp::Now()), - nowSeconds_(now_.Seconds()), - nowTm_(::localtime(&nowSeconds_)) - { - center_.set(width_ * 1.0 / 2, height_ * 1.0 / 2); - } - ~DrawClock() noexcept = default; - - void Render() - { - if (canvas_ == nullptr || width_ == 0 || height_ == 0) { - return; - } - - canvas_->clear(SK_ColorGRAY); - - { - // draw circle - SkScalar radius = std::min(width_, height_) * 0.45; - DrawCircle(radius); - } - - { - // draw center - SkScalar radius = std::min(width_, height_) * 0.02; - DrawCenter(radius); - } - - { - // draw date - DrawDate(24.0); - } - - { - // draw time points - DrawTimePoints(24.0); - } - - { - // draw hands - DrawHands(); - } - canvas_->flush(); - } - -private: - void DrawCircle(SkScalar radius) - { - canvas_->save(); - SkPaint paint; - paint.setAntiAlias(true); - paint.setColor(SK_ColorWHITE); - canvas_->drawCircle(center_, radius, paint); - canvas_->restore(); - - paint.setColor(SK_ColorBLACK); - paint.setStrokeWidth(3.0); - canvas_->drawCircle(center_, radius, paint); - - paint.setColor(SK_ColorRED); - paint.setStrokeWidth(2.0); - canvas_->drawCircle(center_, radius * 0.98, paint); - } - - void DrawCenter(SkScalar radius) - { - canvas_->save(); - SkPaint paint; - paint.setAntiAlias(true); - paint.setColor(SK_ColorBLACK); - paint.setStrokeWidth(2.0); - canvas_->drawCircle(center_, radius, paint); - canvas_->restore(); - } - - void DrawDate(SkScalar fontSize) - { - canvas_->save(); - canvas_->translate(center_.x(), center_.y()); - - auto timeStampString = now_.ToFormattedString(FT::TimePrecision::SECOND); - std::string dateText = timeStampString.substr(0, 10); - auto textBlob = SkTextBlob::MakeFromString(dateText.c_str(), SkFont(nullptr, fontSize, 1.0f, 0.0f)); - auto dateTextBounds = textBlob->bounds(); - canvas_->translate(-1.0 * dateTextBounds.width() / 2.5, dateTextBounds.height() * 1.5); - SkPaint rectPaint; - rectPaint.setColor(0xffefefef); - canvas_->drawRect(dateTextBounds, rectPaint); - - SkPaint texPaint; - texPaint.setColor(SK_ColorBLACK); - texPaint.setAntiAlias(true); - texPaint.setStrokeWidth(3.0); - canvas_->drawTextBlob(textBlob, 0.0, 0.0, texPaint); - canvas_->restore(); - } - - static std::string RomeDigit(int32_t clock) - { - if (clock < 0 || clock >= 12) { - return {}; - } - - static std::vector romeDigits = { - "XII", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI"}; - return romeDigits[clock]; - } - - void DrawTimePoints(SkScalar fontSize) - { - SkScalar radius = std::min(width_, height_) * 0.36; - canvas_->save(); - SkPaint paint; - paint.setColor(SK_ColorBLACK); - paint.setAntiAlias(true); - paint.setStrokeWidth(3.0); - canvas_->translate(center_.x(), center_.y()); - for (auto i = 0; i != 12; ++i) { - canvas_->save(); - auto angle = PI / 6.0 * (i - 3); - std::string text = RomeDigit(i); - auto textBlob = SkTextBlob::MakeFromString(text.c_str(), SkFont(nullptr, fontSize, 1.0f, 0.0f)); - auto offsetX = std::cos(angle) * radius - fontSize / 2 + 2.0; - auto offsetY = std::sin(angle) * radius + fontSize / 2 - 2.0; - canvas_->translate(offsetX, offsetY); - canvas_->drawTextBlob(textBlob, 0.0, 0.0, paint); - canvas_->restore(); - } - canvas_->restore(); - - for (auto i = 0; i < 60; ++i) { - if (i % 5 == 0) { - paint.setStrokeWidth(3.0); - } else { - paint.setStrokeWidth(1.0); - } - - canvas_->save(); - auto angle = PI * 2.0 * i / 60 - PI / 2.0; - SkScalar r1 = std::min(width_, height_) * 0.40; - SkScalar r2 = std::min(width_, height_) * 0.43; - - SkPoint start; - SkPoint end; - start.set(center_.x() + std::cos(angle) * r1, center_.y() + std::sin(angle) * r1); - end.set(center_.x() + std::cos(angle) * r2, center_.y() + std::sin(angle) * r2); - canvas_->drawLine(start, end, paint); - canvas_->restore(); - } - } - - void DrawHand(double val, SkScalar radius, SkColor color, SkScalar strokeWidth) - { - canvas_->save(); - auto angle = PI * 2.0 * val / 60 - PI / 2.0; - SkPaint paint; - paint.setColor(color); - paint.setAntiAlias(true); - paint.setStrokeWidth(strokeWidth); - - SkPoint start = center_; - SkPoint end; - end.set(center_.x() + std::cos(angle) * radius, center_.y() + std::sin(angle) * radius); - - canvas_->drawLine(start, end, paint); - canvas_->restore(); - } - - void DrawHands() - { - FT::TimeType seconds = now_.Get() / FT::MICRO_SECS_PER_SECOND; - auto hour = nowTm_->tm_hour; - auto minute = nowTm_->tm_min; - auto sec = nowTm_->tm_sec; - DrawHand(sec, std::min(width_, height_) * 0.34, SK_ColorBLACK, 2.0); - DrawHand(minute + sec * 1.0 / 60, std::min(width_, height_) * 0.26, SK_ColorBLACK, 6.0); - DrawHand(hour * 5 + minute * 1.0 / 60 * 5, std::min(width_, height_) * 0.2, SK_ColorBLACK, 8.0); - } - -private: - static constexpr double PI = 3.141592653; - SkCanvas *canvas_ = nullptr; - uint32_t width_ = 0; - uint32_t height_ = 0; - SkPoint center_; - FT::TimeStamp now_; - FT::TimeType nowSeconds_; - struct tm *nowTm_; -}; - -static void PaintPixels(void *data, int32_t padding, int32_t width, int32_t height, uint32_t time) -{ - SkImageInfo info = SkImageInfo::Make(width, height, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); - SkBitmap bitmap; - bitmap.installPixels(info, data, info.minRowBytes()); - SkCanvas canvas(bitmap); - - DrawClock drawClock(&canvas, width, height); - drawClock.Render(); -} - -static void Redraw(void *data, struct wl_callback *callback, uint32_t time) -{ - struct window *window = static_cast(data); - struct buffer *buffer = WindowNextBuffer(window); - if (!buffer) { - fprintf(stderr, !callback ? "Failed to create the first buffer.\n" : "Both buffers busy at Redraw()\n"); - abort(); - } - - PaintPixels(buffer->shm_data, 20, window->width, window->height, time); - - wl_surface_attach(window->surface, buffer->buffer, 0, 0); - wl_surface_damage(window->surface, 20, 20, window->width - 40, window->height - 40); - - if (callback) { - wl_callback_destroy(callback); - } - - window->callback = wl_surface_frame(window->surface); - wl_callback_add_listener(window->callback, &g_frameListener, window); - wl_surface_commit(window->surface); - buffer->busy = true; -} - -static void ShmFormat(void *data, struct wl_shm *wl_shm, uint32_t format) -{ - struct display *d = static_cast(data); - - if (format == WL_SHM_FORMAT_RGBA8888) { - d->has_rgba8888 = true; - } -} -struct wl_shm_listener shm_listener = {ShmFormat}; - -static void XdgWmBasePing(void *data, struct xdg_wm_base *shell, uint32_t serial) -{ - xdg_wm_base_pong(shell, serial); -} - -static const struct xdg_wm_base_listener xdg_wm_base_listener = {XdgWmBasePing}; - -void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) -{ - fprintf(stderr, "pointer_enter in, surface_x=%d, surface_y=%d\n", wl_fixed_to_int(surface_x), wl_fixed_to_int(surface_y)); -} - -void pointer_leave(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface) -{ - fprintf(stderr, "pointer_leave in\n"); -} - -void pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) -{ - fprintf(stderr, "pointer_motion in, surface_x=%d, surface_y=%d\n", wl_fixed_to_int(surface_x), wl_fixed_to_int(surface_y)); -} - -void pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) -{ - struct display *d = static_cast(data); - fprintf(stderr, "pointer_button in, button=%d, state=%d\n", button, state); - if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) { - xdg_toplevel_move(d->window->xdg_toplevel, d->seat, serial); - } -} - -void pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis, wl_fixed_t value) -{ - fprintf(stderr, "pointer_axis in\n"); -} - -void pointer_frame(void *data, struct wl_pointer *wl_pointer) -{ - fprintf(stderr, "pointer_frame in\n"); -} - -void pointer_axis_source(void *data, struct wl_pointer *wl_pointer, uint32_t axis_source) -{ - fprintf(stderr, "pointer_axis_source in\n"); -} - -void pointer_axis_stop(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis) -{ - fprintf(stderr, "pointer_axis_stop in\n"); -} - -void pointer_axis_discrete(void *data, struct wl_pointer *wl_pointer, uint32_t axis, int32_t discrete) -{ - fprintf(stderr, "pointer_axis_discrete in\n"); -} - -struct wl_pointer_listener pointer_listener = { - .enter = pointer_enter, - .leave = pointer_leave, - .motion = pointer_motion, - .button = pointer_button, - .axis = pointer_axis, - .frame = pointer_frame, - .axis_source = pointer_axis_source, - .axis_stop = pointer_axis_stop, - .axis_discrete = pointer_axis_discrete, -}; - - -void keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, uint32_t format, - int32_t fd, uint32_t size) -{ - -} - -void keyboard_enter(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, - struct wl_surface *surface, struct wl_array *keys) -{ - fprintf(stderr, "keyboard_enter in\n"); -} - -void keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, - struct wl_surface *surface) -{ - fprintf(stderr, "keyboard_leave in\n"); -} - -void keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, - uint32_t time, uint32_t key, uint32_t state) -{ - fprintf(stderr, "keyboard_key in, key=%u, state=%u\n", key, state); -} - -void keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, - uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) -{ - -} - -void keyboard_repeat_info(void *data, struct wl_keyboard *wl_keyboard, - int32_t rate, int32_t delay) -{ - -} - -struct wl_keyboard_listener keyboard_listener = { - .keymap = keyboard_keymap, - .enter = keyboard_enter, - .leave = keyboard_leave, - .key = keyboard_key, - .modifiers = keyboard_modifiers, - .repeat_info = keyboard_repeat_info, -}; - -void wl_seat_capabilities(void *data, struct wl_seat *wl_seat, uint32_t capabilities) -{ - struct display *d = static_cast(data); - if (capabilities & WL_SEAT_CAPABILITY_POINTER) { - fprintf(stderr, "fangtian has a pointer, get it!\n"); - d->pointer = wl_seat_get_pointer(d->seat); - wl_pointer_add_listener(d->pointer, &pointer_listener, d); - } - if (capabilities & WL_SEAT_CAPABILITY_KEYBOARD) { - fprintf(stderr, "fangtian has a keyboard, get it\n"); - d->keyboard = wl_seat_get_keyboard(d->seat); - wl_keyboard_add_listener(d->keyboard, &keyboard_listener, d); - } -} - -void wl_seat_name(void *data, struct wl_seat *wl_seat, const char *name) {} - -struct wl_seat_listener seat_listener = { - wl_seat_capabilities, - wl_seat_name, -}; - -static void RegistryGlobal(void *data, struct wl_registry *registry, - uint32_t id, const char *interface, uint32_t version) -{ - fprintf(stderr, "RegistryGlobal %s\n", interface); - struct display *d = static_cast(data); - - if (strcmp(interface, "wl_compositor") == 0) { - d->compositor = (struct wl_compositor *)wl_registry_bind(registry, id, &wl_compositor_interface, 1); - } else if (strcmp(interface, "xdg_wm_base") == 0) { - d->wm_base = (struct xdg_wm_base *)wl_registry_bind(registry, id, &xdg_wm_base_interface, 1); - xdg_wm_base_add_listener(d->wm_base, &xdg_wm_base_listener, d); - } else if (strcmp(interface, "wl_shm") == 0) { - d->shm = (struct wl_shm *)wl_registry_bind(registry, id, &wl_shm_interface, 1); - wl_shm_add_listener(d->shm, &shm_listener, d); - } else if (strcmp(interface, "wl_seat") == 0) { - d->seat = (struct wl_seat *)wl_registry_bind(registry, id, &wl_seat_interface, 1); - wl_seat_add_listener(d->seat, &seat_listener, d); - } -} - -static void RegistryHandleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name) {} -struct wl_registry_listener g_registryListener = {RegistryGlobal, RegistryHandleGlobalRemove}; - -static struct display *CreateDisplay() -{ - struct display *pDisplay = (struct display *)malloc(sizeof(*pDisplay)); - if (pDisplay == nullptr) { - fprintf(stderr, "out of memory\n"); - exit(1); - } - memset_s(pDisplay, sizeof(*pDisplay), 0, sizeof(*pDisplay)); - pDisplay->display = wl_display_connect(nullptr); - assert(pDisplay->display); - - pDisplay->has_rgba8888 = false; - pDisplay->registry = wl_display_get_registry(pDisplay->display); - wl_registry_add_listener(pDisplay->registry, &g_registryListener, pDisplay); - - wl_display_roundtrip(pDisplay->display); - - if (pDisplay->shm == nullptr) { - fprintf(stderr, "No wl_shm global\n"); - exit(1); - } - - wl_display_roundtrip(pDisplay->display); - - if (!pDisplay->has_rgba8888) { - fprintf(stderr, "rgba8888 not available\n"); - exit(1); - } - - return pDisplay; -} - -static void DestroyDisplay(struct display *display) -{ - display->window = nullptr; - if (display->shm) { - wl_shm_destroy(display->shm); - } - - if (display->wm_base) { - xdg_wm_base_destroy(display->wm_base); - } - - if (display->compositor) { - wl_compositor_destroy(display->compositor); - } - - wl_registry_destroy(display->registry); - wl_display_flush(display->display); - wl_display_disconnect(display->display); - free(display); -} - -static void SignalInt(int32_t signum) -{ - g_running = false; -} - -int32_t main(int32_t argc, char **argv) -{ - fprintf(stderr, "window width: %d, height: %d\n", WINDOW_WIDTH, WINDOW_HEIGHT); - - struct display *display = CreateDisplay(); - struct window *window = CreateWindow(display, WINDOW_WIDTH, WINDOW_HEIGHT); - if (!window) { - return 1; - } - - struct sigaction sigint; - sigint.sa_handler = SignalInt; - sigemptyset(&sigint.sa_mask); - sigint.sa_flags = SA_RESETHAND; - sigaction(SIGINT, &sigint, nullptr); - - wl_surface_damage(window->surface, 0, 0, window->width, window->height); - - if (!window->wait_for_configure) { - Redraw(window, nullptr, 0); - } - - int32_t ret = 0; - while (g_running && ret != -1) { - ret = wl_display_dispatch(display->display); - } - - fprintf(stderr, "simple-shm exiting\n"); - - DestroyWindow(window); - DestroyDisplay(display); - - return 0; -} \ No newline at end of file diff --git a/wayland_adapter/utils/BUILD.gn b/wayland_adapter/utils/BUILD.gn deleted file mode 100644 index 141cbb99673d9cd56c0661959aadc077634ee7c0..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/BUILD.gn +++ /dev/null @@ -1,37 +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("wayland_utils_public_config") { - include_dirs = [ "include" ] -} - -ft_source_set("wayland_adapter_utils_sources") { - sources = [ - "src/wayland_global.cpp", - "src/wayland_objects_pool.cpp", - "src/wayland_resource_object.cpp", - "src/wayland_keycode_trans.cpp", - "src/wayland_event_loop.cpp", - ] - - public_configs = [ ":wayland_utils_public_config" ] - - deps = [ - "//build/gn/configs/system_libs:mmi", - "//build/gn/configs/system_libs:hilog", - "//display_server/drivers/hal/base:ft_event_loop", - ] -} diff --git a/wayland_adapter/utils/include/version.h b/wayland_adapter/utils/include/version.h deleted file mode 100644 index 7c56a2993634b26e8354d2052028354509518c89..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/include/version.h +++ /dev/null @@ -1,43 +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 - -namespace FT { -/* Core*/ -static const uint32_t WL_COMPOSITOR_MAX_VERSION = 4; // child: wl_surface -static const uint32_t WL_SUBCOMPOSITOR_MAX_VERSION = 1; // child: wl_subsurface -static const uint32_t WL_DATA_DEVICE_MANAGER_MAX_VERSION = 3; // child: wl_data_device -static const uint32_t WL_SHM_MAX_VERSION = 1; -static const uint32_t WL_OUTPUT_MAX_VERSION = 2; -static const uint32_t WL_SEAT_MAX_VERSION = 7; // child: wl_keyboard wl_pointer wl_touch -static const uint32_t WL_BUFFER_MAX_VERSION = 1; - -/* Stable */ -static const uint32_t XDG_WM_BASE_MAX_VERSION = 3; // child: xdg_surface - -/* Unstable */ -static const uint32_t ZXDG_OUTPUT_MANAGER_V1_MAX_VERSION = 2; // child: zxdg_output -static const uint32_t ZWP_LINUX_DMABUF_V1_MAX_VERSION = 3; // child: zwp_linux_buffer_params & zwp_linux_dmabuf_feedback -static const uint32_t ZXDG_SHELL_V6_MAX_VERSION = 1; -static const uint32_t ZXDG_DECORATION_MANAGER_V1_MAX_VERSION = 1; -static const uint32_t ZWLR_SCREENCOPY_MANAGER_V1_MAX_VERSION = 3; -static const uint32_t ZWLR_VIRTUAL_POINTER_MANAGER_V1_MAX_VERSION = 2; -static const uint32_t ZWP_VIRTUAL_KEYBOARD_MANAGER_V1_MAX_VERSION = 1; -static const uint32_t ZWLR_LAYER_SHELL_V1_MAX_VERSION = 4; -static const uint32_t ZWLR_DATA_CONTROL_MANAGER_V1_MAX_VERSION = 2; -} // namespace FT diff --git a/wayland_adapter/utils/include/wayalnd_utils.h b/wayland_adapter/utils/include/wayalnd_utils.h deleted file mode 100644 index 40f1f9ff6c0a76f76198aa7c494dcd4d45cf70c1..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/include/wayalnd_utils.h +++ /dev/null @@ -1,137 +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-server-protocol.h" -#include "window.h" - -namespace FT { -namespace Wayland { -struct Rect { - int32_t x = 0; - int32_t y = 0; - uint32_t width = 0; - uint32_t height = 0; - void Reset() - { - x = 0; - y = 0; - width = 0; - height = 0; - } -}; - -struct Offset { - int32_t x = 0; - int32_t y = 0; - void Reset() - { - x = 0; - y = 0; - } -}; - -struct Size { - uint32_t width = 0; - uint32_t height = 0; - void Reset() - { - width = 0; - height = 0; - } -}; - -struct WindowOptionExt { - bool maximizeAfterShow = false; - bool fullscreenAfterShow = false; - bool minimizeAfterShow = false; - std::string title; -}; - -using SurfaceCommitCallback = std::function; -using SurfaceRectCallback = std::function; -using WindowCreateCallback = std::function)>; - -class FrameCallback final : public WaylandResourceObject { -public: - static OHOS::sptr Create(struct wl_client *client, uint32_t version, uint32_t callback) - { - return OHOS::sptr(new FrameCallback(client, version, callback)); - } - uint32_t Serial() const - { - return serial_; - } -private: - FrameCallback(struct wl_client *client, uint32_t version, uint32_t callback) - : WaylandResourceObject(client, &wl_callback_interface, version, callback, nullptr), serial_(callback) {} - ~FrameCallback() noexcept override {} - uint32_t serial_; -}; - -struct SurfaceState { - struct wl_resource *buffer = nullptr; - Rect damage; - wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL; - int32_t scale = 0; - Rect damageBuffer; - int32_t offsetX = 0; - int32_t offsetY = 0; - OHOS::sptr cb; - Rect inputRegion; - Rect opaqueRegion; - void Reset() - { - damage.Reset(); - transform = WL_OUTPUT_TRANSFORM_NORMAL; - scale = 0; - damageBuffer.Reset(); - offsetX = 0; - offsetY = 0; - inputRegion.Reset(); - opaqueRegion.Reset(); - } -}; - -enum class SurfaceRole : uint32_t { - NONE = 0, - XDG_TOPLEVEL, - XDG_POPUP -}; - -static SkColorType ShmFormatToSkia(const uint32_t& shmFormat) -{ - switch (shmFormat) { - case WL_SHM_FORMAT_ARGB8888: - return SkColorType::kBGRA_8888_SkColorType; - case WL_SHM_FORMAT_RGBA8888: - return SkColorType::kRGBA_8888_SkColorType; - default: - return SkColorType::kUnknown_SkColorType; - } -} - -struct SubSurfaceData { - struct wl_resource *surface = nullptr; - int32_t offsetX = 0; - int32_t offsetY = 0; -}; - -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/utils/include/wayland_adapter_hilog.h b/wayland_adapter/utils/include/wayland_adapter_hilog.h deleted file mode 100644 index 0487cc6a6cd7b076615ccd24bab429d25681525a..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/include/wayland_adapter_hilog.h +++ /dev/null @@ -1,40 +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. - */ - -#ifndef WAYLAND_ADAPTER_HILOG_H -#define WAYLAND_ADAPTER_HILOG_H - -#include "hilog/log.h" - -using namespace OHOS::HiviewDFX; - -namespace FT { -namespace Wayland { -static constexpr unsigned int HILOG_DOMAIN_WAYLAND = 0xD004202; - -#define _W_CPRINTF(func, fmt, ...) func(LABEL, "<%{public}d>" fmt, __LINE__, ##__VA_ARGS__) -#define WLOGD(fmt, ...) _W_CPRINTF(HiLog::Debug, fmt, ##__VA_ARGS__) -#define WLOGI(fmt, ...) _W_CPRINTF(HiLog::Info, fmt, ##__VA_ARGS__) -#define WLOGW(fmt, ...) _W_CPRINTF(HiLog::Warn, fmt, ##__VA_ARGS__) -#define WLOGE(fmt, ...) _W_CPRINTF(HiLog::Error, fmt, ##__VA_ARGS__) - -#define _W_FUNC __func__ -#define LOG_DEBUG(fmt, ...) WLOGD("%{public}s: " fmt, _W_FUNC, ##__VA_ARGS__) -#define LOG_INFO(fmt, ...) WLOGI("%{public}s: " fmt, _W_FUNC, ##__VA_ARGS__) -#define LOG_WARN(fmt, ...) WLOGW("%{public}s: " fmt, _W_FUNC, ##__VA_ARGS__) -#define LOG_ERROR(fmt, ...) WLOGE("%{public}s: " fmt, _W_FUNC, ##__VA_ARGS__) -} // namespace Wayland -} // namespace FT -#endif // WAYLAND_ADAPTER_HILOG_H diff --git a/wayland_adapter/utils/include/wayland_event_loop.h b/wayland_adapter/utils/include/wayland_event_loop.h deleted file mode 100644 index 032cacc16d3c1069d0f197b94ccb91d98a6dde3b..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/include/wayland_event_loop.h +++ /dev/null @@ -1,43 +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_singleton.h" -#include "event_loop.h" - -namespace FT { -namespace Wayland { - -class WaylandEventLoop : public Singleton { - DECLARE_SINGLETON(WaylandEventLoop) - -public: - void Start(); - void QueueToLoop(Functor func); - template > - std::future Schedule(Task task) - { - return loop_->Schedule(task); - } - EventLoop *GetEventLoopPtr(); - WaylandEventLoop(); - ~WaylandEventLoop() noexcept; - -private: - std::shared_ptr loop_ = nullptr; -}; -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/utils/include/wayland_global.h b/wayland_adapter/utils/include/wayland_global.h deleted file mode 100644 index 97e33e07c495f0549aecf48fd6edb0064677e2dd..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/include/wayland_global.h +++ /dev/null @@ -1,47 +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 { -class WaylandGlobal : NonCopyable, public OHOS::RefBase { -public: - virtual ~WaylandGlobal() noexcept override; - - const std::string &Name() const - { - return name_; - } - uint32_t MaxSupportVersion() const - { - return maxSupportVersion_; - } - -protected: - WaylandGlobal(struct wl_display *display, const struct wl_interface *interface, uint32_t maxSupportVersion); - static void BindCallback(struct wl_client *client, void *data, uint32_t version, uint32_t id); - virtual void Bind(struct wl_client *client, uint32_t version, uint32_t id) = 0; - - std::string name_; - uint32_t maxSupportVersion_ = 0; - struct wl_display *display_ = nullptr; - const struct wl_interface *interface_ = nullptr; - struct wl_global *global_ = nullptr; -}; -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/utils/include/wayland_keycode_trans.h b/wayland_adapter/utils/include/wayland_keycode_trans.h deleted file mode 100644 index 7a9471c2c75c388b7ea52fac3f3112ec013fb133..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/include/wayland_keycode_trans.h +++ /dev/null @@ -1,22 +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 - -namespace FT { -namespace Wayland { - int32_t TransferKeyValue(int32_t keyValueOfInput); -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/utils/include/wayland_objects_pool.h b/wayland_adapter/utils/include/wayland_objects_pool.h deleted file mode 100644 index ef8a3d084cd79987977ffe48f1ba2e07837514dd..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/include/wayland_objects_pool.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 - -#include "wayland_singleton.h" -#include "wayland_resource_object.h" - -namespace FT { -namespace Wayland { -class WaylandObjectsPoolCallback : public OHOS::RefBase { -public: - virtual void OnDestroy(ObjectId objectId) {} -}; - -class WaylandObjectsPool : public Singleton { - DECLARE_SINGLETON(WaylandObjectsPool) - -public: - static void SetCallback(OHOS::sptr cb); - void AddObject(ObjectId id, const OHOS::sptr &object); - void RemoveObject(ObjectId id, const OHOS::sptr &object); - OHOS::sptr GetObject(ObjectId id) const; - -private: - WaylandObjectsPool() = default; - ~WaylandObjectsPool() noexcept override = default; - - static OHOS::sptr cb_; - mutable std::mutex mutex_; - std::map> objects_; -}; -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/utils/include/wayland_resource_object.h b/wayland_adapter/utils/include/wayland_resource_object.h deleted file mode 100644 index 8eecc5cb6ecde5c77fdc1f4e3f9d7a6e52980dcb..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/include/wayland_resource_object.h +++ /dev/null @@ -1,158 +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-server-protocol.h" -#include "wayland_adapter_hilog.h" -#include "noncopyable_hal.h" -#include "refbase.h" -#include "types.h" - -namespace FT { -namespace Wayland { -struct ObjectId { - ObjectId(struct wl_client *client, uint32_t id) : client(client), id(id) {} - ~ObjectId() noexcept = default; - - ObjectId(const ObjectId &other) = default; - ObjectId &operator=(const ObjectId &other) = default; - - ObjectId(ObjectId &&other) noexcept : client(other.client), id(other.id) - { - other.client = nullptr; - other.id = 0; - } - ObjectId &operator=(ObjectId &&other) noexcept - { - client = other.client; - id = other.id; - other.client = nullptr; - other.id = 0; - return *this; - } - bool operator<(const ObjectId &other) const - { - if (client != other.client) { - return client < other.client; - } - return id < other.id; - } - bool operator==(const ObjectId &other) const - { - return client == other.client && id == other.id; - } - bool operator!=(const ObjectId &other) const - { - return !(*this == other); - } - - struct wl_client *client = nullptr; - uint32_t id = 0; -}; - -template -inline OutStream &operator<<(OutStream &os, const ObjectId &objId) -{ - os << "ObjectId(client: " << objId.client << ", id: " << objId.id << ")"; - return os; -} - -class WaylandResourceObject : NonCopyable, virtual public OHOS::RefBase { -public: - WaylandResourceObject(struct wl_client *client, const struct wl_interface *interface, - uint32_t version, uint32_t id, void *implementation); - virtual ~WaylandResourceObject() noexcept override; - - const std::string &Name() const - { - return name_; - } - uint32_t Id() const - { - return id_; - } - uint32_t Version() const - { - return version_; - } - struct wl_client *WlClient() const - { - return client_; - } - struct wl_display *WlDisplay() const - { - return display_; - } - struct wl_resource *WlResource() const - { - return resource_; - } - - static bool CheckIfObjectIsValid(const OHOS::sptr &object); - static void DefaultDestroyResource(struct wl_client *client, struct wl_resource *resource); - -protected: - static void OnDestroy(struct wl_resource *resource); - virtual void OnResourceDestroy() {} - - struct wl_client *client_ = nullptr; - struct wl_display *display_ = nullptr; - const struct wl_interface *interface_ = nullptr; - uint32_t version_ = 0; - uint32_t id_ = 0; - void *implementation_ = nullptr; - std::string name_; - struct wl_resource *resource_ = nullptr; -}; - -namespace detail { -template -struct HasFuncDefaultDestroyResource { - template - static char check(decltype(&U::DefaultDestroyResource)); - template - static int32_t check(...); - const static bool value = sizeof(check(0)) == sizeof(char); -}; -} // detail - -template -inline OHOS::sptr CastFromResource(struct wl_resource *resource) -{ - if (resource == nullptr) { - return nullptr; - } - - static_assert(detail::HasFuncDefaultDestroyResource::value, - "Can't cast wl_resource to the type which is neither ResourceObject nor the derived type of it."); - - auto wptrObj = OHOS::wptr(DownCast(wl_resource_get_user_data(resource))); - return wptrObj.promote(); -} - -#define OBJECT_CHECK(object, errlog) \ - if (!WaylandResourceObject::CheckIfObjectIsValid(object)) { \ - LOG_WARN(errlog); \ - return; \ - } - -#define CAST_OBJECT_AND_CALL_FUNC(objectType, resource, errlog, func, args...) \ - auto object = CastFromResource((resource)); \ - OBJECT_CHECK(object, errlog); \ - object->func(args); -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/utils/include/wayland_singleton.h b/wayland_adapter/utils/include/wayland_singleton.h deleted file mode 100644 index 4c87d597e73938bb521bbad1fb9cbbcab4ac13c4..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/include/wayland_singleton.h +++ /dev/null @@ -1,73 +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 "types.h" -#include "noncopyable_hal.h" - -#include - -namespace FT { -template -class Singleton : NonCopyable { -public: - Singleton() = default; - virtual ~Singleton() noexcept = default; - - static T &GetInstance() - { - std::call_once(onceFlag_, CreateInstance); - ASSERT(instance_ != nullptr); - return *instance_; - } - -private: - template - struct HasFuncDontDestroyMe { - template - static char check(decltype(&V::DontDestroyMe)); - template - static int32_t check(...); - const static bool value = sizeof(check(0)) == sizeof(char); - }; - - static void CreateInstance() - { - instance_ = new T(); - if (!HasFuncDontDestroyMe::value) { - ::atexit(DestoryInstance); - } - } - static void DestoryInstance() - { - static_assert(sizeof(T) != 0, "Singleton type T must be complete type."); - delete instance_; - instance_ = nullptr; - } - static std::once_flag onceFlag_; - static T *instance_; -}; - -template -std::once_flag Singleton::onceFlag_; - -template -T *Singleton::instance_ = nullptr; - -#define DECLARE_SINGLETON(T) \ -private: \ - friend class Singleton; -} // namespace FT diff --git a/wayland_adapter/utils/src/wayland_event_loop.cpp b/wayland_adapter/utils/src/wayland_event_loop.cpp deleted file mode 100644 index bdbfb6efcd4e32803c8118410bc0230f48f9a1c2..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/src/wayland_event_loop.cpp +++ /dev/null @@ -1,53 +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_event_loop.h" - -namespace FT { -namespace Wayland { - -WaylandEventLoop::WaylandEventLoop() -{ - loop_ = std::make_shared(); -} - -WaylandEventLoop::~WaylandEventLoop() -{ - loop_ = nullptr; -} - -void WaylandEventLoop::QueueToLoop(Functor func) -{ - if (loop_) { - loop_->QueueToLoop(func); - } -} - -EventLoop *WaylandEventLoop::GetEventLoopPtr() -{ - if (loop_) { - return loop_.get(); - } - return nullptr; -} - -void WaylandEventLoop::Start() -{ - if (loop_) { - loop_->Start(); - } -} -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/utils/src/wayland_global.cpp b/wayland_adapter/utils/src/wayland_global.cpp deleted file mode 100644 index d4c14f0b7cf6f64d792936e67de267a175e82aaf..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/src/wayland_global.cpp +++ /dev/null @@ -1,61 +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_global.h" - -namespace FT { -namespace Wayland { -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandGlobal"}; -} - -WaylandGlobal::WaylandGlobal(struct wl_display *display, const struct wl_interface *interface, uint32_t maxSupportVersion) - : display_(display), - interface_(interface), - maxSupportVersion_(maxSupportVersion), - global_(wl_global_create(display_, interface_, maxSupportVersion_, this, &WaylandGlobal::BindCallback)) -{ - name_ = std::string(interface_->name) + "_" + std::to_string(maxSupportVersion_); -} - -WaylandGlobal::~WaylandGlobal() noexcept -{ - if (global_ != nullptr) { - wl_global_destroy(global_); - } -} - -void WaylandGlobal::BindCallback(struct wl_client *client, void *data, uint32_t version, uint32_t id) -{ - if (client == nullptr) { - LOG_ERROR("wl_client is nullptr"); - return; - } - - auto global = OHOS::sptr(static_cast(data)); - if (global == nullptr) { - LOG_ERROR("BindCallback failed"); - return; - } - - if (version > global->MaxSupportVersion()) { - LOG_ERROR("Unsupported version"); - return; - } - - global->Bind(client, version, id); -} -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/utils/src/wayland_keycode_trans.cpp b/wayland_adapter/utils/src/wayland_keycode_trans.cpp deleted file mode 100644 index 7eebcf49a76f526e1548af8e5222ff4b78e21691..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/src/wayland_keycode_trans.cpp +++ /dev/null @@ -1,408 +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 -#include "wayland_keycode_trans.h" -#include "key_event.h" - -using namespace OHOS::MMI; - -namespace FT { -namespace Wayland { -const std::map MAP_KEY_EVENT_VALUE_TRANSFORMATION = { - { KeyEvent::KEYCODE_UNKNOWN , KEY_UNKNOWN }, - { KeyEvent::KEYCODE_HOME , KEY_HOMEPAGE }, - { KeyEvent::KEYCODE_BACK , KEY_BACK }, - { KeyEvent::KEYCODE_CALL , KEY_PHONE }, - { KeyEvent::KEYCODE_CLEAR , KEY_CLEAR }, - { KeyEvent::KEYCODE_HEADSETHOOK , KEY_MEDIA }, - { KeyEvent::KEYCODE_FOCUS , KEY_CAMERA_FOCUS }, - { KeyEvent::KEYCODE_SEARCH , KEY_SEARCH }, - { KeyEvent::KEYCODE_MEDIA_PLAY_PAUSE , KEY_PLAYPAUSE }, - { KeyEvent::KEYCODE_MEDIA_STOP , KEY_STOPCD }, - { KeyEvent::KEYCODE_MEDIA_NEXT , KEY_NEXTSONG }, - { KeyEvent::KEYCODE_MEDIA_PREVIOUS , KEY_PREVIOUSSONG }, - { KeyEvent::KEYCODE_MEDIA_REWIND , KEY_REWIND }, - { KeyEvent::KEYCODE_MEDIA_FAST_FORWARD , KEY_FASTFORWARD }, - { KeyEvent::KEYCODE_VOLUME_UP , KEY_VOLUMEUP }, - { KeyEvent::KEYCODE_VOLUME_DOWN , KEY_VOLUMEDOWN }, - { KeyEvent::KEYCODE_POWER , KEY_POWER }, - { KeyEvent::KEYCODE_CAMERA , KEY_CAMERA }, - { KeyEvent::KEYCODE_VOICE_ASSISTANT , KEY_VOICECOMMAND }, - { KeyEvent::KEYCODE_VOLUME_MUTE , KEY_MUTE }, - { KeyEvent::KEYCODE_MUTE , KEY_MICMUTE }, - { KeyEvent::KEYCODE_BRIGHTNESS_UP , KEY_BRIGHTNESSUP }, - { KeyEvent::KEYCODE_BRIGHTNESS_DOWN , KEY_BRIGHTNESSDOWN }, - { KeyEvent::KEYCODE_0 , KEY_0 }, - { KeyEvent::KEYCODE_1 , KEY_1 }, - { KeyEvent::KEYCODE_2 , KEY_2 }, - { KeyEvent::KEYCODE_3 , KEY_3 }, - { KeyEvent::KEYCODE_4 , KEY_4 }, - { KeyEvent::KEYCODE_5 , KEY_5 }, - { KeyEvent::KEYCODE_6 , KEY_6 }, - { KeyEvent::KEYCODE_7 , KEY_7 }, - { KeyEvent::KEYCODE_8 , KEY_8 }, - { KeyEvent::KEYCODE_9 , KEY_9 }, - { KeyEvent::KEYCODE_STAR , KEY_NUMERIC_STAR }, - { KeyEvent::KEYCODE_POUND , KEY_NUMERIC_POUND }, - { KeyEvent::KEYCODE_DPAD_UP , KEY_UP }, - { KeyEvent::KEYCODE_DPAD_DOWN , KEY_DOWN }, - { KeyEvent::KEYCODE_DPAD_LEFT , KEY_LEFT }, - { KeyEvent::KEYCODE_DPAD_RIGHT , KEY_RIGHT }, - { KeyEvent::KEYCODE_DPAD_CENTER , KEY_SELECT }, - { KeyEvent::KEYCODE_A , KEY_A }, - { KeyEvent::KEYCODE_B , KEY_B }, - { KeyEvent::KEYCODE_C , KEY_C }, - { KeyEvent::KEYCODE_D , KEY_D }, - { KeyEvent::KEYCODE_E , KEY_E }, - { KeyEvent::KEYCODE_F , KEY_F }, - { KeyEvent::KEYCODE_G , KEY_G }, - { KeyEvent::KEYCODE_H , KEY_H }, - { KeyEvent::KEYCODE_I , KEY_I }, - { KeyEvent::KEYCODE_J , KEY_J }, - { KeyEvent::KEYCODE_K , KEY_K }, - { KeyEvent::KEYCODE_L , KEY_L }, - { KeyEvent::KEYCODE_M , KEY_M }, - { KeyEvent::KEYCODE_N , KEY_N }, - { KeyEvent::KEYCODE_O , KEY_O }, - { KeyEvent::KEYCODE_P , KEY_P }, - { KeyEvent::KEYCODE_Q , KEY_Q }, - { KeyEvent::KEYCODE_R , KEY_R }, - { KeyEvent::KEYCODE_S , KEY_S }, - { KeyEvent::KEYCODE_T , KEY_T }, - { KeyEvent::KEYCODE_U , KEY_U }, - { KeyEvent::KEYCODE_V , KEY_V }, - { KeyEvent::KEYCODE_W , KEY_W }, - { KeyEvent::KEYCODE_X , KEY_X }, - { KeyEvent::KEYCODE_Y , KEY_Y }, - { KeyEvent::KEYCODE_Z , KEY_Z }, - { KeyEvent::KEYCODE_COMMA , KEY_COMMA }, - { KeyEvent::KEYCODE_PERIOD , KEY_DOT }, - { KeyEvent::KEYCODE_ALT_LEFT , KEY_LEFTALT }, - { KeyEvent::KEYCODE_ALT_RIGHT , KEY_RIGHTALT }, - { KeyEvent::KEYCODE_SHIFT_LEFT , KEY_LEFTSHIFT }, - { KeyEvent::KEYCODE_SHIFT_RIGHT , KEY_RIGHTSHIFT }, - { KeyEvent::KEYCODE_TAB , KEY_TAB }, - { KeyEvent::KEYCODE_SPACE , KEY_SPACE }, - { KeyEvent::KEYCODE_EXPLORER , KEY_WWW }, - { KeyEvent::KEYCODE_ENVELOPE , KEY_MAIL }, - { KeyEvent::KEYCODE_ENTER , KEY_ENTER }, - { KeyEvent::KEYCODE_DEL , KEY_BACKSPACE }, - { KeyEvent::KEYCODE_GRAVE , KEY_GRAVE }, - { KeyEvent::KEYCODE_MINUS , KEY_MINUS }, - { KeyEvent::KEYCODE_EQUALS , KEY_EQUAL }, - { KeyEvent::KEYCODE_LEFT_BRACKET , KEY_LEFTBRACE }, - { KeyEvent::KEYCODE_RIGHT_BRACKET , KEY_RIGHTBRACE }, - { KeyEvent::KEYCODE_BACKSLASH , KEY_BACKSLASH }, - { KeyEvent::KEYCODE_SEMICOLON , KEY_SEMICOLON }, - { KeyEvent::KEYCODE_APOSTROPHE , KEY_APOSTROPHE }, - { KeyEvent::KEYCODE_SLASH , KEY_SLASH }, - { KeyEvent::KEYCODE_AT , KEY_EMAIL }, - { KeyEvent::KEYCODE_MENU , KEY_MENU }, - { KeyEvent::KEYCODE_PAGE_UP , KEY_PAGEUP }, - { KeyEvent::KEYCODE_PAGE_DOWN , KEY_PAGEDOWN }, - { KeyEvent::KEYCODE_ESCAPE , KEY_ESC }, - { KeyEvent::KEYCODE_FORWARD_DEL , KEY_DELETE }, - { KeyEvent::KEYCODE_CTRL_LEFT , KEY_LEFTCTRL }, - { KeyEvent::KEYCODE_CTRL_RIGHT , KEY_RIGHTCTRL }, - { KeyEvent::KEYCODE_CAPS_LOCK , KEY_CAPSLOCK }, - { KeyEvent::KEYCODE_SCROLL_LOCK , KEY_SCROLLLOCK }, - { KeyEvent::KEYCODE_META_LEFT , KEY_LEFTMETA }, - { KeyEvent::KEYCODE_META_RIGHT , KEY_RIGHTMETA }, - { KeyEvent::KEYCODE_FUNCTION , KEY_FN }, - { KeyEvent::KEYCODE_SYSRQ , KEY_SYSRQ }, - { KeyEvent::KEYCODE_BREAK , KEY_PAUSE }, - { KeyEvent::KEYCODE_MOVE_HOME , KEY_HOME }, - { KeyEvent::KEYCODE_MOVE_END , KEY_END }, - { KeyEvent::KEYCODE_INSERT , KEY_INSERT }, - { KeyEvent::KEYCODE_FORWARD , KEY_FORWARD }, - { KeyEvent::KEYCODE_MEDIA_PLAY , KEY_PLAY }, - { KeyEvent::KEYCODE_MEDIA_PAUSE , KEY_PAUSECD }, - { KeyEvent::KEYCODE_MEDIA_CLOSE , KEY_CLOSECD }, - { KeyEvent::KEYCODE_MEDIA_EJECT , KEY_EJECTCD }, - { KeyEvent::KEYCODE_MEDIA_RECORD , KEY_RECORD }, - { KeyEvent::KEYCODE_F1 , KEY_F1 }, - { KeyEvent::KEYCODE_F2 , KEY_F2 }, - { KeyEvent::KEYCODE_F3 , KEY_F3 }, - { KeyEvent::KEYCODE_F4 , KEY_F4 }, - { KeyEvent::KEYCODE_F5 , KEY_F5 }, - { KeyEvent::KEYCODE_F6 , KEY_F6 }, - { KeyEvent::KEYCODE_F7 , KEY_F7 }, - { KeyEvent::KEYCODE_F8 , KEY_F8 }, - { KeyEvent::KEYCODE_F9 , KEY_F9 }, - { KeyEvent::KEYCODE_F10 , KEY_F10 }, - { KeyEvent::KEYCODE_F11 , KEY_F11 }, - { KeyEvent::KEYCODE_F12 , KEY_F12 }, - { KeyEvent::KEYCODE_NUM_LOCK , KEY_NUMLOCK }, - { KeyEvent::KEYCODE_NUMPAD_0 , KEY_KP0 }, - { KeyEvent::KEYCODE_NUMPAD_1 , KEY_KP1 }, - { KeyEvent::KEYCODE_NUMPAD_2 , KEY_KP2 }, - { KeyEvent::KEYCODE_NUMPAD_3 , KEY_KP3 }, - { KeyEvent::KEYCODE_NUMPAD_4 , KEY_KP4 }, - { KeyEvent::KEYCODE_NUMPAD_5 , KEY_KP5 }, - { KeyEvent::KEYCODE_NUMPAD_6 , KEY_KP6 }, - { KeyEvent::KEYCODE_NUMPAD_7 , KEY_KP7 }, - { KeyEvent::KEYCODE_NUMPAD_8 , KEY_KP8 }, - { KeyEvent::KEYCODE_NUMPAD_9 , KEY_KP9 }, - { KeyEvent::KEYCODE_NUMPAD_DIVIDE , KEY_KPSLASH }, - { KeyEvent::KEYCODE_NUMPAD_MULTIPLY , KEY_KPASTERISK }, - { KeyEvent::KEYCODE_NUMPAD_SUBTRACT , KEY_KPMINUS }, - { KeyEvent::KEYCODE_NUMPAD_ADD , KEY_KPPLUS }, - { KeyEvent::KEYCODE_NUMPAD_DOT , KEY_KPDOT }, - { KeyEvent::KEYCODE_NUMPAD_COMMA , KEY_KPJPCOMMA }, - { KeyEvent::KEYCODE_NUMPAD_ENTER , KEY_KPENTER }, - { KeyEvent::KEYCODE_NUMPAD_EQUALS , KEY_KPEQUAL }, - { KeyEvent::KEYCODE_NUMPAD_LEFT_PAREN , KEY_KPLEFTPAREN }, - { KeyEvent::KEYCODE_NUMPAD_RIGHT_PAREN , KEY_KPRIGHTPAREN }, - { KeyEvent::KEYCODE_BUTTON_A , BTN_A }, - { KeyEvent::KEYCODE_BUTTON_B , BTN_B }, - { KeyEvent::KEYCODE_BUTTON_C , BTN_C }, - { KeyEvent::KEYCODE_BUTTON_X , BTN_X }, - { KeyEvent::KEYCODE_BUTTON_Y , BTN_Y }, - { KeyEvent::KEYCODE_BUTTON_Z , BTN_Z }, - { KeyEvent::KEYCODE_BUTTON_L1 , BTN_TL }, - { KeyEvent::KEYCODE_BUTTON_R1 , BTN_TR }, - { KeyEvent::KEYCODE_BUTTON_L2 , BTN_TL2 }, - { KeyEvent::KEYCODE_BUTTON_R2 , BTN_TR2 }, - { KeyEvent::KEYCODE_BUTTON_SELECT , BTN_SELECT }, - { KeyEvent::KEYCODE_BUTTON_START , BTN_START }, - { KeyEvent::KEYCODE_BUTTON_MODE , BTN_MODE }, - { KeyEvent::KEYCODE_BUTTON_THUMBL , BTN_THUMBL }, - { KeyEvent::KEYCODE_BUTTON_THUMBR , BTN_THUMBR }, - { KeyEvent::KEYCODE_BUTTON_TRIGGER , BTN_TRIGGER }, - { KeyEvent::KEYCODE_BUTTON_THUMB , BTN_THUMB }, - { KeyEvent::KEYCODE_BUTTON_THUMB2 , BTN_THUMB2 }, - { KeyEvent::KEYCODE_BUTTON_TOP , BTN_TOP }, - { KeyEvent::KEYCODE_BUTTON_TOP2 , BTN_TOP2 }, - { KeyEvent::KEYCODE_BUTTON_PINKIE , BTN_PINKIE }, - { KeyEvent::KEYCODE_BUTTON_BASE1 , BTN_BASE }, - { KeyEvent::KEYCODE_BUTTON_BASE2 , BTN_BASE2 }, - { KeyEvent::KEYCODE_BUTTON_BASE3 , BTN_BASE3 }, - { KeyEvent::KEYCODE_BUTTON_BASE4 , BTN_BASE4 }, - { KeyEvent::KEYCODE_BUTTON_BASE5 , BTN_BASE5 }, - { KeyEvent::KEYCODE_BUTTON_BASE6 , BTN_BASE6 }, - { KeyEvent::KEYCODE_BUTTON_DEAD , BTN_DEAD }, - { KeyEvent::KEYCODE_SLEEP , KEY_SLEEP }, - { KeyEvent::KEYCODE_ZENKAKU_HANKAKU , KEY_ZENKAKUHANKAKU }, - { KeyEvent::KEYCODE_102ND , KEY_102ND }, - { KeyEvent::KEYCODE_RO , KEY_RO }, - { KeyEvent::KEYCODE_KATAKANA , KEY_KATAKANA }, - { KeyEvent::KEYCODE_HIRAGANA , KEY_HIRAGANA }, - { KeyEvent::KEYCODE_HENKAN , KEY_HENKAN }, - { KeyEvent::KEYCODE_KATAKANA_HIRAGANA , KEY_KATAKANAHIRAGANA }, - { KeyEvent::KEYCODE_MUHENKAN , KEY_MUHENKAN }, - { KeyEvent::KEYCODE_LINEFEED , KEY_LINEFEED }, - { KeyEvent::KEYCODE_MACRO , KEY_MACRO }, - { KeyEvent::KEYCODE_NUMPAD_PLUSMINUS , KEY_KPPLUSMINUS }, - { KeyEvent::KEYCODE_SCALE , KEY_SCALE }, - { KeyEvent::KEYCODE_HANGUEL , KEY_HANGUEL }, - { KeyEvent::KEYCODE_HANJA , KEY_HANJA }, - { KeyEvent::KEYCODE_YEN , KEY_YEN }, - { KeyEvent::KEYCODE_STOP , KEY_STOP }, - { KeyEvent::KEYCODE_AGAIN , KEY_AGAIN }, - { KeyEvent::KEYCODE_PROPS , KEY_PROPS }, - { KeyEvent::KEYCODE_UNDO , KEY_UNDO }, - { KeyEvent::KEYCODE_COPY , KEY_COPY }, - { KeyEvent::KEYCODE_OPEN , KEY_OPEN }, - { KeyEvent::KEYCODE_PASTE , KEY_PASTE }, - { KeyEvent::KEYCODE_FIND , KEY_FIND }, - { KeyEvent::KEYCODE_CUT , KEY_CUT }, - { KeyEvent::KEYCODE_HELP , KEY_HELP }, - { KeyEvent::KEYCODE_CALC , KEY_CALC }, - { KeyEvent::KEYCODE_FILE , KEY_FILE }, - { KeyEvent::KEYCODE_BOOKMARKS , KEY_BOOKMARKS }, - { KeyEvent::KEYCODE_NEXT , KEY_NEXT }, - { KeyEvent::KEYCODE_PLAYPAUSE , KEY_PLAYPAUSE }, - { KeyEvent::KEYCODE_PREVIOUS , KEY_PREVIOUS }, - { KeyEvent::KEYCODE_STOPCD , KEY_STOPCD }, - { KeyEvent::KEYCODE_CONFIG , KEY_CONFIG }, - { KeyEvent::KEYCODE_REFRESH , KEY_REFRESH }, - { KeyEvent::KEYCODE_EXIT , KEY_EXIT }, - { KeyEvent::KEYCODE_EDIT , KEY_EDIT }, - { KeyEvent::KEYCODE_SCROLLUP , KEY_SCROLLUP }, - { KeyEvent::KEYCODE_SCROLLDOWN , KEY_SCROLLDOWN }, - { KeyEvent::KEYCODE_NEW , KEY_NEW }, - { KeyEvent::KEYCODE_REDO , KEY_REDO }, - { KeyEvent::KEYCODE_CLOSE , KEY_CLOSE }, - { KeyEvent::KEYCODE_PLAY , KEY_PLAYCD }, - { KeyEvent::KEYCODE_BASSBOOST , KEY_BASSBOOST }, - { KeyEvent::KEYCODE_PRINT , KEY_PRINT }, - { KeyEvent::KEYCODE_CHAT , KEY_CHAT }, - { KeyEvent::KEYCODE_FINANCE , KEY_FINANCE }, - { KeyEvent::KEYCODE_CANCEL , KEY_CANCEL }, - { KeyEvent::KEYCODE_KBDILLUM_TOGGLE , KEY_KBDILLUMTOGGLE }, - { KeyEvent::KEYCODE_KBDILLUM_DOWN , KEY_KBDILLUMDOWN }, - { KeyEvent::KEYCODE_KBDILLUM_UP , KEY_KBDILLUMUP }, - { KeyEvent::KEYCODE_SEND , KEY_SEND }, - { KeyEvent::KEYCODE_REPLY , KEY_REPLY }, - { KeyEvent::KEYCODE_FORWARDMAIL , KEY_FORWARDMAIL }, - { KeyEvent::KEYCODE_SAVE , KEY_SAVE }, - { KeyEvent::KEYCODE_DOCUMENTS , KEY_DOCUMENTS }, - { KeyEvent::KEYCODE_VIDEO_NEXT , KEY_VIDEO_NEXT }, - { KeyEvent::KEYCODE_VIDEO_PREV , KEY_VIDEO_PREV }, - { KeyEvent::KEYCODE_BRIGHTNESS_CYCLE , KEY_BRIGHTNESS_CYCLE }, - { KeyEvent::KEYCODE_BRIGHTNESS_ZERO , KEY_BRIGHTNESS_ZERO }, - { KeyEvent::KEYCODE_DISPLAY_OFF , KEY_DISPLAY_OFF }, - { KeyEvent::KEYCODE_BTN_MISC , BTN_MISC }, - { KeyEvent::KEYCODE_GOTO , KEY_GOTO }, - { KeyEvent::KEYCODE_INFO , KEY_INFO }, - { KeyEvent::KEYCODE_PROGRAM , KEY_PROGRAM }, - { KeyEvent::KEYCODE_PVR , KEY_PVR }, - { KeyEvent::KEYCODE_SUBTITLE , KEY_SUBTITLE }, - { KeyEvent::KEYCODE_FULL_SCREEN , KEY_FULL_SCREEN }, - { KeyEvent::KEYCODE_KEYBOARD , KEY_KEYBOARD }, - { KeyEvent::KEYCODE_ASPECT_RATIO , KEY_ASPECT_RATIO }, - { KeyEvent::KEYCODE_PC , KEY_PC }, - { KeyEvent::KEYCODE_TV , KEY_TV }, - { KeyEvent::KEYCODE_TV2 , KEY_TV2 }, - { KeyEvent::KEYCODE_VCR , KEY_VCR }, - { KeyEvent::KEYCODE_VCR2 , KEY_VCR2 }, - { KeyEvent::KEYCODE_SAT , KEY_SAT }, - { KeyEvent::KEYCODE_CD , KEY_CD }, - { KeyEvent::KEYCODE_TAPE , KEY_TAPE }, - { KeyEvent::KEYCODE_TUNER , KEY_TUNER }, - { KeyEvent::KEYCODE_PLAYER , KEY_PLAYER }, - { KeyEvent::KEYCODE_DVD , KEY_DVD }, - { KeyEvent::KEYCODE_AUDIO , KEY_AUDIO }, - { KeyEvent::KEYCODE_VIDEO , KEY_VIDEO }, - { KeyEvent::KEYCODE_MEMO , KEY_MEMO }, - { KeyEvent::KEYCODE_CALENDAR , KEY_CALENDAR }, - { KeyEvent::KEYCODE_RED , KEY_REDO }, - { KeyEvent::KEYCODE_GREEN , KEY_GREEN }, - { KeyEvent::KEYCODE_YELLOW , KEY_YELLOW }, - { KeyEvent::KEYCODE_BLUE , KEY_BLUE }, - { KeyEvent::KEYCODE_CHANNELUP , KEY_CHANNELUP }, - { KeyEvent::KEYCODE_CHANNELDOWN , KEY_CHANNELDOWN }, - { KeyEvent::KEYCODE_LAST , KEY_LAST }, - { KeyEvent::KEYCODE_RESTART , KEY_RESTART }, - { KeyEvent::KEYCODE_SLOW , KEY_SLOW }, - { KeyEvent::KEYCODE_SHUFFLE , KEY_SHUFFLE }, - { KeyEvent::KEYCODE_VIDEOPHONE , KEY_VIDEOPHONE }, - { KeyEvent::KEYCODE_GAMES , KEY_GAMES }, - { KeyEvent::KEYCODE_ZOOMIN , KEY_ZOOMIN }, - { KeyEvent::KEYCODE_ZOOMOUT , KEY_ZOOMOUT }, - { KeyEvent::KEYCODE_ZOOMRESET , KEY_ZOOMRESET }, - { KeyEvent::KEYCODE_WORDPROCESSOR , KEY_WORDPROCESSOR }, - { KeyEvent::KEYCODE_EDITOR , KEY_EDITOR }, - { KeyEvent::KEYCODE_SPREADSHEET , KEY_SPREADSHEET }, - { KeyEvent::KEYCODE_GRAPHICSEDITOR , KEY_GRAPHICSEDITOR }, - { KeyEvent::KEYCODE_PRESENTATION , KEY_PRESENTATION }, - { KeyEvent::KEYCODE_DATABASE , KEY_DATABASE }, - { KeyEvent::KEYCODE_NEWS , KEY_NEWS }, - { KeyEvent::KEYCODE_VOICEMAIL , KEY_VOICEMAIL }, - { KeyEvent::KEYCODE_ADDRESSBOOK , KEY_ADDRESSBOOK }, - { KeyEvent::KEYCODE_MESSENGER , KEY_MESSENGER }, - { KeyEvent::KEYCODE_BRIGHTNESS_TOGGLE , KEY_BRIGHTNESS_TOGGLE }, - { KeyEvent::KEYCODE_SPELLCHECK , KEY_SPELLCHECK }, - { KeyEvent::KEYCODE_COFFEE , KEY_LOGOFF }, - { KeyEvent::KEYCODE_MEDIA_REPEAT , KEY_MEDIA_REPEAT }, - { KeyEvent::KEYCODE_IMAGES , KEY_IMAGES }, - { KeyEvent::KEYCODE_BUTTONCONFIG , KEY_BUTTONCONFIG }, - { KeyEvent::KEYCODE_TASKMANAGER , KEY_TASKMANAGER }, - { KeyEvent::KEYCODE_JOURNAL , KEY_JOURNAL }, - { KeyEvent::KEYCODE_CONTROLPANEL , KEY_CONTROLPANEL }, - { KeyEvent::KEYCODE_APPSELECT , KEY_APPSELECT }, - { KeyEvent::KEYCODE_SCREENSAVER , KEY_SCREENSAVER }, - { KeyEvent::KEYCODE_ASSISTANT , KEY_ASSISTANT }, - { KeyEvent::KEYCODE_KBD_LAYOUT_NEXT , KEY_KBD_LAYOUT_NEXT }, - { KeyEvent::KEYCODE_BRIGHTNESS_MIN , KEY_BRIGHTNESS_MIN }, - { KeyEvent::KEYCODE_BRIGHTNESS_MAX , KEY_BRIGHTNESS_MAX }, - { KeyEvent::KEYCODE_KBDINPUTASSIST_PREV , KEY_KBDINPUTASSIST_PREV }, - { KeyEvent::KEYCODE_KBDINPUTASSIST_NEXT , KEY_KBDINPUTASSIST_NEXT }, - { KeyEvent::KEYCODE_KBDINPUTASSIST_PREVGROUP , KEY_KBDINPUTASSIST_PREVGROUP }, - { KeyEvent::KEYCODE_KBDINPUTASSIST_NEXTGROUP , KEY_KBDINPUTASSIST_NEXTGROUP }, - { KeyEvent::KEYCODE_KBDINPUTASSIST_ACCEPT , KEY_KBDINPUTASSIST_ACCEPT }, - { KeyEvent::KEYCODE_KBDINPUTASSIST_CANCEL , KEY_KBDINPUTASSIST_CANCEL }, - { KeyEvent::KEYCODE_FRONT , KEY_FRONT }, - { KeyEvent::KEYCODE_SETUP , KEY_SETUP }, - { KeyEvent::KEYCODE_WAKEUP , KEY_WAKEUP }, - { KeyEvent::KEYCODE_SENDFILE , KEY_SENDFILE }, - { KeyEvent::KEYCODE_DELETEFILE , KEY_DELETEFILE }, - { KeyEvent::KEYCODE_XFER , KEY_XFER }, - { KeyEvent::KEYCODE_PROG1 , KEY_PROG1 }, - { KeyEvent::KEYCODE_PROG2 , KEY_PROG2 }, - { KeyEvent::KEYCODE_MSDOS , KEY_MSDOS }, - { KeyEvent::KEYCODE_SCREENLOCK , KEY_SCREENLOCK }, - { KeyEvent::KEYCODE_DIRECTION_ROTATE_DISPLAY , KEY_ROTATE_DISPLAY }, - { KeyEvent::KEYCODE_CYCLEWINDOWS , KEY_CYCLEWINDOWS }, - { KeyEvent::KEYCODE_COMPUTER , KEY_COMPUTER }, - { KeyEvent::KEYCODE_EJECTCLOSECD , KEY_EJECTCLOSECD }, - { KeyEvent::KEYCODE_ISO , KEY_ISO }, - { KeyEvent::KEYCODE_MOVE , KEY_MOVE }, - { KeyEvent::KEYCODE_F13 , KEY_F13 }, - { KeyEvent::KEYCODE_F14 , KEY_F14 }, - { KeyEvent::KEYCODE_F15 , KEY_F15 }, - { KeyEvent::KEYCODE_F16 , KEY_F16 }, - { KeyEvent::KEYCODE_F17 , KEY_F17 }, - { KeyEvent::KEYCODE_F18 , KEY_F18 }, - { KeyEvent::KEYCODE_F19 , KEY_F19 }, - { KeyEvent::KEYCODE_F20 , KEY_F20 }, - { KeyEvent::KEYCODE_F21 , KEY_F21 }, - { KeyEvent::KEYCODE_F22 , KEY_F22 }, - { KeyEvent::KEYCODE_F23 , KEY_F23 }, - { KeyEvent::KEYCODE_F24 , KEY_F24 }, - { KeyEvent::KEYCODE_PROG3 , KEY_PROG3 }, - { KeyEvent::KEYCODE_PROG4 , KEY_PROG4 }, - { KeyEvent::KEYCODE_DASHBOARD , KEY_DASHBOARD }, - { KeyEvent::KEYCODE_SUSPEND , KEY_SUSPEND }, - { KeyEvent::KEYCODE_HP , KEY_HP }, - { KeyEvent::KEYCODE_SOUND , KEY_SOUND }, - { KeyEvent::KEYCODE_QUESTION , KEY_QUESTION }, - { KeyEvent::KEYCODE_CONNECT , KEY_CONNECT }, - { KeyEvent::KEYCODE_SPORT , KEY_SPORT }, - { KeyEvent::KEYCODE_SHOP , KEY_SHOP }, - { KeyEvent::KEYCODE_ALTERASE , KEY_ALTERASE }, - { KeyEvent::KEYCODE_SWITCHVIDEOMODE , KEY_SWITCHVIDEOMODE }, - { KeyEvent::KEYCODE_BATTERY , KEY_BATTERY }, - { KeyEvent::KEYCODE_BLUETOOTH , KEY_BLUETOOTH }, - { KeyEvent::KEYCODE_WLAN , KEY_WLAN }, - { KeyEvent::KEYCODE_UWB , KEY_UWB }, - { KeyEvent::KEYCODE_WWAN_WIMAX , KEY_WWAN }, - { KeyEvent::KEYCODE_RFKILL , KEY_RFKILL }, - { KeyEvent::KEYCODE_CHANNEL , KEY_CHANNEL }, - { KeyEvent::KEYCODE_BTN_0 , BTN_0 }, - { KeyEvent::KEYCODE_BTN_1 , BTN_1 }, - { KeyEvent::KEYCODE_BTN_2 , BTN_2 }, - { KeyEvent::KEYCODE_BTN_3 , BTN_3 }, - { KeyEvent::KEYCODE_BTN_4 , BTN_4 }, - { KeyEvent::KEYCODE_BTN_5 , BTN_5 }, - { KeyEvent::KEYCODE_BTN_6 , BTN_6 }, - { KeyEvent::KEYCODE_BTN_7 , BTN_7 }, - { KeyEvent::KEYCODE_BTN_8 , BTN_8 }, - { KeyEvent::KEYCODE_BTN_9 , BTN_9 }, - { KeyEvent::KEYCODE_BRL_DOT1 , KEY_BRL_DOT1 }, - { KeyEvent::KEYCODE_BRL_DOT2 , KEY_BRL_DOT2 }, - { KeyEvent::KEYCODE_BRL_DOT3 , KEY_BRL_DOT3 }, - { KeyEvent::KEYCODE_BRL_DOT4 , KEY_BRL_DOT4 }, - { KeyEvent::KEYCODE_BRL_DOT5 , KEY_BRL_DOT5 }, - { KeyEvent::KEYCODE_BRL_DOT6 , KEY_BRL_DOT6 }, - { KeyEvent::KEYCODE_BRL_DOT7 , KEY_BRL_DOT7 }, - { KeyEvent::KEYCODE_BRL_DOT8 , KEY_BRL_DOT8 }, - { KeyEvent::KEYCODE_BRL_DOT9 , KEY_BRL_DOT9 }, - { KeyEvent::KEYCODE_BRL_DOT10 , KEY_BRL_DOT10 }, -}; - -int32_t TransferKeyValue(int32_t keyValueOfInput) -{ - auto it = MAP_KEY_EVENT_VALUE_TRANSFORMATION.find(keyValueOfInput); - if (it == MAP_KEY_EVENT_VALUE_TRANSFORMATION.end()) { - return -1; - } - return it->second; -} - -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/utils/src/wayland_objects_pool.cpp b/wayland_adapter/utils/src/wayland_objects_pool.cpp deleted file mode 100644 index 3eddebd069e0d750b54d6f96d12062c82ab42c2f..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/src/wayland_objects_pool.cpp +++ /dev/null @@ -1,72 +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_objects_pool.h" - -namespace FT { -namespace Wayland { -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandObjectsPool"}; -} - -OHOS::sptr WaylandObjectsPool::cb_ = nullptr; -void WaylandObjectsPool::SetCallback(OHOS::sptr cb) -{ - cb_ = cb; -} - -void WaylandObjectsPool::AddObject(ObjectId id, const OHOS::sptr &object) -{ - std::lock_guard lock(mutex_); - if (objects_.count(id) > 0) { - LOG_WARN("object already exists"); - } - - objects_[id] = object; -} - -void WaylandObjectsPool::RemoveObject(ObjectId id, const OHOS::sptr &object) -{ - std::lock_guard lock(mutex_); - if (objects_.count(id) == 0) { - LOG_WARN("object already removed"); - return; - } - - const auto &objInPool = objects_.at(id); - if (objInPool != object) { - LOG_ERROR("invalid id"); - return; - } - - objects_.erase(id); - - if (cb_ != nullptr) { - cb_->OnDestroy(id); - } -} - -OHOS::sptr WaylandObjectsPool::GetObject(ObjectId id) const -{ - std::lock_guard lock(mutex_); - if (objects_.count(id) == 0) { - LOG_WARN("object does not exist"); - return nullptr; - } - - return objects_.at(id); -} -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/utils/src/wayland_resource_object.cpp b/wayland_adapter/utils/src/wayland_resource_object.cpp deleted file mode 100644 index 7810de3c616aeaaef9fa5bb1578eec543c2073bb..0000000000000000000000000000000000000000 --- a/wayland_adapter/utils/src/wayland_resource_object.cpp +++ /dev/null @@ -1,96 +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_resource_object.h" - -#include "wayland_objects_pool.h" - -namespace FT { -namespace Wayland { -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandResourceObject"}; -} - -WaylandResourceObject::WaylandResourceObject(struct wl_client *client, const struct wl_interface *interface, - uint32_t version, uint32_t id, void *implementation) - : client_(client), - display_(wl_client_get_display(client_)), - interface_(interface), - version_(version), - implementation_(implementation) -{ - resource_ = wl_resource_create(client_, interface_, version_, id); - if (resource_ == nullptr) { - LOG_ERROR("no memory"); - wl_client_post_no_memory(client_); - return; - } - - id_ = wl_resource_get_id(resource_); - wl_resource_set_implementation(resource_, implementation_, this, &WaylandResourceObject::OnDestroy); - name_ = std::string(interface_->name) + "_" + std::to_string(version_) + "_" + std::to_string(id_); - LOG_DEBUG("create WaylandResourceObject, name=%{public}s, id=%{public}d", name_.c_str(), id_); -} - -WaylandResourceObject::~WaylandResourceObject() noexcept -{ - if (resource_ != nullptr) { - wl_resource_destroy(resource_); - } -} - -void WaylandResourceObject::DefaultDestroyResource(struct wl_client *client, struct wl_resource *resource) -{ - auto object = CastFromResource(resource); - if (object == nullptr) { - LOG_WARN("object is nullptr"); - return; - } - - object->resource_ = nullptr; - wl_resource_destroy(resource); -} - -void WaylandResourceObject::OnDestroy(struct wl_resource *resource) -{ - auto object = CastFromResource(resource); - if (object == nullptr) { - LOG_WARN("object is nullptr"); - return; - } - - object->OnResourceDestroy(); - object->resource_ = nullptr; - WaylandObjectsPool::GetInstance().RemoveObject(ObjectId(object->WlClient(), object->Id()), object); -} - -bool WaylandResourceObject::CheckIfObjectIsValid(const OHOS::sptr &object) -{ - if (object == nullptr) { - LOG_ERROR("object is nullptr"); - return false; - } - - auto objId = ObjectId(object->WlClient(), object->Id()); - auto objInPool = WaylandObjectsPool::GetInstance().GetObject(objId); - if (objInPool != object) { - LOG_ERROR("CheckIfObjectIsValid failed"); - return false; - } - - return true; -} -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/wayland_protocols/BUILD.gn b/wayland_adapter/wayland_protocols/BUILD.gn deleted file mode 100644 index 679ad09ae1159c728afc3888e2c571ad7c1395ce..0000000000000000000000000000000000000000 --- a/wayland_adapter/wayland_protocols/BUILD.gn +++ /dev/null @@ -1,26 +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("wayland_public_config") { - include_dirs = [ "stable/xdg-shell" ] - include_dirs += [ "unstable" ] -} - -ft_source_set("wayland_protocols_sources") { - sources = [ "stable/xdg-shell/xdg-shell-protocol.c" ] - sources += [ "unstable/xdg-output-unstable-v1-protocol.c" ] - public_configs = [ ":wayland_public_config" ] -} diff --git a/wayland_adapter/wayland_protocols/stable/xdg-shell/xdg-shell-client-protocol.h b/wayland_adapter/wayland_protocols/stable/xdg-shell/xdg-shell-client-protocol.h deleted file mode 100644 index 5751596281331daab454c6d3c9bfeab87ea9ed5f..0000000000000000000000000000000000000000 --- a/wayland_adapter/wayland_protocols/stable/xdg-shell/xdg-shell-client-protocol.h +++ /dev/null @@ -1,2307 +0,0 @@ -/* Generated by wayland-scanner 1.20.0 */ - -#ifndef XDG_SHELL_CLIENT_PROTOCOL_H -#define XDG_SHELL_CLIENT_PROTOCOL_H - -#include -#include -#include "wayland-client.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @page page_xdg_shell The xdg_shell protocol - * @section page_ifaces_xdg_shell Interfaces - * - @subpage page_iface_xdg_wm_base - create desktop-style surfaces - * - @subpage page_iface_xdg_positioner - child surface positioner - * - @subpage page_iface_xdg_surface - desktop user interface surface base interface - * - @subpage page_iface_xdg_toplevel - toplevel surface - * - @subpage page_iface_xdg_popup - short-lived, popup surfaces for menus - * @section page_copyright_xdg_shell Copyright - *
- *
- * Copyright © 2008-2013 Kristian Høgsberg
- * Copyright © 2013      Rafael Antognolli
- * Copyright © 2013      Jasper St. Pierre
- * Copyright © 2010-2013 Intel Corporation
- * Copyright © 2015-2017 Samsung Electronics Co., Ltd
- * Copyright © 2015-2017 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- * 
- */ -struct wl_output; -struct wl_seat; -struct wl_surface; -struct xdg_popup; -struct xdg_positioner; -struct xdg_surface; -struct xdg_toplevel; -struct xdg_wm_base; - -#ifndef XDG_WM_BASE_INTERFACE -#define XDG_WM_BASE_INTERFACE -/** - * @page page_iface_xdg_wm_base xdg_wm_base - * @section page_iface_xdg_wm_base_desc Description - * - * The xdg_wm_base interface is exposed as a global object enabling clients - * to turn their wl_surfaces into windows in a desktop environment. It - * defines the basic functionality needed for clients and the compositor to - * create windows that can be dragged, resized, maximized, etc, as well as - * creating transient windows such as popup menus. - * @section page_iface_xdg_wm_base_api API - * See @ref iface_xdg_wm_base. - */ -/** - * @defgroup iface_xdg_wm_base The xdg_wm_base interface - * - * The xdg_wm_base interface is exposed as a global object enabling clients - * to turn their wl_surfaces into windows in a desktop environment. It - * defines the basic functionality needed for clients and the compositor to - * create windows that can be dragged, resized, maximized, etc, as well as - * creating transient windows such as popup menus. - */ -extern const struct wl_interface xdg_wm_base_interface; -#endif -#ifndef XDG_POSITIONER_INTERFACE -#define XDG_POSITIONER_INTERFACE -/** - * @page page_iface_xdg_positioner xdg_positioner - * @section page_iface_xdg_positioner_desc Description - * - * The xdg_positioner provides a collection of rules for the placement of a - * child surface relative to a parent surface. Rules can be defined to ensure - * the child surface remains within the visible area's borders, and to - * specify how the child surface changes its position, such as sliding along - * an axis, or flipping around a rectangle. These positioner-created rules are - * constrained by the requirement that a child surface must intersect with or - * be at least partially adjacent to its parent surface. - * - * See the various requests for details about possible rules. - * - * At the time of the request, the compositor makes a copy of the rules - * specified by the xdg_positioner. Thus, after the request is complete the - * xdg_positioner object can be destroyed or reused; further changes to the - * object will have no effect on previous usages. - * - * For an xdg_positioner object to be considered complete, it must have a - * non-zero size set by set_size, and a non-zero anchor rectangle set by - * set_anchor_rect. Passing an incomplete xdg_positioner object when - * positioning a surface raises an invalid_positioner error. - * @section page_iface_xdg_positioner_api API - * See @ref iface_xdg_positioner. - */ -/** - * @defgroup iface_xdg_positioner The xdg_positioner interface - * - * The xdg_positioner provides a collection of rules for the placement of a - * child surface relative to a parent surface. Rules can be defined to ensure - * the child surface remains within the visible area's borders, and to - * specify how the child surface changes its position, such as sliding along - * an axis, or flipping around a rectangle. These positioner-created rules are - * constrained by the requirement that a child surface must intersect with or - * be at least partially adjacent to its parent surface. - * - * See the various requests for details about possible rules. - * - * At the time of the request, the compositor makes a copy of the rules - * specified by the xdg_positioner. Thus, after the request is complete the - * xdg_positioner object can be destroyed or reused; further changes to the - * object will have no effect on previous usages. - * - * For an xdg_positioner object to be considered complete, it must have a - * non-zero size set by set_size, and a non-zero anchor rectangle set by - * set_anchor_rect. Passing an incomplete xdg_positioner object when - * positioning a surface raises an invalid_positioner error. - */ -extern const struct wl_interface xdg_positioner_interface; -#endif -#ifndef XDG_SURFACE_INTERFACE -#define XDG_SURFACE_INTERFACE -/** - * @page page_iface_xdg_surface xdg_surface - * @section page_iface_xdg_surface_desc Description - * - * An interface that may be implemented by a wl_surface, for - * implementations that provide a desktop-style user interface. - * - * It provides a base set of functionality required to construct user - * interface elements requiring management by the compositor, such as - * toplevel windows, menus, etc. The types of functionality are split into - * xdg_surface roles. - * - * Creating an xdg_surface does not set the role for a wl_surface. In order - * to map an xdg_surface, the client must create a role-specific object - * using, e.g., get_toplevel, get_popup. The wl_surface for any given - * xdg_surface can have at most one role, and may not be assigned any role - * not based on xdg_surface. - * - * A role must be assigned before any other requests are made to the - * xdg_surface object. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_surface state to take effect. - * - * Creating an xdg_surface from a wl_surface which has a buffer attached or - * committed is a client error, and any attempts by a client to attach or - * manipulate a buffer prior to the first xdg_surface.configure call must - * also be treated as errors. - * - * After creating a role-specific object and setting it up, the client must - * perform an initial commit without any buffer attached. The compositor - * will reply with initial wl_surface state such as - * wl_surface.preferred_buffer_scale followed by an xdg_surface.configure - * event. The client must acknowledge it and is then allowed to attach a - * buffer to map the surface. - * - * Mapping an xdg_surface-based role surface is defined as making it - * possible for the surface to be shown by the compositor. Note that - * a mapped surface is not guaranteed to be visible once it is mapped. - * - * For an xdg_surface to be mapped by the compositor, the following - * conditions must be met: - * (1) the client has assigned an xdg_surface-based role to the surface - * (2) the client has set and committed the xdg_surface state and the - * role-dependent state to the surface - * (3) the client has committed a buffer to the surface - * - * A newly-unmapped surface is considered to have met condition (1) out - * of the 3 required conditions for mapping a surface if its role surface - * has not been destroyed, i.e. the client must perform the initial commit - * again before attaching a buffer. - * @section page_iface_xdg_surface_api API - * See @ref iface_xdg_surface. - */ -/** - * @defgroup iface_xdg_surface The xdg_surface interface - * - * An interface that may be implemented by a wl_surface, for - * implementations that provide a desktop-style user interface. - * - * It provides a base set of functionality required to construct user - * interface elements requiring management by the compositor, such as - * toplevel windows, menus, etc. The types of functionality are split into - * xdg_surface roles. - * - * Creating an xdg_surface does not set the role for a wl_surface. In order - * to map an xdg_surface, the client must create a role-specific object - * using, e.g., get_toplevel, get_popup. The wl_surface for any given - * xdg_surface can have at most one role, and may not be assigned any role - * not based on xdg_surface. - * - * A role must be assigned before any other requests are made to the - * xdg_surface object. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_surface state to take effect. - * - * Creating an xdg_surface from a wl_surface which has a buffer attached or - * committed is a client error, and any attempts by a client to attach or - * manipulate a buffer prior to the first xdg_surface.configure call must - * also be treated as errors. - * - * After creating a role-specific object and setting it up, the client must - * perform an initial commit without any buffer attached. The compositor - * will reply with initial wl_surface state such as - * wl_surface.preferred_buffer_scale followed by an xdg_surface.configure - * event. The client must acknowledge it and is then allowed to attach a - * buffer to map the surface. - * - * Mapping an xdg_surface-based role surface is defined as making it - * possible for the surface to be shown by the compositor. Note that - * a mapped surface is not guaranteed to be visible once it is mapped. - * - * For an xdg_surface to be mapped by the compositor, the following - * conditions must be met: - * (1) the client has assigned an xdg_surface-based role to the surface - * (2) the client has set and committed the xdg_surface state and the - * role-dependent state to the surface - * (3) the client has committed a buffer to the surface - * - * A newly-unmapped surface is considered to have met condition (1) out - * of the 3 required conditions for mapping a surface if its role surface - * has not been destroyed, i.e. the client must perform the initial commit - * again before attaching a buffer. - */ -extern const struct wl_interface xdg_surface_interface; -#endif -#ifndef XDG_TOPLEVEL_INTERFACE -#define XDG_TOPLEVEL_INTERFACE -/** - * @page page_iface_xdg_toplevel xdg_toplevel - * @section page_iface_xdg_toplevel_desc Description - * - * This interface defines an xdg_surface role which allows a surface to, - * among other things, set window-like properties such as maximize, - * fullscreen, and minimize, set application-specific metadata like title and - * id, and well as trigger user interactive operations such as interactive - * resize and move. - * - * Unmapping an xdg_toplevel means that the surface cannot be shown - * by the compositor until it is explicitly mapped again. - * All active operations (e.g., move, resize) are canceled and all - * attributes (e.g. title, state, stacking, ...) are discarded for - * an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to - * the state it had right after xdg_surface.get_toplevel. The client - * can re-map the toplevel by perfoming a commit without any buffer - * attached, waiting for a configure event and handling it as usual (see - * xdg_surface description). - * - * Attaching a null buffer to a toplevel unmaps the surface. - * @section page_iface_xdg_toplevel_api API - * See @ref iface_xdg_toplevel. - */ -/** - * @defgroup iface_xdg_toplevel The xdg_toplevel interface - * - * This interface defines an xdg_surface role which allows a surface to, - * among other things, set window-like properties such as maximize, - * fullscreen, and minimize, set application-specific metadata like title and - * id, and well as trigger user interactive operations such as interactive - * resize and move. - * - * Unmapping an xdg_toplevel means that the surface cannot be shown - * by the compositor until it is explicitly mapped again. - * All active operations (e.g., move, resize) are canceled and all - * attributes (e.g. title, state, stacking, ...) are discarded for - * an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to - * the state it had right after xdg_surface.get_toplevel. The client - * can re-map the toplevel by perfoming a commit without any buffer - * attached, waiting for a configure event and handling it as usual (see - * xdg_surface description). - * - * Attaching a null buffer to a toplevel unmaps the surface. - */ -extern const struct wl_interface xdg_toplevel_interface; -#endif -#ifndef XDG_POPUP_INTERFACE -#define XDG_POPUP_INTERFACE -/** - * @page page_iface_xdg_popup xdg_popup - * @section page_iface_xdg_popup_desc Description - * - * A popup surface is a short-lived, temporary surface. It can be used to - * implement for example menus, popovers, tooltips and other similar user - * interface concepts. - * - * A popup can be made to take an explicit grab. See xdg_popup.grab for - * details. - * - * When the popup is dismissed, a popup_done event will be sent out, and at - * the same time the surface will be unmapped. See the xdg_popup.popup_done - * event for details. - * - * Explicitly destroying the xdg_popup object will also dismiss the popup and - * unmap the surface. Clients that want to dismiss the popup when another - * surface of their own is clicked should dismiss the popup using the destroy - * request. - * - * A newly created xdg_popup will be stacked on top of all previously created - * xdg_popup surfaces associated with the same xdg_toplevel. - * - * The parent of an xdg_popup must be mapped (see the xdg_surface - * description) before the xdg_popup itself. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_popup state to take effect. - * @section page_iface_xdg_popup_api API - * See @ref iface_xdg_popup. - */ -/** - * @defgroup iface_xdg_popup The xdg_popup interface - * - * A popup surface is a short-lived, temporary surface. It can be used to - * implement for example menus, popovers, tooltips and other similar user - * interface concepts. - * - * A popup can be made to take an explicit grab. See xdg_popup.grab for - * details. - * - * When the popup is dismissed, a popup_done event will be sent out, and at - * the same time the surface will be unmapped. See the xdg_popup.popup_done - * event for details. - * - * Explicitly destroying the xdg_popup object will also dismiss the popup and - * unmap the surface. Clients that want to dismiss the popup when another - * surface of their own is clicked should dismiss the popup using the destroy - * request. - * - * A newly created xdg_popup will be stacked on top of all previously created - * xdg_popup surfaces associated with the same xdg_toplevel. - * - * The parent of an xdg_popup must be mapped (see the xdg_surface - * description) before the xdg_popup itself. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_popup state to take effect. - */ -extern const struct wl_interface xdg_popup_interface; -#endif - -#ifndef XDG_WM_BASE_ERROR_ENUM -#define XDG_WM_BASE_ERROR_ENUM -enum xdg_wm_base_error { - /** - * given wl_surface has another role - */ - XDG_WM_BASE_ERROR_ROLE = 0, - /** - * xdg_wm_base was destroyed before children - */ - XDG_WM_BASE_ERROR_DEFUNCT_SURFACES = 1, - /** - * the client tried to map or destroy a non-topmost popup - */ - XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP = 2, - /** - * the client specified an invalid popup parent surface - */ - XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT = 3, - /** - * the client provided an invalid surface state - */ - XDG_WM_BASE_ERROR_INVALID_SURFACE_STATE = 4, - /** - * the client provided an invalid positioner - */ - XDG_WM_BASE_ERROR_INVALID_POSITIONER = 5, - /** - * the client didn’t respond to a ping event in time - */ - XDG_WM_BASE_ERROR_UNRESPONSIVE = 6, -}; -#endif /* XDG_WM_BASE_ERROR_ENUM */ - -/** - * @ingroup iface_xdg_wm_base - * @struct xdg_wm_base_listener - */ -struct xdg_wm_base_listener { - /** - * check if the client is alive - * - * The ping event asks the client if it's still alive. Pass the - * serial specified in the event back to the compositor by sending - * a "pong" request back with the specified serial. See - * xdg_wm_base.pong. - * - * Compositors can use this to determine if the client is still - * alive. It's unspecified what will happen if the client doesn't - * respond to the ping request, or in what timeframe. Clients - * should try to respond in a reasonable amount of time. The - * “unresponsive” error is provided for compositors that wish - * to disconnect unresponsive clients. - * - * A compositor is free to ping in any way it wants, but a client - * must always respond to any xdg_wm_base object it created. - * @param serial pass this to the pong request - */ - void (*ping)(void *data, - struct xdg_wm_base *xdg_wm_base, - uint32_t serial); -}; - -/** - * @ingroup iface_xdg_wm_base - */ -static inline int -xdg_wm_base_add_listener(struct xdg_wm_base *xdg_wm_base, - const struct xdg_wm_base_listener *listener, void *data) -{ - return wl_proxy_add_listener((struct wl_proxy *) xdg_wm_base, - (void (**)(void)) listener, data); -} - -#define XDG_WM_BASE_DESTROY 0 -#define XDG_WM_BASE_CREATE_POSITIONER 1 -#define XDG_WM_BASE_GET_XDG_SURFACE 2 -#define XDG_WM_BASE_PONG 3 - -/** - * @ingroup iface_xdg_wm_base - */ -#define XDG_WM_BASE_PING_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_wm_base - */ -#define XDG_WM_BASE_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_wm_base - */ -#define XDG_WM_BASE_CREATE_POSITIONER_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_wm_base - */ -#define XDG_WM_BASE_GET_XDG_SURFACE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_wm_base - */ -#define XDG_WM_BASE_PONG_SINCE_VERSION 1 - -/** @ingroup iface_xdg_wm_base */ -static inline void -xdg_wm_base_set_user_data(struct xdg_wm_base *xdg_wm_base, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) xdg_wm_base, user_data); -} - -/** @ingroup iface_xdg_wm_base */ -static inline void * -xdg_wm_base_get_user_data(struct xdg_wm_base *xdg_wm_base) -{ - return wl_proxy_get_user_data((struct wl_proxy *) xdg_wm_base); -} - -static inline uint32_t -xdg_wm_base_get_version(struct xdg_wm_base *xdg_wm_base) -{ - return wl_proxy_get_version((struct wl_proxy *) xdg_wm_base); -} - -/** - * @ingroup iface_xdg_wm_base - * - * Destroy this xdg_wm_base object. - * - * Destroying a bound xdg_wm_base object while there are surfaces - * still alive created by this xdg_wm_base object instance is illegal - * and will result in a defunct_surfaces error. - */ -static inline void -xdg_wm_base_destroy(struct xdg_wm_base *xdg_wm_base) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base, - XDG_WM_BASE_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), WL_MARSHAL_FLAG_DESTROY); -} - -/** - * @ingroup iface_xdg_wm_base - * - * Create a positioner object. A positioner object is used to position - * surfaces relative to some parent surface. See the interface description - * and xdg_surface.get_popup for details. - */ -static inline struct xdg_positioner * -xdg_wm_base_create_positioner(struct xdg_wm_base *xdg_wm_base) -{ - struct wl_proxy *id; - - id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base, - XDG_WM_BASE_CREATE_POSITIONER, &xdg_positioner_interface, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), 0, NULL); - - return (struct xdg_positioner *) id; -} - -/** - * @ingroup iface_xdg_wm_base - * - * This creates an xdg_surface for the given surface. While xdg_surface - * itself is not a role, the corresponding surface may only be assigned - * a role extending xdg_surface, such as xdg_toplevel or xdg_popup. It is - * illegal to create an xdg_surface for a wl_surface which already has an - * assigned role and this will result in a role error. - * - * This creates an xdg_surface for the given surface. An xdg_surface is - * used as basis to define a role to a given surface, such as xdg_toplevel - * or xdg_popup. It also manages functionality shared between xdg_surface - * based surface roles. - * - * See the documentation of xdg_surface for more details about what an - * xdg_surface is and how it is used. - */ -static inline struct xdg_surface * -xdg_wm_base_get_xdg_surface(struct xdg_wm_base *xdg_wm_base, struct wl_surface *surface) -{ - struct wl_proxy *id; - - id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base, - XDG_WM_BASE_GET_XDG_SURFACE, &xdg_surface_interface, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), 0, NULL, surface); - - return (struct xdg_surface *) id; -} - -/** - * @ingroup iface_xdg_wm_base - * - * A client must respond to a ping event with a pong request or - * the client may be deemed unresponsive. See xdg_wm_base.ping - * and xdg_wm_base.error.unresponsive. - */ -static inline void -xdg_wm_base_pong(struct xdg_wm_base *xdg_wm_base, uint32_t serial) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base, - XDG_WM_BASE_PONG, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), 0, serial); -} - -#ifndef XDG_POSITIONER_ERROR_ENUM -#define XDG_POSITIONER_ERROR_ENUM -enum xdg_positioner_error { - /** - * invalid input provided - */ - XDG_POSITIONER_ERROR_INVALID_INPUT = 0, -}; -#endif /* XDG_POSITIONER_ERROR_ENUM */ - -#ifndef XDG_POSITIONER_ANCHOR_ENUM -#define XDG_POSITIONER_ANCHOR_ENUM -enum xdg_positioner_anchor { - XDG_POSITIONER_ANCHOR_NONE = 0, - XDG_POSITIONER_ANCHOR_TOP = 1, - XDG_POSITIONER_ANCHOR_BOTTOM = 2, - XDG_POSITIONER_ANCHOR_LEFT = 3, - XDG_POSITIONER_ANCHOR_RIGHT = 4, - XDG_POSITIONER_ANCHOR_TOP_LEFT = 5, - XDG_POSITIONER_ANCHOR_BOTTOM_LEFT = 6, - XDG_POSITIONER_ANCHOR_TOP_RIGHT = 7, - XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT = 8, -}; -#endif /* XDG_POSITIONER_ANCHOR_ENUM */ - -#ifndef XDG_POSITIONER_GRAVITY_ENUM -#define XDG_POSITIONER_GRAVITY_ENUM -enum xdg_positioner_gravity { - XDG_POSITIONER_GRAVITY_NONE = 0, - XDG_POSITIONER_GRAVITY_TOP = 1, - XDG_POSITIONER_GRAVITY_BOTTOM = 2, - XDG_POSITIONER_GRAVITY_LEFT = 3, - XDG_POSITIONER_GRAVITY_RIGHT = 4, - XDG_POSITIONER_GRAVITY_TOP_LEFT = 5, - XDG_POSITIONER_GRAVITY_BOTTOM_LEFT = 6, - XDG_POSITIONER_GRAVITY_TOP_RIGHT = 7, - XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT = 8, -}; -#endif /* XDG_POSITIONER_GRAVITY_ENUM */ - -#ifndef XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM -#define XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM -/** - * @ingroup iface_xdg_positioner - * constraint adjustments - * - * The constraint adjustment value define ways the compositor will adjust - * the position of the surface, if the unadjusted position would result - * in the surface being partly constrained. - * - * Whether a surface is considered 'constrained' is left to the compositor - * to determine. For example, the surface may be partly outside the - * compositor's defined 'work area', thus necessitating the child surface's - * position be adjusted until it is entirely inside the work area. - * - * The adjustments can be combined, according to a defined precedence: 1) - * Flip, 2) Slide, 3) Resize. - */ -enum xdg_positioner_constraint_adjustment { - /** - * don't move the child surface when constrained - * - * Don't alter the surface position even if it is constrained on - * some axis, for example partially outside the edge of an output. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE = 0, - /** - * move along the x axis until unconstrained - * - * Slide the surface along the x axis until it is no longer - * constrained. - * - * First try to slide towards the direction of the gravity on the x - * axis until either the edge in the opposite direction of the - * gravity is unconstrained or the edge in the direction of the - * gravity is constrained. - * - * Then try to slide towards the opposite direction of the gravity - * on the x axis until either the edge in the direction of the - * gravity is unconstrained or the edge in the opposite direction - * of the gravity is constrained. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1, - /** - * move along the y axis until unconstrained - * - * Slide the surface along the y axis until it is no longer - * constrained. - * - * First try to slide towards the direction of the gravity on the y - * axis until either the edge in the opposite direction of the - * gravity is unconstrained or the edge in the direction of the - * gravity is constrained. - * - * Then try to slide towards the opposite direction of the gravity - * on the y axis until either the edge in the direction of the - * gravity is unconstrained or the edge in the opposite direction - * of the gravity is constrained. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2, - /** - * invert the anchor and gravity on the x axis - * - * Invert the anchor and gravity on the x axis if the surface is - * constrained on the x axis. For example, if the left edge of the - * surface is constrained, the gravity is 'left' and the anchor is - * 'left', change the gravity to 'right' and the anchor to 'right'. - * - * If the adjusted position also ends up being constrained, the - * resulting position of the flip_x adjustment will be the one - * before the adjustment. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X = 4, - /** - * invert the anchor and gravity on the y axis - * - * Invert the anchor and gravity on the y axis if the surface is - * constrained on the y axis. For example, if the bottom edge of - * the surface is constrained, the gravity is 'bottom' and the - * anchor is 'bottom', change the gravity to 'top' and the anchor - * to 'top'. - * - * The adjusted position is calculated given the original anchor - * rectangle and offset, but with the new flipped anchor and - * gravity values. - * - * If the adjusted position also ends up being constrained, the - * resulting position of the flip_y adjustment will be the one - * before the adjustment. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8, - /** - * horizontally resize the surface - * - * Resize the surface horizontally so that it is completely - * unconstrained. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16, - /** - * vertically resize the surface - * - * Resize the surface vertically so that it is completely - * unconstrained. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32, -}; -#endif /* XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM */ - -#define XDG_POSITIONER_DESTROY 0 -#define XDG_POSITIONER_SET_SIZE 1 -#define XDG_POSITIONER_SET_ANCHOR_RECT 2 -#define XDG_POSITIONER_SET_ANCHOR 3 -#define XDG_POSITIONER_SET_GRAVITY 4 -#define XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT 5 -#define XDG_POSITIONER_SET_OFFSET 6 -#define XDG_POSITIONER_SET_REACTIVE 7 -#define XDG_POSITIONER_SET_PARENT_SIZE 8 -#define XDG_POSITIONER_SET_PARENT_CONFIGURE 9 - - -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_SIZE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_ANCHOR_RECT_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_ANCHOR_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_GRAVITY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_OFFSET_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_REACTIVE_SINCE_VERSION 3 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_PARENT_SIZE_SINCE_VERSION 3 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_PARENT_CONFIGURE_SINCE_VERSION 3 - -/** @ingroup iface_xdg_positioner */ -static inline void -xdg_positioner_set_user_data(struct xdg_positioner *xdg_positioner, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) xdg_positioner, user_data); -} - -/** @ingroup iface_xdg_positioner */ -static inline void * -xdg_positioner_get_user_data(struct xdg_positioner *xdg_positioner) -{ - return wl_proxy_get_user_data((struct wl_proxy *) xdg_positioner); -} - -static inline uint32_t -xdg_positioner_get_version(struct xdg_positioner *xdg_positioner) -{ - return wl_proxy_get_version((struct wl_proxy *) xdg_positioner); -} - -/** - * @ingroup iface_xdg_positioner - * - * Notify the compositor that the xdg_positioner will no longer be used. - */ -static inline void -xdg_positioner_destroy(struct xdg_positioner *xdg_positioner) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, - XDG_POSITIONER_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), WL_MARSHAL_FLAG_DESTROY); -} - -/** - * @ingroup iface_xdg_positioner - * - * Set the size of the surface that is to be positioned with the positioner - * object. The size is in surface-local coordinates and corresponds to the - * window geometry. See xdg_surface.set_window_geometry. - * - * If a zero or negative size is set the invalid_input error is raised. - */ -static inline void -xdg_positioner_set_size(struct xdg_positioner *xdg_positioner, int32_t width, int32_t height) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, - XDG_POSITIONER_SET_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, width, height); -} - -/** - * @ingroup iface_xdg_positioner - * - * Specify the anchor rectangle within the parent surface that the child - * surface will be placed relative to. The rectangle is relative to the - * window geometry as defined by xdg_surface.set_window_geometry of the - * parent surface. - * - * When the xdg_positioner object is used to position a child surface, the - * anchor rectangle may not extend outside the window geometry of the - * positioned child's parent surface. - * - * If a negative size is set the invalid_input error is raised. - */ -static inline void -xdg_positioner_set_anchor_rect(struct xdg_positioner *xdg_positioner, int32_t x, int32_t y, int32_t width, int32_t height) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, - XDG_POSITIONER_SET_ANCHOR_RECT, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, x, y, width, height); -} - -/** - * @ingroup iface_xdg_positioner - * - * Defines the anchor point for the anchor rectangle. The specified anchor - * is used derive an anchor point that the child surface will be - * positioned relative to. If a corner anchor is set (e.g. 'top_left' or - * 'bottom_right'), the anchor point will be at the specified corner; - * otherwise, the derived anchor point will be centered on the specified - * edge, or in the center of the anchor rectangle if no edge is specified. - */ -static inline void -xdg_positioner_set_anchor(struct xdg_positioner *xdg_positioner, uint32_t anchor) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, - XDG_POSITIONER_SET_ANCHOR, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, anchor); -} - -/** - * @ingroup iface_xdg_positioner - * - * Defines in what direction a surface should be positioned, relative to - * the anchor point of the parent surface. If a corner gravity is - * specified (e.g. 'bottom_right' or 'top_left'), then the child surface - * will be placed towards the specified gravity; otherwise, the child - * surface will be centered over the anchor point on any axis that had no - * gravity specified. If the gravity is not in the ‘gravity’ enum, an - * invalid_input error is raised. - */ -static inline void -xdg_positioner_set_gravity(struct xdg_positioner *xdg_positioner, uint32_t gravity) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, - XDG_POSITIONER_SET_GRAVITY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, gravity); -} - -/** - * @ingroup iface_xdg_positioner - * - * Specify how the window should be positioned if the originally intended - * position caused the surface to be constrained, meaning at least - * partially outside positioning boundaries set by the compositor. The - * adjustment is set by constructing a bitmask describing the adjustment to - * be made when the surface is constrained on that axis. - * - * If no bit for one axis is set, the compositor will assume that the child - * surface should not change its position on that axis when constrained. - * - * If more than one bit for one axis is set, the order of how adjustments - * are applied is specified in the corresponding adjustment descriptions. - * - * The default adjustment is none. - */ -static inline void -xdg_positioner_set_constraint_adjustment(struct xdg_positioner *xdg_positioner, uint32_t constraint_adjustment) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, - XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, constraint_adjustment); -} - -/** - * @ingroup iface_xdg_positioner - * - * Specify the surface position offset relative to the position of the - * anchor on the anchor rectangle and the anchor on the surface. For - * example if the anchor of the anchor rectangle is at (x, y), the surface - * has the gravity bottom|right, and the offset is (ox, oy), the calculated - * surface position will be (x + ox, y + oy). The offset position of the - * surface is the one used for constraint testing. See - * set_constraint_adjustment. - * - * An example use case is placing a popup menu on top of a user interface - * element, while aligning the user interface element of the parent surface - * with some user interface element placed somewhere in the popup surface. - */ -static inline void -xdg_positioner_set_offset(struct xdg_positioner *xdg_positioner, int32_t x, int32_t y) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, - XDG_POSITIONER_SET_OFFSET, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, x, y); -} - -/** - * @ingroup iface_xdg_positioner - * - * When set reactive, the surface is reconstrained if the conditions used - * for constraining changed, e.g. the parent window moved. - * - * If the conditions changed and the popup was reconstrained, an - * xdg_popup.configure event is sent with updated geometry, followed by an - * xdg_surface.configure event. - */ -static inline void -xdg_positioner_set_reactive(struct xdg_positioner *xdg_positioner) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, - XDG_POSITIONER_SET_REACTIVE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0); -} - -/** - * @ingroup iface_xdg_positioner - * - * Set the parent window geometry the compositor should use when - * positioning the popup. The compositor may use this information to - * determine the future state the popup should be constrained using. If - * this doesn't match the dimension of the parent the popup is eventually - * positioned against, the behavior is undefined. - * - * The arguments are given in the surface-local coordinate space. - */ -static inline void -xdg_positioner_set_parent_size(struct xdg_positioner *xdg_positioner, int32_t parent_width, int32_t parent_height) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, - XDG_POSITIONER_SET_PARENT_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, parent_width, parent_height); -} - -/** - * @ingroup iface_xdg_positioner - * - * Set the serial of an xdg_surface.configure event this positioner will be - * used in response to. The compositor may use this information together - * with set_parent_size to determine what future state the popup should be - * constrained using. - */ -static inline void -xdg_positioner_set_parent_configure(struct xdg_positioner *xdg_positioner, uint32_t serial) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, - XDG_POSITIONER_SET_PARENT_CONFIGURE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, serial); -} - -#ifndef XDG_SURFACE_ERROR_ENUM -#define XDG_SURFACE_ERROR_ENUM -enum xdg_surface_error { - /** - * Surface was not fully constructed - */ - XDG_SURFACE_ERROR_NOT_CONSTRUCTED = 1, - /** - * Surface was already constructed - */ - XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED = 2, - /** - * Attaching a buffer to an unconfigured surface - */ - XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER = 3, - /** - * Invalid serial number when acking a configure event - */ - XDG_SURFACE_ERROR_INVALID_SERIAL = 4, - /** - * Width or height was zero or negative - */ - XDG_SURFACE_ERROR_INVALID_SIZE = 5, - /** - * Surface was destroyed before its role object - */ - XDG_SURFACE_ERROR_DEFUNCT_ROLE_OBJECT = 6, -}; -#endif /* XDG_SURFACE_ERROR_ENUM */ - -/** - * @ingroup iface_xdg_surface - * @struct xdg_surface_listener - */ -struct xdg_surface_listener { - /** - * suggest a surface change - * - * The configure event marks the end of a configure sequence. A - * configure sequence is a set of one or more events configuring - * the state of the xdg_surface, including the final - * xdg_surface.configure event. - * - * Where applicable, xdg_surface surface roles will during a - * configure sequence extend this event as a latched state sent as - * events before the xdg_surface.configure event. Such events - * should be considered to make up a set of atomically applied - * configuration states, where the xdg_surface.configure commits - * the accumulated state. - * - * Clients should arrange their surface for the new states, and - * then send an ack_configure request with the serial sent in this - * configure event at some point before committing the new surface. - * - * If the client receives multiple configure events before it can - * respond to one, it is free to discard all but the last event it - * received. - * @param serial serial of the configure event - */ - void (*configure)(void *data, - struct xdg_surface *xdg_surface, - uint32_t serial); -}; - -/** - * @ingroup iface_xdg_surface - */ -static inline int -xdg_surface_add_listener(struct xdg_surface *xdg_surface, - const struct xdg_surface_listener *listener, void *data) -{ - return wl_proxy_add_listener((struct wl_proxy *) xdg_surface, - (void (**)(void)) listener, data); -} - -#define XDG_SURFACE_DESTROY 0 -#define XDG_SURFACE_GET_TOPLEVEL 1 -#define XDG_SURFACE_GET_POPUP 2 -#define XDG_SURFACE_SET_WINDOW_GEOMETRY 3 -#define XDG_SURFACE_ACK_CONFIGURE 4 - -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_CONFIGURE_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_GET_TOPLEVEL_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_GET_POPUP_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_WINDOW_GEOMETRY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_ACK_CONFIGURE_SINCE_VERSION 1 - -/** @ingroup iface_xdg_surface */ -static inline void -xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) xdg_surface, user_data); -} - -/** @ingroup iface_xdg_surface */ -static inline void * -xdg_surface_get_user_data(struct xdg_surface *xdg_surface) -{ - return wl_proxy_get_user_data((struct wl_proxy *) xdg_surface); -} - -static inline uint32_t -xdg_surface_get_version(struct xdg_surface *xdg_surface) -{ - return wl_proxy_get_version((struct wl_proxy *) xdg_surface); -} - -/** - * @ingroup iface_xdg_surface - * - * Destroy the xdg_surface object. An xdg_surface must only be destroyed - * after its role object has been destroyed, otherwise - * a defunct_role_object error is raised. - */ -static inline void -xdg_surface_destroy(struct xdg_surface *xdg_surface) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface, - XDG_SURFACE_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_surface), WL_MARSHAL_FLAG_DESTROY); -} - -/** - * @ingroup iface_xdg_surface - * - * This creates an xdg_toplevel object for the given xdg_surface and gives - * the associated wl_surface the xdg_toplevel role. - * - * See the documentation of xdg_toplevel for more details about what an - * xdg_toplevel is and how it is used. - */ -static inline struct xdg_toplevel * -xdg_surface_get_toplevel(struct xdg_surface *xdg_surface) -{ - struct wl_proxy *id; - - id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface, - XDG_SURFACE_GET_TOPLEVEL, &xdg_toplevel_interface, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, NULL); - - return (struct xdg_toplevel *) id; -} - -/** - * @ingroup iface_xdg_surface - * - * This creates an xdg_popup object for the given xdg_surface and gives - * the associated wl_surface the xdg_popup role. - * - * If null is passed as a parent, a parent surface must be specified using - * some other protocol, before committing the initial state. - * - * See the documentation of xdg_popup for more details about what an - * xdg_popup is and how it is used. - */ -static inline struct xdg_popup * -xdg_surface_get_popup(struct xdg_surface *xdg_surface, struct xdg_surface *parent, struct xdg_positioner *positioner) -{ - struct wl_proxy *id; - - id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface, - XDG_SURFACE_GET_POPUP, &xdg_popup_interface, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, NULL, parent, positioner); - - return (struct xdg_popup *) id; -} - -/** - * @ingroup iface_xdg_surface - * - * The window geometry of a surface is its "visible bounds" from the - * user's perspective. Client-side decorations often have invisible - * portions like drop-shadows which should be ignored for the - * purposes of aligning, placing and constraining windows. - * - * The window geometry is double buffered, and will be applied at the - * time wl_surface.commit of the corresponding wl_surface is called. - * - * When maintaining a position, the compositor should treat the (x, y) - * coordinate of the window geometry as the top left corner of the window. - * A client changing the (x, y) window geometry coordinate should in - * general not alter the position of the window. - * - * Once the window geometry of the surface is set, it is not possible to - * unset it, and it will remain the same until set_window_geometry is - * called again, even if a new subsurface or buffer is attached. - * - * If never set, the value is the full bounds of the surface, - * including any subsurfaces. This updates dynamically on every - * commit. This unset is meant for extremely simple clients. - * - * The arguments are given in the surface-local coordinate space of - * the wl_surface associated with this xdg_surface, and may extend outside - * of the wl_surface itself to mark parts of the subsurface tree as part of - * the window geometry. - * - * When applied, the effective window geometry will be the set window - * geometry clamped to the bounding rectangle of the combined - * geometry of the surface of the xdg_surface and the associated - * subsurfaces. - * - * The effective geometry will not be recalculated unless a new call to - * set_window_geometry is done and the new pending surface state is - * subsequently applied. - * - * The width and height of the effective window geometry must be - * greater than zero. Setting an invalid size will raise an - * invalid_size error. - */ -static inline void -xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface, - XDG_SURFACE_SET_WINDOW_GEOMETRY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, x, y, width, height); -} - -/** - * @ingroup iface_xdg_surface - * - * When a configure event is received, if a client commits the - * surface in response to the configure event, then the client - * must make an ack_configure request sometime before the commit - * request, passing along the serial of the configure event. - * - * For instance, for toplevel surfaces the compositor might use this - * information to move a surface to the top left only when the client has - * drawn itself for the maximized or fullscreen state. - * - * If the client receives multiple configure events before it - * can respond to one, it only has to ack the last configure event. - * Acking a configure event that was never sent raises an invalid_serial - * error. - * - * A client is not required to commit immediately after sending - * an ack_configure request - it may even ack_configure several times - * before its next surface commit. - * - * A client may send multiple ack_configure requests before committing, but - * only the last request sent before a commit indicates which configure - * event the client really is responding to. - * - * Sending an ack_configure request consumes the serial number sent with - * the request, as well as serial numbers sent by all configure events - * sent on this xdg_surface prior to the configure event referenced by - * the committed serial. - * - * It is an error to issue multiple ack_configure requests referencing a - * serial from the same configure event, or to issue an ack_configure - * request referencing a serial from a configure event issued before the - * event identified by the last ack_configure request for the same - * xdg_surface. Doing so will raise an invalid_serial error. - */ -static inline void -xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface, - XDG_SURFACE_ACK_CONFIGURE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, serial); -} - -#ifndef XDG_TOPLEVEL_ERROR_ENUM -#define XDG_TOPLEVEL_ERROR_ENUM -enum xdg_toplevel_error { - /** - * provided value is not a valid variant of the resize_edge enum - */ - XDG_TOPLEVEL_ERROR_INVALID_RESIZE_EDGE = 0, - /** - * invalid parent toplevel - */ - XDG_TOPLEVEL_ERROR_INVALID_PARENT = 1, - /** - * client provided an invalid min or max size - */ - XDG_TOPLEVEL_ERROR_INVALID_SIZE = 2, -}; -#endif /* XDG_TOPLEVEL_ERROR_ENUM */ - -#ifndef XDG_TOPLEVEL_RESIZE_EDGE_ENUM -#define XDG_TOPLEVEL_RESIZE_EDGE_ENUM -/** - * @ingroup iface_xdg_toplevel - * edge values for resizing - * - * These values are used to indicate which edge of a surface - * is being dragged in a resize operation. - */ -enum xdg_toplevel_resize_edge { - XDG_TOPLEVEL_RESIZE_EDGE_NONE = 0, - XDG_TOPLEVEL_RESIZE_EDGE_TOP = 1, - XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM = 2, - XDG_TOPLEVEL_RESIZE_EDGE_LEFT = 4, - XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT = 5, - XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT = 6, - XDG_TOPLEVEL_RESIZE_EDGE_RIGHT = 8, - XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT = 9, - XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT = 10, -}; -#endif /* XDG_TOPLEVEL_RESIZE_EDGE_ENUM */ - -#ifndef XDG_TOPLEVEL_STATE_ENUM -#define XDG_TOPLEVEL_STATE_ENUM -/** - * @ingroup iface_xdg_toplevel - * types of state on the surface - * - * The different state values used on the surface. This is designed for - * state values like maximized, fullscreen. It is paired with the - * configure event to ensure that both the client and the compositor - * setting the state can be synchronized. - * - * States set in this way are double-buffered. They will get applied on - * the next commit. - */ -enum xdg_toplevel_state { - /** - * the surface is maximized - * the surface is maximized - * - * The surface is maximized. The window geometry specified in the - * configure event must be obeyed by the client, or the - * xdg_wm_base.invalid_surface_state error is raised. - * - * The client should draw without shadow or other decoration - * outside of the window geometry. - */ - XDG_TOPLEVEL_STATE_MAXIMIZED = 1, - /** - * the surface is fullscreen - * the surface is fullscreen - * - * The surface is fullscreen. The window geometry specified in - * the configure event is a maximum; the client cannot resize - * beyond it. For a surface to cover the whole fullscreened area, - * the geometry dimensions must be obeyed by the client. For more - * details, see xdg_toplevel.set_fullscreen. - */ - XDG_TOPLEVEL_STATE_FULLSCREEN = 2, - /** - * the surface is being resized - * the surface is being resized - * - * The surface is being resized. The window geometry specified in - * the configure event is a maximum; the client cannot resize - * beyond it. Clients that have aspect ratio or cell sizing - * configuration can use a smaller size, however. - */ - XDG_TOPLEVEL_STATE_RESIZING = 3, - /** - * the surface is now activated - * the surface is now activated - * - * Client window decorations should be painted as if the window - * is active. Do not assume this means that the window actually has - * keyboard or pointer focus. - */ - XDG_TOPLEVEL_STATE_ACTIVATED = 4, - /** - * the surface’s left edge is tiled - * - * The window is currently in a tiled layout and the left edge is - * considered to be adjacent to another part of the tiling grid. - * @since 2 - */ - XDG_TOPLEVEL_STATE_TILED_LEFT = 5, - /** - * the surface’s right edge is tiled - * - * The window is currently in a tiled layout and the right edge - * is considered to be adjacent to another part of the tiling grid. - * @since 2 - */ - XDG_TOPLEVEL_STATE_TILED_RIGHT = 6, - /** - * the surface’s top edge is tiled - * - * The window is currently in a tiled layout and the top edge is - * considered to be adjacent to another part of the tiling grid. - * @since 2 - */ - XDG_TOPLEVEL_STATE_TILED_TOP = 7, - /** - * the surface’s bottom edge is tiled - * - * The window is currently in a tiled layout and the bottom edge - * is considered to be adjacent to another part of the tiling grid. - * @since 2 - */ - XDG_TOPLEVEL_STATE_TILED_BOTTOM = 8, - /** - * surface repaint is suspended - * - * The surface is currently not ordinarily being repainted; for - * example because its content is occluded by another window, or - * its outputs are switched off due to screen locking. - * @since 6 - */ - XDG_TOPLEVEL_STATE_SUSPENDED = 9, -}; -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION 2 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION 2 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_STATE_TILED_TOP_SINCE_VERSION 2 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_STATE_TILED_BOTTOM_SINCE_VERSION 2 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_STATE_SUSPENDED_SINCE_VERSION 6 -#endif /* XDG_TOPLEVEL_STATE_ENUM */ - -#ifndef XDG_TOPLEVEL_WM_CAPABILITIES_ENUM -#define XDG_TOPLEVEL_WM_CAPABILITIES_ENUM -enum xdg_toplevel_wm_capabilities { - /** - * show_window_menu is available - */ - XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU = 1, - /** - * set_maximized and unset_maximized are available - */ - XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE = 2, - /** - * set_fullscreen and unset_fullscreen are available - */ - XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN = 3, - /** - * set_minimized is available - */ - XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE = 4, -}; -#endif /* XDG_TOPLEVEL_WM_CAPABILITIES_ENUM */ - -/** - * @ingroup iface_xdg_toplevel - * @struct xdg_toplevel_listener - */ -struct xdg_toplevel_listener { - /** - * suggest a surface change - * - * This configure event asks the client to resize its toplevel - * surface or to change its state. The configured state should not - * be applied immediately. See xdg_surface.configure for details. - * - * The width and height arguments specify a hint to the window - * about how its surface should be resized in window geometry - * coordinates. See set_window_geometry. - * - * If the width or height arguments are zero, it means the client - * should decide its own window dimension. This may happen when the - * compositor needs to configure the state of the surface but - * doesn't have any information about any previous or expected - * dimension. - * - * The states listed in the event specify how the width/height - * arguments should be interpreted, and possibly how it should be - * drawn. - * - * Clients must send an ack_configure in response to this event. - * See xdg_surface.configure and xdg_surface.ack_configure for - * details. - */ - void (*configure)(void *data, - struct xdg_toplevel *xdg_toplevel, - int32_t width, - int32_t height, - struct wl_array *states); - /** - * surface wants to be closed - * - * The close event is sent by the compositor when the user wants - * the surface to be closed. This should be equivalent to the user - * clicking the close button in client-side decorations, if your - * application has any. - * - * This is only a request that the user intends to close the - * window. The client may choose to ignore this request, or show a - * dialog to ask the user to save their data, etc. - */ - void (*close)(void *data, - struct xdg_toplevel *xdg_toplevel); - /** - * recommended window geometry bounds - * - * The configure_bounds event may be sent prior to a - * xdg_toplevel.configure event to communicate the bounds a window - * geometry size is recommended to constrain to. - * - * The passed width and height are in surface coordinate space. If - * width and height are 0, it means bounds is unknown and - * equivalent to as if no configure_bounds event was ever sent for - * this surface. - * - * The bounds can for example correspond to the size of a monitor - * excluding any panels or other shell components, so that a - * surface isn't created in a way that it cannot fit. - * - * The bounds may change at any point, and in such a case, a new - * xdg_toplevel.configure_bounds will be sent, followed by - * xdg_toplevel.configure and xdg_surface.configure. - * @since 4 - */ - void (*configure_bounds)(void *data, - struct xdg_toplevel *xdg_toplevel, - int32_t width, - int32_t height); - /** - * compositor capabilities - * - * This event advertises the capabilities supported by the - * compositor. If a capability isn't supported, clients should hide - * or disable the UI elements that expose this functionality. For - * instance, if the compositor doesn't advertise support for - * minimized toplevels, a button triggering the set_minimized - * request should not be displayed. - * - * The compositor will ignore requests it doesn't support. For - * instance, a compositor which doesn't advertise support for - * minimized will ignore set_minimized requests. - * - * Compositors must send this event once before the first - * xdg_surface.configure event. When the capabilities change, - * compositors must send this event again and then send an - * xdg_surface.configure event. - * - * The configured state should not be applied immediately. See - * xdg_surface.configure for details. - * - * The capabilities are sent as an array of 32-bit unsigned - * integers in native endianness. - * @param capabilities array of 32-bit capabilities - * @since 5 - */ - void (*wm_capabilities)(void *data, - struct xdg_toplevel *xdg_toplevel, - struct wl_array *capabilities); -}; - -/** - * @ingroup iface_xdg_toplevel - */ -static inline int -xdg_toplevel_add_listener(struct xdg_toplevel *xdg_toplevel, - const struct xdg_toplevel_listener *listener, void *data) -{ - return wl_proxy_add_listener((struct wl_proxy *) xdg_toplevel, - (void (**)(void)) listener, data); -} - -#define XDG_TOPLEVEL_DESTROY 0 -#define XDG_TOPLEVEL_SET_PARENT 1 -#define XDG_TOPLEVEL_SET_TITLE 2 -#define XDG_TOPLEVEL_SET_APP_ID 3 -#define XDG_TOPLEVEL_SHOW_WINDOW_MENU 4 -#define XDG_TOPLEVEL_MOVE 5 -#define XDG_TOPLEVEL_RESIZE 6 -#define XDG_TOPLEVEL_SET_MAX_SIZE 7 -#define XDG_TOPLEVEL_SET_MIN_SIZE 8 -#define XDG_TOPLEVEL_SET_MAXIMIZED 9 -#define XDG_TOPLEVEL_UNSET_MAXIMIZED 10 -#define XDG_TOPLEVEL_SET_FULLSCREEN 11 -#define XDG_TOPLEVEL_UNSET_FULLSCREEN 12 -#define XDG_TOPLEVEL_SET_MINIMIZED 13 - -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_CONFIGURE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_CLOSE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION 4 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION 5 - -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_PARENT_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_TITLE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_APP_ID_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SHOW_WINDOW_MENU_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_MOVE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_RESIZE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_MAX_SIZE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_MIN_SIZE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_MAXIMIZED_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_UNSET_MAXIMIZED_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_FULLSCREEN_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_UNSET_FULLSCREEN_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_MINIMIZED_SINCE_VERSION 1 - -/** @ingroup iface_xdg_toplevel */ -static inline void -xdg_toplevel_set_user_data(struct xdg_toplevel *xdg_toplevel, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) xdg_toplevel, user_data); -} - -/** @ingroup iface_xdg_toplevel */ -static inline void * -xdg_toplevel_get_user_data(struct xdg_toplevel *xdg_toplevel) -{ - return wl_proxy_get_user_data((struct wl_proxy *) xdg_toplevel); -} - -static inline uint32_t -xdg_toplevel_get_version(struct xdg_toplevel *xdg_toplevel) -{ - return wl_proxy_get_version((struct wl_proxy *) xdg_toplevel); -} - -/** - * @ingroup iface_xdg_toplevel - * - * This request destroys the role surface and unmaps the surface; - * see "Unmapping" behavior in interface section for details. - */ -static inline void -xdg_toplevel_destroy(struct xdg_toplevel *xdg_toplevel) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), WL_MARSHAL_FLAG_DESTROY); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Set the "parent" of this surface. This surface should be stacked - * above the parent surface and all other ancestor surfaces. - * - * Parent surfaces should be set on dialogs, toolboxes, or other - * "auxiliary" surfaces, so that the parent is raised when the dialog - * is raised. - * - * Setting a null parent for a child surface unsets its parent. Setting - * a null parent for a surface which currently has no parent is a no-op. - * - * Only mapped surfaces can have child surfaces. Setting a parent which - * is not mapped is equivalent to setting a null parent. If a surface - * becomes unmapped, its children's parent is set to the parent of - * the now-unmapped surface. If the now-unmapped surface has no parent, - * its children's parent is unset. If the now-unmapped surface becomes - * mapped again, its parent-child relationship is not restored. - * - * The parent toplevel must not be one of the child toplevel's - * descendants, and the parent must be different from the child toplevel, - * otherwise the invalid_parent protocol error is raised. - */ -static inline void -xdg_toplevel_set_parent(struct xdg_toplevel *xdg_toplevel, struct xdg_toplevel *parent) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_SET_PARENT, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, parent); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Set a short title for the surface. - * - * This string may be used to identify the surface in a task bar, - * window list, or other user interface elements provided by the - * compositor. - * - * The string must be encoded in UTF-8. - */ -static inline void -xdg_toplevel_set_title(struct xdg_toplevel *xdg_toplevel, const char *title) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_SET_TITLE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, title); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Set an application identifier for the surface. - * - * The app ID identifies the general class of applications to which - * the surface belongs. The compositor can use this to group multiple - * surfaces together, or to determine how to launch a new application. - * - * For D-Bus activatable applications, the app ID is used as the D-Bus - * service name. - * - * The compositor shell will try to group application surfaces together - * by their app ID. As a best practice, it is suggested to select app - * ID's that match the basename of the application's .desktop file. - * For example, "org.freedesktop.FooViewer" where the .desktop file is - * "org.freedesktop.FooViewer.desktop". - * - * Like other properties, a set_app_id request can be sent after the - * xdg_toplevel has been mapped to update the property. - * - * See the desktop-entry specification [0] for more details on - * application identifiers and how they relate to well-known D-Bus - * names and .desktop files. - * - * [0] https://standards.freedesktop.org/desktop-entry-spec/ - */ -static inline void -xdg_toplevel_set_app_id(struct xdg_toplevel *xdg_toplevel, const char *app_id) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_SET_APP_ID, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, app_id); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Clients implementing client-side decorations might want to show - * a context menu when right-clicking on the decorations, giving the - * user a menu that they can use to maximize or minimize the window. - * - * This request asks the compositor to pop up such a window menu at - * the given position, relative to the local surface coordinates of - * the parent surface. There are no guarantees as to what menu items - * the window menu contains, or even if a window menu will be drawn - * at all. - * - * This request must be used in response to some sort of user action - * like a button press, key press, or touch down event. - */ -static inline void -xdg_toplevel_show_window_menu(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_SHOW_WINDOW_MENU, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, seat, serial, x, y); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Start an interactive, user-driven move of the surface. - * - * This request must be used in response to some sort of user action - * like a button press, key press, or touch down event. The passed - * serial is used to determine the type of interactive move (touch, - * pointer, etc). - * - * The server may ignore move requests depending on the state of - * the surface (e.g. fullscreen or maximized), or if the passed serial - * is no longer valid. - * - * If triggered, the surface will lose the focus of the device - * (wl_pointer, wl_touch, etc) used for the move. It is up to the - * compositor to visually indicate that the move is taking place, such as - * updating a pointer cursor, during the move. There is no guarantee - * that the device focus will return when the move is completed. - */ -static inline void -xdg_toplevel_move(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_MOVE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, seat, serial); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Start a user-driven, interactive resize of the surface. - * - * This request must be used in response to some sort of user action - * like a button press, key press, or touch down event. The passed - * serial is used to determine the type of interactive resize (touch, - * pointer, etc). - * - * The server may ignore resize requests depending on the state of - * the surface (e.g. fullscreen or maximized). - * - * If triggered, the client will receive configure events with the - * "resize" state enum value and the expected sizes. See the "resize" - * enum value for more details about what is required. The client - * must also acknowledge configure events using "ack_configure". After - * the resize is completed, the client will receive another "configure" - * event without the resize state. - * - * If triggered, the surface also will lose the focus of the device - * (wl_pointer, wl_touch, etc) used for the resize. It is up to the - * compositor to visually indicate that the resize is taking place, - * such as updating a pointer cursor, during the resize. There is no - * guarantee that the device focus will return when the resize is - * completed. - * - * The edges parameter specifies how the surface should be resized, and - * is one of the values of the resize_edge enum. Values not matching - * a variant of the enum will cause the invalid_resize_edge protocol error. - * The compositor may use this information to update the surface position - * for example when dragging the top left corner. The compositor may also - * use this information to adapt its behavior, e.g. choose an appropriate - * cursor image. - */ -static inline void -xdg_toplevel_resize(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial, uint32_t edges) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_RESIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, seat, serial, edges); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Set a maximum size for the window. - * - * The client can specify a maximum size so that the compositor does - * not try to configure the window beyond this size. - * - * The width and height arguments are in window geometry coordinates. - * See xdg_surface.set_window_geometry. - * - * Values set in this way are double-buffered. They will get applied - * on the next commit. - * - * The compositor can use this information to allow or disallow - * different states like maximize or fullscreen and draw accurate - * animations. - * - * Similarly, a tiling window manager may use this information to - * place and resize client windows in a more effective way. - * - * The client should not rely on the compositor to obey the maximum - * size. The compositor may decide to ignore the values set by the - * client and request a larger size. - * - * If never set, or a value of zero in the request, means that the - * client has no expected maximum size in the given dimension. - * As a result, a client wishing to reset the maximum size - * to an unspecified state can use zero for width and height in the - * request. - * - * Requesting a maximum size to be smaller than the minimum size of - * a surface is illegal and will result in an invalid_size error. - * - * The width and height must be greater than or equal to zero. Using - * strictly negative values for width or height will result in a - * invalid_size error. - */ -static inline void -xdg_toplevel_set_max_size(struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_SET_MAX_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, width, height); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Set a minimum size for the window. - * - * The client can specify a minimum size so that the compositor does - * not try to configure the window below this size. - * - * The width and height arguments are in window geometry coordinates. - * See xdg_surface.set_window_geometry. - * - * Values set in this way are double-buffered. They will get applied - * on the next commit. - * - * The compositor can use this information to allow or disallow - * different states like maximize or fullscreen and draw accurate - * animations. - * - * Similarly, a tiling window manager may use this information to - * place and resize client windows in a more effective way. - * - * The client should not rely on the compositor to obey the minimum - * size. The compositor may decide to ignore the values set by the - * client and request a smaller size. - * - * If never set, or a value of zero in the request, means that the - * client has no expected minimum size in the given dimension. - * As a result, a client wishing to reset the minimum size - * to an unspecified state can use zero for width and height in the - * request. - * - * Requesting a minimum size to be larger than the maximum size of - * a surface is illegal and will result in an invalid_size error. - * - * The width and height must be greater than or equal to zero. Using - * strictly negative values for width and height will result in a - * invalid_size error. - */ -static inline void -xdg_toplevel_set_min_size(struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_SET_MIN_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, width, height); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Maximize the surface. - * - * After requesting that the surface should be maximized, the compositor - * will respond by emitting a configure event. Whether this configure - * actually sets the window maximized is subject to compositor policies. - * The client must then update its content, drawing in the configured - * state. The client must also acknowledge the configure when committing - * the new content (see ack_configure). - * - * It is up to the compositor to decide how and where to maximize the - * surface, for example which output and what region of the screen should - * be used. - * - * If the surface was already maximized, the compositor will still emit - * a configure event with the "maximized" state. - * - * If the surface is in a fullscreen state, this request has no direct - * effect. It may alter the state the surface is returned to when - * unmaximized unless overridden by the compositor. - */ -static inline void -xdg_toplevel_set_maximized(struct xdg_toplevel *xdg_toplevel) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_SET_MAXIMIZED, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Unmaximize the surface. - * - * After requesting that the surface should be unmaximized, the compositor - * will respond by emitting a configure event. Whether this actually - * un-maximizes the window is subject to compositor policies. - * If available and applicable, the compositor will include the window - * geometry dimensions the window had prior to being maximized in the - * configure event. The client must then update its content, drawing it in - * the configured state. The client must also acknowledge the configure - * when committing the new content (see ack_configure). - * - * It is up to the compositor to position the surface after it was - * unmaximized; usually the position the surface had before maximizing, if - * applicable. - * - * If the surface was already not maximized, the compositor will still - * emit a configure event without the "maximized" state. - * - * If the surface is in a fullscreen state, this request has no direct - * effect. It may alter the state the surface is returned to when - * unmaximized unless overridden by the compositor. - */ -static inline void -xdg_toplevel_unset_maximized(struct xdg_toplevel *xdg_toplevel) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_UNSET_MAXIMIZED, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Make the surface fullscreen. - * - * After requesting that the surface should be fullscreened, the - * compositor will respond by emitting a configure event. Whether the - * client is actually put into a fullscreen state is subject to compositor - * policies. The client must also acknowledge the configure when - * committing the new content (see ack_configure). - * - * The output passed by the request indicates the client's preference as - * to which display it should be set fullscreen on. If this value is NULL, - * it's up to the compositor to choose which display will be used to map - * this surface. - * - * If the surface doesn't cover the whole output, the compositor will - * position the surface in the center of the output and compensate with - * with border fill covering the rest of the output. The content of the - * border fill is undefined, but should be assumed to be in some way that - * attempts to blend into the surrounding area (e.g. solid black). - * - * If the fullscreened surface is not opaque, the compositor must make - * sure that other screen content not part of the same surface tree (made - * up of subsurfaces, popups or similarly coupled surfaces) are not - * visible below the fullscreened surface. - */ -static inline void -xdg_toplevel_set_fullscreen(struct xdg_toplevel *xdg_toplevel, struct wl_output *output) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_SET_FULLSCREEN, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, output); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Make the surface no longer fullscreen. - * - * After requesting that the surface should be unfullscreened, the - * compositor will respond by emitting a configure event. - * Whether this actually removes the fullscreen state of the client is - * subject to compositor policies. - * - * Making a surface unfullscreen sets states for the surface based on the following: - * * the state(s) it may have had before becoming fullscreen - * * any state(s) decided by the compositor - * * any state(s) requested by the client while the surface was fullscreen - * - * The compositor may include the previous window geometry dimensions in - * the configure event, if applicable. - * - * The client must also acknowledge the configure when committing the new - * content (see ack_configure). - */ -static inline void -xdg_toplevel_unset_fullscreen(struct xdg_toplevel *xdg_toplevel) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_UNSET_FULLSCREEN, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0); -} - -/** - * @ingroup iface_xdg_toplevel - * - * Request that the compositor minimize your surface. There is no - * way to know if the surface is currently minimized, nor is there - * any way to unset minimization on this surface. - * - * If you are looking to throttle redrawing when minimized, please - * instead use the wl_surface.frame event for this, as this will - * also work with live previews on windows in Alt-Tab, Expose or - * similar compositor features. - */ -static inline void -xdg_toplevel_set_minimized(struct xdg_toplevel *xdg_toplevel) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, - XDG_TOPLEVEL_SET_MINIMIZED, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0); -} - -#ifndef XDG_POPUP_ERROR_ENUM -#define XDG_POPUP_ERROR_ENUM -enum xdg_popup_error { - /** - * tried to grab after being mapped - */ - XDG_POPUP_ERROR_INVALID_GRAB = 0, -}; -#endif /* XDG_POPUP_ERROR_ENUM */ - -/** - * @ingroup iface_xdg_popup - * @struct xdg_popup_listener - */ -struct xdg_popup_listener { - /** - * configure the popup surface - * - * This event asks the popup surface to configure itself given - * the configuration. The configured state should not be applied - * immediately. See xdg_surface.configure for details. - * - * The x and y arguments represent the position the popup was - * placed at given the xdg_positioner rule, relative to the upper - * left corner of the window geometry of the parent surface. - * - * For version 2 or older, the configure event for an xdg_popup is - * only ever sent once for the initial configuration. Starting with - * version 3, it may be sent again if the popup is setup with an - * xdg_positioner with set_reactive requested, or in response to - * xdg_popup.reposition requests. - * @param x x position relative to parent surface window geometry - * @param y y position relative to parent surface window geometry - * @param width window geometry width - * @param height window geometry height - */ - void (*configure)(void *data, - struct xdg_popup *xdg_popup, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - /** - * popup interaction is done - * - * The popup_done event is sent out when a popup is dismissed by - * the compositor. The client should destroy the xdg_popup object - * at this point. - */ - void (*popup_done)(void *data, - struct xdg_popup *xdg_popup); - /** - * signal the completion of a repositioned request - * - * The repositioned event is sent as part of a popup - * configuration sequence, together with xdg_popup.configure and - * lastly xdg_surface.configure to notify the completion of a - * reposition request. - * - * The repositioned event is to notify about the completion of a - * xdg_popup.reposition request. The token argument is the token - * passed in the xdg_popup.reposition request. - * - * Immediately after this event is emitted, xdg_popup.configure and - * xdg_surface.configure will be sent with the updated size and - * position, as well as a new configure serial. - * - * The client should optionally update the content of the popup, - * but must acknowledge the new popup configuration for the new - * position to take effect. See xdg_surface.ack_configure for - * details. - * @param token reposition request token - * @since 3 - */ - void (*repositioned)(void *data, - struct xdg_popup *xdg_popup, - uint32_t token); -}; - -/** - * @ingroup iface_xdg_popup - */ -static inline int -xdg_popup_add_listener(struct xdg_popup *xdg_popup, - const struct xdg_popup_listener *listener, void *data) -{ - return wl_proxy_add_listener((struct wl_proxy *) xdg_popup, - (void (**)(void)) listener, data); -} - -#define XDG_POPUP_DESTROY 0 -#define XDG_POPUP_GRAB 1 -#define XDG_POPUP_REPOSITION 2 - -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_CONFIGURE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_POPUP_DONE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_REPOSITIONED_SINCE_VERSION 3 - -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_GRAB_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_REPOSITION_SINCE_VERSION 3 - -/** @ingroup iface_xdg_popup */ -static inline void -xdg_popup_set_user_data(struct xdg_popup *xdg_popup, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) xdg_popup, user_data); -} - -/** @ingroup iface_xdg_popup */ -static inline void * -xdg_popup_get_user_data(struct xdg_popup *xdg_popup) -{ - return wl_proxy_get_user_data((struct wl_proxy *) xdg_popup); -} - -static inline uint32_t -xdg_popup_get_version(struct xdg_popup *xdg_popup) -{ - return wl_proxy_get_version((struct wl_proxy *) xdg_popup); -} - -/** - * @ingroup iface_xdg_popup - * - * This destroys the popup. Explicitly destroying the xdg_popup - * object will also dismiss the popup, and unmap the surface. - * - * If this xdg_popup is not the "topmost" popup, the - * xdg_wm_base.not_the_topmost_popup protocol error will be sent. - */ -static inline void -xdg_popup_destroy(struct xdg_popup *xdg_popup) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_popup, - XDG_POPUP_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_popup), WL_MARSHAL_FLAG_DESTROY); -} - -/** - * @ingroup iface_xdg_popup - * - * This request makes the created popup take an explicit grab. An explicit - * grab will be dismissed when the user dismisses the popup, or when the - * client destroys the xdg_popup. This can be done by the user clicking - * outside the surface, using the keyboard, or even locking the screen - * through closing the lid or a timeout. - * - * If the compositor denies the grab, the popup will be immediately - * dismissed. - * - * This request must be used in response to some sort of user action like a - * button press, key press, or touch down event. The serial number of the - * event should be passed as 'serial'. - * - * The parent of a grabbing popup must either be an xdg_toplevel surface or - * another xdg_popup with an explicit grab. If the parent is another - * xdg_popup it means that the popups are nested, with this popup now being - * the topmost popup. - * - * Nested popups must be destroyed in the reverse order they were created - * in, e.g. the only popup you are allowed to destroy at all times is the - * topmost one. - * - * When compositors choose to dismiss a popup, they may dismiss every - * nested grabbing popup as well. When a compositor dismisses popups, it - * will follow the same dismissing order as required from the client. - * - * If the topmost grabbing popup is destroyed, the grab will be returned to - * the parent of the popup, if that parent previously had an explicit grab. - * - * If the parent is a grabbing popup which has already been dismissed, this - * popup will be immediately dismissed. If the parent is a popup that did - * not take an explicit grab, an error will be raised. - * - * During a popup grab, the client owning the grab will receive pointer - * and touch events for all their surfaces as normal (similar to an - * "owner-events" grab in X11 parlance), while the top most grabbing popup - * will always have keyboard focus. - */ -static inline void -xdg_popup_grab(struct xdg_popup *xdg_popup, struct wl_seat *seat, uint32_t serial) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_popup, - XDG_POPUP_GRAB, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_popup), 0, seat, serial); -} - -/** - * @ingroup iface_xdg_popup - * - * Reposition an already-mapped popup. The popup will be placed given the - * details in the passed xdg_positioner object, and a - * xdg_popup.repositioned followed by xdg_popup.configure and - * xdg_surface.configure will be emitted in response. Any parameters set - * by the previous positioner will be discarded. - * - * The passed token will be sent in the corresponding - * xdg_popup.repositioned event. The new popup position will not take - * effect until the corresponding configure event is acknowledged by the - * client. See xdg_popup.repositioned for details. The token itself is - * opaque, and has no other special meaning. - * - * If multiple reposition requests are sent, the compositor may skip all - * but the last one. - * - * If the popup is repositioned in response to a configure event for its - * parent, the client should send an xdg_positioner.set_parent_configure - * and possibly an xdg_positioner.set_parent_size request to allow the - * compositor to properly constrain the popup. - * - * If the popup is repositioned together with a parent that is being - * resized, but not in response to a configure event, the client should - * send an xdg_positioner.set_parent_size request. - */ -static inline void -xdg_popup_reposition(struct xdg_popup *xdg_popup, struct xdg_positioner *positioner, uint32_t token) -{ - wl_proxy_marshal_flags((struct wl_proxy *) xdg_popup, - XDG_POPUP_REPOSITION, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_popup), 0, positioner, token); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/wayland_adapter/wayland_protocols/stable/xdg-shell/xdg-shell-protocol.c b/wayland_adapter/wayland_protocols/stable/xdg-shell/xdg-shell-protocol.c deleted file mode 100644 index da289269daf9c0c6b824a447e0d859a4553246cf..0000000000000000000000000000000000000000 --- a/wayland_adapter/wayland_protocols/stable/xdg-shell/xdg-shell-protocol.c +++ /dev/null @@ -1,183 +0,0 @@ -/* Generated by wayland-scanner 1.20.0 */ - -/* - * Copyright © 2008-2013 Kristian Høgsberg - * Copyright © 2013 Rafael Antognolli - * Copyright © 2013 Jasper St. Pierre - * Copyright © 2010-2013 Intel Corporation - * Copyright © 2015-2017 Samsung Electronics Co., Ltd - * Copyright © 2015-2017 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include "wayland-util.h" - -#ifndef __has_attribute -# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ -#endif - -#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) -#define WL_PRIVATE __attribute__ ((visibility("hidden"))) -#else -#define WL_PRIVATE -#endif - -extern const struct wl_interface wl_output_interface; -extern const struct wl_interface wl_seat_interface; -extern const struct wl_interface wl_surface_interface; -extern const struct wl_interface xdg_popup_interface; -extern const struct wl_interface xdg_positioner_interface; -extern const struct wl_interface xdg_surface_interface; -extern const struct wl_interface xdg_toplevel_interface; - -static const struct wl_interface *xdg_shell_types[] = { - NULL, - NULL, - NULL, - NULL, - &xdg_positioner_interface, - &xdg_surface_interface, - &wl_surface_interface, - &xdg_toplevel_interface, - &xdg_popup_interface, - &xdg_surface_interface, - &xdg_positioner_interface, - &xdg_toplevel_interface, - &wl_seat_interface, - NULL, - NULL, - NULL, - &wl_seat_interface, - NULL, - &wl_seat_interface, - NULL, - NULL, - &wl_output_interface, - &wl_seat_interface, - NULL, - &xdg_positioner_interface, - NULL, -}; - -static const struct wl_message xdg_wm_base_requests[] = { - { "destroy", "", xdg_shell_types + 0 }, - { "create_positioner", "n", xdg_shell_types + 4 }, - { "get_xdg_surface", "no", xdg_shell_types + 5 }, - { "pong", "u", xdg_shell_types + 0 }, -}; - -static const struct wl_message xdg_wm_base_events[] = { - { "ping", "u", xdg_shell_types + 0 }, -}; - -WL_PRIVATE const struct wl_interface xdg_wm_base_interface = { - "xdg_wm_base", 6, - 4, xdg_wm_base_requests, - 1, xdg_wm_base_events, -}; - -static const struct wl_message xdg_positioner_requests[] = { - { "destroy", "", xdg_shell_types + 0 }, - { "set_size", "ii", xdg_shell_types + 0 }, - { "set_anchor_rect", "iiii", xdg_shell_types + 0 }, - { "set_anchor", "u", xdg_shell_types + 0 }, - { "set_gravity", "u", xdg_shell_types + 0 }, - { "set_constraint_adjustment", "u", xdg_shell_types + 0 }, - { "set_offset", "ii", xdg_shell_types + 0 }, - { "set_reactive", "3", xdg_shell_types + 0 }, - { "set_parent_size", "3ii", xdg_shell_types + 0 }, - { "set_parent_configure", "3u", xdg_shell_types + 0 }, -}; - -WL_PRIVATE const struct wl_interface xdg_positioner_interface = { - "xdg_positioner", 6, - 10, xdg_positioner_requests, - 0, NULL, -}; - -static const struct wl_message xdg_surface_requests[] = { - { "destroy", "", xdg_shell_types + 0 }, - { "get_toplevel", "n", xdg_shell_types + 7 }, - { "get_popup", "n?oo", xdg_shell_types + 8 }, - { "set_window_geometry", "iiii", xdg_shell_types + 0 }, - { "ack_configure", "u", xdg_shell_types + 0 }, -}; - -static const struct wl_message xdg_surface_events[] = { - { "configure", "u", xdg_shell_types + 0 }, -}; - -WL_PRIVATE const struct wl_interface xdg_surface_interface = { - "xdg_surface", 6, - 5, xdg_surface_requests, - 1, xdg_surface_events, -}; - -static const struct wl_message xdg_toplevel_requests[] = { - { "destroy", "", xdg_shell_types + 0 }, - { "set_parent", "?o", xdg_shell_types + 11 }, - { "set_title", "s", xdg_shell_types + 0 }, - { "set_app_id", "s", xdg_shell_types + 0 }, - { "show_window_menu", "ouii", xdg_shell_types + 12 }, - { "move", "ou", xdg_shell_types + 16 }, - { "resize", "ouu", xdg_shell_types + 18 }, - { "set_max_size", "ii", xdg_shell_types + 0 }, - { "set_min_size", "ii", xdg_shell_types + 0 }, - { "set_maximized", "", xdg_shell_types + 0 }, - { "unset_maximized", "", xdg_shell_types + 0 }, - { "set_fullscreen", "?o", xdg_shell_types + 21 }, - { "unset_fullscreen", "", xdg_shell_types + 0 }, - { "set_minimized", "", xdg_shell_types + 0 }, -}; - -static const struct wl_message xdg_toplevel_events[] = { - { "configure", "iia", xdg_shell_types + 0 }, - { "close", "", xdg_shell_types + 0 }, - { "configure_bounds", "4ii", xdg_shell_types + 0 }, - { "wm_capabilities", "5a", xdg_shell_types + 0 }, -}; - -WL_PRIVATE const struct wl_interface xdg_toplevel_interface = { - "xdg_toplevel", 6, - 14, xdg_toplevel_requests, - 4, xdg_toplevel_events, -}; - -static const struct wl_message xdg_popup_requests[] = { - { "destroy", "", xdg_shell_types + 0 }, - { "grab", "ou", xdg_shell_types + 22 }, - { "reposition", "3ou", xdg_shell_types + 24 }, -}; - -static const struct wl_message xdg_popup_events[] = { - { "configure", "iiii", xdg_shell_types + 0 }, - { "popup_done", "", xdg_shell_types + 0 }, - { "repositioned", "3u", xdg_shell_types + 0 }, -}; - -WL_PRIVATE const struct wl_interface xdg_popup_interface = { - "xdg_popup", 6, - 3, xdg_popup_requests, - 3, xdg_popup_events, -}; - diff --git a/wayland_adapter/wayland_protocols/stable/xdg-shell/xdg-shell-server-protocol.h b/wayland_adapter/wayland_protocols/stable/xdg-shell/xdg-shell-server-protocol.h deleted file mode 100644 index a388d3df15c471e79b76aea1d04919c1f7714a00..0000000000000000000000000000000000000000 --- a/wayland_adapter/wayland_protocols/stable/xdg-shell/xdg-shell-server-protocol.h +++ /dev/null @@ -1,1961 +0,0 @@ -/* Generated by wayland-scanner 1.20.0 */ - -#ifndef XDG_SHELL_SERVER_PROTOCOL_H -#define XDG_SHELL_SERVER_PROTOCOL_H - -#include -#include -#include "wayland-server.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct wl_client; -struct wl_resource; - -/** - * @page page_xdg_shell The xdg_shell protocol - * @section page_ifaces_xdg_shell Interfaces - * - @subpage page_iface_xdg_wm_base - create desktop-style surfaces - * - @subpage page_iface_xdg_positioner - child surface positioner - * - @subpage page_iface_xdg_surface - desktop user interface surface base interface - * - @subpage page_iface_xdg_toplevel - toplevel surface - * - @subpage page_iface_xdg_popup - short-lived, popup surfaces for menus - * @section page_copyright_xdg_shell Copyright - *
- *
- * Copyright © 2008-2013 Kristian Høgsberg
- * Copyright © 2013      Rafael Antognolli
- * Copyright © 2013      Jasper St. Pierre
- * Copyright © 2010-2013 Intel Corporation
- * Copyright © 2015-2017 Samsung Electronics Co., Ltd
- * Copyright © 2015-2017 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- * 
- */ -struct wl_output; -struct wl_seat; -struct wl_surface; -struct xdg_popup; -struct xdg_positioner; -struct xdg_surface; -struct xdg_toplevel; -struct xdg_wm_base; - -#ifndef XDG_WM_BASE_INTERFACE -#define XDG_WM_BASE_INTERFACE -/** - * @page page_iface_xdg_wm_base xdg_wm_base - * @section page_iface_xdg_wm_base_desc Description - * - * The xdg_wm_base interface is exposed as a global object enabling clients - * to turn their wl_surfaces into windows in a desktop environment. It - * defines the basic functionality needed for clients and the compositor to - * create windows that can be dragged, resized, maximized, etc, as well as - * creating transient windows such as popup menus. - * @section page_iface_xdg_wm_base_api API - * See @ref iface_xdg_wm_base. - */ -/** - * @defgroup iface_xdg_wm_base The xdg_wm_base interface - * - * The xdg_wm_base interface is exposed as a global object enabling clients - * to turn their wl_surfaces into windows in a desktop environment. It - * defines the basic functionality needed for clients and the compositor to - * create windows that can be dragged, resized, maximized, etc, as well as - * creating transient windows such as popup menus. - */ -extern const struct wl_interface xdg_wm_base_interface; -#endif -#ifndef XDG_POSITIONER_INTERFACE -#define XDG_POSITIONER_INTERFACE -/** - * @page page_iface_xdg_positioner xdg_positioner - * @section page_iface_xdg_positioner_desc Description - * - * The xdg_positioner provides a collection of rules for the placement of a - * child surface relative to a parent surface. Rules can be defined to ensure - * the child surface remains within the visible area's borders, and to - * specify how the child surface changes its position, such as sliding along - * an axis, or flipping around a rectangle. These positioner-created rules are - * constrained by the requirement that a child surface must intersect with or - * be at least partially adjacent to its parent surface. - * - * See the various requests for details about possible rules. - * - * At the time of the request, the compositor makes a copy of the rules - * specified by the xdg_positioner. Thus, after the request is complete the - * xdg_positioner object can be destroyed or reused; further changes to the - * object will have no effect on previous usages. - * - * For an xdg_positioner object to be considered complete, it must have a - * non-zero size set by set_size, and a non-zero anchor rectangle set by - * set_anchor_rect. Passing an incomplete xdg_positioner object when - * positioning a surface raises an invalid_positioner error. - * @section page_iface_xdg_positioner_api API - * See @ref iface_xdg_positioner. - */ -/** - * @defgroup iface_xdg_positioner The xdg_positioner interface - * - * The xdg_positioner provides a collection of rules for the placement of a - * child surface relative to a parent surface. Rules can be defined to ensure - * the child surface remains within the visible area's borders, and to - * specify how the child surface changes its position, such as sliding along - * an axis, or flipping around a rectangle. These positioner-created rules are - * constrained by the requirement that a child surface must intersect with or - * be at least partially adjacent to its parent surface. - * - * See the various requests for details about possible rules. - * - * At the time of the request, the compositor makes a copy of the rules - * specified by the xdg_positioner. Thus, after the request is complete the - * xdg_positioner object can be destroyed or reused; further changes to the - * object will have no effect on previous usages. - * - * For an xdg_positioner object to be considered complete, it must have a - * non-zero size set by set_size, and a non-zero anchor rectangle set by - * set_anchor_rect. Passing an incomplete xdg_positioner object when - * positioning a surface raises an invalid_positioner error. - */ -extern const struct wl_interface xdg_positioner_interface; -#endif -#ifndef XDG_SURFACE_INTERFACE -#define XDG_SURFACE_INTERFACE -/** - * @page page_iface_xdg_surface xdg_surface - * @section page_iface_xdg_surface_desc Description - * - * An interface that may be implemented by a wl_surface, for - * implementations that provide a desktop-style user interface. - * - * It provides a base set of functionality required to construct user - * interface elements requiring management by the compositor, such as - * toplevel windows, menus, etc. The types of functionality are split into - * xdg_surface roles. - * - * Creating an xdg_surface does not set the role for a wl_surface. In order - * to map an xdg_surface, the client must create a role-specific object - * using, e.g., get_toplevel, get_popup. The wl_surface for any given - * xdg_surface can have at most one role, and may not be assigned any role - * not based on xdg_surface. - * - * A role must be assigned before any other requests are made to the - * xdg_surface object. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_surface state to take effect. - * - * Creating an xdg_surface from a wl_surface which has a buffer attached or - * committed is a client error, and any attempts by a client to attach or - * manipulate a buffer prior to the first xdg_surface.configure call must - * also be treated as errors. - * - * After creating a role-specific object and setting it up, the client must - * perform an initial commit without any buffer attached. The compositor - * will reply with initial wl_surface state such as - * wl_surface.preferred_buffer_scale followed by an xdg_surface.configure - * event. The client must acknowledge it and is then allowed to attach a - * buffer to map the surface. - * - * Mapping an xdg_surface-based role surface is defined as making it - * possible for the surface to be shown by the compositor. Note that - * a mapped surface is not guaranteed to be visible once it is mapped. - * - * For an xdg_surface to be mapped by the compositor, the following - * conditions must be met: - * (1) the client has assigned an xdg_surface-based role to the surface - * (2) the client has set and committed the xdg_surface state and the - * role-dependent state to the surface - * (3) the client has committed a buffer to the surface - * - * A newly-unmapped surface is considered to have met condition (1) out - * of the 3 required conditions for mapping a surface if its role surface - * has not been destroyed, i.e. the client must perform the initial commit - * again before attaching a buffer. - * @section page_iface_xdg_surface_api API - * See @ref iface_xdg_surface. - */ -/** - * @defgroup iface_xdg_surface The xdg_surface interface - * - * An interface that may be implemented by a wl_surface, for - * implementations that provide a desktop-style user interface. - * - * It provides a base set of functionality required to construct user - * interface elements requiring management by the compositor, such as - * toplevel windows, menus, etc. The types of functionality are split into - * xdg_surface roles. - * - * Creating an xdg_surface does not set the role for a wl_surface. In order - * to map an xdg_surface, the client must create a role-specific object - * using, e.g., get_toplevel, get_popup. The wl_surface for any given - * xdg_surface can have at most one role, and may not be assigned any role - * not based on xdg_surface. - * - * A role must be assigned before any other requests are made to the - * xdg_surface object. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_surface state to take effect. - * - * Creating an xdg_surface from a wl_surface which has a buffer attached or - * committed is a client error, and any attempts by a client to attach or - * manipulate a buffer prior to the first xdg_surface.configure call must - * also be treated as errors. - * - * After creating a role-specific object and setting it up, the client must - * perform an initial commit without any buffer attached. The compositor - * will reply with initial wl_surface state such as - * wl_surface.preferred_buffer_scale followed by an xdg_surface.configure - * event. The client must acknowledge it and is then allowed to attach a - * buffer to map the surface. - * - * Mapping an xdg_surface-based role surface is defined as making it - * possible for the surface to be shown by the compositor. Note that - * a mapped surface is not guaranteed to be visible once it is mapped. - * - * For an xdg_surface to be mapped by the compositor, the following - * conditions must be met: - * (1) the client has assigned an xdg_surface-based role to the surface - * (2) the client has set and committed the xdg_surface state and the - * role-dependent state to the surface - * (3) the client has committed a buffer to the surface - * - * A newly-unmapped surface is considered to have met condition (1) out - * of the 3 required conditions for mapping a surface if its role surface - * has not been destroyed, i.e. the client must perform the initial commit - * again before attaching a buffer. - */ -extern const struct wl_interface xdg_surface_interface; -#endif -#ifndef XDG_TOPLEVEL_INTERFACE -#define XDG_TOPLEVEL_INTERFACE -/** - * @page page_iface_xdg_toplevel xdg_toplevel - * @section page_iface_xdg_toplevel_desc Description - * - * This interface defines an xdg_surface role which allows a surface to, - * among other things, set window-like properties such as maximize, - * fullscreen, and minimize, set application-specific metadata like title and - * id, and well as trigger user interactive operations such as interactive - * resize and move. - * - * Unmapping an xdg_toplevel means that the surface cannot be shown - * by the compositor until it is explicitly mapped again. - * All active operations (e.g., move, resize) are canceled and all - * attributes (e.g. title, state, stacking, ...) are discarded for - * an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to - * the state it had right after xdg_surface.get_toplevel. The client - * can re-map the toplevel by perfoming a commit without any buffer - * attached, waiting for a configure event and handling it as usual (see - * xdg_surface description). - * - * Attaching a null buffer to a toplevel unmaps the surface. - * @section page_iface_xdg_toplevel_api API - * See @ref iface_xdg_toplevel. - */ -/** - * @defgroup iface_xdg_toplevel The xdg_toplevel interface - * - * This interface defines an xdg_surface role which allows a surface to, - * among other things, set window-like properties such as maximize, - * fullscreen, and minimize, set application-specific metadata like title and - * id, and well as trigger user interactive operations such as interactive - * resize and move. - * - * Unmapping an xdg_toplevel means that the surface cannot be shown - * by the compositor until it is explicitly mapped again. - * All active operations (e.g., move, resize) are canceled and all - * attributes (e.g. title, state, stacking, ...) are discarded for - * an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to - * the state it had right after xdg_surface.get_toplevel. The client - * can re-map the toplevel by perfoming a commit without any buffer - * attached, waiting for a configure event and handling it as usual (see - * xdg_surface description). - * - * Attaching a null buffer to a toplevel unmaps the surface. - */ -extern const struct wl_interface xdg_toplevel_interface; -#endif -#ifndef XDG_POPUP_INTERFACE -#define XDG_POPUP_INTERFACE -/** - * @page page_iface_xdg_popup xdg_popup - * @section page_iface_xdg_popup_desc Description - * - * A popup surface is a short-lived, temporary surface. It can be used to - * implement for example menus, popovers, tooltips and other similar user - * interface concepts. - * - * A popup can be made to take an explicit grab. See xdg_popup.grab for - * details. - * - * When the popup is dismissed, a popup_done event will be sent out, and at - * the same time the surface will be unmapped. See the xdg_popup.popup_done - * event for details. - * - * Explicitly destroying the xdg_popup object will also dismiss the popup and - * unmap the surface. Clients that want to dismiss the popup when another - * surface of their own is clicked should dismiss the popup using the destroy - * request. - * - * A newly created xdg_popup will be stacked on top of all previously created - * xdg_popup surfaces associated with the same xdg_toplevel. - * - * The parent of an xdg_popup must be mapped (see the xdg_surface - * description) before the xdg_popup itself. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_popup state to take effect. - * @section page_iface_xdg_popup_api API - * See @ref iface_xdg_popup. - */ -/** - * @defgroup iface_xdg_popup The xdg_popup interface - * - * A popup surface is a short-lived, temporary surface. It can be used to - * implement for example menus, popovers, tooltips and other similar user - * interface concepts. - * - * A popup can be made to take an explicit grab. See xdg_popup.grab for - * details. - * - * When the popup is dismissed, a popup_done event will be sent out, and at - * the same time the surface will be unmapped. See the xdg_popup.popup_done - * event for details. - * - * Explicitly destroying the xdg_popup object will also dismiss the popup and - * unmap the surface. Clients that want to dismiss the popup when another - * surface of their own is clicked should dismiss the popup using the destroy - * request. - * - * A newly created xdg_popup will be stacked on top of all previously created - * xdg_popup surfaces associated with the same xdg_toplevel. - * - * The parent of an xdg_popup must be mapped (see the xdg_surface - * description) before the xdg_popup itself. - * - * The client must call wl_surface.commit on the corresponding wl_surface - * for the xdg_popup state to take effect. - */ -extern const struct wl_interface xdg_popup_interface; -#endif - -#ifndef XDG_WM_BASE_ERROR_ENUM -#define XDG_WM_BASE_ERROR_ENUM -enum xdg_wm_base_error { - /** - * given wl_surface has another role - */ - XDG_WM_BASE_ERROR_ROLE = 0, - /** - * xdg_wm_base was destroyed before children - */ - XDG_WM_BASE_ERROR_DEFUNCT_SURFACES = 1, - /** - * the client tried to map or destroy a non-topmost popup - */ - XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP = 2, - /** - * the client specified an invalid popup parent surface - */ - XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT = 3, - /** - * the client provided an invalid surface state - */ - XDG_WM_BASE_ERROR_INVALID_SURFACE_STATE = 4, - /** - * the client provided an invalid positioner - */ - XDG_WM_BASE_ERROR_INVALID_POSITIONER = 5, - /** - * the client didn’t respond to a ping event in time - */ - XDG_WM_BASE_ERROR_UNRESPONSIVE = 6, -}; -#endif /* XDG_WM_BASE_ERROR_ENUM */ - -/** - * @ingroup iface_xdg_wm_base - * @struct xdg_wm_base_interface - */ -struct xdg_wm_base_interface { - /** - * destroy xdg_wm_base - * - * Destroy this xdg_wm_base object. - * - * Destroying a bound xdg_wm_base object while there are surfaces - * still alive created by this xdg_wm_base object instance is - * illegal and will result in a defunct_surfaces error. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); - /** - * create a positioner object - * - * Create a positioner object. A positioner object is used to - * position surfaces relative to some parent surface. See the - * interface description and xdg_surface.get_popup for details. - */ - void (*create_positioner)(struct wl_client *client, - struct wl_resource *resource, - uint32_t id); - /** - * create a shell surface from a surface - * - * This creates an xdg_surface for the given surface. While - * xdg_surface itself is not a role, the corresponding surface may - * only be assigned a role extending xdg_surface, such as - * xdg_toplevel or xdg_popup. It is illegal to create an - * xdg_surface for a wl_surface which already has an assigned role - * and this will result in a role error. - * - * This creates an xdg_surface for the given surface. An - * xdg_surface is used as basis to define a role to a given - * surface, such as xdg_toplevel or xdg_popup. It also manages - * functionality shared between xdg_surface based surface roles. - * - * See the documentation of xdg_surface for more details about what - * an xdg_surface is and how it is used. - */ - void (*get_xdg_surface)(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface); - /** - * respond to a ping event - * - * A client must respond to a ping event with a pong request or - * the client may be deemed unresponsive. See xdg_wm_base.ping and - * xdg_wm_base.error.unresponsive. - * @param serial serial of the ping event - */ - void (*pong)(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial); -}; - -#define XDG_WM_BASE_PING 0 - -/** - * @ingroup iface_xdg_wm_base - */ -#define XDG_WM_BASE_PING_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_wm_base - */ -#define XDG_WM_BASE_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_wm_base - */ -#define XDG_WM_BASE_CREATE_POSITIONER_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_wm_base - */ -#define XDG_WM_BASE_GET_XDG_SURFACE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_wm_base - */ -#define XDG_WM_BASE_PONG_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_wm_base - * Sends an ping event to the client owning the resource. - * @param resource_ The client's resource - * @param serial pass this to the pong request - */ -static inline void -xdg_wm_base_send_ping(struct wl_resource *resource_, uint32_t serial) -{ - wl_resource_post_event(resource_, XDG_WM_BASE_PING, serial); -} - -#ifndef XDG_POSITIONER_ERROR_ENUM -#define XDG_POSITIONER_ERROR_ENUM -enum xdg_positioner_error { - /** - * invalid input provided - */ - XDG_POSITIONER_ERROR_INVALID_INPUT = 0, -}; -#endif /* XDG_POSITIONER_ERROR_ENUM */ - -#ifndef XDG_POSITIONER_ANCHOR_ENUM -#define XDG_POSITIONER_ANCHOR_ENUM -enum xdg_positioner_anchor { - XDG_POSITIONER_ANCHOR_NONE = 0, - XDG_POSITIONER_ANCHOR_TOP = 1, - XDG_POSITIONER_ANCHOR_BOTTOM = 2, - XDG_POSITIONER_ANCHOR_LEFT = 3, - XDG_POSITIONER_ANCHOR_RIGHT = 4, - XDG_POSITIONER_ANCHOR_TOP_LEFT = 5, - XDG_POSITIONER_ANCHOR_BOTTOM_LEFT = 6, - XDG_POSITIONER_ANCHOR_TOP_RIGHT = 7, - XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT = 8, -}; -#endif /* XDG_POSITIONER_ANCHOR_ENUM */ - -#ifndef XDG_POSITIONER_GRAVITY_ENUM -#define XDG_POSITIONER_GRAVITY_ENUM -enum xdg_positioner_gravity { - XDG_POSITIONER_GRAVITY_NONE = 0, - XDG_POSITIONER_GRAVITY_TOP = 1, - XDG_POSITIONER_GRAVITY_BOTTOM = 2, - XDG_POSITIONER_GRAVITY_LEFT = 3, - XDG_POSITIONER_GRAVITY_RIGHT = 4, - XDG_POSITIONER_GRAVITY_TOP_LEFT = 5, - XDG_POSITIONER_GRAVITY_BOTTOM_LEFT = 6, - XDG_POSITIONER_GRAVITY_TOP_RIGHT = 7, - XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT = 8, -}; -#endif /* XDG_POSITIONER_GRAVITY_ENUM */ - -#ifndef XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM -#define XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM -/** - * @ingroup iface_xdg_positioner - * constraint adjustments - * - * The constraint adjustment value define ways the compositor will adjust - * the position of the surface, if the unadjusted position would result - * in the surface being partly constrained. - * - * Whether a surface is considered 'constrained' is left to the compositor - * to determine. For example, the surface may be partly outside the - * compositor's defined 'work area', thus necessitating the child surface's - * position be adjusted until it is entirely inside the work area. - * - * The adjustments can be combined, according to a defined precedence: 1) - * Flip, 2) Slide, 3) Resize. - */ -enum xdg_positioner_constraint_adjustment { - /** - * don't move the child surface when constrained - * - * Don't alter the surface position even if it is constrained on - * some axis, for example partially outside the edge of an output. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE = 0, - /** - * move along the x axis until unconstrained - * - * Slide the surface along the x axis until it is no longer - * constrained. - * - * First try to slide towards the direction of the gravity on the x - * axis until either the edge in the opposite direction of the - * gravity is unconstrained or the edge in the direction of the - * gravity is constrained. - * - * Then try to slide towards the opposite direction of the gravity - * on the x axis until either the edge in the direction of the - * gravity is unconstrained or the edge in the opposite direction - * of the gravity is constrained. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1, - /** - * move along the y axis until unconstrained - * - * Slide the surface along the y axis until it is no longer - * constrained. - * - * First try to slide towards the direction of the gravity on the y - * axis until either the edge in the opposite direction of the - * gravity is unconstrained or the edge in the direction of the - * gravity is constrained. - * - * Then try to slide towards the opposite direction of the gravity - * on the y axis until either the edge in the direction of the - * gravity is unconstrained or the edge in the opposite direction - * of the gravity is constrained. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2, - /** - * invert the anchor and gravity on the x axis - * - * Invert the anchor and gravity on the x axis if the surface is - * constrained on the x axis. For example, if the left edge of the - * surface is constrained, the gravity is 'left' and the anchor is - * 'left', change the gravity to 'right' and the anchor to 'right'. - * - * If the adjusted position also ends up being constrained, the - * resulting position of the flip_x adjustment will be the one - * before the adjustment. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X = 4, - /** - * invert the anchor and gravity on the y axis - * - * Invert the anchor and gravity on the y axis if the surface is - * constrained on the y axis. For example, if the bottom edge of - * the surface is constrained, the gravity is 'bottom' and the - * anchor is 'bottom', change the gravity to 'top' and the anchor - * to 'top'. - * - * The adjusted position is calculated given the original anchor - * rectangle and offset, but with the new flipped anchor and - * gravity values. - * - * If the adjusted position also ends up being constrained, the - * resulting position of the flip_y adjustment will be the one - * before the adjustment. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8, - /** - * horizontally resize the surface - * - * Resize the surface horizontally so that it is completely - * unconstrained. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16, - /** - * vertically resize the surface - * - * Resize the surface vertically so that it is completely - * unconstrained. - */ - XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32, -}; -#endif /* XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM */ - -/** - * @ingroup iface_xdg_positioner - * @struct xdg_positioner_interface - */ -struct xdg_positioner_interface { - /** - * destroy the xdg_positioner object - * - * Notify the compositor that the xdg_positioner will no longer - * be used. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); - /** - * set the size of the to-be positioned rectangle - * - * Set the size of the surface that is to be positioned with the - * positioner object. The size is in surface-local coordinates and - * corresponds to the window geometry. See - * xdg_surface.set_window_geometry. - * - * If a zero or negative size is set the invalid_input error is - * raised. - * @param width width of positioned rectangle - * @param height height of positioned rectangle - */ - void (*set_size)(struct wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height); - /** - * set the anchor rectangle within the parent surface - * - * Specify the anchor rectangle within the parent surface that - * the child surface will be placed relative to. The rectangle is - * relative to the window geometry as defined by - * xdg_surface.set_window_geometry of the parent surface. - * - * When the xdg_positioner object is used to position a child - * surface, the anchor rectangle may not extend outside the window - * geometry of the positioned child's parent surface. - * - * If a negative size is set the invalid_input error is raised. - * @param x x position of anchor rectangle - * @param y y position of anchor rectangle - * @param width width of anchor rectangle - * @param height height of anchor rectangle - */ - void (*set_anchor_rect)(struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - /** - * set anchor rectangle anchor - * - * Defines the anchor point for the anchor rectangle. The - * specified anchor is used derive an anchor point that the child - * surface will be positioned relative to. If a corner anchor is - * set (e.g. 'top_left' or 'bottom_right'), the anchor point will - * be at the specified corner; otherwise, the derived anchor point - * will be centered on the specified edge, or in the center of the - * anchor rectangle if no edge is specified. - * @param anchor anchor - */ - void (*set_anchor)(struct wl_client *client, - struct wl_resource *resource, - uint32_t anchor); - /** - * set child surface gravity - * - * Defines in what direction a surface should be positioned, - * relative to the anchor point of the parent surface. If a corner - * gravity is specified (e.g. 'bottom_right' or 'top_left'), then - * the child surface will be placed towards the specified gravity; - * otherwise, the child surface will be centered over the anchor - * point on any axis that had no gravity specified. If the gravity - * is not in the ‘gravity’ enum, an invalid_input error is - * raised. - * @param gravity gravity direction - */ - void (*set_gravity)(struct wl_client *client, - struct wl_resource *resource, - uint32_t gravity); - /** - * set the adjustment to be done when constrained - * - * Specify how the window should be positioned if the originally - * intended position caused the surface to be constrained, meaning - * at least partially outside positioning boundaries set by the - * compositor. The adjustment is set by constructing a bitmask - * describing the adjustment to be made when the surface is - * constrained on that axis. - * - * If no bit for one axis is set, the compositor will assume that - * the child surface should not change its position on that axis - * when constrained. - * - * If more than one bit for one axis is set, the order of how - * adjustments are applied is specified in the corresponding - * adjustment descriptions. - * - * The default adjustment is none. - * @param constraint_adjustment bit mask of constraint adjustments - */ - void (*set_constraint_adjustment)(struct wl_client *client, - struct wl_resource *resource, - uint32_t constraint_adjustment); - /** - * set surface position offset - * - * Specify the surface position offset relative to the position - * of the anchor on the anchor rectangle and the anchor on the - * surface. For example if the anchor of the anchor rectangle is at - * (x, y), the surface has the gravity bottom|right, and the offset - * is (ox, oy), the calculated surface position will be (x + ox, y - * + oy). The offset position of the surface is the one used for - * constraint testing. See set_constraint_adjustment. - * - * An example use case is placing a popup menu on top of a user - * interface element, while aligning the user interface element of - * the parent surface with some user interface element placed - * somewhere in the popup surface. - * @param x surface position x offset - * @param y surface position y offset - */ - void (*set_offset)(struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y); - /** - * continuously reconstrain the surface - * - * When set reactive, the surface is reconstrained if the - * conditions used for constraining changed, e.g. the parent window - * moved. - * - * If the conditions changed and the popup was reconstrained, an - * xdg_popup.configure event is sent with updated geometry, - * followed by an xdg_surface.configure event. - * @since 3 - */ - void (*set_reactive)(struct wl_client *client, - struct wl_resource *resource); - /** - * - * - * Set the parent window geometry the compositor should use when - * positioning the popup. The compositor may use this information - * to determine the future state the popup should be constrained - * using. If this doesn't match the dimension of the parent the - * popup is eventually positioned against, the behavior is - * undefined. - * - * The arguments are given in the surface-local coordinate space. - * @param parent_width future window geometry width of parent - * @param parent_height future window geometry height of parent - * @since 3 - */ - void (*set_parent_size)(struct wl_client *client, - struct wl_resource *resource, - int32_t parent_width, - int32_t parent_height); - /** - * set parent configure this is a response to - * - * Set the serial of an xdg_surface.configure event this - * positioner will be used in response to. The compositor may use - * this information together with set_parent_size to determine what - * future state the popup should be constrained using. - * @param serial serial of parent configure event - * @since 3 - */ - void (*set_parent_configure)(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial); -}; - - -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_SIZE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_ANCHOR_RECT_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_ANCHOR_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_GRAVITY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_OFFSET_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_REACTIVE_SINCE_VERSION 3 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_PARENT_SIZE_SINCE_VERSION 3 -/** - * @ingroup iface_xdg_positioner - */ -#define XDG_POSITIONER_SET_PARENT_CONFIGURE_SINCE_VERSION 3 - -#ifndef XDG_SURFACE_ERROR_ENUM -#define XDG_SURFACE_ERROR_ENUM -enum xdg_surface_error { - /** - * Surface was not fully constructed - */ - XDG_SURFACE_ERROR_NOT_CONSTRUCTED = 1, - /** - * Surface was already constructed - */ - XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED = 2, - /** - * Attaching a buffer to an unconfigured surface - */ - XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER = 3, - /** - * Invalid serial number when acking a configure event - */ - XDG_SURFACE_ERROR_INVALID_SERIAL = 4, - /** - * Width or height was zero or negative - */ - XDG_SURFACE_ERROR_INVALID_SIZE = 5, - /** - * Surface was destroyed before its role object - */ - XDG_SURFACE_ERROR_DEFUNCT_ROLE_OBJECT = 6, -}; -#endif /* XDG_SURFACE_ERROR_ENUM */ - -/** - * @ingroup iface_xdg_surface - * @struct xdg_surface_interface - */ -struct xdg_surface_interface { - /** - * destroy the xdg_surface - * - * Destroy the xdg_surface object. An xdg_surface must only be - * destroyed after its role object has been destroyed, otherwise a - * defunct_role_object error is raised. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); - /** - * assign the xdg_toplevel surface role - * - * This creates an xdg_toplevel object for the given xdg_surface - * and gives the associated wl_surface the xdg_toplevel role. - * - * See the documentation of xdg_toplevel for more details about - * what an xdg_toplevel is and how it is used. - */ - void (*get_toplevel)(struct wl_client *client, - struct wl_resource *resource, - uint32_t id); - /** - * assign the xdg_popup surface role - * - * This creates an xdg_popup object for the given xdg_surface and - * gives the associated wl_surface the xdg_popup role. - * - * If null is passed as a parent, a parent surface must be - * specified using some other protocol, before committing the - * initial state. - * - * See the documentation of xdg_popup for more details about what - * an xdg_popup is and how it is used. - */ - void (*get_popup)(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *parent, - struct wl_resource *positioner); - /** - * set the new window geometry - * - * The window geometry of a surface is its "visible bounds" from - * the user's perspective. Client-side decorations often have - * invisible portions like drop-shadows which should be ignored for - * the purposes of aligning, placing and constraining windows. - * - * The window geometry is double buffered, and will be applied at - * the time wl_surface.commit of the corresponding wl_surface is - * called. - * - * When maintaining a position, the compositor should treat the (x, - * y) coordinate of the window geometry as the top left corner of - * the window. A client changing the (x, y) window geometry - * coordinate should in general not alter the position of the - * window. - * - * Once the window geometry of the surface is set, it is not - * possible to unset it, and it will remain the same until - * set_window_geometry is called again, even if a new subsurface or - * buffer is attached. - * - * If never set, the value is the full bounds of the surface, - * including any subsurfaces. This updates dynamically on every - * commit. This unset is meant for extremely simple clients. - * - * The arguments are given in the surface-local coordinate space of - * the wl_surface associated with this xdg_surface, and may extend - * outside of the wl_surface itself to mark parts of the subsurface - * tree as part of the window geometry. - * - * When applied, the effective window geometry will be the set - * window geometry clamped to the bounding rectangle of the - * combined geometry of the surface of the xdg_surface and the - * associated subsurfaces. - * - * The effective geometry will not be recalculated unless a new - * call to set_window_geometry is done and the new pending surface - * state is subsequently applied. - * - * The width and height of the effective window geometry must be - * greater than zero. Setting an invalid size will raise an - * invalid_size error. - */ - void (*set_window_geometry)(struct wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - /** - * ack a configure event - * - * When a configure event is received, if a client commits the - * surface in response to the configure event, then the client must - * make an ack_configure request sometime before the commit - * request, passing along the serial of the configure event. - * - * For instance, for toplevel surfaces the compositor might use - * this information to move a surface to the top left only when the - * client has drawn itself for the maximized or fullscreen state. - * - * If the client receives multiple configure events before it can - * respond to one, it only has to ack the last configure event. - * Acking a configure event that was never sent raises an - * invalid_serial error. - * - * A client is not required to commit immediately after sending an - * ack_configure request - it may even ack_configure several times - * before its next surface commit. - * - * A client may send multiple ack_configure requests before - * committing, but only the last request sent before a commit - * indicates which configure event the client really is responding - * to. - * - * Sending an ack_configure request consumes the serial number sent - * with the request, as well as serial numbers sent by all - * configure events sent on this xdg_surface prior to the configure - * event referenced by the committed serial. - * - * It is an error to issue multiple ack_configure requests - * referencing a serial from the same configure event, or to issue - * an ack_configure request referencing a serial from a configure - * event issued before the event identified by the last - * ack_configure request for the same xdg_surface. Doing so will - * raise an invalid_serial error. - * @param serial the serial from the configure event - */ - void (*ack_configure)(struct wl_client *client, - struct wl_resource *resource, - uint32_t serial); -}; - -#define XDG_SURFACE_CONFIGURE 0 - -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_CONFIGURE_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_GET_TOPLEVEL_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_GET_POPUP_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_SET_WINDOW_GEOMETRY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_surface - */ -#define XDG_SURFACE_ACK_CONFIGURE_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_surface - * Sends an configure event to the client owning the resource. - * @param resource_ The client's resource - * @param serial serial of the configure event - */ -static inline void -xdg_surface_send_configure(struct wl_resource *resource_, uint32_t serial) -{ - wl_resource_post_event(resource_, XDG_SURFACE_CONFIGURE, serial); -} - -#ifndef XDG_TOPLEVEL_ERROR_ENUM -#define XDG_TOPLEVEL_ERROR_ENUM -enum xdg_toplevel_error { - /** - * provided value is not a valid variant of the resize_edge enum - */ - XDG_TOPLEVEL_ERROR_INVALID_RESIZE_EDGE = 0, - /** - * invalid parent toplevel - */ - XDG_TOPLEVEL_ERROR_INVALID_PARENT = 1, - /** - * client provided an invalid min or max size - */ - XDG_TOPLEVEL_ERROR_INVALID_SIZE = 2, -}; -#endif /* XDG_TOPLEVEL_ERROR_ENUM */ - -#ifndef XDG_TOPLEVEL_RESIZE_EDGE_ENUM -#define XDG_TOPLEVEL_RESIZE_EDGE_ENUM -/** - * @ingroup iface_xdg_toplevel - * edge values for resizing - * - * These values are used to indicate which edge of a surface - * is being dragged in a resize operation. - */ -enum xdg_toplevel_resize_edge { - XDG_TOPLEVEL_RESIZE_EDGE_NONE = 0, - XDG_TOPLEVEL_RESIZE_EDGE_TOP = 1, - XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM = 2, - XDG_TOPLEVEL_RESIZE_EDGE_LEFT = 4, - XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT = 5, - XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT = 6, - XDG_TOPLEVEL_RESIZE_EDGE_RIGHT = 8, - XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT = 9, - XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT = 10, -}; -#endif /* XDG_TOPLEVEL_RESIZE_EDGE_ENUM */ - -#ifndef XDG_TOPLEVEL_STATE_ENUM -#define XDG_TOPLEVEL_STATE_ENUM -/** - * @ingroup iface_xdg_toplevel - * types of state on the surface - * - * The different state values used on the surface. This is designed for - * state values like maximized, fullscreen. It is paired with the - * configure event to ensure that both the client and the compositor - * setting the state can be synchronized. - * - * States set in this way are double-buffered. They will get applied on - * the next commit. - */ -enum xdg_toplevel_state { - /** - * the surface is maximized - * the surface is maximized - * - * The surface is maximized. The window geometry specified in the - * configure event must be obeyed by the client, or the - * xdg_wm_base.invalid_surface_state error is raised. - * - * The client should draw without shadow or other decoration - * outside of the window geometry. - */ - XDG_TOPLEVEL_STATE_MAXIMIZED = 1, - /** - * the surface is fullscreen - * the surface is fullscreen - * - * The surface is fullscreen. The window geometry specified in - * the configure event is a maximum; the client cannot resize - * beyond it. For a surface to cover the whole fullscreened area, - * the geometry dimensions must be obeyed by the client. For more - * details, see xdg_toplevel.set_fullscreen. - */ - XDG_TOPLEVEL_STATE_FULLSCREEN = 2, - /** - * the surface is being resized - * the surface is being resized - * - * The surface is being resized. The window geometry specified in - * the configure event is a maximum; the client cannot resize - * beyond it. Clients that have aspect ratio or cell sizing - * configuration can use a smaller size, however. - */ - XDG_TOPLEVEL_STATE_RESIZING = 3, - /** - * the surface is now activated - * the surface is now activated - * - * Client window decorations should be painted as if the window - * is active. Do not assume this means that the window actually has - * keyboard or pointer focus. - */ - XDG_TOPLEVEL_STATE_ACTIVATED = 4, - /** - * the surface’s left edge is tiled - * - * The window is currently in a tiled layout and the left edge is - * considered to be adjacent to another part of the tiling grid. - * @since 2 - */ - XDG_TOPLEVEL_STATE_TILED_LEFT = 5, - /** - * the surface’s right edge is tiled - * - * The window is currently in a tiled layout and the right edge - * is considered to be adjacent to another part of the tiling grid. - * @since 2 - */ - XDG_TOPLEVEL_STATE_TILED_RIGHT = 6, - /** - * the surface’s top edge is tiled - * - * The window is currently in a tiled layout and the top edge is - * considered to be adjacent to another part of the tiling grid. - * @since 2 - */ - XDG_TOPLEVEL_STATE_TILED_TOP = 7, - /** - * the surface’s bottom edge is tiled - * - * The window is currently in a tiled layout and the bottom edge - * is considered to be adjacent to another part of the tiling grid. - * @since 2 - */ - XDG_TOPLEVEL_STATE_TILED_BOTTOM = 8, - /** - * surface repaint is suspended - * - * The surface is currently not ordinarily being repainted; for - * example because its content is occluded by another window, or - * its outputs are switched off due to screen locking. - * @since 6 - */ - XDG_TOPLEVEL_STATE_SUSPENDED = 9, -}; -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION 2 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION 2 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_STATE_TILED_TOP_SINCE_VERSION 2 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_STATE_TILED_BOTTOM_SINCE_VERSION 2 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_STATE_SUSPENDED_SINCE_VERSION 6 -#endif /* XDG_TOPLEVEL_STATE_ENUM */ - -#ifndef XDG_TOPLEVEL_WM_CAPABILITIES_ENUM -#define XDG_TOPLEVEL_WM_CAPABILITIES_ENUM -enum xdg_toplevel_wm_capabilities { - /** - * show_window_menu is available - */ - XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU = 1, - /** - * set_maximized and unset_maximized are available - */ - XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE = 2, - /** - * set_fullscreen and unset_fullscreen are available - */ - XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN = 3, - /** - * set_minimized is available - */ - XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE = 4, -}; -#endif /* XDG_TOPLEVEL_WM_CAPABILITIES_ENUM */ - -/** - * @ingroup iface_xdg_toplevel - * @struct xdg_toplevel_interface - */ -struct xdg_toplevel_interface { - /** - * destroy the xdg_toplevel - * - * This request destroys the role surface and unmaps the surface; - * see "Unmapping" behavior in interface section for details. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); - /** - * set the parent of this surface - * - * Set the "parent" of this surface. This surface should be - * stacked above the parent surface and all other ancestor - * surfaces. - * - * Parent surfaces should be set on dialogs, toolboxes, or other - * "auxiliary" surfaces, so that the parent is raised when the - * dialog is raised. - * - * Setting a null parent for a child surface unsets its parent. - * Setting a null parent for a surface which currently has no - * parent is a no-op. - * - * Only mapped surfaces can have child surfaces. Setting a parent - * which is not mapped is equivalent to setting a null parent. If a - * surface becomes unmapped, its children's parent is set to the - * parent of the now-unmapped surface. If the now-unmapped surface - * has no parent, its children's parent is unset. If the - * now-unmapped surface becomes mapped again, its parent-child - * relationship is not restored. - * - * The parent toplevel must not be one of the child toplevel's - * descendants, and the parent must be different from the child - * toplevel, otherwise the invalid_parent protocol error is raised. - */ - void (*set_parent)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *parent); - /** - * set surface title - * - * Set a short title for the surface. - * - * This string may be used to identify the surface in a task bar, - * window list, or other user interface elements provided by the - * compositor. - * - * The string must be encoded in UTF-8. - */ - void (*set_title)(struct wl_client *client, - struct wl_resource *resource, - const char *title); - /** - * set application ID - * - * Set an application identifier for the surface. - * - * The app ID identifies the general class of applications to which - * the surface belongs. The compositor can use this to group - * multiple surfaces together, or to determine how to launch a new - * application. - * - * For D-Bus activatable applications, the app ID is used as the - * D-Bus service name. - * - * The compositor shell will try to group application surfaces - * together by their app ID. As a best practice, it is suggested to - * select app ID's that match the basename of the application's - * .desktop file. For example, "org.freedesktop.FooViewer" where - * the .desktop file is "org.freedesktop.FooViewer.desktop". - * - * Like other properties, a set_app_id request can be sent after - * the xdg_toplevel has been mapped to update the property. - * - * See the desktop-entry specification [0] for more details on - * application identifiers and how they relate to well-known D-Bus - * names and .desktop files. - * - * [0] https://standards.freedesktop.org/desktop-entry-spec/ - */ - void (*set_app_id)(struct wl_client *client, - struct wl_resource *resource, - const char *app_id); - /** - * show the window menu - * - * Clients implementing client-side decorations might want to - * show a context menu when right-clicking on the decorations, - * giving the user a menu that they can use to maximize or minimize - * the window. - * - * This request asks the compositor to pop up such a window menu at - * the given position, relative to the local surface coordinates of - * the parent surface. There are no guarantees as to what menu - * items the window menu contains, or even if a window menu will be - * drawn at all. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - * @param x the x position to pop up the window menu at - * @param y the y position to pop up the window menu at - */ - void (*show_window_menu)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - /** - * start an interactive move - * - * Start an interactive, user-driven move of the surface. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. The - * passed serial is used to determine the type of interactive move - * (touch, pointer, etc). - * - * The server may ignore move requests depending on the state of - * the surface (e.g. fullscreen or maximized), or if the passed - * serial is no longer valid. - * - * If triggered, the surface will lose the focus of the device - * (wl_pointer, wl_touch, etc) used for the move. It is up to the - * compositor to visually indicate that the move is taking place, - * such as updating a pointer cursor, during the move. There is no - * guarantee that the device focus will return when the move is - * completed. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - */ - void (*move)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial); - /** - * start an interactive resize - * - * Start a user-driven, interactive resize of the surface. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. The - * passed serial is used to determine the type of interactive - * resize (touch, pointer, etc). - * - * The server may ignore resize requests depending on the state of - * the surface (e.g. fullscreen or maximized). - * - * If triggered, the client will receive configure events with the - * "resize" state enum value and the expected sizes. See the - * "resize" enum value for more details about what is required. The - * client must also acknowledge configure events using - * "ack_configure". After the resize is completed, the client will - * receive another "configure" event without the resize state. - * - * If triggered, the surface also will lose the focus of the device - * (wl_pointer, wl_touch, etc) used for the resize. It is up to the - * compositor to visually indicate that the resize is taking place, - * such as updating a pointer cursor, during the resize. There is - * no guarantee that the device focus will return when the resize - * is completed. - * - * The edges parameter specifies how the surface should be resized, - * and is one of the values of the resize_edge enum. Values not - * matching a variant of the enum will cause the - * invalid_resize_edge protocol error. The compositor may use this - * information to update the surface position for example when - * dragging the top left corner. The compositor may also use this - * information to adapt its behavior, e.g. choose an appropriate - * cursor image. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - * @param edges which edge or corner is being dragged - */ - void (*resize)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial, - uint32_t edges); - /** - * set the maximum size - * - * Set a maximum size for the window. - * - * The client can specify a maximum size so that the compositor - * does not try to configure the window beyond this size. - * - * The width and height arguments are in window geometry - * coordinates. See xdg_surface.set_window_geometry. - * - * Values set in this way are double-buffered. They will get - * applied on the next commit. - * - * The compositor can use this information to allow or disallow - * different states like maximize or fullscreen and draw accurate - * animations. - * - * Similarly, a tiling window manager may use this information to - * place and resize client windows in a more effective way. - * - * The client should not rely on the compositor to obey the maximum - * size. The compositor may decide to ignore the values set by the - * client and request a larger size. - * - * If never set, or a value of zero in the request, means that the - * client has no expected maximum size in the given dimension. As a - * result, a client wishing to reset the maximum size to an - * unspecified state can use zero for width and height in the - * request. - * - * Requesting a maximum size to be smaller than the minimum size of - * a surface is illegal and will result in an invalid_size error. - * - * The width and height must be greater than or equal to zero. - * Using strictly negative values for width or height will result - * in a invalid_size error. - */ - void (*set_max_size)(struct wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height); - /** - * set the minimum size - * - * Set a minimum size for the window. - * - * The client can specify a minimum size so that the compositor - * does not try to configure the window below this size. - * - * The width and height arguments are in window geometry - * coordinates. See xdg_surface.set_window_geometry. - * - * Values set in this way are double-buffered. They will get - * applied on the next commit. - * - * The compositor can use this information to allow or disallow - * different states like maximize or fullscreen and draw accurate - * animations. - * - * Similarly, a tiling window manager may use this information to - * place and resize client windows in a more effective way. - * - * The client should not rely on the compositor to obey the minimum - * size. The compositor may decide to ignore the values set by the - * client and request a smaller size. - * - * If never set, or a value of zero in the request, means that the - * client has no expected minimum size in the given dimension. As a - * result, a client wishing to reset the minimum size to an - * unspecified state can use zero for width and height in the - * request. - * - * Requesting a minimum size to be larger than the maximum size of - * a surface is illegal and will result in an invalid_size error. - * - * The width and height must be greater than or equal to zero. - * Using strictly negative values for width and height will result - * in a invalid_size error. - */ - void (*set_min_size)(struct wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height); - /** - * maximize the window - * - * Maximize the surface. - * - * After requesting that the surface should be maximized, the - * compositor will respond by emitting a configure event. Whether - * this configure actually sets the window maximized is subject to - * compositor policies. The client must then update its content, - * drawing in the configured state. The client must also - * acknowledge the configure when committing the new content (see - * ack_configure). - * - * It is up to the compositor to decide how and where to maximize - * the surface, for example which output and what region of the - * screen should be used. - * - * If the surface was already maximized, the compositor will still - * emit a configure event with the "maximized" state. - * - * If the surface is in a fullscreen state, this request has no - * direct effect. It may alter the state the surface is returned to - * when unmaximized unless overridden by the compositor. - */ - void (*set_maximized)(struct wl_client *client, - struct wl_resource *resource); - /** - * unmaximize the window - * - * Unmaximize the surface. - * - * After requesting that the surface should be unmaximized, the - * compositor will respond by emitting a configure event. Whether - * this actually un-maximizes the window is subject to compositor - * policies. If available and applicable, the compositor will - * include the window geometry dimensions the window had prior to - * being maximized in the configure event. The client must then - * update its content, drawing it in the configured state. The - * client must also acknowledge the configure when committing the - * new content (see ack_configure). - * - * It is up to the compositor to position the surface after it was - * unmaximized; usually the position the surface had before - * maximizing, if applicable. - * - * If the surface was already not maximized, the compositor will - * still emit a configure event without the "maximized" state. - * - * If the surface is in a fullscreen state, this request has no - * direct effect. It may alter the state the surface is returned to - * when unmaximized unless overridden by the compositor. - */ - void (*unset_maximized)(struct wl_client *client, - struct wl_resource *resource); - /** - * set the window as fullscreen on an output - * - * Make the surface fullscreen. - * - * After requesting that the surface should be fullscreened, the - * compositor will respond by emitting a configure event. Whether - * the client is actually put into a fullscreen state is subject to - * compositor policies. The client must also acknowledge the - * configure when committing the new content (see ack_configure). - * - * The output passed by the request indicates the client's - * preference as to which display it should be set fullscreen on. - * If this value is NULL, it's up to the compositor to choose which - * display will be used to map this surface. - * - * If the surface doesn't cover the whole output, the compositor - * will position the surface in the center of the output and - * compensate with with border fill covering the rest of the - * output. The content of the border fill is undefined, but should - * be assumed to be in some way that attempts to blend into the - * surrounding area (e.g. solid black). - * - * If the fullscreened surface is not opaque, the compositor must - * make sure that other screen content not part of the same surface - * tree (made up of subsurfaces, popups or similarly coupled - * surfaces) are not visible below the fullscreened surface. - */ - void (*set_fullscreen)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output); - /** - * unset the window as fullscreen - * - * Make the surface no longer fullscreen. - * - * After requesting that the surface should be unfullscreened, the - * compositor will respond by emitting a configure event. Whether - * this actually removes the fullscreen state of the client is - * subject to compositor policies. - * - * Making a surface unfullscreen sets states for the surface based - * on the following: * the state(s) it may have had before becoming - * fullscreen * any state(s) decided by the compositor * any - * state(s) requested by the client while the surface was - * fullscreen - * - * The compositor may include the previous window geometry - * dimensions in the configure event, if applicable. - * - * The client must also acknowledge the configure when committing - * the new content (see ack_configure). - */ - void (*unset_fullscreen)(struct wl_client *client, - struct wl_resource *resource); - /** - * set the window as minimized - * - * Request that the compositor minimize your surface. There is no - * way to know if the surface is currently minimized, nor is there - * any way to unset minimization on this surface. - * - * If you are looking to throttle redrawing when minimized, please - * instead use the wl_surface.frame event for this, as this will - * also work with live previews on windows in Alt-Tab, Expose or - * similar compositor features. - */ - void (*set_minimized)(struct wl_client *client, - struct wl_resource *resource); -}; - -#define XDG_TOPLEVEL_CONFIGURE 0 -#define XDG_TOPLEVEL_CLOSE 1 -#define XDG_TOPLEVEL_CONFIGURE_BOUNDS 2 -#define XDG_TOPLEVEL_WM_CAPABILITIES 3 - -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_CONFIGURE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_CLOSE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION 4 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION 5 - -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_PARENT_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_TITLE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_APP_ID_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SHOW_WINDOW_MENU_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_MOVE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_RESIZE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_MAX_SIZE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_MIN_SIZE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_MAXIMIZED_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_UNSET_MAXIMIZED_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_FULLSCREEN_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_UNSET_FULLSCREEN_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_toplevel - */ -#define XDG_TOPLEVEL_SET_MINIMIZED_SINCE_VERSION 1 - -/** - * @ingroup iface_xdg_toplevel - * Sends an configure event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -xdg_toplevel_send_configure(struct wl_resource *resource_, int32_t width, int32_t height, struct wl_array *states) -{ - wl_resource_post_event(resource_, XDG_TOPLEVEL_CONFIGURE, width, height, states); -} - -/** - * @ingroup iface_xdg_toplevel - * Sends an close event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -xdg_toplevel_send_close(struct wl_resource *resource_) -{ - wl_resource_post_event(resource_, XDG_TOPLEVEL_CLOSE); -} - -/** - * @ingroup iface_xdg_toplevel - * Sends an configure_bounds event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -xdg_toplevel_send_configure_bounds(struct wl_resource *resource_, int32_t width, int32_t height) -{ - wl_resource_post_event(resource_, XDG_TOPLEVEL_CONFIGURE_BOUNDS, width, height); -} - -/** - * @ingroup iface_xdg_toplevel - * Sends an wm_capabilities event to the client owning the resource. - * @param resource_ The client's resource - * @param capabilities array of 32-bit capabilities - */ -static inline void -xdg_toplevel_send_wm_capabilities(struct wl_resource *resource_, struct wl_array *capabilities) -{ - wl_resource_post_event(resource_, XDG_TOPLEVEL_WM_CAPABILITIES, capabilities); -} - -#ifndef XDG_POPUP_ERROR_ENUM -#define XDG_POPUP_ERROR_ENUM -enum xdg_popup_error { - /** - * tried to grab after being mapped - */ - XDG_POPUP_ERROR_INVALID_GRAB = 0, -}; -#endif /* XDG_POPUP_ERROR_ENUM */ - -/** - * @ingroup iface_xdg_popup - * @struct xdg_popup_interface - */ -struct xdg_popup_interface { - /** - * remove xdg_popup interface - * - * This destroys the popup. Explicitly destroying the xdg_popup - * object will also dismiss the popup, and unmap the surface. - * - * If this xdg_popup is not the "topmost" popup, the - * xdg_wm_base.not_the_topmost_popup protocol error will be sent. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); - /** - * make the popup take an explicit grab - * - * This request makes the created popup take an explicit grab. An - * explicit grab will be dismissed when the user dismisses the - * popup, or when the client destroys the xdg_popup. This can be - * done by the user clicking outside the surface, using the - * keyboard, or even locking the screen through closing the lid or - * a timeout. - * - * If the compositor denies the grab, the popup will be immediately - * dismissed. - * - * This request must be used in response to some sort of user - * action like a button press, key press, or touch down event. The - * serial number of the event should be passed as 'serial'. - * - * The parent of a grabbing popup must either be an xdg_toplevel - * surface or another xdg_popup with an explicit grab. If the - * parent is another xdg_popup it means that the popups are nested, - * with this popup now being the topmost popup. - * - * Nested popups must be destroyed in the reverse order they were - * created in, e.g. the only popup you are allowed to destroy at - * all times is the topmost one. - * - * When compositors choose to dismiss a popup, they may dismiss - * every nested grabbing popup as well. When a compositor dismisses - * popups, it will follow the same dismissing order as required - * from the client. - * - * If the topmost grabbing popup is destroyed, the grab will be - * returned to the parent of the popup, if that parent previously - * had an explicit grab. - * - * If the parent is a grabbing popup which has already been - * dismissed, this popup will be immediately dismissed. If the - * parent is a popup that did not take an explicit grab, an error - * will be raised. - * - * During a popup grab, the client owning the grab will receive - * pointer and touch events for all their surfaces as normal - * (similar to an "owner-events" grab in X11 parlance), while the - * top most grabbing popup will always have keyboard focus. - * @param seat the wl_seat of the user event - * @param serial the serial of the user event - */ - void (*grab)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *seat, - uint32_t serial); - /** - * recalculate the popup's location - * - * Reposition an already-mapped popup. The popup will be placed - * given the details in the passed xdg_positioner object, and a - * xdg_popup.repositioned followed by xdg_popup.configure and - * xdg_surface.configure will be emitted in response. Any - * parameters set by the previous positioner will be discarded. - * - * The passed token will be sent in the corresponding - * xdg_popup.repositioned event. The new popup position will not - * take effect until the corresponding configure event is - * acknowledged by the client. See xdg_popup.repositioned for - * details. The token itself is opaque, and has no other special - * meaning. - * - * If multiple reposition requests are sent, the compositor may - * skip all but the last one. - * - * If the popup is repositioned in response to a configure event - * for its parent, the client should send an - * xdg_positioner.set_parent_configure and possibly an - * xdg_positioner.set_parent_size request to allow the compositor - * to properly constrain the popup. - * - * If the popup is repositioned together with a parent that is - * being resized, but not in response to a configure event, the - * client should send an xdg_positioner.set_parent_size request. - * @param token reposition request token - * @since 3 - */ - void (*reposition)(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *positioner, - uint32_t token); -}; - -#define XDG_POPUP_CONFIGURE 0 -#define XDG_POPUP_POPUP_DONE 1 -#define XDG_POPUP_REPOSITIONED 2 - -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_CONFIGURE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_POPUP_DONE_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_REPOSITIONED_SINCE_VERSION 3 - -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_GRAB_SINCE_VERSION 1 -/** - * @ingroup iface_xdg_popup - */ -#define XDG_POPUP_REPOSITION_SINCE_VERSION 3 - -/** - * @ingroup iface_xdg_popup - * Sends an configure event to the client owning the resource. - * @param resource_ The client's resource - * @param x x position relative to parent surface window geometry - * @param y y position relative to parent surface window geometry - * @param width window geometry width - * @param height window geometry height - */ -static inline void -xdg_popup_send_configure(struct wl_resource *resource_, int32_t x, int32_t y, int32_t width, int32_t height) -{ - wl_resource_post_event(resource_, XDG_POPUP_CONFIGURE, x, y, width, height); -} - -/** - * @ingroup iface_xdg_popup - * Sends an popup_done event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -xdg_popup_send_popup_done(struct wl_resource *resource_) -{ - wl_resource_post_event(resource_, XDG_POPUP_POPUP_DONE); -} - -/** - * @ingroup iface_xdg_popup - * Sends an repositioned event to the client owning the resource. - * @param resource_ The client's resource - * @param token reposition request token - */ -static inline void -xdg_popup_send_repositioned(struct wl_resource *resource_, uint32_t token) -{ - wl_resource_post_event(resource_, XDG_POPUP_REPOSITIONED, token); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/wayland_adapter/wayland_protocols/unstable/xdg-output-unstable-v1-client-protocol.h b/wayland_adapter/wayland_protocols/unstable/xdg-output-unstable-v1-client-protocol.h deleted file mode 100644 index 5df793a8d3ff26edf03042e1599ade0b58a0b3cb..0000000000000000000000000000000000000000 --- a/wayland_adapter/wayland_protocols/unstable/xdg-output-unstable-v1-client-protocol.h +++ /dev/null @@ -1,411 +0,0 @@ -/* Generated by wayland-scanner 1.21.90 */ - -#ifndef XDG_OUTPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H -#define XDG_OUTPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H - -#include -#include -#include "wayland-client.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @page page_xdg_output_unstable_v1 The xdg_output_unstable_v1 protocol - * Protocol to describe output regions - * - * @section page_desc_xdg_output_unstable_v1 Description - * - * This protocol aims at describing outputs in a way which is more in line - * with the concept of an output on desktop oriented systems. - * - * Some information are more specific to the concept of an output for - * a desktop oriented system and may not make sense in other applications, - * such as IVI systems for example. - * - * Typically, the global compositor space on a desktop system is made of - * a contiguous or overlapping set of rectangular regions. - * - * Some of the information provided in this protocol might be identical - * to their counterparts already available from wl_output, in which case - * the information provided by this protocol should be preferred to their - * equivalent in wl_output. The goal is to move the desktop specific - * concepts (such as output location within the global compositor space, - * the connector name and types, etc.) out of the core wl_output protocol. - * - * Warning! The protocol described in this file is experimental and - * backward incompatible changes may be made. Backward compatible - * changes may be added together with the corresponding interface - * version bump. - * Backward incompatible changes are done by bumping the version - * number in the protocol and interface names and resetting the - * interface version. Once the protocol is to be declared stable, - * the 'z' prefix and the version number in the protocol and - * interface names are removed and the interface version number is - * reset. - * - * @section page_ifaces_xdg_output_unstable_v1 Interfaces - * - @subpage page_iface_zxdg_output_manager_v1 - manage xdg_output objects - * - @subpage page_iface_zxdg_output_v1 - compositor logical output region - * @section page_copyright_xdg_output_unstable_v1 Copyright - *
- *
- * Copyright © 2017 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- * 
- */ -struct wl_output; -struct zxdg_output_manager_v1; -struct zxdg_output_v1; - -#ifndef ZXDG_OUTPUT_MANAGER_V1_INTERFACE -#define ZXDG_OUTPUT_MANAGER_V1_INTERFACE -/** - * @page page_iface_zxdg_output_manager_v1 zxdg_output_manager_v1 - * @section page_iface_zxdg_output_manager_v1_desc Description - * - * A global factory interface for xdg_output objects. - * @section page_iface_zxdg_output_manager_v1_api API - * See @ref iface_zxdg_output_manager_v1. - */ -/** - * @defgroup iface_zxdg_output_manager_v1 The zxdg_output_manager_v1 interface - * - * A global factory interface for xdg_output objects. - */ -extern const struct wl_interface zxdg_output_manager_v1_interface; -#endif -#ifndef ZXDG_OUTPUT_V1_INTERFACE -#define ZXDG_OUTPUT_V1_INTERFACE -/** - * @page page_iface_zxdg_output_v1 zxdg_output_v1 - * @section page_iface_zxdg_output_v1_desc Description - * - * An xdg_output describes part of the compositor geometry. - * - * This typically corresponds to a monitor that displays part of the - * compositor space. - * - * For objects version 3 onwards, after all xdg_output properties have been - * sent (when the object is created and when properties are updated), a - * wl_output.done event is sent. This allows changes to the output - * properties to be seen as atomic, even if they happen via multiple events. - * @section page_iface_zxdg_output_v1_api API - * See @ref iface_zxdg_output_v1. - */ -/** - * @defgroup iface_zxdg_output_v1 The zxdg_output_v1 interface - * - * An xdg_output describes part of the compositor geometry. - * - * This typically corresponds to a monitor that displays part of the - * compositor space. - * - * For objects version 3 onwards, after all xdg_output properties have been - * sent (when the object is created and when properties are updated), a - * wl_output.done event is sent. This allows changes to the output - * properties to be seen as atomic, even if they happen via multiple events. - */ -extern const struct wl_interface zxdg_output_v1_interface; -#endif - -#define ZXDG_OUTPUT_MANAGER_V1_DESTROY 0 -#define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT 1 - - -/** - * @ingroup iface_zxdg_output_manager_v1 - */ -#define ZXDG_OUTPUT_MANAGER_V1_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_zxdg_output_manager_v1 - */ -#define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT_SINCE_VERSION 1 - -/** @ingroup iface_zxdg_output_manager_v1 */ -static inline void -zxdg_output_manager_v1_set_user_data(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) zxdg_output_manager_v1, user_data); -} - -/** @ingroup iface_zxdg_output_manager_v1 */ -static inline void * -zxdg_output_manager_v1_get_user_data(struct zxdg_output_manager_v1 *zxdg_output_manager_v1) -{ - return wl_proxy_get_user_data((struct wl_proxy *) zxdg_output_manager_v1); -} - -static inline uint32_t -zxdg_output_manager_v1_get_version(struct zxdg_output_manager_v1 *zxdg_output_manager_v1) -{ - return wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1); -} - -/** - * @ingroup iface_zxdg_output_manager_v1 - * - * Using this request a client can tell the server that it is not - * going to use the xdg_output_manager object anymore. - * - * Any objects already created through this instance are not affected. - */ -static inline void -zxdg_output_manager_v1_destroy(struct zxdg_output_manager_v1 *zxdg_output_manager_v1) -{ - wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_manager_v1, - ZXDG_OUTPUT_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1), WL_MARSHAL_FLAG_DESTROY); -} - -/** - * @ingroup iface_zxdg_output_manager_v1 - * - * This creates a new xdg_output object for the given wl_output. - */ -static inline struct zxdg_output_v1 * -zxdg_output_manager_v1_get_xdg_output(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, struct wl_output *output) -{ - struct wl_proxy *id; - - id = wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_manager_v1, - ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT, &zxdg_output_v1_interface, wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1), 0, NULL, output); - - return (struct zxdg_output_v1 *) id; -} - -/** - * @ingroup iface_zxdg_output_v1 - * @struct zxdg_output_v1_listener - */ -struct zxdg_output_v1_listener { - /** - * position of the output within the global compositor space - * - * The position event describes the location of the wl_output - * within the global compositor space. - * - * The logical_position event is sent after creating an xdg_output - * (see xdg_output_manager.get_xdg_output) and whenever the - * location of the output changes within the global compositor - * space. - * @param x x position within the global compositor space - * @param y y position within the global compositor space - */ - void (*logical_position)(void *data, - struct zxdg_output_v1 *zxdg_output_v1, - int32_t x, - int32_t y); - /** - * size of the output in the global compositor space - * - * The logical_size event describes the size of the output in the - * global compositor space. - * - * For example, a surface without any buffer scale, transformation - * nor rotation set, with the size matching the logical_size will - * have the same size as the corresponding output when displayed. - * - * Most regular Wayland clients should not pay attention to the - * logical size and would rather rely on xdg_shell interfaces. - * - * Some clients such as Xwayland, however, need this to configure - * their surfaces in the global compositor space as the compositor - * may apply a different scale from what is advertised by the - * output scaling property (to achieve fractional scaling, for - * example). - * - * For example, for a wl_output mode 3840×2160 and a scale factor - * 2: - * - * - A compositor not scaling the surface buffers will advertise a - * logical size of 3840×2160, - * - * - A compositor automatically scaling the surface buffers will - * advertise a logical size of 1920×1080, - * - * - A compositor using a fractional scale of 1.5 will advertise a - * logical size of 2560×1440. - * - * For example, for a wl_output mode 1920×1080 and a 90 degree - * rotation, the compositor will advertise a logical size of - * 1080x1920. - * - * The logical_size event is sent after creating an xdg_output (see - * xdg_output_manager.get_xdg_output) and whenever the logical size - * of the output changes, either as a result of a change in the - * applied scale or because of a change in the corresponding output - * mode(see wl_output.mode) or transform (see wl_output.transform). - * @param width width in global compositor space - * @param height height in global compositor space - */ - void (*logical_size)(void *data, - struct zxdg_output_v1 *zxdg_output_v1, - int32_t width, - int32_t height); - /** - * all information about the output have been sent - * - * This event is sent after all other properties of an xdg_output - * have been sent. - * - * This allows changes to the xdg_output properties to be seen as - * atomic, even if they happen via multiple events. - * - * For objects version 3 onwards, this event is deprecated. - * Compositors are not required to send it anymore and must send - * wl_output.done instead. - */ - void (*done)(void *data, - struct zxdg_output_v1 *zxdg_output_v1); - /** - * name of this output - * - * Many compositors will assign names to their outputs, show them - * to the user, allow them to be configured by name, etc. The - * client may wish to know this name as well to offer the user - * similar behaviors. - * - * The naming convention is compositor defined, but limited to - * alphanumeric characters and dashes (-). Each name is unique - * among all wl_output globals, but if a wl_output global is - * destroyed the same name may be reused later. The names will also - * remain consistent across sessions with the same hardware and - * software configuration. - * - * Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. - * However, do not assume that the name is a reflection of an - * underlying DRM connector, X11 connection, etc. - * - * The name event is sent after creating an xdg_output (see - * xdg_output_manager.get_xdg_output). This event is only sent once - * per xdg_output, and the name does not change over the lifetime - * of the wl_output global. - * @param name output name - * @since 2 - */ - void (*name)(void *data, - struct zxdg_output_v1 *zxdg_output_v1, - const char *name); - /** - * human-readable description of this output - * - * Many compositors can produce human-readable descriptions of - * their outputs. The client may wish to know this description as - * well, to communicate the user for various purposes. - * - * The description is a UTF-8 string with no convention defined for - * its contents. Examples might include 'Foocorp 11" Display' or - * 'Virtual X11 output via :1'. - * - * The description event is sent after creating an xdg_output (see - * xdg_output_manager.get_xdg_output) and whenever the description - * changes. The description is optional, and may not be sent at - * all. - * - * For objects of version 2 and lower, this event is only sent once - * per xdg_output, and the description does not change over the - * lifetime of the wl_output global. - * @param description output description - * @since 2 - */ - void (*description)(void *data, - struct zxdg_output_v1 *zxdg_output_v1, - const char *description); -}; - -/** - * @ingroup iface_zxdg_output_v1 - */ -static inline int -zxdg_output_v1_add_listener(struct zxdg_output_v1 *zxdg_output_v1, - const struct zxdg_output_v1_listener *listener, void *data) -{ - return wl_proxy_add_listener((struct wl_proxy *) zxdg_output_v1, - (void (**)(void)) listener, data); -} - -#define ZXDG_OUTPUT_V1_DESTROY 0 - -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_LOGICAL_POSITION_SINCE_VERSION 1 -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_LOGICAL_SIZE_SINCE_VERSION 1 -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_DONE_SINCE_VERSION 1 -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_NAME_SINCE_VERSION 2 -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION 2 - -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_DESTROY_SINCE_VERSION 1 - -/** @ingroup iface_zxdg_output_v1 */ -static inline void -zxdg_output_v1_set_user_data(struct zxdg_output_v1 *zxdg_output_v1, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) zxdg_output_v1, user_data); -} - -/** @ingroup iface_zxdg_output_v1 */ -static inline void * -zxdg_output_v1_get_user_data(struct zxdg_output_v1 *zxdg_output_v1) -{ - return wl_proxy_get_user_data((struct wl_proxy *) zxdg_output_v1); -} - -static inline uint32_t -zxdg_output_v1_get_version(struct zxdg_output_v1 *zxdg_output_v1) -{ - return wl_proxy_get_version((struct wl_proxy *) zxdg_output_v1); -} - -/** - * @ingroup iface_zxdg_output_v1 - * - * Using this request a client can tell the server that it is not - * going to use the xdg_output object anymore. - */ -static inline void -zxdg_output_v1_destroy(struct zxdg_output_v1 *zxdg_output_v1) -{ - wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_v1, - ZXDG_OUTPUT_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_output_v1), WL_MARSHAL_FLAG_DESTROY); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/wayland_adapter/wayland_protocols/unstable/xdg-output-unstable-v1-protocol.c b/wayland_adapter/wayland_protocols/unstable/xdg-output-unstable-v1-protocol.c deleted file mode 100644 index f17f34387f900ea58b75bb649def6bed504bc876..0000000000000000000000000000000000000000 --- a/wayland_adapter/wayland_protocols/unstable/xdg-output-unstable-v1-protocol.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Generated by wayland-scanner 1.21.90 */ - -/* - * Copyright © 2017 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include "wayland-util.h" - -#ifndef __has_attribute -# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ -#endif - -#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) -#define WL_PRIVATE __attribute__ ((visibility("hidden"))) -#else -#define WL_PRIVATE -#endif - -extern const struct wl_interface wl_output_interface; -extern const struct wl_interface zxdg_output_v1_interface; - -static const struct wl_interface *xdg_output_unstable_v1_types[] = { - NULL, - NULL, - &zxdg_output_v1_interface, - &wl_output_interface, -}; - -static const struct wl_message zxdg_output_manager_v1_requests[] = { - { "destroy", "", xdg_output_unstable_v1_types + 0 }, - { "get_xdg_output", "no", xdg_output_unstable_v1_types + 2 }, -}; - -WL_PRIVATE const struct wl_interface zxdg_output_manager_v1_interface = { - "zxdg_output_manager_v1", 3, - 2, zxdg_output_manager_v1_requests, - 0, NULL, -}; - -static const struct wl_message zxdg_output_v1_requests[] = { - { "destroy", "", xdg_output_unstable_v1_types + 0 }, -}; - -static const struct wl_message zxdg_output_v1_events[] = { - { "logical_position", "ii", xdg_output_unstable_v1_types + 0 }, - { "logical_size", "ii", xdg_output_unstable_v1_types + 0 }, - { "done", "", xdg_output_unstable_v1_types + 0 }, - { "name", "2s", xdg_output_unstable_v1_types + 0 }, - { "description", "2s", xdg_output_unstable_v1_types + 0 }, -}; - -WL_PRIVATE const struct wl_interface zxdg_output_v1_interface = { - "zxdg_output_v1", 3, - 1, zxdg_output_v1_requests, - 5, zxdg_output_v1_events, -}; - diff --git a/wayland_adapter/wayland_protocols/unstable/xdg-output-unstable-v1-server-protocol.h b/wayland_adapter/wayland_protocols/unstable/xdg-output-unstable-v1-server-protocol.h deleted file mode 100644 index 86001a97d6ab05848fd62241a50c299b88773973..0000000000000000000000000000000000000000 --- a/wayland_adapter/wayland_protocols/unstable/xdg-output-unstable-v1-server-protocol.h +++ /dev/null @@ -1,283 +0,0 @@ -/* Generated by wayland-scanner 1.21.90 */ - -#ifndef XDG_OUTPUT_UNSTABLE_V1_SERVER_PROTOCOL_H -#define XDG_OUTPUT_UNSTABLE_V1_SERVER_PROTOCOL_H - -#include -#include -#include "wayland-server.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct wl_client; -struct wl_resource; - -/** - * @page page_xdg_output_unstable_v1 The xdg_output_unstable_v1 protocol - * Protocol to describe output regions - * - * @section page_desc_xdg_output_unstable_v1 Description - * - * This protocol aims at describing outputs in a way which is more in line - * with the concept of an output on desktop oriented systems. - * - * Some information are more specific to the concept of an output for - * a desktop oriented system and may not make sense in other applications, - * such as IVI systems for example. - * - * Typically, the global compositor space on a desktop system is made of - * a contiguous or overlapping set of rectangular regions. - * - * Some of the information provided in this protocol might be identical - * to their counterparts already available from wl_output, in which case - * the information provided by this protocol should be preferred to their - * equivalent in wl_output. The goal is to move the desktop specific - * concepts (such as output location within the global compositor space, - * the connector name and types, etc.) out of the core wl_output protocol. - * - * Warning! The protocol described in this file is experimental and - * backward incompatible changes may be made. Backward compatible - * changes may be added together with the corresponding interface - * version bump. - * Backward incompatible changes are done by bumping the version - * number in the protocol and interface names and resetting the - * interface version. Once the protocol is to be declared stable, - * the 'z' prefix and the version number in the protocol and - * interface names are removed and the interface version number is - * reset. - * - * @section page_ifaces_xdg_output_unstable_v1 Interfaces - * - @subpage page_iface_zxdg_output_manager_v1 - manage xdg_output objects - * - @subpage page_iface_zxdg_output_v1 - compositor logical output region - * @section page_copyright_xdg_output_unstable_v1 Copyright - *
- *
- * Copyright © 2017 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- * 
- */ -struct wl_output; -struct zxdg_output_manager_v1; -struct zxdg_output_v1; - -#ifndef ZXDG_OUTPUT_MANAGER_V1_INTERFACE -#define ZXDG_OUTPUT_MANAGER_V1_INTERFACE -/** - * @page page_iface_zxdg_output_manager_v1 zxdg_output_manager_v1 - * @section page_iface_zxdg_output_manager_v1_desc Description - * - * A global factory interface for xdg_output objects. - * @section page_iface_zxdg_output_manager_v1_api API - * See @ref iface_zxdg_output_manager_v1. - */ -/** - * @defgroup iface_zxdg_output_manager_v1 The zxdg_output_manager_v1 interface - * - * A global factory interface for xdg_output objects. - */ -extern const struct wl_interface zxdg_output_manager_v1_interface; -#endif -#ifndef ZXDG_OUTPUT_V1_INTERFACE -#define ZXDG_OUTPUT_V1_INTERFACE -/** - * @page page_iface_zxdg_output_v1 zxdg_output_v1 - * @section page_iface_zxdg_output_v1_desc Description - * - * An xdg_output describes part of the compositor geometry. - * - * This typically corresponds to a monitor that displays part of the - * compositor space. - * - * For objects version 3 onwards, after all xdg_output properties have been - * sent (when the object is created and when properties are updated), a - * wl_output.done event is sent. This allows changes to the output - * properties to be seen as atomic, even if they happen via multiple events. - * @section page_iface_zxdg_output_v1_api API - * See @ref iface_zxdg_output_v1. - */ -/** - * @defgroup iface_zxdg_output_v1 The zxdg_output_v1 interface - * - * An xdg_output describes part of the compositor geometry. - * - * This typically corresponds to a monitor that displays part of the - * compositor space. - * - * For objects version 3 onwards, after all xdg_output properties have been - * sent (when the object is created and when properties are updated), a - * wl_output.done event is sent. This allows changes to the output - * properties to be seen as atomic, even if they happen via multiple events. - */ -extern const struct wl_interface zxdg_output_v1_interface; -#endif - -/** - * @ingroup iface_zxdg_output_manager_v1 - * @struct zxdg_output_manager_v1_interface - */ -struct zxdg_output_manager_v1_interface { - /** - * destroy the xdg_output_manager object - * - * Using this request a client can tell the server that it is not - * going to use the xdg_output_manager object anymore. - * - * Any objects already created through this instance are not - * affected. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); - /** - * create an xdg output from a wl_output - * - * This creates a new xdg_output object for the given wl_output. - */ - void (*get_xdg_output)(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *output); -}; - - -/** - * @ingroup iface_zxdg_output_manager_v1 - */ -#define ZXDG_OUTPUT_MANAGER_V1_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_zxdg_output_manager_v1 - */ -#define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT_SINCE_VERSION 1 - -/** - * @ingroup iface_zxdg_output_v1 - * @struct zxdg_output_v1_interface - */ -struct zxdg_output_v1_interface { - /** - * destroy the xdg_output object - * - * Using this request a client can tell the server that it is not - * going to use the xdg_output object anymore. - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); -}; - -#define ZXDG_OUTPUT_V1_LOGICAL_POSITION 0 -#define ZXDG_OUTPUT_V1_LOGICAL_SIZE 1 -#define ZXDG_OUTPUT_V1_DONE 2 -#define ZXDG_OUTPUT_V1_NAME 3 -#define ZXDG_OUTPUT_V1_DESCRIPTION 4 - -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_LOGICAL_POSITION_SINCE_VERSION 1 -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_LOGICAL_SIZE_SINCE_VERSION 1 -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_DONE_SINCE_VERSION 1 -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_NAME_SINCE_VERSION 2 -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION 2 - -/** - * @ingroup iface_zxdg_output_v1 - */ -#define ZXDG_OUTPUT_V1_DESTROY_SINCE_VERSION 1 - -/** - * @ingroup iface_zxdg_output_v1 - * Sends an logical_position event to the client owning the resource. - * @param resource_ The client's resource - * @param x x position within the global compositor space - * @param y y position within the global compositor space - */ -static inline void -zxdg_output_v1_send_logical_position(struct wl_resource *resource_, int32_t x, int32_t y) -{ - wl_resource_post_event(resource_, ZXDG_OUTPUT_V1_LOGICAL_POSITION, x, y); -} - -/** - * @ingroup iface_zxdg_output_v1 - * Sends an logical_size event to the client owning the resource. - * @param resource_ The client's resource - * @param width width in global compositor space - * @param height height in global compositor space - */ -static inline void -zxdg_output_v1_send_logical_size(struct wl_resource *resource_, int32_t width, int32_t height) -{ - wl_resource_post_event(resource_, ZXDG_OUTPUT_V1_LOGICAL_SIZE, width, height); -} - -/** - * @ingroup iface_zxdg_output_v1 - * Sends an done event to the client owning the resource. - * @param resource_ The client's resource - */ -static inline void -zxdg_output_v1_send_done(struct wl_resource *resource_) -{ - wl_resource_post_event(resource_, ZXDG_OUTPUT_V1_DONE); -} - -/** - * @ingroup iface_zxdg_output_v1 - * Sends an name event to the client owning the resource. - * @param resource_ The client's resource - * @param name output name - */ -static inline void -zxdg_output_v1_send_name(struct wl_resource *resource_, const char *name) -{ - wl_resource_post_event(resource_, ZXDG_OUTPUT_V1_NAME, name); -} - -/** - * @ingroup iface_zxdg_output_v1 - * Sends an description event to the client owning the resource. - * @param resource_ The client's resource - * @param description output description - */ -static inline void -zxdg_output_v1_send_description(struct wl_resource *resource_, const char *description) -{ - wl_resource_post_event(resource_, ZXDG_OUTPUT_V1_DESCRIPTION, description); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/wayland_adapter/wayland_server.cpp b/wayland_adapter/wayland_server.cpp deleted file mode 100644 index 5ebbad8e83f0ade175ed5493ab6918684d266cb0..0000000000000000000000000000000000000000 --- a/wayland_adapter/wayland_server.cpp +++ /dev/null @@ -1,123 +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_server.h" - -#include -#include "wayland_adapter_hilog.h" -#include "wayland_event_loop.h" - -namespace FT { -namespace Wayland { -namespace { - constexpr HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WAYLAND, "WaylandServer"}; -} - -const bool REGISTER_RESULT = OHOS::SystemAbility::MakeAndRegisterAbility(new WaylandServer()); - -// TODO: replace WINDOW_MANAGER_ID with WAYLAND_ADAPTER_ID -WaylandServer::WaylandServer() : OHOS::SystemAbility(OHOS::WINDOW_MANAGER_ID, true) {} - -WaylandServer::~WaylandServer() noexcept -{ - OnStop(); -} - -void WaylandServer::CreateGlobalObjects() -{ - compositorGlobal_ = WaylandCompositor::Create(display_); - xdgWmBaseGlobal_ = WaylandXdgWmBase::Create(display_); - outputGlobal_ = WaylandOutput::Create(display_); - seatGlobal_ = WaylandSeat::Create(display_); - subCompositorGlobal_ = WaylandSubCompositor::Create(display_); - zxdgOutputMgrGlobal_ = WaylandZxdgOutputManagerV1::Create(display_); - dataDeviceManagerGlobal_ = WaylandDataDeviceManager::Create(display_); - wl_display_add_shm_format(display_, WL_SHM_FORMAT_RGBA8888); - wl_display_init_shm(display_); -} - -void WaylandServer::OnStart() -{ - LOG_INFO("OnStart"); - - display_ = wl_display_create(); - if (display_ == nullptr) { - LOG_ERROR("wl_display_create failed"); - return; - } - - wlDisplayLoop_ = wl_display_get_event_loop(display_); - if (wlDisplayLoop_ == nullptr) { - LOG_ERROR("wl_display_get_event_loop failed"); - wl_display_destroy(display_); - return; - } - - socketName_ = wl_display_add_socket_auto(display_); - if (socketName_.empty()) { - LOG_ERROR("wl_display_add_socket_auto failed"); - wl_display_destroy(display_); - return; - } - - CreateGlobalObjects(); - wlDisplayChannel_ = std::make_unique(wl_event_loop_get_fd(wlDisplayLoop_), - WaylandEventLoop::GetInstance().GetEventLoopPtr()); - wlDisplayChannel_->SetReadCallback([this](TimeStamp timeStamp) { - wl_event_loop_dispatch(wlDisplayLoop_, -1); - wl_display_flush_clients(display_); - }); - wlDisplayChannel_->EnableReading(true); - WaylandEventLoop::GetInstance().Start(); -} - -void WaylandServer::OnStop() -{ - LOG_INFO("OnStop"); - - if (display_ == nullptr) { - return; - } - - auto stopWlDisplay = WaylandEventLoop::GetInstance().Schedule([this]() { - wl_display_terminate(display_); - wl_display_destroy_clients(display_); - wl_display_destroy(display_); - if (wlDisplayChannel_ != nullptr) { - wlDisplayChannel_->DisableAll(true); - wlDisplayChannel_ = nullptr; - } - }); - stopWlDisplay.wait(); - - display_ = nullptr; - compositorGlobal_ = nullptr; - xdgWmBaseGlobal_ = nullptr; - seatGlobal_ = nullptr; - outputGlobal_ = nullptr; - subCompositorGlobal_ = nullptr; -} - -void WaylandServer::OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) -{ - LOG_INFO("systemAbilityId: %{public}d, start", systemAbilityId); -} - -std::string WaylandServer::GetClassName() -{ - return "WaylandServer"; -} -} // namespace Wayland -} // namespace FT diff --git a/wayland_adapter/wayland_server.h b/wayland_adapter/wayland_server.h deleted file mode 100644 index a22d5e9a28d8dbcd1ed144902b7e0ef9e5150352..0000000000000000000000000000000000000000 --- a/wayland_adapter/wayland_server.h +++ /dev/null @@ -1,65 +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. - */ - -#ifndef WAYLAND_SERVER_H -#define WAYLAND_SERVER_H - -#include -#include - -#include "wayland-server-core.h" -#include "event_loop.h" -#include "wayland_compositor.h" -#include "wayland_xdg_wm_base.h" -#include "wayland_output.h" -#include "wayland_seat.h" -#include "wayland_subcompositor.h" -#include "wayland_zxdg_output_manager_v1.h" -#include "wayland_data_device_manager.h" - -namespace FT { -namespace Wayland { -class WaylandServer : public OHOS::SystemAbility { -public: - WaylandServer(); - ~WaylandServer() noexcept; - - WaylandServer(const WaylandServer&) = delete; - WaylandServer& operator=(const WaylandServer&) = delete; - - // sa_main implementation - void OnStart() override; - void OnStop() override; - void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; - std::string GetClassName() override; - -private: - void CreateGlobalObjects(); - - struct wl_display *display_ = nullptr; - struct wl_event_loop *wlDisplayLoop_ = nullptr; - std::string socketName_; - std::unique_ptr wlDisplayChannel_; - OHOS::sptr compositorGlobal_; - OHOS::sptr xdgWmBaseGlobal_; - OHOS::sptr outputGlobal_; - OHOS::sptr seatGlobal_; - OHOS::sptr subCompositorGlobal_; - OHOS::sptr zxdgOutputMgrGlobal_; - OHOS::sptr dataDeviceManagerGlobal_; -}; -} // namespace Wayland -} // namespace FT -#endif // WAYLAND_SERVER_H