changeset 34081:66c5a04a5c32

Fix cursor autohide functionality of the GUI. There will only be calls to wsEvents() (through GUI_HANDLE_X_EVENT in x11_common.c) which handles the cursor autohide, if there are X events pending - which during normal playback isn't the case. If you happen to have configured option use-filename-title, then there will be periodical XStoreName() calls which trigger X events that keep calling GUI_HANDLE_X_EVENT as a side effect. To ensure recurring calls to the cursor autohide code in any case it has been made a separate function which is called through GUI_HANDLE_EVENTS now. GUI_HANDLE_EVENTS is periodically called by MPlayer. Additionally, only show cursor in wsEvents() (and thereby enable autohide) if it previously was hidden.
author ib
date Sat, 01 Oct 2011 15:09:09 +0000
parents 0d4741369ee1
children 9e90daeb37d4
files gui/interface.c gui/wm/ws.c gui/wm/ws.h
diffstat 3 files changed, 26 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/gui/interface.c	Sat Oct 01 10:20:41 2011 +0000
+++ b/gui/interface.c	Sat Oct 01 15:09:09 2011 +0000
@@ -350,6 +350,7 @@
     case GUI_HANDLE_EVENTS:
         if (!guiInfo.Playing || !guiInfo.VideoWindow)
             wsHandleEvents();
+        wsAutohideCursor(&guiApp.subWindow);
         gtkEventHandling();
         break;
 
--- a/gui/wm/ws.c	Sat Oct 01 10:20:41 2011 +0000
+++ b/gui/wm/ws.c	Sat Oct 01 15:09:09 2011 +0000
@@ -68,6 +68,9 @@
 
 #define MOUSEHIDE_DELAY 1000   // in milliseconds
 
+static Bool mouse_hide;
+static unsigned int mouse_time;
+
 typedef struct {
     unsigned long flags;
     unsigned long functions;
@@ -639,14 +642,27 @@
 #endif
 }
 
+/**
+ * @brief Handle automatic hiding of the cursor.
+ *
+ * @param win pointer to a ws window structure
+ *
+ * @note Only one window will be handled at a time.
+ */
+void wsAutohideCursor(wsTWindow *win)
+{
+    if (mouse_hide && (GetTimerMS() - mouse_time >= MOUSEHIDE_DELAY)) {
+        wsVisibleMouse(win, wsHideMouseCursor);
+        mouse_hide = False;
+    }
+}
+
 // ----------------------------------------------------------------------------------------------
 //   Handle events.
 // ----------------------------------------------------------------------------------------------
 
 Bool wsEvents(Display *display, XEvent *Event)
 {
-    static Bool mouse_hide;
-    static unsigned int mouse_time;
     unsigned long i = 0;
     int l;
     int x, y;
@@ -659,11 +675,6 @@
 
     wsWindowList[l]->State = 0;
 
-    if (mouse_hide && (GetTimerMS() - mouse_time >= MOUSEHIDE_DELAY)) {
-        wsVisibleMouse(wsWindowList[l], wsHideMouseCursor);
-        mouse_hide = False;
-    }
-
     switch (Event->type) {
     case ClientMessage:
 
@@ -849,23 +860,29 @@
                 }
             }
         }
+        if (wsWindowList[l]->wsCursor != None) {
         wsVisibleMouse(wsWindowList[l], wsShowMouseCursor);
         mouse_hide = True;
         mouse_time = GetTimerMS();
+        }
         goto buttonreleased;
 
     case ButtonRelease:
         i = Event->xbutton.button + 128;
+        if (wsWindowList[l]->wsCursor != None) {
         wsVisibleMouse(wsWindowList[l], wsShowMouseCursor);
         mouse_hide = True;
         mouse_time = GetTimerMS();
+        }
         goto buttonreleased;
 
     case ButtonPress:
         i = Event->xbutton.button;
+        if (wsWindowList[l]->wsCursor != None) {
         wsVisibleMouse(wsWindowList[l], wsShowMouseCursor);
         mouse_hide = True;
         mouse_time = GetTimerMS();
+        }
         goto buttonreleased;
 
     case EnterNotify:
--- a/gui/wm/ws.h	Sat Oct 01 10:20:41 2011 +0000
+++ b/gui/wm/ws.h	Sat Oct 01 15:09:09 2011 +0000
@@ -216,6 +216,7 @@
 
 void wsDoExit(void);
 void wsMainLoop(void);
+void wsAutohideCursor(wsTWindow *win);
 Bool wsEvents(Display *display, XEvent *Event);
 void wsHandleEvents(void);