Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screensaver timeout not reset on mouse click #11

Open
christian523 opened this issue Aug 10, 2023 · 6 comments
Open

Screensaver timeout not reset on mouse click #11

christian523 opened this issue Aug 10, 2023 · 6 comments

Comments

@christian523
Copy link

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

@christian523 christian523 changed the title Screensaver timeout reset Screensaver timeout not reset on mouse click Aug 10, 2023
@otavio
Copy link
Member

otavio commented Aug 10, 2023

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:

InputEventHandler::InputEventHandler(QQuickItem *parent): QObject(parent)
.

@christian523
Copy link
Author

christian523 commented Aug 10, 2023

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

@otavio
Copy link
Member

otavio commented Aug 10, 2023

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?

@rafael2k
Copy link

I think I'm hitting this bug too. Any idea how to fix?
I'll take a look in this too.

@christian523
Copy link
Author

christian523 commented Sep 28, 2023

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
+#include

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);

rafael2k added a commit to Rhizomatica/qt-kiosk-browser that referenced this issue Sep 28, 2023
@rafael2k
Copy link

Thanks!
I committed this in my fork and I'm now testing:
Rhizomatica@a302a22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants