Skip to content

Commit c5fe1a4

Browse files
committedSep 18, 2019
[maliit] Set the opaque region of the window to same as the input region. Contributes to JB#47331
1 parent 980c6aa commit c5fe1a4

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed
 

‎maliit-framework/connection/libmaliit-connection.pri

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ INCLUDEPATH += $$TOP_DIR/connection $$OUT_PWD/$$TOP_DIR/connection
1111

1212
QT += dbus
1313

14-
wayland {
14+
wayland|lipstick {
1515
CONFIG += link_pkgconfig
1616
PKGCONFIG += wayland-client
1717
}

‎maliit-framework/src/lipstickplatform.cpp

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* * This file is part of Maliit framework *
22
*
33
* Copyright (C) 2013 Jolla Ltd.
4+
* Copyright (C) 2019 Open Mobile Platform LLC.
45
*
56
* Contact: maliit-discuss@lists.maliit.org
67
*
@@ -17,9 +18,32 @@
1718
#include <QPlatformSurfaceEvent>
1819
#include <qpa/qplatformnativeinterface.h>
1920

21+
#include <wayland-client.h>
22+
2023
namespace Maliit
2124
{
2225

26+
static void setWaylandInputRegion(QPlatformNativeInterface *wliface, QWindow *window, const QRegion &region)
27+
{
28+
if (wl_compositor *wlcompositor = static_cast<wl_compositor *>(
29+
wliface->nativeResourceForIntegration("compositor"))) {
30+
if (wl_surface *wlsurface = static_cast<wl_surface *>(
31+
wliface->nativeResourceForWindow("surface", window))) {
32+
wl_region *wlregion = wl_compositor_create_region(wlcompositor);
33+
34+
for (const QRect &rect : region.rects()) {
35+
wl_region_add(wlregion, rect.x(), rect.y(), rect.width(), rect.height());
36+
}
37+
38+
wl_surface_set_input_region(wlsurface, wlregion);
39+
wl_surface_set_opaque_region(wlsurface, wlregion);
40+
wl_region_destroy(wlregion);
41+
42+
wl_surface_commit(wlsurface);
43+
}
44+
}
45+
}
46+
2347
class LipstickWindowPropertyBroadcaster : public QObject
2448
{
2549
public:
@@ -45,6 +69,8 @@ class LipstickWindowPropertyBroadcaster : public QObject
4569

4670
native->setWindowProperty(handle, QStringLiteral("CATEGORY"), QStringLiteral("overlay"));
4771
native->setWindowProperty(handle, QStringLiteral("MOUSE_REGION"), m_window->property("MOUSE_REGION"));
72+
73+
setWaylandInputRegion(native, m_window, m_window->property("MOUSE_REGION").value<QRegion>());
4874
}
4975
return false;
5076
}
@@ -56,6 +82,7 @@ class LipstickWindowPropertyBroadcaster : public QObject
5682
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
5783

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

76103
void LipstickPlatform::setInputRegion(QWindow* window, const QRegion& region)
77104
{
78-
window->setProperty("MOUSE_REGION", region);
79105
window->setMask(region);
106+
window->setProperty("MOUSE_REGION", region);
80107
}
81108

82109
} // namespace Maliit

‎rpm/maliit-framework-wayland.spec

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ BuildRequires: pkgconfig(Qt5DBus)
1818
BuildRequires: pkgconfig(Qt5Quick)
1919
BuildRequires: pkgconfig(Qt5Test)
2020
BuildRequires: pkgconfig(libudev)
21+
BuildRequires: pkgconfig(wayland-client)
2122
BuildRequires: fdupes
2223
BuildRequires: pkgconfig(qt5-boostable)
2324
BuildRequires: pkgconfig(contextkit-statefs)

0 commit comments

Comments
 (0)