mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2026-01-05 03:25:10 +00:00
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.
This commit is contained in:
parent
55477f9f20
commit
db1b308a63
@ -87,6 +87,7 @@ remote_viewer_SOURCES = \
|
||||
remote-viewer-main.c \
|
||||
$(NULL)
|
||||
remote_viewer_LDFLAGS = \
|
||||
-Wl,--subsystem,windows \
|
||||
$(GLIB2_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(LIBXML2_LIBS) \
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user