Gdk's window_foreign_new_for_display returns null for external xwindow xid


I’m trying to construct a GdkWindow from an external xwindow xid. The other window is already shown. I’m trying the following code:

  GdkDisplayManager *mn = gdk_display_manager_get();
  const gchar *env = getenv("DISPLAY");
  GdkDisplay *disp = gdk_display_manager_open_display(mn, env);
  GdkWindow *win = gdk_x11_window_foreign_new_for_display(disp, xid); // <-- external xid
  assert(win); // win is null

The bigger picture is that I’m trying to construct a custom GtkWidget containing this GdkWindow (the idea is to pass it to webview_create(int, void *) which expects a GtkWindow or GtkWidget on linux. But I’m using an alternative toolkit from which I can get an X11 XID.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.