Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[maliit] Set the opaque region of the window to same as the input reg…
…ion. Contributes to JB#47331
  • Loading branch information
adenexter committed Sep 18, 2019
1 parent 980c6aa commit c5fe1a4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion maliit-framework/connection/libmaliit-connection.pri
Expand Up @@ -11,7 +11,7 @@ INCLUDEPATH += $$TOP_DIR/connection $$OUT_PWD/$$TOP_DIR/connection

QT += dbus

wayland {
wayland|lipstick {
CONFIG += link_pkgconfig
PKGCONFIG += wayland-client
}
29 changes: 28 additions & 1 deletion maliit-framework/src/lipstickplatform.cpp
@@ -1,6 +1,7 @@
/* * This file is part of Maliit framework *
*
* Copyright (C) 2013 Jolla Ltd.
* Copyright (C) 2019 Open Mobile Platform LLC.
*
* Contact: maliit-discuss@lists.maliit.org
*
Expand All @@ -17,9 +18,32 @@
#include <QPlatformSurfaceEvent>
#include <qpa/qplatformnativeinterface.h>

#include <wayland-client.h>

namespace Maliit
{

static void setWaylandInputRegion(QPlatformNativeInterface *wliface, QWindow *window, const QRegion &region)
{
if (wl_compositor *wlcompositor = static_cast<wl_compositor *>(
wliface->nativeResourceForIntegration("compositor"))) {
if (wl_surface *wlsurface = static_cast<wl_surface *>(
wliface->nativeResourceForWindow("surface", window))) {
wl_region *wlregion = wl_compositor_create_region(wlcompositor);

for (const QRect &rect : region.rects()) {
wl_region_add(wlregion, rect.x(), rect.y(), rect.width(), rect.height());
}

wl_surface_set_input_region(wlsurface, wlregion);
wl_surface_set_opaque_region(wlsurface, wlregion);
wl_region_destroy(wlregion);

wl_surface_commit(wlsurface);
}
}
}

class LipstickWindowPropertyBroadcaster : public QObject
{
public:
Expand All @@ -45,6 +69,8 @@ class LipstickWindowPropertyBroadcaster : public QObject

native->setWindowProperty(handle, QStringLiteral("CATEGORY"), QStringLiteral("overlay"));
native->setWindowProperty(handle, QStringLiteral("MOUSE_REGION"), m_window->property("MOUSE_REGION"));

setWaylandInputRegion(native, m_window, m_window->property("MOUSE_REGION").value<QRegion>());
}
return false;
}
Expand All @@ -56,6 +82,7 @@ class LipstickWindowPropertyBroadcaster : public QObject
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();

native->setWindowProperty(handle, QStringLiteral("MOUSE_REGION"), m_window->property("MOUSE_REGION"));
setWaylandInputRegion(native, m_window, m_window->property("MOUSE_REGION").value<QRegion>());
}
return false;
}
Expand All @@ -75,8 +102,8 @@ void LipstickPlatform::setupInputPanel(QWindow* window, Maliit::Position)

void LipstickPlatform::setInputRegion(QWindow* window, const QRegion& region)
{
window->setProperty("MOUSE_REGION", region);
window->setMask(region);
window->setProperty("MOUSE_REGION", region);
}

} // namespace Maliit
1 change: 1 addition & 0 deletions rpm/maliit-framework-wayland.spec
Expand Up @@ -18,6 +18,7 @@ BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Quick)
BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(wayland-client)
BuildRequires: fdupes
BuildRequires: pkgconfig(qt5-boostable)
BuildRequires: pkgconfig(contextkit-statefs)
Expand Down

0 comments on commit c5fe1a4

Please sign in to comment.