[MPlayer-dev-eng] [PATCH] GUI cursor control
Ingo Brückl
ib at wupperonline.de
Mon Sep 12 12:58:58 CEST 2011
Reimar Döffinger wrote on Sun, 11 Sep 2011 11:31:29 +0200:
> On Sat, Sep 10, 2011 at 02:05:02PM +0200, Ingo Brückl wrote:
>>
>> +void vo_x11_handle_autohide_cursor(Display * dpy, Window win, int show)
> Could you please add a bit of doxygen documentation?
> Because the function signature might actually look like it would
> work properly for multiple windows,
Something like this (or is the \syntax - used throughout x11_common -
preferred)?
/**
* @brief Handle appearance and automatic hiding of the cursor.
*
* @param dpy display
* @param win window
* @param show flag indicating whether to show the cursor (anything but 0)
* or whether to hide it if display time has elapsed (0)
*
* @note Only one window will be handled at a time, i.e. after a cursor has
* been shown on a window it only can be hidden from the window if
* display time has elapsed, but not be shown on a second one.
*/
> due to the mouse_timer/mouse_waiting_hide variables being shared it will
> actually break quite badly if someone ever tried to use it on multiple
> windows at the same time.
We could prevent this, but it would blow up the code (untested, but should
work):
void vo_x11_handle_autohide_cursor(Display * dpy, Window win, int show)
{
static unsigned int mouse_timer;
static int mouse_waiting_hide;
+ static Window mouse_win = None;
- if (show) {
+ if (show && (mouse_win == None)) {
vo_showcursor(dpy, win);
+ mouse_win = win;
mouse_waiting_hide = 1;
mouse_timer = GetTimerMS();
- } else if (mouse_waiting_hide && (GetTimerMS() - mouse_timer >= 1000)) {
+ } else if (mouse_waiting_hide && (win == mouse_win) && (GetTimerMS() - mouse_timer >= 1000)) {
vo_hidecursor(dpy, win);
+ mouse_win = None;
mouse_waiting_hide = 0;
}
}
Considering everything discussed so far, wouldn't it be better to just patch
vo_hidecursor() and vo_showcursor() (and copy the few autohide lines - as
they currently are, not as separate function - to the GUI code):
Index: libvo/x11_common.c
===================================================================
--- libvo/x11_common.c (revision 34097)
+++ libvo/x11_common.c (working copy)
@@ -186,7 +186,7 @@
Colormap colormap;
static char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
- if (WinID == 0)
+ if (WinID >= 0)
return; // do not hide if playing on the root window
colormap = DefaultColormap(disp, DefaultScreen(disp));
@@ -205,7 +205,7 @@
static void vo_showcursor(Display * disp, Window win)
{
- if (WinID == 0)
+ if (WinID >= 0)
return;
XDefineCursor(disp, win, 0);
}
We won't do (cursor-wise) with a given window then what we don't do with the
root window. Seems far less complex to me.
Ingo
More information about the MPlayer-dev-eng
mailing list