[vlc-devel] [PATCH] window: add an API to show or hide the cursor over the window
Steve Lhomme
robux4 at ycbcr.xyz
Fri Apr 5 09:34:16 CEST 2019
On 4/5/2019 8:38 AM, Rémi Denis-Courmont wrote:
> This was removed on purpose for reasons already outlined. I don't
> think it should be added back.
OK, I think you're referring to https://trac.videolan.org/vlc/ticket/18661
I don't like duplicated (many times) code but in this case it kinda
makes sense. Showing the mouse has to be done ASAP when the mouse starts
moving again. I'm not sure the delay going through the core is that big
though. When the mouse moves or buttons are clicked the vout_window_t
reports it (to the core). This is done synchronously. In would call
vout_window_ShowCursor(true) right away, also synchronously. This is
exactly the same as when it's handled internally.
The timer to hide the mouse is a different story. It can tick in another
thread then the vout_window_ShowCursor(false) has to be sent
asynchronously to the UI thread. While the message is pending to be
treated the mouse could move and vout_window_ShowCursor(true) would then
be called and be treated synchronously. The "false" state will be
received after that.
That's the case where the .show_cursor() callback sets the cursor state
right away. But if we say that the callback can be sent from any thread,
it's the responsibility of the receiver to forward it properly to its UI
thread (if any). For example using an atomic bool to keep the latest
state and sending a message to the UI thread. But in that case the
cursor showing would not be done ASAP and would be treated possibly
after a lot of other messages to the UI thread, maybe even some paint
messages.
So it's a pity we have to duplicate the code but I don't see another way.
More information about the vlc-devel
mailing list