diff gui/wm/ws.c @ 34033:395a736cd075

Add cursor autohide functionality to the GUI. Utilize the code from x11_common.
author ib
date Wed, 21 Sep 2011 13:26:02 +0000
parents 5c33025ccfd8
children 8c75091726d8
line wrap: on
line diff
--- a/gui/wm/ws.c	Wed Sep 21 13:20:12 2011 +0000
+++ b/gui/wm/ws.c	Wed Sep 21 13:26:02 2011 +0000
@@ -46,6 +46,7 @@
 #include "help_mp.h"
 #include "mplayer.h"
 #include "mpbswap.h"
+#include "osdep/timer.h"
 #include "ws.h"
 #include "wsxdnd.h"
 
@@ -642,6 +643,8 @@
 
 Bool wsEvents(Display *display, XEvent *Event)
 {
+    static Bool mouse_hide;
+    static unsigned int mouse_time;
     unsigned long i = 0;
     int l;
     int x, y;
@@ -654,6 +657,11 @@
 
     wsWindowList[l]->State = 0;
 
+    if (mouse_hide && (GetTimerMS() - mouse_time >= 1000)) {
+        wsVisibleMouse(wsWindowList[l], wsHideMouseCursor);
+        mouse_hide = False;
+    }
+
     switch (Event->type) {
     case ClientMessage:
 
@@ -839,14 +847,23 @@
                 }
             }
         }
+        wsVisibleMouse(wsWindowList[l], wsShowMouseCursor);
+        mouse_hide = True;
+        mouse_time = GetTimerMS();
         goto buttonreleased;
 
     case ButtonRelease:
         i = Event->xbutton.button + 128;
+        wsVisibleMouse(wsWindowList[l], wsShowMouseCursor);
+        mouse_hide = True;
+        mouse_time = GetTimerMS();
         goto buttonreleased;
 
     case ButtonPress:
         i = Event->xbutton.button;
+        wsVisibleMouse(wsWindowList[l], wsShowMouseCursor);
+        mouse_hide = True;
+        mouse_time = GetTimerMS();
         goto buttonreleased;
 
     case EnterNotify: