1
1
/* * This file is part of Maliit framework *
2
2
*
3
3
* Copyright (C) 2013 Jolla Ltd.
4
+ * Copyright (C) 2019 Open Mobile Platform LLC.
4
5
*
5
6
* Contact: maliit-discuss@lists.maliit.org
6
7
*
17
18
#include < QPlatformSurfaceEvent>
18
19
#include < qpa/qplatformnativeinterface.h>
19
20
21
+ #include < wayland-client.h>
22
+
20
23
namespace Maliit
21
24
{
22
25
26
+ static void setWaylandInputRegion (QPlatformNativeInterface *wliface, QWindow *window, const QRegion ®ion)
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
+
23
47
class LipstickWindowPropertyBroadcaster : public QObject
24
48
{
25
49
public:
@@ -45,6 +69,8 @@ class LipstickWindowPropertyBroadcaster : public QObject
45
69
46
70
native->setWindowProperty (handle, QStringLiteral (" CATEGORY" ), QStringLiteral (" overlay" ));
47
71
native->setWindowProperty (handle, QStringLiteral (" MOUSE_REGION" ), m_window->property (" MOUSE_REGION" ));
72
+
73
+ setWaylandInputRegion (native, m_window, m_window->property (" MOUSE_REGION" ).value <QRegion>());
48
74
}
49
75
return false ;
50
76
}
@@ -56,6 +82,7 @@ class LipstickWindowPropertyBroadcaster : public QObject
56
82
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface ();
57
83
58
84
native->setWindowProperty (handle, QStringLiteral (" MOUSE_REGION" ), m_window->property (" MOUSE_REGION" ));
85
+ setWaylandInputRegion (native, m_window, m_window->property (" MOUSE_REGION" ).value <QRegion>());
59
86
}
60
87
return false ;
61
88
}
@@ -75,8 +102,8 @@ void LipstickPlatform::setupInputPanel(QWindow* window, Maliit::Position)
75
102
76
103
void LipstickPlatform::setInputRegion (QWindow* window, const QRegion& region)
77
104
{
78
- window->setProperty (" MOUSE_REGION" , region);
79
105
window->setMask (region);
106
+ window->setProperty (" MOUSE_REGION" , region);
80
107
}
81
108
82
109
} // namespace Maliit
0 commit comments