aboutsummaryrefslogtreecommitdiff
path: root/xorg-server
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-02-01 16:40:17 +0000
committermarha <marha@users.sourceforge.net>2011-02-01 16:40:17 +0000
commitd1cb96c4a8bac3c220e08a4b60aab8c4e8b6f38d (patch)
treeee93baf534df425d9d7b51e1bd2b4c050bb00507 /xorg-server
parentd4a8565009962e162d86a9c4ae24062a3fa12025 (diff)
downloadvcxsrv-d1cb96c4a8bac3c220e08a4b60aab8c4e8b6f38d.tar.gz
vcxsrv-d1cb96c4a8bac3c220e08a4b60aab8c4e8b6f38d.tar.bz2
vcxsrv-d1cb96c4a8bac3c220e08a4b60aab8c4e8b6f38d.zip
Added host selection menu in case -broadcast was specified
Diffstat (limited to 'xorg-server')
-rw-r--r--xorg-server/hw/xwin/XWin.rc11
-rw-r--r--xorg-server/hw/xwin/makefile3
-rw-r--r--xorg-server/hw/xwin/winclipboardthread.c1
-rw-r--r--xorg-server/hw/xwin/winresource.h2
-rw-r--r--xorg-server/hw/xwin/xdmcphostselect.c158
-rw-r--r--xorg-server/os/xdmcp.c61
6 files changed, 234 insertions, 2 deletions
diff --git a/xorg-server/hw/xwin/XWin.rc b/xorg-server/hw/xwin/XWin.rc
index 315ce05fa..f0cc74f8d 100644
--- a/xorg-server/hw/xwin/XWin.rc
+++ b/xorg-server/hw/xwin/XWin.rc
@@ -80,6 +80,17 @@ BEGIN
CTEXT "Proceed with shutdown of this display/server?", IDC_STATIC, 7, 36, 166, 8
END
+/* Xdmcp host selection dialog */
+XDMCP_HOSTS DIALOGEX 32, 32, 260, 156
+STYLE DS_SETFONT | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION
+EXSTYLE WS_EX_NOPARENTNOTIFY
+CAPTION "Select host to connect to"
+FONT 8, "MS Shell Dlg 2", 0, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Connect",IDOK,61,132,50,15
+ LISTBOX IDC_HOSTLIST,7,7,245,113,LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Cancel",IDCANCEL,147,134,50,14
+END
/*
* Menus
diff --git a/xorg-server/hw/xwin/makefile b/xorg-server/hw/xwin/makefile
index d1d95274d..6968c917b 100644
--- a/xorg-server/hw/xwin/makefile
+++ b/xorg-server/hw/xwin/makefile
@@ -137,7 +137,8 @@ SRCS = InitInput.c \
$(SRCS_NATIVEGDI) \
$(SRCS_PRIMARYFB) \
$(SRCS_RANDR) \
- $(SRCS_XV)
+ $(SRCS_XV) \
+ xdmcphostselect.c
CSRCS=$(filter %.c,$(SRCS)) $(filter %.y,$(SRCS)) $(filter %.l,$(SRCS))
CSRCS := $(CSRCS:%.y=%.c)
diff --git a/xorg-server/hw/xwin/winclipboardthread.c b/xorg-server/hw/xwin/winclipboardthread.c
index 3af62eb96..6df6ff380 100644
--- a/xorg-server/hw/xwin/winclipboardthread.c
+++ b/xorg-server/hw/xwin/winclipboardthread.c
@@ -525,5 +525,6 @@ static void
winClipboardThreadExit(void *arg)
{
/* clipboard thread has exited, stop server as well */
+ AbortDDX();
TerminateProcess(GetCurrentProcess(),1);
}
diff --git a/xorg-server/hw/xwin/winresource.h b/xorg-server/hw/xwin/winresource.h
index 7085117e6..6a04153f0 100644
--- a/xorg-server/hw/xwin/winresource.h
+++ b/xorg-server/hw/xwin/winresource.h
@@ -51,4 +51,6 @@
#define ID_ABOUT_CHANGELOG 302
#define ID_ABOUT_WEBSITE 303
+#define IDC_HOSTLIST 100
+
#endif
diff --git a/xorg-server/hw/xwin/xdmcphostselect.c b/xorg-server/hw/xwin/xdmcphostselect.c
new file mode 100644
index 000000000..a447f9495
--- /dev/null
+++ b/xorg-server/hw/xwin/xdmcphostselect.c
@@ -0,0 +1,158 @@
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+void XdmcpHostSelected(int HostIndex);
+
+static HWND g_hDlgHosts;
+
+/*
+ * Process messages for the about dialog.
+ */
+
+static wBOOL CALLBACK DisplayXdmcpHostsDlgProc (HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ {
+ HWND hwndDesk=GetForegroundWindow();
+ RECT rc, rcDlg, rcDesk;
+
+ GetWindowRect (hwndDesk, &rcDesk);
+ GetWindowRect (hwndDialog, &rcDlg);
+ CopyRect (&rc, &rcDesk);
+
+ OffsetRect (&rcDlg, -rcDlg.left, -rcDlg.top);
+ OffsetRect (&rc, -rc.left, -rc.top);
+ OffsetRect (&rc, -rcDlg.right, -rcDlg.bottom);
+
+ SetWindowPos (hwndDialog,
+ HWND_TOPMOST,
+ rcDesk.left + (rc.right / 2),
+ rcDesk.top + (rc.bottom / 2),
+ 0, 0,
+ SWP_NOSIZE | SWP_FRAMECHANGED);
+ return TRUE;
+ }
+ break;
+ case WM_MOUSEMOVE:
+ case WM_NCMOUSEMOVE:
+ /* Show the cursor if it is hidden */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD (wParam))
+ {
+ case IDOK:
+ {
+ int Index;
+ winDebug ("DisplayXdmcpHostsDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
+
+ /* Retreive the host to connect to */
+ Index=SendDlgItemMessage(g_hDlgHosts, IDC_HOSTLIST, LB_GETCURSEL, 0, 0);
+ if (Index==LB_ERR)
+ {
+ MessageBox(hwndDialog,"Please select a host to connect to!","Error",MB_OK);
+ }
+ else
+ {
+ int HostIndex=SendDlgItemMessage(g_hDlgHosts, IDC_HOSTLIST, LB_GETITEMDATA, (WPARAM)Index, 0);
+ XdmcpHostSelected(HostIndex);
+
+ DestroyWindow (g_hDlgHosts);
+ g_hDlgHosts = NULL;
+ }
+
+ return TRUE;
+ }
+ break;
+ case IDCANCEL:
+ winDebug ("DisplayXdmcpHostsDlgProc - WM_COMMAND - IDCANCEL\n");
+
+ DestroyWindow (g_hDlgHosts);
+ AbortDDX();
+ TerminateProcess(GetCurrentProcess(),1); /* Exit the application */
+
+ return TRUE;
+ break;
+ case IDC_HOSTLIST:
+ if (HIWORD(wParam)==LBN_DBLCLK)
+ {
+ int Index=SendDlgItemMessage(g_hDlgHosts, IDC_HOSTLIST, LB_GETCURSEL, 0, 0);
+ int HostIndex=SendDlgItemMessage(g_hDlgHosts, IDC_HOSTLIST, LB_GETITEMDATA, (WPARAM)Index, 0);
+ XdmcpHostSelected(HostIndex);
+
+ DestroyWindow (g_hDlgHosts);
+ g_hDlgHosts = NULL;
+ return TRUE;
+ }
+ break;
+ }
+ break;
+
+ case WM_CLOSE:
+ ErrorF ("DisplayXdmcpHostsDlgProc - WM_CLOSE\n");
+
+ DestroyWindow (g_hDlgHosts);
+ g_hDlgHosts = NULL;
+ AbortDDX();
+ TerminateProcess(GetCurrentProcess(),1); /* Exit the application */
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+int XdmcpHostAddName(const char *HostName, int HostIndex)
+{
+ int Index=SendDlgItemMessage(g_hDlgHosts, IDC_HOSTLIST, LB_FINDSTRINGEXACT, -1, (LPARAM)HostName);
+ if (LB_ERR==Index)
+ {
+ Index=SendDlgItemMessage(g_hDlgHosts, IDC_HOSTLIST, LB_ADDSTRING, 0, (LPARAM)HostName);
+ SendDlgItemMessage(g_hDlgHosts, IDC_HOSTLIST, LB_SETITEMDATA, (WPARAM)Index, (LPARAM)HostIndex);
+ return -1;
+ }
+ else
+ return SendDlgItemMessage(g_hDlgHosts, IDC_HOSTLIST, LB_GETITEMDATA, (WPARAM)Index, 0);
+}
+/*
+ * Display the host selection dialog box
+ */
+
+void DisplayXdmcpHostsDialog(void)
+{
+ /* Check if dialog already exists */
+ if (g_hDlgHosts != NULL)
+ {
+ /* Dialog box already exists, display it */
+ ShowWindow (g_hDlgHosts, SW_SHOWDEFAULT);
+
+ /* User has lost the dialog. Show them where it is. */
+ SetForegroundWindow (g_hDlgHosts);
+
+ return;
+ }
+
+ /*
+ * Display the about box
+ */
+ g_hDlgHosts = CreateDialogParam (g_hInstance, "XDMCP_HOSTS", NULL, DisplayXdmcpHostsDlgProc, 0);
+
+ /* Show the dialog box */
+ ShowWindow (g_hDlgHosts, SW_SHOW);
+
+ /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
+ SetForegroundWindow (g_hDlgHosts);
+
+ /* Set focus to the OK button */
+ PostMessage (g_hDlgAbout, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g_hDlgHosts, IDOK), TRUE);
+}
diff --git a/xorg-server/os/xdmcp.c b/xorg-server/os/xdmcp.c
index 6429b8b77..83e391319 100644
--- a/xorg-server/os/xdmcp.c
+++ b/xorg-server/os/xdmcp.c
@@ -776,6 +776,37 @@ XdmcpSelectHost(
* selects the first host to respond with willing message.
*/
+#ifdef _MSC_VER
+void DisplayXdmcpHostsDialog(void);
+int XdmcpHostAddName(const char *HostName, int HostIndex);
+
+struct hostinfo
+{
+ struct sockaddr *from;
+ int fromlen;
+ ARRAY8 AuthenticationName;
+};
+static int g_NrHosts;
+static struct hostinfo *g_Hosts;
+
+void XdmcpHostSelected(int HostIdx)
+{
+ int i;
+
+ /* Connect to the selected host */
+ XdmcpSelectHost(g_Hosts[HostIdx].from, g_Hosts[HostIdx].fromlen, &g_Hosts[HostIdx].AuthenticationName);
+
+ for (i=0; i<g_NrHosts; i++)
+ {
+ free(g_Hosts[i].from);
+ free(g_Hosts[i].AuthenticationName.data);
+ }
+ free(g_Hosts);
+ g_Hosts=NULL;
+ g_NrHosts=0;
+}
+#endif
+
/*ARGSUSED*/
static void
XdmcpAddHost(
@@ -785,7 +816,35 @@ XdmcpAddHost(
ARRAY8Ptr hostname,
ARRAY8Ptr status)
{
- XdmcpSelectHost(from, fromlen, AuthenticationName);
+#ifdef _MSC_VER
+ char szHostName[100];
+ int HostIdx;
+
+ memcpy(szHostName,hostname->data,hostname->length);
+ szHostName[hostname->length]=0;
+
+ DisplayXdmcpHostsDialog(); /* Display the dialog if not already displayed */
+
+ HostIdx=XdmcpHostAddName(szHostName, g_NrHosts);
+ if (HostIdx==-1)
+ {
+ HostIdx=g_NrHosts;
+ g_NrHosts++;
+ g_Hosts=realloc(g_Hosts,g_NrHosts*sizeof(*g_Hosts));
+ g_Hosts[HostIdx].AuthenticationName.data=NULL;
+ g_Hosts[HostIdx].from=NULL;
+ }
+
+ g_Hosts[HostIdx].fromlen=fromlen;
+ g_Hosts[HostIdx].from=realloc(g_Hosts[HostIdx].from,g_Hosts[HostIdx].fromlen);
+ memcpy(g_Hosts[HostIdx].from,from,fromlen);
+
+ g_Hosts[HostIdx].AuthenticationName.length=AuthenticationName->length;
+ g_Hosts[HostIdx].AuthenticationName.data=realloc(g_Hosts[HostIdx].AuthenticationName.data,AuthenticationName->length);
+ memcpy(g_Hosts[HostIdx].AuthenticationName.data,AuthenticationName->data,AuthenticationName->length);
+#else
+ XdmcpSelectHost(from, fromlen, AuthenticationName);
+#endif
}
/*