Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: [ANNOUNCE] vdr-softdevice-0.0.7pre1



Here's a patch that enables automatic hiding of the cursor when using
Xv. Might not be 100% styled as the rest of the source though.

-- 
Torgeir Veimo <torgeir@pobox.com>
--- softdevice-0.0.7pre1-orig/video-xv.h	2004-05-24 11:48:53.000000000 +0100
+++ softdevice-0.0.7pre1/video-xv.h	2004-07-22 23:51:27.455819944 +0100
@@ -91,6 +92,9 @@
   Display           *dpy;
   Screen            *scn;
   Window            rwin, win;
+  Cursor            hidden_cursor;
+  Bool              cursor_visible;
+  struct timeval    prev_time, cur_time;
   int               initialized,
                     osd_refresh_counter,
                     osd_skip_counter,
--- softdevice-0.0.7pre1-orig/video-xv.c	2004-07-10 21:24:03.000000000 +0100
+++ softdevice-0.0.7pre1/video-xv.c	2004-07-22 23:57:08.947905256 +0100
@@ -288,6 +288,8 @@
     KeySym          keysym;
 
   while (XCheckMaskEvent (dpy, /* win, */
+                                 PointerMotionMask |
+                                 ButtonPressMask |
                                  KeyPressMask |
                                  ExposureMask |
                                  ConfigureNotify |
@@ -296,6 +298,15 @@
   {
     switch (event.type)
     {
+      case MotionNotify:
+      case ButtonPress:
+        if(cursor_visible == False) {
+          XUndefineCursor(dpy, win);
+          cursor_visible = True;
+        }
+        gettimeofday(&prev_time, NULL);
+        cur_time.tv_sec = prev_time.tv_sec;
+        break;
       case ConfigureNotify:
         dwidth = event.xconfigure.width;
         dheight = event.xconfigure.height;
@@ -309,6 +320,13 @@
         CheckAspect (current_afd, old_aspect);
         break;
       case KeyPress:
+        if(cursor_visible == False) {
+          XUndefineCursor(dpy, win);
+          cursor_visible = True;
+        }
+        gettimeofday(&prev_time, NULL);
+	cur_time.tv_sec = prev_time.tv_sec;
+
         len = XLookupString (&event. xkey, buffer, 80, &keysym, &compose);
         switch (keysym)
         {
@@ -366,8 +384,8 @@
             }
             break;
         }
-
         break;
+
       case MapNotify:
         XvShmPutImage(dpy, port,
                       win, gc,
@@ -381,11 +399,22 @@
         break;
       case UnmapNotify:
         XvStopVideo (dpy,port,win);
+        if(cursor_visible == False) {
+          XUndefineCursor(dpy, win);
+          cursor_visible = True;
+        }
         break;
       default:
         break;
     }
   }
+  if(cursor_visible == True) {
+    gettimeofday(&prev_time, NULL);
+    if(prev_time.tv_sec - cur_time.tv_sec >= 2) {
+      XDefineCursor(dpy, win, hidden_cursor);
+      cursor_visible = False;
+    }
+  }
 }
 
 /* ---------------------------------------------------------------------------
@@ -497,12 +526,30 @@
                    &hints, &wmhints, NULL);
 
   XSelectInput(dpy, win, KeyPressMask | ExposureMask |
-                         ConfigureNotify | StructureNotifyMask);
+                         ConfigureNotify | StructureNotifyMask |
+                         PointerMotionMask | ButtonPressMask);
+
   XMapRaised(dpy, win);
   XNextEvent(dpy, &event);
 
   gc = XCreateGC(dpy, win, 0, &values);
 
+  /*
+   * Create transparent cursor
+   */
+  Pixmap cursor_mask;
+  XColor dummy_col;
+  
+  const char cursor_data[] = { 0x0 };
+  
+  cursor_mask = XCreateBitmapFromData(dpy, win, cursor_data, 1, 1);
+  hidden_cursor = XCreatePixmapCursor(dpy, cursor_mask, cursor_mask,
+				      &dummy_col, &dummy_col, 0, 0);
+  XFreePixmap(dpy, cursor_mask);
+  cursor_visible = True;
+  gettimeofday(&prev_time, NULL);
+  cur_time.tv_sec = prev_time.tv_sec;
+
   /* -----------------------------------------------------------------------
    * now let's do some OSD initialisations
    */

Home | Main Index | Thread Index