From 2066a4899588bd83d2ee2dd8a8c94124a72572c4 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Mon, 25 May 2026 08:26:52 +0200 Subject: [PATCH] Allow multiple shell input regions A unified chrome surface needs separate interactive areas for the top bar and dock while the workspace passes input through. Add ShellUtil::setInputRegions() and keep setInputRegion() as the compatibility wrapper. --- components/mobileshell/shellutil.cpp | 21 ++++++++++++++++++--- components/mobileshell/shellutil.h | 8 ++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/components/mobileshell/shellutil.cpp b/components/mobileshell/shellutil.cpp index 8bbc1837..4fabaf69 100644 --- a/components/mobileshell/shellutil.cpp +++ b/components/mobileshell/shellutil.cpp @@ -121,12 +121,22 @@ void ShellUtil::setWindowLayer(QQuickWindow *window, LayerShellQt::Window::Layer } void ShellUtil::setInputRegion(QWindow *window, const QRect ®ion) +{ + setInputRegions(window, region.isEmpty() ? QVariantList{} : QVariantList{region}); +} + +void ShellUtil::setInputRegions(QWindow *window, const QVariantList ®ions) { if (!window) { return; } - auto waylandWindow = dynamic_cast(window->handle()); + auto handle = window->handle(); + if (!handle) { + return; + } + + auto waylandWindow = dynamic_cast(handle); if (!waylandWindow) { qWarning() << "Failed to retrieve Wayland window handle."; return; @@ -150,12 +160,17 @@ void ShellUtil::setInputRegion(QWindow *window, const QRect ®ion) return; } - if (region.isEmpty()) { + if (regions.isEmpty()) { wl_surface_set_input_region(surface, nullptr); } else { wl_region *inputRegion = wl_compositor_create_region(compositorResource); - wl_region_add(inputRegion, region.x(), region.y(), region.width(), region.height()); + for (const QVariant &value : regions) { + const QRect region = value.toRect(); + if (!region.isEmpty()) { + wl_region_add(inputRegion, region.x(), region.y(), region.width(), region.height()); + } + } wl_surface_set_input_region(surface, inputRegion); wl_region_destroy(inputRegion); } diff --git a/components/mobileshell/shellutil.h b/components/mobileshell/shellutil.h index 2b6f56a1..1c67666e 100644 --- a/components/mobileshell/shellutil.h +++ b/components/mobileshell/shellutil.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -84,6 +85,13 @@ public: */ Q_INVOKABLE void setInputRegion(QWindow *window, const QRect ®ion); + /** + * Sets multiple regions where inputs will get registered on a window. + * Inputs outside the regions will pass through to the surface below. + * Set this to an empty list to fill the whole window again. + */ + Q_INVOKABLE void setInputRegions(QWindow *window, const QVariantList ®ions); + /** * Converts rich text to plain text. */