[virt-tools-list] [PATCH virt-viewer 2/4] remote-viewer: make it a GUI/windows application with hybrid console
Marc-André Lureau
marcandre.lureau at gmail.com
Mon Apr 2 21:57:00 UTC 2012
If the application can attach to its parent console, redirect
input/output. So that will work nicely with the command line wrapper.
---
src/Makefile.am | 1 +
src/remote-viewer-main.c | 15 +++++++++++++++
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
--
1.7.7.6
More information about the virt-tools-list
mailing list