Loading...
Searching...
No Matches
WindowInputMonitor Class Reference

`#include <plugins/Utils/WindowInputMonitor.h>`

## Signals

void | homeKeyActivated ()
void | touchBegun ()
void | touchEnded (const QPointF &pos)

## Public Member Functions

| WindowInputMonitor (QQuickItem *parent=0)
| WindowInputMonitor (LomiriUtil::AbstractTimer *timer, LomiriUtil::AbstractElapsedTimer *elapsedTimer, QQuickItem *parent=0)
bool | eventFilter (QObject *watched, QEvent *event) override
void | update (QEvent *event)

## Public Attributes

const qint64 | msecsWithoutTouches = 150

## Detailed Description

Monitors input events received by the window holding this item and the Home (Win aka Super_L) key presses.

Additionally, this class monitors for generic touch events on the screen, to help with hiding/revealing the mouse pointer.

Definition at line 34 of file WindowInputMonitor.h.

## Constructor & Destructor Documentation

## WindowInputMonitor() [1/2]

WindowInputMonitor::WindowInputMonitor | ( | QQuickItem * | parent = 0 | ) |

Definition at line 23 of file WindowInputMonitor.cpp.

: WindowInputMonitor(new Timer, new ElapsedTimer, parent)
{
}

## WindowInputMonitor() [2/2]

WindowInputMonitor::WindowInputMonitor | ( | LomiriUtil::AbstractTimer * | timer,
|  | LomiriUtil::AbstractElapsedTimer * | elapsedTimer,
|  | QQuickItem * | parent = 0 )

Definition at line 28 of file WindowInputMonitor.cpp.

: QQuickItem(parent)
, m_windowBeingTouched(false)
, m_windowLastTouchedTimer(elapsedTimer)
, m_activationTimer(timer)
{
m_windowLastTouchedTimer->start();
connect(this, &QQuickItem::windowChanged,
this, &WindowInputMonitor::setupFilterOnWindow);
connect(m_activationTimer, &LomiriUtil::AbstractTimer::timeout,
this, &WindowInputMonitor::emitActivatedIfNoTouchesAround);
m_activationTimer->setInterval(msecsWithoutTouches);
m_activationTimer->setSingleShot(true);
}

## ~WindowInputMonitor()

WindowInputMonitor::~WindowInputMonitor | ( |  | ) |

virtual

Definition at line 47 of file WindowInputMonitor.cpp.

{
delete m_windowLastTouchedTimer;
delete m_activationTimer;
}

## Member Function Documentation

## eventFilter()

bool WindowInputMonitor::eventFilter | ( | QObject * | watched,
|  | QEvent * | event )

override

Definition at line 53 of file WindowInputMonitor.cpp.

{
Q_ASSERT(!m_filteredWindow.isNull());
Q_ASSERT(watched == static_cast<QObject*>(m_filteredWindow.data()));
Q_UNUSED(watched);
update(event);
// We're only monitoring, never filtering out events
return false;
}

## homeKeyActivated

void WindowInputMonitor::homeKeyActivated | ( |  | ) |

signal

Emitted when the home key has been intentionally tapped

It only says the home key has been activated if it has been tapped in isolation, that is, without being accompanied by touches on the screen. Home key taps that happen along with (or immediately after, or immediately before) touches on the screen are considered to have happened unintentionally and are thus ignored.

Rationale being that it's easy to accidentally hit the home key while performing a swipe from a screen edge, for instance. That's particularly the case when the home key is a capacitive key.

## touchBegun

void WindowInputMonitor::touchBegun | ( |  | ) |

signal

Emitted when a touch begin event is detected

## touchEnded

void WindowInputMonitor::touchEnded | ( | const QPointF & | pos | ) |

signal

Emitted when a touch end event is detected

Parameters

  pos | the position in screen coordinates

## update()

void WindowInputMonitor::update | ( | QEvent * | event | ) |

Definition at line 65 of file WindowInputMonitor.cpp.

{
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (m_pressedHomeKey == 0 && m_homeKeys.contains(keyEvent->key()) && !keyEvent->isAutoRepeat()
&& !m_activationTimer->isRunning()
&& !m_windowBeingTouched
&& m_windowLastTouchedTimer->elapsed() >= msecsWithoutTouches) {
m_pressedHomeKey = keyEvent->key();
m_activationTimer->start();
} else if (m_pressedHomeKey != 0 && !m_homeKeys.contains(keyEvent->key())) {
// something else came in... cancel activation
m_activationTimer->stop();
}
} else if (event->type() == QEvent::KeyRelease) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == m_pressedHomeKey) {
m_pressedHomeKey = 0;
}
} else if (event->type() == QEvent::TouchBegin) {
m_activationTimer->stop();
m_windowBeingTouched = true;
Q_EMIT touchBegun();
} else if (event->type() == QEvent::TouchEnd) {
m_windowBeingTouched = false;
m_windowLastTouchedTimer->start();
QTouchEvent * touchEv = static_cast<QTouchEvent *>(event);
if (touchEv && !touchEv->touchPoints().isEmpty()) {
const QPointF pos = touchEv->touchPoints().last().screenPos();
Q_EMIT touchEnded(pos);
}
}
}
WindowInputMonitor::touchEnded
void touchEnded(const QPointF &pos)
WindowInputMonitor::touchBegun
void touchBegun()

## Member Data Documentation

## msecsWithoutTouches

const qint64 WindowInputMonitor::msecsWithoutTouches = 150

Definition at line 52 of file WindowInputMonitor.h.

The documentation for this class was generated from the following files:

- plugins/Utils/WindowInputMonitor.h
- plugins/Utils/WindowInputMonitor.cpp