--- a/src/socket.c
+++ b/src/socket.c
@@ -663,12 +663,18 @@
 	if (popup)
 	{
 #ifdef GDK_WINDOWING_X11
+		GdkWindow *x11_window = gtk_widget_get_window(window);
+
 		/* Set the proper interaction time on the window. This seems necessary to make
 		 * gtk_window_present() really bring the main window into the foreground on some
 		 * window managers like Gnome's metacity.
 		 * Code taken from Gedit. */
-		gdk_x11_window_set_user_time(gtk_widget_get_window(window),
-			gdk_x11_get_server_time(gtk_widget_get_window(window)));
+#	if GTK_CHECK_VERSION(3, 0, 0)
+		if (GDK_IS_X11_WINDOW(x11_window))
+#	endif
+		{
+			gdk_x11_window_set_user_time(x11_window, gdk_x11_get_server_time(x11_window));
+		}
 #endif
 		gtk_window_present(GTK_WINDOW(window));
 #ifdef G_OS_WIN32