QPrompt-Teleprompter icon indicating copy to clipboard operation
QPrompt-Teleprompter copied to clipboard

Auto-hide mouse cursor after 3 seconds of stillness while prompting

Open Cuperino opened this issue 1 year ago • 4 comments

Request

[..] there is a cross symbol for the mouse and it sits on top of the text and moves if I move the mouse. I currently just move it to the bottom so that the client does not see it in their prompter glass. If it could be made to go away after 2-3 seconds or so of no mouse movement and come back if mouse movement.

Planned Solution

Use a transparent blank image to make all cursors invisible until its changed back:

QGuiApplication::setOverrideCursor(QCursor(QPixmap("invisibleCursorImage.png"));

Method to run the following code to restore normal cursor behavior:

QGuiApplication::restoreOverrideCursor();

Restore cursors when:

  • mouse is moved and mode is countdown or prompting
  • enter any mode that isn't countdown or prompting

Cancel previous timer if it exists when:

  • mouse is moved and mode is countdown or prompting
  • enter any mode that isn't countdown or prompting

Set 3 second countdown to make cursor blank when:

  • mouse is moved and mode is countdown or prompting
  • entering countdown mode
  • entering prompting mode

Reference

  • https://forum.qt.io/topic/101941/custom-mouse-pointer/5
  • https://forum.qt.io/topic/67650/custom-cursor/3
  • https://doc.qt.io/qt-5/qguiapplication.html#setOverrideCursor

Cuperino avatar Aug 23 '22 03:08 Cuperino

Would hiding the cursor affect animation performance?

videosmith avatar Aug 24 '22 03:08 videosmith

It should not. Mouse cursors are drawn by X11 or by the shell when you're using a Wayland session. Drawing a blank image, like I've described, should not increase nor reduce GPU processing costs.

The timer used to determine when to hide the cursor would use a separate CPU thread, so there is a small CPU cost that would have its greatest impact in systems with few cores. Nonetheless, this impact should be negligible.

Cuperino avatar Aug 24 '22 05:08 Cuperino

Would it be possible to make this a selectable option in your preferences?

videosmith avatar Aug 24 '22 15:08 videosmith

What I do to keep performance optimal is perform checks to prevent unnecessary code from running. The faster the checks and the less are needed, the better. If the feature in question doesn't cost much more than performing a settings check, there may be not be a need to make this something you can disable.

Taking the overlay contrast effect as an example, that added a big layer of semi-transparent content that needed to be composited in the GPU.

The question that needs to be answered first is, will "changing the cursor image" or "running a timer" impact performance noticeably? I think it should make no difference if the new cursor image is registered to video memory from beforehand. The timer's impact should also be negligible. The Timer object would only need to be instantiated once when entering Countdown or Prompting mode. After that, the same timer would just be reset with every mouse move, meaning no extra time is dedicated to resource allocation and de-allocation while prompting; all that is used is already in memory.

Cuperino avatar Aug 24 '22 19:08 Cuperino