--- rdesktop.c.orig	2004-03-08 18:02:58.000000000 +0100
+++ rdesktop.c	2004-03-09 22:32:19.000000000 +0100
@@ -27,6 +27,7 @@
 #include <sys/time.h>		/* gettimeofday */
 #include <sys/times.h>		/* times */
 #include <errno.h>
+#include <X11/Xlib.h>           /* Window */
 #include "rdesktop.h"
 
 #ifdef EGD_SOCKET
@@ -68,6 +69,7 @@
 BOOL g_console_session = False;
 BOOL g_numlock_sync = False;
 extern BOOL g_owncolmap;
+extern Window g_embed_wnd;
 
 #ifdef WITH_RDPSND
 BOOL g_rdpsnd = False;
@@ -112,6 +114,7 @@
 	fprintf(stderr, "   -S: caption button size (single application mode)\n");
 	fprintf(stderr, "   -T: window title\n");
 	fprintf(stderr, "   -N: enable numlock synchronisation\n");
+        fprintf(stderr, "   -X: embed into another window with a given id.\n");
 	fprintf(stderr, "   -a: connection colour depth\n");
 	fprintf(stderr, "   -r: enable specified device redirection (currently: sound)\n");
 	fprintf(stderr, "   -0: attach to console\n");
@@ -224,6 +227,7 @@
 	prompt_password = False;
 	domain[0] = password[0] = shell[0] = directory[0] = 0;
 	strcpy(keymapname, "en-us");
+	g_embed_wnd = 0;
 
 #ifdef RDP2VNC
 #define VNCOPT "V:Q:"
@@ -231,7 +235,7 @@
 #define VNCOPT
 #endif
 
-	while ((c = getopt(argc, argv, VNCOPT "u:d:s:c:p:n:k:g:fbeEmCDKS:T:Na:r:045h?")) != -1)
+	while ((c = getopt(argc, argv, VNCOPT "u:d:s:c:p:n:k:g:fbeEmCDKS:T:NX:a:r:045h?")) != -1)
 	{
 		switch (c)
 		{
@@ -374,6 +378,10 @@
 				g_numlock_sync = True;
 				break;
 
+                        case 'X':
+                                g_embed_wnd = strtod(optarg, NULL);
+                                break;
+
 			case 'a':
 				g_server_bpp = strtol(optarg, NULL, 10);
 				if (g_server_bpp != 8 && g_server_bpp != 16 && g_server_bpp != 15
--- xwin.c.orig	2004-03-08 18:02:58.000000000 +0100
+++ xwin.c	2004-03-10 16:17:59.000000000 +0100
@@ -41,6 +41,7 @@
 static int g_x_socket;
 static Screen *g_screen;
 Window g_wnd;
+Window g_embed_wnd;
 BOOL g_enable_compose = False;
 static GC g_gc;
 static BOOL g_gc_initialized = False;
@@ -929,6 +930,11 @@
 		XFree(sizehints);
 	}
 
+        if ( g_embed_wnd )
+        {
+                XReparentWindow(g_display, g_wnd, g_embed_wnd, 0, 0);
+        }
+
 	input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
 		VisibilityChangeMask | FocusChangeMask;
 
