[Mplayer-commits] r154 - trunk/libvo

serge at garage.maemo.org serge at garage.maemo.org
Wed Mar 21 17:02:27 EET 2007


Author: serge
Date: 2007-03-21 17:02:27 +0200 (Wed, 21 Mar 2007)
New Revision: 154

Modified:
   trunk/libvo/vo_nokia770.c
Log:
Tap on 'close window icon' is now intercepted and mapped to ESC key,
providing a clean and safe exit. Older versions were just violently killed 
by trying to close mplayer this way, keeping video surfaces in inconsistent 
state and forcing the user to reboot. Almost all this code was taken from 
Allegro game programing library sources.

Modified: trunk/libvo/vo_nokia770.c
===================================================================
--- trunk/libvo/vo_nokia770.c	2007-03-21 14:54:48 UTC (rev 153)
+++ trunk/libvo/vo_nokia770.c	2007-03-21 15:02:27 UTC (rev 154)
@@ -172,6 +172,9 @@
 static int screen_num; // number of screen to place the window on.
 static Window win; // pointer to the newly created window.
 
+/* This is used to intercept window closing requests.  */
+static Atom wm_delete_window;
+
 /**
  * Function that controls fullscreen state for x11 window
  * action = 1 (set fullscreen)
@@ -235,6 +238,10 @@
 
     XMapWindow(display, win);
 
+    /* Set WM_DELETE_WINDOW atom in WM_PROTOCOLS property (to get window_delete requests).  */
+    wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
+    XSetWMProtocols(display, win, &wm_delete_window, 1);
+
     XSelectInput(display, win, ExposureMask | VisibilityChangeMask | KeyPressMask);
 }
 
@@ -328,6 +335,11 @@
                     mp_msg(MSGT_VO, MSGL_ERR, "[nokia770] unexpected key pressed: %d\n", key);
                     break;
             }
+        } else if (Event.type == ClientMessage) {
+            /* Window close request */
+            if ((Atom)Event.xclient.data.l[0] == wm_delete_window) {
+                mplayer_put_key(KEY_ESC);
+            }
         }
     }
     return ret;



More information about the Mplayer-commits mailing list