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.
This commit is contained in:
Marco Allegretti 2026-05-25 08:26:52 +02:00
parent 07f3a46d4b
commit 2066a48995
2 changed files with 26 additions and 3 deletions

View file

@ -121,12 +121,22 @@ void ShellUtil::setWindowLayer(QQuickWindow *window, LayerShellQt::Window::Layer
}
void ShellUtil::setInputRegion(QWindow *window, const QRect &region)
{
setInputRegions(window, region.isEmpty() ? QVariantList{} : QVariantList{region});
}
void ShellUtil::setInputRegions(QWindow *window, const QVariantList &regions)
{
if (!window) {
return;
}
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle());
auto handle = window->handle();
if (!handle) {
return;
}
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(handle);
if (!waylandWindow) {
qWarning() << "Failed to retrieve Wayland window handle.";
return;
@ -150,12 +160,17 @@ void ShellUtil::setInputRegion(QWindow *window, const QRect &region)
return;
}
if (region.isEmpty()) {
if (regions.isEmpty()) {
wl_surface_set_input_region(surface, nullptr);
} else {
wl_region *inputRegion = wl_compositor_create_region(compositorResource);
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);
}

View file

@ -10,6 +10,7 @@
#include <QObject>
#include <QQuickItem>
#include <QQuickWindow>
#include <QVariantList>
#include <qqmlregistration.h>
#include <KConfigWatcher>
@ -84,6 +85,13 @@ public:
*/
Q_INVOKABLE void setInputRegion(QWindow *window, const QRect &region);
/**
* 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 &regions);
/**
* Converts rich text to plain text.
*/