From 1fa0b5a1ac21ae204f5514203e2fa1d5ea287a67 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 31 Aug 2015 13:05:51 +0100 Subject: [PATCH] Introduce a config option for building on OS X GTK. Using GTK to run on OS X is going to require several workarounds and behaviour tweaks to be enabled at various points in the code, and it's already getting cumbersome to remember what they all are to put on the command line. Here's a central #define (OSX_GTK) that enables them all in one go, and a configure option (--with-quartz) that sets it. As part of this commit, I've also rearranged the #include order in the GTK source files, so that they include unix.h (which now might be where NOT_X_WINDOWS gets defined) before they test NOT_X_WINDOWS to decide whether to include X11 headers. --- configure.ac | 6 ++++++ unix/gtkdlg.c | 13 +++++++------ unix/gtkfont.c | 12 +++++++----- unix/gtkwin.c | 13 +++++++------ unix/unix.h | 14 ++++++++++++++ 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/configure.ac b/configure.ac index f1bff955..2ad3675b 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,12 @@ AC_ARG_WITH([gssapi], [], [with_gssapi=yes]) +AC_ARG_WITH([quartz], + [AS_HELP_STRING([--with-quartz], + [build for the MacOS Quartz GTK back end])], + [AC_DEFINE([OSX_GTK], [1], [Define if building with GTK for MacOS.])], + []) + WITH_GSSAPI= AS_IF([test "x$with_gssapi" != xno], [AC_DEFINE([WITH_GSSAPI], [1], [Define if building with GSSAPI support.])]) diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index c044c062..23e9f465 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -6,26 +6,27 @@ #include #include #include + #include #if !GTK_CHECK_VERSION(3,0,0) #include #endif + +#include "putty.h" +#include "gtkcompat.h" +#include "gtkcols.h" +#include "gtkfont.h" + #ifndef NOT_X_WINDOWS #include #include #include #endif -#include "gtkcompat.h" - -#include "gtkcols.h" -#include "gtkfont.h" - #ifdef TESTMODE #define PUTTY_DO_GLOBALS /* actually _define_ globals */ #endif -#include "putty.h" #include "storage.h" #include "dialog.h" #include "tree234.h" diff --git a/unix/gtkfont.c b/unix/gtkfont.c index a43363b9..1a9860ab 100644 --- a/unix/gtkfont.c +++ b/unix/gtkfont.c @@ -12,10 +12,17 @@ #include #include #include + #include #if !GTK_CHECK_VERSION(3,0,0) #include #endif + +#include "putty.h" +#include "gtkfont.h" +#include "gtkcompat.h" +#include "tree234.h" + #ifndef NOT_X_WINDOWS #include #include @@ -23,11 +30,6 @@ #include #endif -#include "putty.h" -#include "gtkfont.h" -#include "gtkcompat.h" -#include "tree234.h" - /* * Future work: * diff --git a/unix/gtkwin.c b/unix/gtkwin.c index f6befeed..69535c36 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -22,12 +22,6 @@ #if !GTK_CHECK_VERSION(3,0,0) #include #endif -#ifndef NOT_X_WINDOWS -#include -#include -#include -#include -#endif #if GTK_CHECK_VERSION(2,0,0) #include @@ -42,6 +36,13 @@ #include "gtkcompat.h" #include "gtkfont.h" +#ifndef NOT_X_WINDOWS +#include +#include +#include +#include +#endif + #define CAT2(x,y) x ## y #define CAT(x,y) CAT2(x,y) #define ASSERT(x) enum {CAT(assertion_,__LINE__) = 1 / (x)} diff --git a/unix/unix.h b/unix/unix.h index fbe025ba..90922451 100644 --- a/unix/unix.h +++ b/unix/unix.h @@ -12,6 +12,20 @@ #endif /* NO_LIBDL */ #include "charset.h" +#ifdef OSX_GTK +/* + * Assorted tweaks to various parts of the GTK front end which all + * need to be enabled when compiling on OS X. Because I might need the + * same tweaks on other systems in future, I don't want to + * conditionalise all of them on OSX_GTK directly, so instead, each + * one has its own name and we enable them all centrally here if + * OSX_GTK is defined at configure time. + */ +#define NOT_X_WINDOWS /* of course, all the X11 stuff should be disabled */ +#define NO_PTY_PRE_INIT /* OS X gets very huffy if we try to set[ug]id */ +#define SET_NONBLOCK_VIA_OPENPT /* work around missing fcntl functionality */ +#endif + struct Filename { char *path; }; -- 2.45.2