summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2012-04-02 19:54:21 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2012-04-02 23:56:50 +0200
commitdb1b308a63a3c52f7b3b05bacbdc2f5c1d91c937 (patch)
tree028f962ce7b3630363b390a21b0f25af312f7718
parent55477f9f2055d4bed2bccb920a8289b462f75506 (diff)
remote-viewer: make it a GUI/windows application with hybrid console
If the application can attach to its parent console, redirect input/output. So that will work nicely with the command line wrapper.
-rw-r--r--src/Makefile.am1
-rw-r--r--src/remote-viewer-main.c15
2 files changed, 16 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d47cc09..283733f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -87,6 +87,7 @@ remote_viewer_SOURCES = \
remote-viewer-main.c \
$(NULL)
remote_viewer_LDFLAGS = \
+ -Wl,--subsystem,windows \
$(GLIB2_LIBS) \
$(GTK_LIBS) \
$(LIBXML2_LIBS) \
diff --git a/src/remote-viewer-main.c b/src/remote-viewer-main.c
index 64e0cbe..230c1cd 100644
--- a/src/remote-viewer-main.c
+++ b/src/remote-viewer-main.c
@@ -25,6 +25,10 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <stdlib.h>
+#ifdef G_OS_WIN32
+#include <windows.h>
+#include <io.h>
+#endif
#ifdef HAVE_GTK_VNC
#include <vncdisplay.h>
@@ -222,6 +226,17 @@ main(int argc, char **argv)
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
+#ifdef G_OS_WIN32
+ if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) {
+ freopen("CONIN$", "r", stdin);
+ freopen("CONOUT$", "w", stdout);
+ freopen("CONERR$", "w", stderr);
+ dup2(fileno(stdin), STDIN_FILENO);
+ dup2(fileno(stdout), STDOUT_FILENO);
+ dup2(fileno(stderr), STDERR_FILENO);
+ }
+#endif
+
#if !GLIB_CHECK_VERSION(2,31,0)
g_thread_init(NULL);
#endif