summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2015-03-30 01:19:29 +1100
committerJames Ross-Gowan <rossymiles@gmail.com>2015-04-11 14:34:33 +1000
commit527911d2a2047796acd59bae03b075e4425cf73b (patch)
tree11e07919e9d81939fc8b6b44c0c6cbf79b51a3e6 /player
parentac7ecbe30cdec598955471d2ed012f36296b78de (diff)
downloadmpv-527911d2a2047796acd59bae03b075e4425cf73b.tar.bz2
mpv-527911d2a2047796acd59bae03b075e4425cf73b.tar.xz
win32: only attach to the console from mpv.com
Previously, mpv.exe used the --terminal option to decide whether to attach to the parent process's console, which made it impossible to tell whether mpv would attach to the console before the config files were parsed. Instead, make mpv always attach to the console when launched from the console wrapper (mpv.com) and never attach otherwise. This will be useful for the next commit, which will use the presence of the console to decide whether to use the pseudo-gui profile. This change should also be an improvement in behavior. The old code would attach to the parent process's console, regardless of whether it was mpv.com or some other program like cmd.exe. This could be confusing, since mpv.exe is marked as a Windows GUI program and shouldn't write text to its parent process's console when launched directly. (See #768.) Visual Studio does something similar with its devenv.com wrapper. devenv.exe only attaches to the console when launched from devenv.com.
Diffstat (limited to 'player')
-rw-r--r--player/main-fn-win.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/player/main-fn-win.c b/player/main-fn-win.c
index 125b4116f8..9e46e4af5f 100644
--- a/player/main-fn-win.c
+++ b/player/main-fn-win.c
@@ -1,6 +1,7 @@
#include "config.h"
#include "core.h"
#include "osdep/io.h"
+#include "osdep/terminal.h"
int wmain(int argc, wchar_t *argv[]);
@@ -9,6 +10,10 @@ int _dowildcard = 0;
int wmain(int argc, wchar_t *argv[])
{
+ // If started from the console wrapper (see osdep/win32-console-wrapper.c),
+ // attach to the console and set up the standard IO handles
+ terminal_try_attach();
+
char **argv_u8 = talloc_zero_array(NULL, char*, argc + 1);
for (int i = 0; i < argc; i++)
argv_u8[i] = mp_to_utf8(argv_u8, argv[i]);