changeset 35652:f6c00eacd816

Add wsMapWait(). This waits for a map notify event which is required in order to paint into the window. Remove the waiting loop in interface.c and set a corresponding property for the video window which, now, will regard vo_keepaspect. This also closes Bugzilla #1357.
author ib
date Tue, 15 Jan 2013 11:54:22 +0000
parents ebaac70ff6dc
children 59a6b817a287
files gui/interface.c gui/wm/ws.c gui/wm/ws.h
diffstat 3 files changed, 21 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/gui/interface.c	Tue Jan 15 09:41:34 2013 +0000
+++ b/gui/interface.c	Tue Jan 15 11:54:22 2013 +0000
@@ -172,7 +172,7 @@
     if (guiWinID >= 0)
         guiApp.mainWindow.Parent = guiWinID;
 
-    wsCreateWindow(&guiApp.videoWindow, guiApp.video.x, guiApp.video.y, guiApp.video.width, guiApp.video.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsHideWindow, "MPlayer - Video");
+    wsCreateWindow(&guiApp.videoWindow, guiApp.video.x, guiApp.video.y, guiApp.video.width, guiApp.video.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsHideWindow | wsWaitMap, "MPlayer - Video");
     wsDestroyImage(&guiApp.videoWindow);
     wsCreateImage(&guiApp.videoWindow, guiApp.video.Bitmap.Width, guiApp.video.Bitmap.Height);
     wsXDNDMakeAwareness(&guiApp.videoWindow);
@@ -224,16 +224,8 @@
     if (gtkShowVideoWindow) {
         wsVisibleWindow(&guiApp.videoWindow, wsShowWindow);
 
-        {
-            XEvent xev;
-
-            do
-                XNextEvent(wsDisplay, &xev);
-            while (xev.type != MapNotify || xev.xmap.event != guiApp.videoWindow.WindowID);
-
             guiApp.videoWindow.Mapped = wsMapped;
             guiInfo.VideoWindow       = True;
-        }
 
         if (gtkLoadFullscreen)
             uiFullScreen();
--- a/gui/wm/ws.c	Tue Jan 15 09:41:34 2013 +0000
+++ b/gui/wm/ws.c	Tue Jan 15 11:54:22 2013 +0000
@@ -490,6 +490,21 @@
     XSetWMNormalHints(wsDisplay, win->WindowID, &win->SizeHint);
 }
 
+/**
+ * @brief Wait until a window is mapped if its property requires it.
+ *
+ * @param win pointer to a ws window structure
+ */
+static void wsMapWait(wsTWindow *win)
+{
+    XEvent xev;
+
+    if (win->Property & wsWaitMap)
+        do
+            XNextEvent(wsDisplay, &xev);
+        while (xev.type != MapNotify || xev.xmap.event != win->WindowID);
+}
+
 // ----------------------------------------------------------------------------------------------
 //   Create window.
 //     X,Y   : window position
@@ -627,8 +642,10 @@
     win->Mapped  = wsNo;
     win->Rolled  = wsNo;
 
-    if (D & wsShowWindow)
+    if (D & wsShowWindow) {
         XMapWindow(wsDisplay, win->WindowID);
+        wsMapWait(win);
+    }
 
     wsCreateImage(win, win->Width, win->Height);
 /* End of creating -------------------------------------------------------------------------- */
@@ -1425,6 +1442,7 @@
     case wsShowWindow:
 
         XMapRaised(wsDisplay, win->WindowID);
+        wsMapWait(win);
 
         if (vo_fs_type & vo_wm_FULLSCREEN)
             win->isFullScreen = False;
--- a/gui/wm/ws.h	Tue Jan 15 09:41:34 2013 +0000
+++ b/gui/wm/ws.h	Tue Jan 15 11:54:22 2013 +0000
@@ -71,6 +71,7 @@
 #define  wsShowWindow   8
 #define  wsHideWindow   16
 #define  wsOverredirect 32
+#define  wsWaitMap      64
 
 #define  wsNoBorder 0