Porting GTK+ applications to Wayland
GTK+ is using a backend architecture to isolate platform-specific code from the portable GTK+ API. The bulk of the platform-specific code is inside GDK, and you have to explicitly include a header file such as gdkx.h or gdkwin32.h. There are a few exceptions, such as the GtkPlug/GtkSocket API in GTK+, which also requires you to include a special header, gtkx.h.
Trying out if your application works under Wayland
For a very quick test of your application under Wayland, you can run either weston (the Wayland reference compositor) or mutter-wayland nested under X:
$ weston $ mutter-wayland --wayland
Then run your application using the Wayland backend:
If everything works alright, you should have your application appear inside the weston (or mutter-wayland) window.
The page at Initiatives/Wayland/TryingIt has more details about running mutter or gnome-shell as a Wayland compositor.
Porting your application to Wayland
If your application is not including any backend-specific header such as gdkx.h or gdkwin32.h, it will most likely just work under Wayland without any porting.
Otherwise, you should find the places in your code where backend-specific API is being used. You can recognize these functions by having names starting with gdk_x11_ (or gdk_win32, gdk_quartz, etc). For any such API call, you need to wrap it in a check for the current backend, and possibly supplant it by equivalent code for the other backends, like this:
gdk_x11_window_set_user_time (window, timestamp);
#ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_WINDOW (window)) gdk_x11_window_set_user_time (window, timestamp); #endif #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_WINDOW (window)) /* do something else */ #endif