[MPlayer-cvslog] r34169 - in trunk/gui: interface.c wm/ws.c wm/ws.h

ib subversion at mplayerhq.hu
Sat Oct 1 17:09:14 CEST 2011


Author: ib
Date: Sat Oct  1 17:09:09 2011
New Revision: 34169

Log:
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.

Modified:
   trunk/gui/interface.c
   trunk/gui/wm/ws.c
   trunk/gui/wm/ws.h

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Sat Oct  1 12:20:41 2011	(r34168)
+++ trunk/gui/interface.c	Sat Oct  1 17:09:09 2011	(r34169)
@@ -350,6 +350,7 @@ int gui(int what, void *data)
     case GUI_HANDLE_EVENTS:
         if (!guiInfo.Playing || !guiInfo.VideoWindow)
             wsHandleEvents();
+        wsAutohideCursor(&guiApp.subWindow);
         gtkEventHandling();
         break;
 

Modified: trunk/gui/wm/ws.c
==============================================================================
--- trunk/gui/wm/ws.c	Sat Oct  1 12:20:41 2011	(r34168)
+++ trunk/gui/wm/ws.c	Sat Oct  1 17:09:09 2011	(r34169)
@@ -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 @@ void wsDestroyWindow(wsTWindow *win)
 #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 @@ Bool wsEvents(Display *display, XEvent *
 
     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 @@ keypressed:
                 }
             }
         }
+        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:

Modified: trunk/gui/wm/ws.h
==============================================================================
--- trunk/gui/wm/ws.h	Sat Oct  1 12:20:41 2011	(r34168)
+++ trunk/gui/wm/ws.h	Sat Oct  1 17:09:09 2011	(r34169)
@@ -216,6 +216,7 @@ int wsGetDepthOnScreen(void);
 
 void wsDoExit(void);
 void wsMainLoop(void);
+void wsAutohideCursor(wsTWindow *win);
 Bool wsEvents(Display *display, XEvent *Event);
 void wsHandleEvents(void);
 


More information about the MPlayer-cvslog mailing list