Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb42563' into 'master'
[maliit] Don't block touch events outside the visible part of the keyboard. Contributes to JB#42563

See merge request mer-core/maliit-framework!6
  • Loading branch information
adenexter committed Aug 24, 2018
2 parents cd3f65f + 84e2073 commit b27f98f
Showing 1 changed file with 52 additions and 6 deletions.
58 changes: 52 additions & 6 deletions maliit-framework/src/lipstickplatform.cpp
Expand Up @@ -14,23 +14,69 @@
#include "lipstickplatform.h"

#include <QGuiApplication>
#include <QPlatformSurfaceEvent>
#include <qpa/qplatformnativeinterface.h>

namespace Maliit
{

class LipstickWindowPropertyBroadcaster : public QObject
{
public:
LipstickWindowPropertyBroadcaster(QWindow *window)
: QObject(window)
, m_window(window)
{
m_window->installEventFilter(this);
}

bool eventFilter(QObject *object, QEvent *event)
{
if (object != m_window) {
return false;
} else switch (event->type()) {
case QEvent::PlatformSurface: {
QPlatformSurfaceEvent *platformEvent = static_cast<QPlatformSurfaceEvent *>(event);

if (QPlatformWindow *handle = platformEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated
? m_window->handle()
: nullptr) {
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();

native->setWindowProperty(handle, QStringLiteral("CATEGORY"), QStringLiteral("overlay"));
native->setWindowProperty(handle, QStringLiteral("MOUSE_REGION"), m_window->property("MOUSE_REGION"));
}
return false;
}
case QEvent::DynamicPropertyChange: {
QDynamicPropertyChangeEvent *propertyEvent = static_cast<QDynamicPropertyChangeEvent *>(event);
if (QPlatformWindow *handle = propertyEvent->propertyName() == "MOUSE_REGION"
? m_window->handle()
: nullptr) {
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();

native->setWindowProperty(handle, QStringLiteral("MOUSE_REGION"), m_window->property("MOUSE_REGION"));
}
return false;
}
default:
return false;
}
}

private:
QWindow * const m_window;
};

void LipstickPlatform::setupInputPanel(QWindow* window, Maliit::Position)
{
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
window->create();
native->setWindowProperty(window->handle(), QLatin1String("CATEGORY"), QString("overlay"));
new LipstickWindowPropertyBroadcaster(window);
}

void LipstickPlatform::setInputRegion(QWindow* window, const QRegion& region)
{
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
window->create();
native->setWindowProperty(window->handle(), QLatin1String("MOUSE_REGION"), QVariant(region));
window->setProperty("MOUSE_REGION", region);
window->setMask(region);
}

} // namespace Maliit

0 comments on commit b27f98f

Please sign in to comment.