From 5809266da219d4a86383911905db6d1597de9b13 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Fri, 22 Apr 2022 12:03:54 +0200 Subject: [PATCH 1/2] Replace FindWaylandProtocols.cmake with the version from ECM It uses pkgconfig correctly and allows using things like CMAKE_PREFIX_PATH to point at different installations. --- CMakeLists.txt | 6 +-- cmake/FindWaylandProtocols.cmake | 65 ++++++++++++++++---------------- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dffb4c06..cb8f7e31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,7 @@ if(enable-wayland) connection/waylandinputmethodconnection.cpp connection/waylandinputmethodconnection.h) - ecm_add_qtwayland_client_protocol(CONNECTION_SOURCES PROTOCOL ${WAYLANDPROTOCOLS_PATH}/unstable/input-method/input-method-unstable-v1.xml BASENAME input-method-unstable-v1) + ecm_add_qtwayland_client_protocol(CONNECTION_SOURCES PROTOCOL ${WaylandProtocols_DATADIR}/unstable/input-method/input-method-unstable-v1.xml BASENAME input-method-unstable-v1) add_definitions(-DHAVE_WAYLAND) endif() @@ -309,7 +309,7 @@ if(enable-wayland) src/qt/plugins/shellintegration/qwaylandinputpanelshellintegration.cpp src/qt/plugins/shellintegration/qwaylandinputpanelshellintegration.h src/qt/plugins/shellintegration/qwaylandinputpanelsurface.cpp src/qt/plugins/shellintegration/qwaylandinputpanelsurface.h) - ecm_add_qtwayland_client_protocol(INPUT_PANEL_SHELL_SOURCES PROTOCOL ${WAYLANDPROTOCOLS_PATH}/unstable/input-method/input-method-unstable-v1.xml BASENAME input-method-unstable-v1) + ecm_add_qtwayland_client_protocol(INPUT_PANEL_SHELL_SOURCES PROTOCOL ${WaylandProtocols_DATADIR}/unstable/input-method/input-method-unstable-v1.xml BASENAME input-method-unstable-v1) add_library(inputpanel-shell MODULE ${INPUT_PANEL_SHELL_SOURCES}) target_link_libraries(inputpanel-shell Qt5::WaylandClient PkgConfig::XKBCOMMON Wayland::Client) @@ -320,7 +320,7 @@ if(enable-wayland) src/gtk/plugins/im-module/gtkimcontextwayland.c src/gtk/plugins/im-module/gtkimcontextwayland.h src/gtk/plugins/im-module/imwayland.c) - ecm_add_wayland_client_protocol(IM_WAYLAND_SOURCES PROTOCOL ${WAYLANDPROTOCOLS_PATH}/unstable/text-input/text-input-unstable-v1.xml BASENAME text-input-unstable-v1) + ecm_add_wayland_client_protocol(IM_WAYLAND_SOURCES PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v1.xml BASENAME text-input-unstable-v1) target_sources(im-wayland PRIVATE ${IM_WAYLAND_SOURCES}) target_link_libraries(im-wayland Gtk3::Gtk) endif() diff --git a/cmake/FindWaylandProtocols.cmake b/cmake/FindWaylandProtocols.cmake index a7882376..a4449885 100644 --- a/cmake/FindWaylandProtocols.cmake +++ b/cmake/FindWaylandProtocols.cmake @@ -1,39 +1,38 @@ -#.rst: -# FindWaylandProtocols -# ------- +# SPDX-FileCopyrightText: 2019 Vlad Zahorodnii # -# Find wayland protocol description files -# -# Try to find wayland protocol files. The following values are defined -# -# :: -# -# WAYLANDPROTOCOLS_FOUND - True if wayland protocol files are available -# WAYLANDPROTOCOLS_PATH - Path to wayland protocol files -# -#============================================================================= -# Copyright (c) 2015 Jari Vetoniemi -# -# Distributed under the OSI-approved BSD License (the "License"); -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= +# SPDX-License-Identifier: BSD-3-Clause -include(FeatureSummary) -set_package_properties(WaylandProtocols PROPERTIES - URL "https://cgit.freedesktop.org/wayland/wayland-protocols" - DESCRIPTION "Wayland protocol development") +#[=======================================================================[.rst: +FindWaylandProtocols +-------------------- + +Try to find wayland-protocols on a Unix system. + +This will define the following variables: + +``WaylandProtocols_FOUND`` + True if (the requested version of) wayland-protocols is available +``WaylandProtocols_VERSION`` + The version of wayland-protocols +``WaylandProtocols_DATADIR`` + The wayland protocols data directory +#]=======================================================================] -unset(WAYLANDPROTOCOLS_PATH) +find_package(PkgConfig QUIET) +pkg_check_modules(PKG_wayland_protocols QUIET wayland-protocols) -find_package(PkgConfig) -if (PKG_CONFIG_FOUND) - execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols - OUTPUT_VARIABLE WAYLANDPROTOCOLS_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) -endif () +set(WaylandProtocols_VERSION ${PKG_wayland_protocols_VERSION}) +pkg_get_variable(WaylandProtocols_DATADIR wayland-protocols pkgdatadir) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(WaylandProtocols DEFAULT_MSG WAYLANDPROTOCOLS_PATH) -mark_as_advanced(WAYLANDPROTOCOLS_PATH) \ No newline at end of file +find_package_handle_standard_args(WaylandProtocols + FOUND_VAR WaylandProtocols_FOUND + REQUIRED_VARS WaylandProtocols_DATADIR + VERSION_VAR WaylandProtocols_VERSION +) + +include(FeatureSummary) +set_package_properties(WaylandProtocols PROPERTIES + DESCRIPTION "Specifications of extended Wayland protocols" + URL "https://wayland.freedesktop.org/" +) From 54c396d6697ebb2476d4e88ded0e6b7f5e555c16 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Fri, 22 Apr 2022 12:04:23 +0200 Subject: [PATCH 2/2] Support resizing the input panel when using Wayland This relies on a new "configure" event that has been added to the input-panel-surface-v1 protocol, which allows the compositor to request a new size for the input panel. This is primarily intended to allow the compositor to position the panel in such a way that it avoids things like task managers. --- .../qwaylandinputpanelsurface.cpp | 24 ++++++++++++++++++- .../qwaylandinputpanelsurface.h | 8 +++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/qt/plugins/shellintegration/qwaylandinputpanelsurface.cpp b/src/qt/plugins/shellintegration/qwaylandinputpanelsurface.cpp index f5e6210a..8186e265 100644 --- a/src/qt/plugins/shellintegration/qwaylandinputpanelsurface.cpp +++ b/src/qt/plugins/shellintegration/qwaylandinputpanelsurface.cpp @@ -26,7 +26,6 @@ QWaylandInputPanelSurface::QWaylandInputPanelSurface(struct ::zwp_input_panel_su , QtWayland::zwp_input_panel_surface_v1(object) { qCDebug(qLcQpaShellIntegration) << Q_FUNC_INFO; - window->applyConfigureWhenPossible(); } QWaylandInputPanelSurface::~QWaylandInputPanelSurface() @@ -37,6 +36,29 @@ QWaylandInputPanelSurface::~QWaylandInputPanelSurface() void QWaylandInputPanelSurface::applyConfigure() { set_toplevel(window()->waylandScreen()->output(), position_center_bottom); + window()->resizeFromApplyConfigure(m_pendingSize); +} + +bool QWaylandInputPanelSurface::isExposed() const +{ + return m_configured; +} + +void QWaylandInputPanelSurface::zwp_input_panel_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) +{ + ack_configure(serial); + + m_pendingSize = QSize(width, height); + + if (!m_configured) { + m_configured = true; + window()->resizeFromApplyConfigure(m_pendingSize); + window()->handleExpose(QRect(QPoint(), m_pendingSize)); + } else { + // Later configures are resizes, so we have to queue them up for a time when we + // are not painting to the window. + window()->applyConfigureWhenPossible(); + } } } diff --git a/src/qt/plugins/shellintegration/qwaylandinputpanelsurface.h b/src/qt/plugins/shellintegration/qwaylandinputpanelsurface.h index 2791d3fa..ea8686c7 100644 --- a/src/qt/plugins/shellintegration/qwaylandinputpanelsurface.h +++ b/src/qt/plugins/shellintegration/qwaylandinputpanelsurface.h @@ -30,6 +30,14 @@ class QWaylandInputPanelSurface : public QWaylandShellSurface, public QtWayland: ~QWaylandInputPanelSurface() override; void applyConfigure() override; + + bool isExposed() const override; + +private: + void zwp_input_panel_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override; + + QSize m_pendingSize; + bool m_configured = false; }; }