diff --git a/src/post_modules/GTK2/configure.in b/src/post_modules/GTK2/configure.in
index 1a770e7c5e..48ca86384b 100644
--- a/src/post_modules/GTK2/configure.in
+++ b/src/post_modules/GTK2/configure.in
@@ -392,6 +392,7 @@ LIBS="$LIBS $GTK_LIBS"
 AC_CHECK_HEADERS( gdk/gdkx.h gdk/gdkwin32.h gdk/gdkquartz.h )
 
 AC_CHECK_FUNCS(gtk_tree_selection_unselect_range g_value_get_schar g_value_set_schar)
+AC_CHECK_TYPES([GdkNativeWindow], [], [], [[#include <gdk/gdktypes.h>]])
 
 AC_MSG_CHECKING([if g_signal_connect_data takes six args])
 AC_CACHE_VAL(pgtk2_cv_g_signal_connect_has_six_args, [
diff --git a/src/post_modules/GTK2/source/gdkevent.pre b/src/post_modules/GTK2/source/gdkevent.pre
index d1f230a7d9..c4390a33f1 100644
--- a/src/post_modules/GTK2/source/gdkevent.pre
+++ b/src/post_modules/GTK2/source/gdkevent.pre
@@ -149,7 +149,7 @@ mixed _index(string ind)
      if( is_same_string(index,_STR("selection")) ) RETURN_ATOM( e->selection.selection );
      if( is_same_string(index,_STR("target")) ) RETURN_ATOM( e->selection.target );
      if( is_same_string(index,_STR("property")) ) RETURN_ATOM( e->selection.property );
-     if( is_same_string(index,_STR("requestor")) ) RETURN_INT( e->selection.requestor );
+     if( is_same_string(index,_STR("requestor")) ) RETURN_INT( (INT_TYPE)e->selection.requestor );
      break;
 
    case GDK_PROXIMITY_IN:
@@ -422,7 +422,7 @@ mapping cast(string to)
      ref_push_string(_STR("selection")); push_atom( e->selection.selection );
      ref_push_string(_STR("target"));    push_atom( e->selection.target );
      ref_push_string(_STR("property"));  push_atom( e->selection.property );
-     ref_push_string(_STR("requestor")); push_int( e->selection.requestor );
+     ref_push_string(_STR("requestor")); push_int((INT_TYPE) e->selection.requestor );
      break;
 
    case GDK_PROXIMITY_IN:
diff --git a/src/post_modules/GTK2/source/gdkpixmap.pre b/src/post_modules/GTK2/source/gdkpixmap.pre
index 7b1a90e020..a2ac5d879f 100644
--- a/src/post_modules/GTK2/source/gdkpixmap.pre
+++ b/src/post_modules/GTK2/source/gdkpixmap.pre
@@ -58,7 +58,11 @@ void create(int|object image)
     if (f)
       g_object_unref(i);
   } else if (args && TYPEOF(Pike_sp[-1]) == PIKE_T_INT) {
+#ifdef HAVE_GDKNATIVEWINDOW
+    gp=gdk_pixmap_foreign_new((GdkNativeWindow)Pike_sp[-1].u.integer);
+#else
     gp=gdk_pixmap_foreign_new(Pike_sp[-1].u.integer);
+#endif /* HAVE_GDKNATIVEWINDOW */
     THIS->obj=G_OBJECT(gp);
     if (!THIS->obj)
       Pike_error("Failed to find remote pixmap\n");
diff --git a/src/post_modules/GTK2/source/gdkwindow.pre b/src/post_modules/GTK2/source/gdkwindow.pre
index 7b81266e38..2f24e84a29 100644
--- a/src/post_modules/GTK2/source/gdkwindow.pre
+++ b/src/post_modules/GTK2/source/gdkwindow.pre
@@ -16,7 +16,11 @@ void create(GDK2.Window|int parent, mapping|void attributes)
     GdkWindow *w;
     INT_TYPE id;
     get_all_args(NULL,args,"%i",&id);
+#ifdef HAVE_GDKNATIVEWINDOW
+    w=gdk_window_foreign_new((GdkNativeWindow)id);
+#else
     w=gdk_window_foreign_new(id);
+#endif /* HAVE_GDKNATIVEWINDOW */
     THIS->obj=G_OBJECT(w);
     if (!THIS->obj)
       Pike_error("The window with id 0x%lx does not exist\n",
diff --git a/src/post_modules/GTK2/source/gtkplug.pre b/src/post_modules/GTK2/source/gtkplug.pre
index 1bf7ade6da..f8501b24c3 100644
--- a/src/post_modules/GTK2/source/gtkplug.pre
+++ b/src/post_modules/GTK2/source/gtkplug.pre
@@ -26,7 +26,11 @@ void create(int|mapping(string:mixed) socket_id_or_props)
   pgtk2_verify_setup();
   {
     if (TYPEOF(Pike_sp[-args]) == PIKE_T_INT) {
+#ifdef HAVE_GDKNATIVEWINDOW
+      GdkNativeWindow id;
+#else
       INT_TYPE id;
+#endif /* HAVE_GDKNATIVEWINDOW */
       GtkWidget *gp;
       get_all_args(NULL,args,"%i",&id);
       gp=gtk_plug_new(id);
@@ -39,6 +43,18 @@ void create(int|mapping(string:mixed) socket_id_or_props)
   pgtk2__init_this_object();
 }
 
-int get_id();
+int get_id()
 //! Gets the window id of this widget.
-
+{
+  pgtk2_verify_inited();
+  {
+#ifdef HAVE_GDKNATIVEWINDOW
+    GdkNativeWindow a1;
+#else
+    INT_TYPE a1;
+#endif /* HAVE_GDKNATIVEWINDOW */
+    a1 =   gtk_plug_get_id( GTK_PLUG(THIS->obj) );
+    my_pop_n_elems(args);
+    PGTK_PUSH_INT( a1 );
+  } 
+}   
diff --git a/src/post_modules/GTK2/source/gtksocket.pre b/src/post_modules/GTK2/source/gtksocket.pre
index 0187220abd..711345a64b 100644
--- a/src/post_modules/GTK2/source/gtksocket.pre
+++ b/src/post_modules/GTK2/source/gtksocket.pre
@@ -51,14 +51,44 @@ int id()
   push_int64 (wid);
 }
 
-void add_id(int wid);
+void add_id(int wid)
 //! Adds an XEMBED client, such as a W(Plug), to the W(Socket).
+{
+#ifdef HAVE_GDKNATIVEWINDOW
+  GdkNativeWindow a0;
+#else
+  INT_TYPE a0;
+#endif /* HAVE_GDKNATIVEWINDOW */
+
+  if( args < 1 )
+    SIMPLE_WRONG_NUM_ARGS_ERROR(NULL, 1);
+#ifdef HAVE_GDKNATIVEWINDOW
+  a0 = (GdkNativeWindow)PGTK_GETINT(&Pike_sp[0-args]);
+#else
+  a0 = PGTK_GETINT(&Pike_sp[0-args]);
+#endif /* HAVE_GDKNATIVEWINDOW */
+  pgtk2_verify_inited();
+  gtk_socket_add_id( GTK_SOCKET(THIS->obj), a0 );
+  RETURN_THIS();
+}
 
-int get_id();
+int get_id()
 //! Gets the window id of a W(Socket) widget, which can then be used
 //! to create a client embedded inside the socket, for instance with
 //! GTK2.Plug->create().
-
+{
+  pgtk2_verify_inited();
+  {
+#ifdef HAVE_GDKNATIVEWINDOW
+    GdkNativeWindow a1;
+#else
+    INT_TYPE a1;
+#endif /* HAVE_GDKNATIVEWINDOW */
+    a1 =   gtk_socket_get_id( GTK_SOCKET(THIS->obj) );
+    my_pop_n_elems(args);
+    PGTK_PUSH_INT( a1 );
+  }
+}
 /*
 int has_plug()
 //! Returns true if this socket is occupied
