diff gui/wm/ws.c @ 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 7777da659cbe
line wrap: on
line diff
--- 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;