changeset 34083:0a44fc1d4e72

Simplify wsAutohideCursor(). Use window pointer as the flag. This enables omitting the parameter to the function and doesn't require a special note on the usage, because misuse isn't possible any longer.
author ib
date Sat, 01 Oct 2011 15:32:04 +0000
parents 9e90daeb37d4
children b77b5e7bee72
files gui/interface.c gui/wm/ws.c gui/wm/ws.h
diffstat 3 files changed, 10 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/gui/interface.c	Sat Oct 01 15:12:54 2011 +0000
+++ b/gui/interface.c	Sat Oct 01 15:32:04 2011 +0000
@@ -350,7 +350,7 @@
     case GUI_HANDLE_EVENTS:
         if (!guiInfo.Playing || !guiInfo.VideoWindow)
             wsHandleEvents();
-        wsAutohideCursor(&guiApp.subWindow);
+        wsAutohideCursor();
         gtkEventHandling();
         break;
 
--- a/gui/wm/ws.c	Sat Oct 01 15:12:54 2011 +0000
+++ b/gui/wm/ws.c	Sat Oct 01 15:32:04 2011 +0000
@@ -68,7 +68,7 @@
 
 #define MOUSEHIDE_DELAY 1000   // in milliseconds
 
-static Bool mouse_hide;
+static wsTWindow *mouse_win;
 static unsigned int mouse_time;
 
 typedef struct {
@@ -644,16 +644,12 @@
 
 /**
  * @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)
+void wsAutohideCursor(void)
 {
-    if (mouse_hide && (GetTimerMS() - mouse_time >= MOUSEHIDE_DELAY)) {
-        wsVisibleMouse(win, wsHideMouseCursor);
-        mouse_hide = False;
+    if (mouse_win && (GetTimerMS() - mouse_time >= MOUSEHIDE_DELAY)) {
+        wsVisibleMouse(mouse_win, wsHideMouseCursor);
+        mouse_win = NULL;
     }
 }
 
@@ -862,7 +858,7 @@
         }
         if (wsWindowList[l]->wsCursor != None) {
             wsVisibleMouse(wsWindowList[l], wsShowMouseCursor);
-            mouse_hide = True;
+            mouse_win  = wsWindowList[l];
             mouse_time = GetTimerMS();
         }
         goto buttonreleased;
@@ -871,7 +867,7 @@
         i = Event->xbutton.button + 128;
         if (wsWindowList[l]->wsCursor != None) {
             wsVisibleMouse(wsWindowList[l], wsShowMouseCursor);
-            mouse_hide = True;
+            mouse_win  = wsWindowList[l];
             mouse_time = GetTimerMS();
         }
         goto buttonreleased;
@@ -880,7 +876,7 @@
         i = Event->xbutton.button;
         if (wsWindowList[l]->wsCursor != None) {
             wsVisibleMouse(wsWindowList[l], wsShowMouseCursor);
-            mouse_hide = True;
+            mouse_win  = wsWindowList[l];
             mouse_time = GetTimerMS();
         }
         goto buttonreleased;
--- a/gui/wm/ws.h	Sat Oct 01 15:12:54 2011 +0000
+++ b/gui/wm/ws.h	Sat Oct 01 15:32:04 2011 +0000
@@ -216,7 +216,7 @@
 
 void wsDoExit(void);
 void wsMainLoop(void);
-void wsAutohideCursor(wsTWindow *win);
+void wsAutohideCursor(void);
 Bool wsEvents(Display *display, XEvent *Event);
 void wsHandleEvents(void);