qt-kiosk-browser
qt-kiosk-browser copied to clipboard
Screensaver timeout not reset on mouse click
Currently it seems that the screensaver timer is only reset if a keyboard input is detected:
line 186 in main.qml: InputEventHandler { onTriggered: { screenSaverTimer.restart(); }
I'm using qt virtual keyboard as input device and when I simply touch the screen or touch a button/menu items of the GUI the timer is not reset. It's only reset if I select an input field and enter actual text. Is this intended or a bug?
BR, Chris
It appears that there may be a bug. Would you like to take a look and see if you can fix it? Here is the link for reference: https://github.com/OSSystems/qt-kiosk-browser/blob/5250ae592abe3cde9818a542c1c45f34630e4d9d/inputeventhandler.cpp#L13.
Otavio, Thanks for your quick response and pointing me the the issue.
Note also that all our content is generated by JavaScript in case this is relevant.
It seems to be depending on the type of input device used:
-
If you have physical keyboard and mouse, the code is fine.
-
If you use a touch controller with qt virtual keyboard, you get MouseButtonPress only when an input field is selected or if you type something with the qt virtual keyboard. If I just press some virtual buttons (or navitage though view-only content) I never get a MouseButtonPress event. Maybe a native qt application would issue a MouseButtonPress if a "native" button is pressed.
For our use case I would then replace MouseButtonPress by TouchBegin but I doubt this is a generic solution.
BR, Chris
As far as I know, since it's an input device, it might be feasible to incorporate it into the reset procedure. Could you also provide a physical keyboard case and submit a pull request, please?
I think I'm hitting this bug too. Any idea how to fix? I'll take a look in this too.
I got it working by the below. This way, both, touch screen and external physical keyboard keypresses reset the screensaver time.
diff --git a/inputeventhandler.cpp b/inputeventhandler.cpp index c496d2f..dd6bd7d 100644 --- a/inputeventhandler.cpp +++ b/inputeventhandler.cpp @@ -9,6 +9,7 @@ #include "inputeventhandler.hpp"
#include <QApplication> +#include <QDebug>
InputEventHandler::InputEventHandler(QQuickItem *parent): QObject(parent) { @@ -17,8 +18,9 @@ InputEventHandler::InputEventHandler(QQuickItem *parent): QObject(parent)
bool InputEventHandler::eventFilter(QObject *obj, QEvent *event) {
- if (event->type() == QEvent::MouseButtonPress) {
-
emit triggered();
-
if (event->type() == QEvent::TouchBegin || event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) { emit triggered(); }
return QObject::eventFilter(obj, event);
Thanks! I committed this in my fork and I'm now testing: https://github.com/Rhizomatica/qt-kiosk-browser/commit/a302a221a6fff8387e2575d6c0d4949f7436b7df