mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-06-11 00:47:22 +00:00
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:
parent
07f3a46d4b
commit
2066a48995
2 changed files with 26 additions and 3 deletions
|
|
@ -121,12 +121,22 @@ void ShellUtil::setWindowLayer(QQuickWindow *window, LayerShellQt::Window::Layer
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellUtil::setInputRegion(QWindow *window, const QRect ®ion)
|
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) {
|
if (!window) {
|
||||||
return;
|
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) {
|
if (!waylandWindow) {
|
||||||
qWarning() << "Failed to retrieve Wayland window handle.";
|
qWarning() << "Failed to retrieve Wayland window handle.";
|
||||||
return;
|
return;
|
||||||
|
|
@ -150,12 +160,17 @@ void ShellUtil::setInputRegion(QWindow *window, const QRect ®ion)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (region.isEmpty()) {
|
if (regions.isEmpty()) {
|
||||||
wl_surface_set_input_region(surface, nullptr);
|
wl_surface_set_input_region(surface, nullptr);
|
||||||
} else {
|
} else {
|
||||||
wl_region *inputRegion = wl_compositor_create_region(compositorResource);
|
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_surface_set_input_region(surface, inputRegion);
|
||||||
wl_region_destroy(inputRegion);
|
wl_region_destroy(inputRegion);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
|
#include <QVariantList>
|
||||||
#include <qqmlregistration.h>
|
#include <qqmlregistration.h>
|
||||||
|
|
||||||
#include <KConfigWatcher>
|
#include <KConfigWatcher>
|
||||||
|
|
@ -84,6 +85,13 @@ public:
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void setInputRegion(QWindow *window, const QRect ®ion);
|
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.
|
* Converts rich text to plain text.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue