From 9909077be131c5dc7b3dee14cb25b8a799040616 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 26 Nov 2017 08:56:16 +0000 Subject: [PATCH] Make the current code compile again under GTK1. Apparently I haven't tested this compile mode in a while: I had a couple of compile errors due to new code not properly #ifdeffed (the true-colour mode has to be effectively disabled in the palette-based GTK1 graphics model) and one for an unused static function (get_monitor_geometry is only used in GTK2 and above, and with -Werror that means I mustn't even _define_ it in GTK1). With these changes, I still didn't get a clean compile unless I also configured CFLAGS=-std=gnu89, due to the GTK1 headers having an outdated set of ifdefs to figure out the compiler's semantics of 'inline'. (They seem to expect old-style gcc, which inconveniently treats 'inline' and 'extern inline' more or less the opposite way round from the version standardised by C99.) --- unix/gtkwin.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 3a3c2a54..a851c258 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -3039,11 +3039,16 @@ static void draw_set_colour(struct draw_ctx *dctx, int col, int dim) #ifdef DRAW_TEXT_GDK if (dctx->uctx.type == DRAWTYPE_GDK) { if (dim) { +#if GTK_CHECK_VERSION(2,0,0) GdkColor color; color.red = dctx->inst->cols[col].red * 2 / 3; color.green = dctx->inst->cols[col].green * 2 / 3; color.blue = dctx->inst->cols[col].blue * 2 / 3; gdk_gc_set_rgb_fg_color(dctx->uctx.u.gdk.gc, &color); +#else + /* Poor GTK1 fallback */ + gdk_gc_set_foreground(dctx->uctx.u.gdk.gc, &dctx->inst->cols[col]); +#endif } else { gdk_gc_set_foreground(dctx->uctx.u.gdk.gc, &dctx->inst->cols[col]); } @@ -3064,6 +3069,7 @@ static void draw_set_colour_rgb(struct draw_ctx *dctx, optionalrgb orgb, { #ifdef DRAW_TEXT_GDK if (dctx->uctx.type == DRAWTYPE_GDK) { +#if GTK_CHECK_VERSION(2,0,0) GdkColor color; color.red = orgb.r * 256; color.green = orgb.g * 256; @@ -3074,6 +3080,10 @@ static void draw_set_colour_rgb(struct draw_ctx *dctx, optionalrgb orgb, color.blue = color.blue * 2 / 3; } gdk_gc_set_rgb_fg_color(dctx->uctx.u.gdk.gc, &color); +#else + /* Poor GTK1 fallback */ + gdk_gc_set_foreground(dctx->uctx.u.gdk.gc, &dctx->inst->cols[256]); +#endif } #endif #ifdef DRAW_TEXT_CAIRO @@ -4374,6 +4384,7 @@ static void start_backend(struct gui_data *inst) gtk_widget_set_sensitive(inst->restartitem, FALSE); } +#if GTK_CHECK_VERSION(2,0,0) static void get_monitor_geometry(GtkWidget *widget, GdkRectangle *geometry) { #if GTK_CHECK_VERSION(3,4,0) @@ -4397,6 +4408,7 @@ static void get_monitor_geometry(GtkWidget *widget, GdkRectangle *geometry) geometry->height = gdk_screen_height(); #endif } +#endif struct gui_data *new_session_window(Conf *conf, const char *geometry_string) {