diff --exclude-from=c:\util\tool\diff.ign -u -r from-cvs/gtk+/gtk/gtkplug.c my-gtk/gtk+/gtk/gtkplug.c
--- from-cvs/gtk+/gtk/gtkplug.c	Wed Oct 24 20:29:08 2001
+++ my-gtk/gtk+/gtk/gtkplug.c	Fri Oct 26 13:58:26 2001
@@ -24,6 +24,7 @@
  * files for a list of changes.  These files are distributed with
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
+#include "gdkconfig.h"
 
 #include "gtkmain.h"
 #include "gtkmarshal.h"
@@ -31,7 +32,12 @@
 #include "gtkprivate.h"
 
 #include "gdk/gdkkeysyms.h"
+#if defined (GDK_WINDOWING_X11)
 #include "x11/gdkx.h"
+#elif defined (GDK_WINDOWING_WIN32)
+#include "win32/gdkwin32.h"
+UINT xembed_message = 0;
+#endif
 
 #include "xembed.h"
 
@@ -106,6 +112,9 @@
       };
 
       plug_type = g_type_register_static (GTK_TYPE_WINDOW, "GtkPlug", &plug_info, 0);
+#if defined (GDK_WINDOWING_WIN32)
+      xembed_message = RegisterWindowMessage ("gtk:xembed_message");
+#endif
     }
 
   return plug_type;
@@ -348,7 +357,11 @@
   if (!GTK_WIDGET_REALIZED (plug))
     gtk_widget_realize (GTK_WIDGET (plug));
 
+#if defined (GDK_WINDOWING_X11)
   return GDK_WINDOW_XWINDOW (GTK_WIDGET (plug)->window);
+#elif defined (GDK_WINDOWING_WIN32)
+  return (GdkNativeWindow) GDK_WINDOW_HWND (GTK_WIDGET (plug)->window);
+#endif
 }
 
 static void
@@ -563,6 +576,7 @@
 static void
 gtk_plug_forward_key_press (GtkPlug *plug, GdkEventKey *event)
 {
+#if defined (GDK_WINDOWING_X11)
   XEvent xevent;
   
   xevent.xkey.type = KeyPress;
@@ -587,6 +601,17 @@
 	      False, NoEventMask, &xevent);
   gdk_flush ();
   gdk_error_trap_pop ();
+#elif defined (GDK_WINDOWING_WIN32)
+  /* forward message to our socket counterpart */
+  PostMessage (GDK_WINDOW_HWND (plug->socket_window),
+               WM_KEYDOWN, event->hardware_keycode, 0);
+  gdk_flush ();
+  PostMessage (GDK_WINDOW_HWND (plug->socket_window),
+               WM_KEYUP, event->hardware_keycode, 0);
+  gdk_flush ();
+#else
+  g_warning ("gdk_plug_forward_keypress XXX");
+#endif
 }
 
 static void
@@ -846,6 +871,7 @@
 {
   if (plug->socket_window)
     {
+#if defined (GDK_WINDOWING_X11)
       XEvent xevent;
 
       xevent.xclient.window = GDK_WINDOW_XWINDOW (plug->socket_window);
@@ -864,6 +890,12 @@
 		  False, NoEventMask, &xevent);
       gdk_flush ();
       gdk_error_trap_pop ();
+#elif defined (GDK_WINDOWING_WIN32)
+      PostMessage (GDK_WINDOW_HWND (plug->socket_window),
+                   xembed_message, message, detail);
+#else
+      g_warning ("send_xembed_message XXX");
+#endif
     }
 }
 
@@ -914,6 +946,7 @@
 xembed_set_info (GdkWindow     *gdk_window,
 		 unsigned long  flags)
 {
+#if defined (GDK_WINDOWING_X11)
   Display *display = GDK_WINDOW_XDISPLAY (gdk_window);
   Window window = GDK_WINDOW_XWINDOW (gdk_window);
   unsigned long buffer[2];
@@ -927,6 +960,9 @@
 		   xembed_info_atom, xembed_info_atom, 32,
 		   PropModeReplace,
 		   (unsigned char *)buffer, 2);
+#elif defined (GDK_WINDOWING_WIN32)
+  /* FIXME: not sure if something needs to be done */
+#endif
 }
 
 static void
@@ -1002,6 +1038,7 @@
     }
 }
 
+#if defined (GDK_WINDOWING_X11)
 static GdkFilterReturn
 gtk_plug_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
 {
@@ -1129,3 +1166,41 @@
 
   return GDK_FILTER_CONTINUE;
 }
+
+#elif defined (GDK_WINDOWING_WIN32)
+
+static GdkFilterReturn
+gtk_plug_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
+{
+  GtkPlug *plug = GTK_PLUG (data);
+  MSG *msg = (MSG *)gdk_xevent;
+
+  GdkFilterReturn return_val;
+  
+  return_val = GDK_FILTER_CONTINUE;
+
+  if (msg->message == xembed_message)
+    {
+      handle_xembed_message (plug,
+                             msg->wParam,
+                             msg->lParam,
+                             0, /* ?= xevent->xclient.data.l[3] */
+                             0, /* ?= xevent->xclient.data.l[4] */
+                             msg->time);
+
+      return GDK_FILTER_REMOVE;
+    }
+
+  return GDK_FILTER_CONTINUE;
+}
+
+#else
+
+static GdkFilterReturn
+gtk_plug_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
+{
+  /* XXX */
+  return GDK_FILTER_CONTINUE;
+}
+
+#endif
\ No newline at end of file
diff --exclude-from=c:\util\tool\diff.ign -u -r from-cvs/gtk+/gtk/gtksocket.c my-gtk/gtk+/gtk/gtksocket.c
--- from-cvs/gtk+/gtk/gtksocket.c	Wed Oct 24 20:29:12 2001
+++ my-gtk/gtk+/gtk/gtksocket.c	Fri Oct 26 14:03:18 2001
@@ -25,6 +25,8 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#include "gdkconfig.h"
+
 #include "gdk/gdkkeysyms.h"
 #include "gtkmain.h"
 #include "gtkmarshal.h"
@@ -35,7 +37,12 @@
 #include "gtksocket.h"
 #include "gtkdnd.h"
 
+#if defined (GDK_WINDOWING_X11)
 #include "x11/gdkx.h"
+#elif defined (GDK_WINDOWING_WIN32)
+#include "win32/gdkwin32.h"
+extern UINT xembed_message; /* from gtkplug.c */
+#endif 
 
 #include "xembed.h"
 
@@ -124,6 +131,9 @@
       };
 
       socket_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkSocket", &socket_info, 0);
+#if defined (GDK_WINDOWING_WIN32)
+      xembed_message = RegisterWindowMessage ("gtk:xembed_message");
+#endif
     }
 
   return socket_type;
@@ -280,7 +290,11 @@
   if (!GTK_WIDGET_REALIZED (socket))
     gtk_widget_realize (GTK_WIDGET (socket));
 
+#if defined (GDK_WINDOWING_X11)
   return GDK_WINDOW_XWINDOW (GTK_WIDGET (socket)->window);
+#elif defined (GDK_WINDOWING_WIN32)
+  return (GdkNativeWindow)GDK_WINDOW_HWND (GTK_WIDGET (socket)->window);
+#endif
 }
 
 static void
@@ -289,7 +303,6 @@
   GtkSocket *socket;
   GdkWindowAttr attributes;
   gint attributes_mask;
-  XWindowAttributes xattrs;
 
   g_return_if_fail (GTK_IS_SOCKET (widget));
 
@@ -315,6 +328,9 @@
   widget->style = gtk_style_attach (widget->style, widget->window);
   gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
 
+#if defined (GDK_WINDOWING_X11)
+  {
+  XWindowAttributes xattrs;
   XGetWindowAttributes (GDK_DISPLAY (),
 			GDK_WINDOW_XWINDOW (widget->window),
 			&xattrs);
@@ -323,7 +339,15 @@
 		GDK_WINDOW_XWINDOW(widget->window), 
 		xattrs.your_event_mask | 
 		SubstructureNotifyMask | SubstructureRedirectMask);
-
+  }
+#elif defined (GDK_WINDOWING_WIN32)
+  /* this shouldn't be necessary a the moment */
+  GTK_NOTE (PLUGSOCKET,
+            g_print ("gtk_socket_realize (XSelectInput) 0x%X\n",
+                     GDK_WINDOW_HWND (widget->window)));
+#else
+  g_warning ("gtk_socket_realize (XSelectInput)");
+#endif
   gdk_window_add_filter (widget->window, gtk_socket_filter_func, widget);
 
   GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
@@ -348,8 +372,15 @@
     {
       GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
       if (toplevel && GTK_IS_WINDOW (toplevel))
+#if defined (GDK_WINDOWING_X11)
 	gtk_window_remove_embedded_xid (GTK_WINDOW (toplevel), 
 					GDK_WINDOW_XWINDOW (socket->plug_window));
+#elif defined (GDK_WINDOWING_WIN32)
+	gtk_window_remove_embedded_xid (GTK_WINDOW (toplevel), 
+					(UINT)GDK_WINDOW_HWND (socket->plug_window));
+#else
+      /* XXX */
+#endif
 
       g_object_unref (socket->plug_window);
       socket->plug_window = NULL;
@@ -382,6 +413,7 @@
     {
       if (socket->is_mapped && !socket->have_size && socket->plug_window)
 	{
+#if defined (GDK_WINDOWING_X11)
 	  XSizeHints hints;
 	  long supplied;
 	  
@@ -412,6 +444,29 @@
 	  socket->have_size = TRUE;	/* don't check again? */
 	  
 	  gdk_error_trap_pop ();
+#elif defined (GDK_WINDOWING_WIN32)
+      MINMAXINFO mmi;
+      DWORD dwResult = 1;
+      if (SendMessageTimeout (GDK_WINDOW_HWND (socket->plug_window),
+                              WM_GETMINMAXINFO,
+                              (WPARAM)0, (LPARAM)&mmi,
+                              SMTO_BLOCK, /* block ourself while waiting */
+                              50, /* with ms timeout */
+                              &dwResult)
+          && 0 == dwResult)
+        {
+           /* XXX: could get min or max size, what do we need ? */
+           socket->request_width = mmi.ptMinTrackSize.x;
+           socket->request_height = mmi.ptMinTrackSize.y;
+           GTK_NOTE (PLUGSOCKET,
+                     g_print ("gdk_socket_size_request 0x%X (%d x %d)\n",
+                              GDK_WINDOW_HWND (socket->plug_window),
+                              socket->request_width, socket->request_height));
+           socket->have_size = TRUE;
+        }
+#else
+      /* XXX */
+#endif
 	}
 
       if (socket->is_mapped && socket->have_size)
@@ -687,6 +742,7 @@
   
   if (socket->plug_window)
     {
+#if defined (GDK_WINDOWING_X11)
       XEvent xevent;
       
       xevent.xkey.type = KeyPress;
@@ -709,6 +765,17 @@
 		  False, NoEventMask, &xevent);
       gdk_flush ();
       gdk_error_trap_pop ();
+#elif defined (GDK_WINDOWING_WIN32)
+      /* forward message to our plug counterpart */
+      PostMessage (GDK_WINDOW_HWND (socket->plug_window),
+                   WM_KEYDOWN, event->hardware_keycode, 0);
+      gdk_flush ();
+      PostMessage (GDK_WINDOW_HWND (socket->plug_window),
+                   WM_KEYUP, event->hardware_keycode, 0);
+      gdk_flush ();
+#else
+      g_warning ("gtk_socket_keypress_event XXX");
+#endif
       
       return TRUE;
     }
@@ -920,6 +987,7 @@
 static void
 gtk_socket_send_configure_event (GtkSocket *socket)
 {
+#if defined (GDK_WINDOWING_X11)
   XEvent event;
 
   g_return_if_fail (socket->plug_window != NULL);
@@ -945,6 +1013,21 @@
 	      False, NoEventMask, &event);
   gdk_flush ();
   gdk_error_trap_pop ();
+#elif defined (GDK_WINDOWING_WIN32)
+  GTK_NOTE(PLUGSOCKET,
+           g_print ("gtk_socket_send_configure_event 0x%X (%d x %d)",
+                    GDK_WINDOW_HWND (socket->plug_window),
+                    GTK_WIDGET(socket)->allocation.width,
+                    GTK_WIDGET(socket)->allocation.height));
+  /* XXX: is this correct (inform about size change) ? */
+  PostMessage (GDK_WINDOW_HWND (socket->plug_window),
+               WM_SIZE, SIZE_RESTORED,
+               (GTK_WIDGET(socket)->allocation.width & 0xFFFF)
+               + (GTK_WIDGET(socket)->allocation.height << 16));
+  gdk_flush ();
+#else
+  /* XXX */
+#endif
 }
 
 static void
@@ -998,9 +1081,15 @@
 	    }
 	}
 	
+#if defined (GDK_WINDOWING_X11)
       XSelectInput (GDK_DISPLAY (),
 		    GDK_WINDOW_XWINDOW(socket->plug_window),
 		    StructureNotifyMask | PropertyChangeMask);
+#elif defined (GDK_WINDOWING_WIN32)
+      /* XXX: probably nothing to do */
+#else
+      g_warning ("gtk_socket_add_window (XSelectInput)");
+#endif
       
       if (gdk_error_trap_pop ())
 	{
@@ -1073,6 +1162,7 @@
   
   if (socket->plug_window)
     {
+#if defined (GDK_WINDOWING_X11)
       XEvent xevent;
 
       xevent.xclient.window = GDK_WINDOW_XWINDOW (socket->plug_window);
@@ -1091,6 +1181,14 @@
 		  False, NoEventMask, &xevent);
       gdk_flush ();
       gdk_error_trap_pop ();
+#elif defined (GDK_WINDOWING_WIN32)
+      /* forward to our GtkPlug counterpart */
+      PostMessage (GDK_WINDOW_HWND (socket->plug_window),
+                   xembed_message, message, detail);
+      gdk_flush ();
+#else
+      /* XXX */
+#endif
     }
 }
 
@@ -1099,6 +1197,7 @@
 		 unsigned long *version,
 		 unsigned long *flags)
 {
+#if defined (GDK_WINDOWING_X11)
   Display *display = GDK_WINDOW_XDISPLAY (gdk_window);
   Window window = GDK_WINDOW_XWINDOW (gdk_window);
   Atom xembed_info_atom = gdk_x11_get_xatom_by_name ("_XEMBED_INFO");
@@ -1144,6 +1243,10 @@
   
   XFree (data);
   return TRUE;
+#elif defined (GDK_WINDOWING_WIN32)
+  /* XXX : not sure what to do ... */
+  return FALSE;
+#endif
 }
 
 static void
@@ -1223,6 +1326,7 @@
     }
 }
 
+#if defined (GDK_WINDOWING_X11)
 static GdkFilterReturn
 gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
 {
@@ -1469,3 +1573,193 @@
   
   return return_val;
 }
+
+#elif defined (GDK_WINDOWING_WIN32)
+static GdkFilterReturn
+gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
+{
+  GtkSocket *socket;
+  GtkWidget *widget;
+  MSG *msg = (MSG *)gdk_xevent;
+
+  GdkFilterReturn return_val;
+  
+  socket = GTK_SOCKET (data);
+  widget = GTK_WIDGET (socket);
+
+  return_val = GDK_FILTER_CONTINUE;
+
+  switch (msg->message)
+    {
+    case WM_CREATE: /* CreateNotify */
+      {
+	if (!socket->plug_window)
+	  {
+	    LPCREATESTRUCT lpcs = (LPCREATESTRUCT)msg->lParam;
+
+	    gtk_socket_add_window (socket, (UINT)msg->hwnd, FALSE);
+
+	    gdk_error_trap_push ();
+	    gdk_window_move_resize(socket->plug_window,
+				   0, 0,
+				   widget->allocation.width, 
+				   widget->allocation.height);
+	    gdk_flush ();
+	    gdk_error_trap_pop ();
+	
+	    socket->request_width = lpcs->cx;
+	    socket->request_height = lpcs->cy;
+	    socket->have_size = TRUE;
+
+	    GTK_NOTE(PLUGSOCKET,
+		     g_message ("GtkSocket - window created with size: %d %d",
+				socket->request_width,
+				socket->request_height));
+	  }
+	
+	return_val = GDK_FILTER_REMOVE;
+	
+	break;
+      }
+
+    case WM_SIZE : /* ConfigureRequest */
+    case WM_MOVE :
+      {
+	
+	if (!socket->plug_window)
+	  gtk_socket_add_window (socket, (UINT)msg->hwnd, FALSE);
+	
+	if (socket->plug_window &&
+	    msg->hwnd == GDK_WINDOW_HWND (socket->plug_window))
+	  {
+	    if (WM_SIZE == msg->message)
+	      {
+		socket->request_width = LOWORD(msg->lParam);
+		socket->request_height = HIWORD(msg->lParam);
+		socket->have_size = TRUE;
+		
+		GTK_NOTE(PLUGSOCKET,
+			 g_message ("GtkSocket - configure request: %d %d",
+				    socket->request_width,
+				    socket->request_height));
+		
+		gtk_widget_queue_resize (widget);
+	      }
+	    else if (WM_MOVE == msg->message)
+	      {
+		/*
+		 * xPos = (int)LOWORD(lParam);
+		 * yPos = (int)HIWORD(lParam);
+		 */
+            /* XXX: X11 version does almost nothing, is it enough ? */
+		gtk_socket_send_configure_event (socket);
+	      }
+	    /* Ignore stacking requests. */
+	    
+	    return_val = GDK_FILTER_REMOVE;
+	  }
+	break;
+      }
+
+    case WM_DESTROY : /* DestroyNotify */
+      {
+
+	if (socket->plug_window &&
+	    (msg->hwnd == GDK_WINDOW_HWND (socket->plug_window)))
+	  {
+	    GtkWidget *toplevel;
+
+	    GTK_NOTE(PLUGSOCKET,
+		     g_message ("GtkSocket - destroy notify"));
+	    
+	    toplevel = gtk_widget_get_toplevel (GTK_WIDGET (socket));
+	    if (toplevel && GTK_IS_WINDOW (toplevel))
+	      gtk_window_remove_embedded_xid (GTK_WINDOW (toplevel), (UINT)msg->hwnd);
+	    
+	    gdk_window_destroy_notify (socket->plug_window);
+	    gtk_widget_destroy (widget);
+
+	    socket->plug_window = NULL;
+	    
+	    return_val = GDK_FILTER_REMOVE;
+	  }
+	break;
+      }
+
+    case WM_SETFOCUS: /* FocusIn */
+	gtk_socket_claim_focus (socket);
+      return_val = GDK_FILTER_REMOVE;
+      break;
+    case WM_KILLFOCUS: /* FocusOut */
+      return_val = GDK_FILTER_REMOVE;
+      break;
+    case WM_SHOWWINDOW: /* MapRequest */
+      if (!socket->plug_window)
+	gtk_socket_add_window (socket, (UINT)msg->hwnd, FALSE);
+	
+      if (   (msg->wParam) /* Show */  
+          // && (msg->hwnd == GDK_WINDOW_HWND (socket->plug_window)
+          && (msg->lParam != 0)) /* avoid infinite recursion */
+	{
+	  GTK_NOTE(PLUGSOCKET,
+		   g_message ("GtkSocket - Map Request"));
+	  
+	  gdk_error_trap_push ();
+	  gdk_window_show (socket->plug_window);
+	  gdk_flush ();
+	  gdk_error_trap_pop ();
+
+	  return_val = GDK_FILTER_REMOVE;
+	}
+      break;
+#if 0 /* XXX Drag&Drop */
+    case PropertyNotify:
+      if (xevent->xproperty.window ==
+	  GDK_WINDOW_XWINDOW (socket->plug_window))
+	{
+	  GdkDragProtocol protocol;
+
+	  if ((xevent->xproperty.atom == gdk_atom_intern ("XdndAware", FALSE)) ||
+	      (xevent->xproperty.atom == gdk_atom_intern ("_MOTIF_DRAG_RECEIVER_INFO", FALSE)))
+	    {
+	      gdk_error_trap_push ();
+	      if (gdk_drag_get_protocol (xevent->xproperty.window, &protocol))
+		gtk_drag_dest_set_proxy (GTK_WIDGET (socket),
+					 socket->plug_window,
+					 protocol, TRUE);
+	      gdk_flush ();
+	      gdk_error_trap_pop ();
+	    }
+	  return_val = GDK_FILTER_REMOVE;
+	}
+      break;
+#endif /* XXX Drag&Drop */
+    default:
+      if (msg->message == xembed_message) /* not const at win32 */
+	{
+        GTK_NOTE (PLUGSOCKET,
+                  g_message ("GtkSocket - handle_xembed_message (%d,%d,x,x,%d)",
+				     msg->wParam, msg->lParam, msg->time));
+	  handle_xembed_message (socket,
+				 msg->wParam,
+				 msg->lParam,
+				 0, /* msg->hwnd ?= xevent->xclient.data.l[3] */
+				 0, /* msg->pt ?= xevent->xclient.data.l[4] */
+				 msg->time);
+	  
+	  
+	  return_val = GDK_FILTER_REMOVE;
+	}
+      break;
+    }
+  
+  return return_val;
+}
+#else
+static GdkFilterReturn
+gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
+{
+  /* XXX */
+  return GDK_FILTER_CONTINUE;
+}
+#endif
