get_x11_display.c 767 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Return the Xlib 'Display *' underlying our GTK environment, if any.
  3. */
  4. #include <gtk/gtk.h>
  5. #include "putty.h"
  6. #include "gtkcompat.h"
  7. #include "gtkmisc.h"
  8. #ifndef NOT_X_WINDOWS
  9. #include <gdk/gdkx.h>
  10. #include <X11/Xlib.h>
  11. Display *get_x11_display(void)
  12. {
  13. #if GTK_CHECK_VERSION(3,0,0)
  14. if (!GDK_IS_X11_DISPLAY(gdk_display_get_default()))
  15. return NULL;
  16. #endif
  17. return GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
  18. }
  19. #else
  20. /*
  21. * Include _something_ in this file to prevent an annoying compiler
  22. * warning, and to avoid having to condition out this file in
  23. * CMakeLists. It's in a library, so this variable shouldn't end up in
  24. * any actual program, because nothing will refer to it.
  25. */
  26. const int get_x11_display_dummy_variable = 0;
  27. #endif