... #include #include /* After the standard includes, add the following: */ #include #include #include ... int main(int argc, char *argv[]) { Display *dpy; /* the X display to use */ Window win; /* the actual X window */ ... /* other variables we might use */ /* * Add this to turn your program into a Hildon program: */ HildonProgram *program; GdkWindow *gdkWindow; gtk_init(&argc, &argv); program = HILDON_PROGRAM(hildon_program_get_instance()); g_set_application_name("Hello maemo!"); /* Find the code that opens the Display and creates the X Window: */ ... dpy = XOpenDisplay(NULL); ... win = XCreateWindow(dpy, ...); ... XMapWindow(dpy, win); /* * Now that the window has been mapped, we can turn it into a GDK window: */ gdkWindow = gdk_window_foreign_new(win); ... /* * Add gtk_main_iteration() to the X11 event loop: */ while (!quit) { XEvent event; XNextEvent(dpy, &event); ... /* handle X event as usual, then handle GTK events: */ while (gtk_events_pending()) gtk_main_iteration(); } /* Unreference the GDK window before destroying the X window: * g_object_unref(gdkWindow); }