changeset 34551:4f7637d076a4

Support -wid for vo_sdl.
author reimar
date Sun, 29 Jan 2012 16:27:46 +0000
parents 41574d60dc98
children d78200e50c03
files libvo/sdl_common.c
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/sdl_common.c	Sat Jan 28 14:55:15 2012 +0000
+++ b/libvo/sdl_common.c	Sun Jan 29 16:27:46 2012 +0000
@@ -55,9 +55,18 @@
 {
     reinit = 0;
 
-    if (!SDL_WasInit(SDL_INIT_VIDEO) &&
-        SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0)
-        return 0;
+    if (!SDL_WasInit(SDL_INIT_VIDEO)) {
+        // Unfortunately SDL_WINDOWID must be set at SDL_Init
+        // and is ignored afterwards, thus it cannot work per-file.
+        // Also, a value of 0 does not work for selecting the root window.
+        if (WinID > 0) {
+            char envstr[20];
+            snprintf(envstr, sizeof(envstr), "0x%"PRIx64, WinID);
+            setenv("SDL_WINDOWID", envstr, 1);
+        }
+        if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0)
+            return 0;
+    }
 
     // Setup Keyrepeats (500/30 are defaults)
     SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 100 /*SDL_DEFAULT_REPEAT_INTERVAL*/);