diff options
-rw-r--r-- | xorg-server/hw/xwin/xlaunch/config.h | 8 | ||||
-rw-r--r-- | xorg-server/hw/xwin/xlaunch/main.cc | 42 | ||||
-rw-r--r-- | xorg-server/hw/xwin/xlaunch/resources/dialog.rc | 3 | ||||
-rw-r--r-- | xorg-server/hw/xwin/xlaunch/resources/resources.h | 49 | ||||
-rw-r--r-- | xorg-server/hw/xwin/xlaunch/resources/strings.rc | 1 |
5 files changed, 69 insertions, 34 deletions
diff --git a/xorg-server/hw/xwin/xlaunch/config.h b/xorg-server/hw/xwin/xlaunch/config.h index ecd22fe75..d9ec96ede 100644 --- a/xorg-server/hw/xwin/xlaunch/config.h +++ b/xorg-server/hw/xwin/xlaunch/config.h @@ -59,11 +59,7 @@ struct CConfig bool disableac; bool xdmcpterminate; std::string extra_params; -#ifdef _DEBUG - CConfig() : window(MultiWindow), client(NoClient), display("1"), -#else - CConfig() : window(MultiWindow), client(NoClient), display("0"), -#endif + CConfig() : window(MultiWindow), client(NoClient), display("-1"), local(false), remotepassword(""), localprogram("xcalc"), @@ -77,7 +73,7 @@ struct CConfig clipboard(true), clipboardprimary(true), extra_params(), - disableac(true), + disableac(false), wgl(true), xdmcpterminate(false) { diff --git a/xorg-server/hw/xwin/xlaunch/main.cc b/xorg-server/hw/xwin/xlaunch/main.cc index 730d7c547..1bdcf6ae3 100644 --- a/xorg-server/hw/xwin/xlaunch/main.cc +++ b/xorg-server/hw/xwin/xlaunch/main.cc @@ -35,6 +35,7 @@ #include <X11/Xlib.h> #include <stdlib.h> +#include <sstream> /// @brief Send WM_ENDSESSION to all program windows. /// This will shutdown the started xserver @@ -536,11 +537,14 @@ class CMyWizard : public CWizard std::string client; // Construct display strings + int DisplayNbr=atoi(config.display.c_str()); std::string display_id = ":" + config.display; std::string display = "DISPLAY=127.0.0.1" + display_id + ".0"; // Build Xsrv commandline - buffer = "vcxsrv " + display_id + " "; + buffer = "vcxsrv "; + if (DisplayNbr!=-1) + buffer += display_id + " "; switch (config.window) { case CConfig::MultiWindow: @@ -585,7 +589,23 @@ class CMyWizard : public CWizard buffer += config.extra_params; buffer += " "; } - + + int *pDisplayfd; + if (DisplayNbr==-1) + { + // Pass the handle of some shared memory to vcxsrv to getting back the display nbr + SECURITY_ATTRIBUTES sa; + sa.nLength=sizeof(sa); + sa.lpSecurityDescriptor=NULL; + sa.bInheritHandle=TRUE; + HANDLE hDisplayFdMem=CreateFileMapping(INVALID_HANDLE_VALUE, &sa, PAGE_READWRITE, 0, sizeof(int), NULL); + pDisplayfd=(int*)MapViewOfFile(hDisplayFdMem, FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, 0); + *pDisplayfd=-1; // Not yet initialised + buffer+="-displayfd "; + std::stringstream ss; + ss<<(int)hDisplayFdMem; + buffer+=ss.str(); + } // Construct client commandline if (config.client == CConfig::StartProgram) { @@ -630,13 +650,29 @@ class CMyWizard : public CWizard char CurDir[MAX_PATH]; GetModuleFileName(NULL,CurDir,MAX_PATH); *strrchr(CurDir,'\\')=0; + if( !CreateProcess( NULL, (CHAR*)buffer.c_str(), NULL, NULL, - FALSE, 0, NULL, CurDir, &si, &pi )) + TRUE, 0, NULL, CurDir, &si, &pi )) throw win32_error("CreateProcess failed"); handles[hcount++] = pi.hProcess; if (!client.empty()) { + if (DisplayNbr==-1) + { + // Wait maximum 10 seconds + int Count=1000; + while (-1==*pDisplayfd) + { + if (Count-- < 0) + throw std::runtime_error("Connection to server failed"); + Sleep(10); + } + std::stringstream ss; + ss<<*pDisplayfd; + display_id = ":" + ss.str(); + display = "DISPLAY=127.0.0.1" + display_id + ".0"; + } // Set DISPLAY variable _putenv(display.c_str()); diff --git a/xorg-server/hw/xwin/xlaunch/resources/dialog.rc b/xorg-server/hw/xwin/xlaunch/resources/dialog.rc index d7f1aa46f..2809bcc4b 100644 --- a/xorg-server/hw/xwin/xlaunch/resources/dialog.rc +++ b/xorg-server/hw/xwin/xlaunch/resources/dialog.rc @@ -46,7 +46,8 @@ BEGIN CONTROL "IMG_NODECORATION",IDC_NODECORATION_IMG,"Static",SS_BITMAP | SS_NOTIFY,230,60,0,0 LTEXT STR_DISPLAY_DESC,IDC_DISPLAY_DESC,7,120,64,12 - EDITTEXT IDC_DISPLAY,80,118,67,12,ES_NUMBER + LTEXT STR_DISPLAY_EXTRA_DESC,IDC_DISPLAY_EXTRA_DESC,7,132,200,12 + EDITTEXT IDC_DISPLAY,80,118,67,12 END IDD_CLIENTS DIALOGEX 0, 0, 317, 143 diff --git a/xorg-server/hw/xwin/xlaunch/resources/resources.h b/xorg-server/hw/xwin/xlaunch/resources/resources.h index 03f3dac1f..8db7ef190 100644 --- a/xorg-server/hw/xwin/xlaunch/resources/resources.h +++ b/xorg-server/hw/xwin/xlaunch/resources/resources.h @@ -47,31 +47,32 @@ #define IDC_NODECORATION_IMG 207
#define IDC_DISPLAY 208
#define IDC_DISPLAY_DESC 209
+#define IDC_DISPLAY_EXTRA_DESC 210
-#define IDC_CLIENT_NONE 210
-#define IDC_XDMCP 211
-#define IDC_CLIENT 212
-#define IDC_CLIENT_LOCAL 213
-#define IDC_CLIENT_REMOTE 214
-#define IDC_CLIENT_HOST 215
-#define IDC_CLIENT_USER 216
-#define IDC_CLIENT_PASSWORD 217
-#define IDC_CLIENT_CONFIGURE 218
-#define IDC_CLIENT_PROGRAM 219
-#define IDC_XDMCP_QUERY 220
-#define IDC_XDMCP_BROADCAST 221
-#define IDC_XDMCP_INDIRECT 222
-#define IDC_XDMCP_HOST 223
-#define IDC_CLIENT_NONE_DESC 224
-#define IDC_XDMCP_DESC 225
-#define IDC_CLIENT_DESC 226
-#define IDC_XDMCP_QUERY_DESC 227
-#define IDC_CLIENT_PROGRAM_DESC 228
-#define IDC_CLIENT_HOST_DESC 229
-#define IDC_CLIENT_USER_DESC 230
-#define IDC_CLIENT_PASSWORD_DESC 231
-#define IDC_CLIENT_REMOTEPROGRAM 232
-#define IDC_CLIENT_REMOTEPROGRAM_DESC 233
+#define IDC_CLIENT_NONE 211
+#define IDC_XDMCP 212
+#define IDC_CLIENT 213
+#define IDC_CLIENT_LOCAL 214
+#define IDC_CLIENT_REMOTE 215
+#define IDC_CLIENT_HOST 216
+#define IDC_CLIENT_USER 217
+#define IDC_CLIENT_PASSWORD 218
+#define IDC_CLIENT_CONFIGURE 219
+#define IDC_CLIENT_PROGRAM 220
+#define IDC_XDMCP_QUERY 221
+#define IDC_XDMCP_BROADCAST 222
+#define IDC_XDMCP_INDIRECT 223
+#define IDC_XDMCP_HOST 224
+#define IDC_CLIENT_NONE_DESC 225
+#define IDC_XDMCP_DESC 226
+#define IDC_CLIENT_DESC 227
+#define IDC_XDMCP_QUERY_DESC 228
+#define IDC_CLIENT_PROGRAM_DESC 229
+#define IDC_CLIENT_HOST_DESC 230
+#define IDC_CLIENT_USER_DESC 231
+#define IDC_CLIENT_PASSWORD_DESC 232
+#define IDC_CLIENT_REMOTEPROGRAM 233
+#define IDC_CLIENT_REMOTEPROGRAM_DESC 234
#define IDC_FONTPATH_DESC 240
diff --git a/xorg-server/hw/xwin/xlaunch/resources/strings.rc b/xorg-server/hw/xwin/xlaunch/resources/strings.rc index dab2b30af..8a3c487f5 100644 --- a/xorg-server/hw/xwin/xlaunch/resources/strings.rc +++ b/xorg-server/hw/xwin/xlaunch/resources/strings.rc @@ -30,6 +30,7 @@ #define STR_WINDOWED "One large window" #define STR_NODECORATION "One window without titlebar" #define STR_DISPLAY_DESC "Display number" +#define STR_DISPLAY_EXTRA_DESC "(Specify -1 to let vcxsrv automatically choose one)" #define STR_CAPTION_CLIENTS "Client startup" #define STR_CLIENT_NONE "Start no client" |