From 220918e5cd908e406fcac55e4e416884d2a6d806 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 1 Nov 2017 05:16:32 -0700 Subject: [PATCH] fix to compile with gdk3.2 (latest Debian) --- xwords4/linux/Makefile | 4 ++-- xwords4/linux/gtkboard.h | 4 ++++ xwords4/linux/gtkdraw.c | 18 +++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/xwords4/linux/Makefile b/xwords4/linux/Makefile index f09c514ee..fc85f7f7c 100644 --- a/xwords4/linux/Makefile +++ b/xwords4/linux/Makefile @@ -226,7 +226,7 @@ OBJ = \ $(BUILD_PLAT_DIR)/relaycon.o \ $(CURSES_OBJS) $(GTK_OBJS) $(MAIN_OBJS) -LIBS = -lm -luuid -lcurl -ljson-c $(GPROFFLAG) +LIBS = -lm -lpthread -luuid -lcurl -ljson-c $(GPROFFLAG) ifdef USE_SQLITE LIBS += -lsqlite3 DEFINES += -DUSE_SQLITE @@ -242,7 +242,7 @@ endif ifneq (,$(findstring DPLATFORM_GTK,$(DEFINES))) LIBS += `pkg-config --libs gtk+-3.0` CFLAGS += `pkg-config --cflags gtk+-3.0` -# CFLAGS += -DGDK_DISABLE_DEPRECATED + CFLAGS += -DGDK_DISABLE_DEPRECATED POINTER_SUPPORT = -DPOINTER_SUPPORT endif diff --git a/xwords4/linux/gtkboard.h b/xwords4/linux/gtkboard.h index 491be224f..d2abde645 100644 --- a/xwords4/linux/gtkboard.h +++ b/xwords4/linux/gtkboard.h @@ -46,6 +46,10 @@ typedef struct GtkDrawCtx { /* GdkDrawable* pixmap; */ GtkWidget* drawing_area; cairo_surface_t* surface; +#ifdef GDK_AVAILABLE_IN_3_22 + GdkDrawingContext* dc; +#endif + struct GtkGameGlobals* globals; #ifdef USE_CAIRO diff --git a/xwords4/linux/gtkdraw.c b/xwords4/linux/gtkdraw.c index aeab1f824..fa04326ad 100644 --- a/xwords4/linux/gtkdraw.c +++ b/xwords4/linux/gtkdraw.c @@ -1,6 +1,6 @@ -/* -*- compile-command: "make MEMDEBUG=TRUE -j3"; -*- */ +/* -*- compile-command: "make MEMDEBUG=TRUE -j5"; -*- */ /* - * Copyright 1997-2011 by Eric House (xwords@eehouse.org). All rights + * Copyright 1997 - 2017 by Eric House (xwords@eehouse.org). All rights * reserved. * * This program is free software; you can redistribute it and/or @@ -86,7 +86,14 @@ initCairo( GtkDrawCtx* dctx ) if ( !!dctx->surface ) { cairo = cairo_create( dctx->surface ); } else if ( !!dctx->drawing_area ) { +#ifdef GDK_AVAILABLE_IN_3_22 + GdkWindow* window = gtk_widget_get_window( dctx->drawing_area ); + const cairo_region_t* region = gdk_window_get_visible_region( window ); + dctx->dc = gdk_window_begin_draw_frame( window, region ); + cairo = gdk_drawing_context_get_cairo_context( dctx->dc ); +#else cairo = gdk_cairo_create( gtk_widget_get_window(dctx->drawing_area) ); +#endif } else { XP_ASSERT( 0 ); } @@ -108,7 +115,12 @@ destroyCairo( GtkDrawCtx* dctx ) { /* XP_LOGF( "%s(dctx=%p)", __func__, dctx ); */ XP_ASSERT( !!dctx->_cairo ); - cairo_destroy(dctx->_cairo); +#ifdef GDK_AVAILABLE_IN_3_22 + GdkWindow* window = gtk_widget_get_window( dctx->drawing_area ); + gdk_window_end_draw_frame( window, dctx->dc ); +#else + cairo_destroy( dctx->_cairo ); +#endif dctx->_cairo = NULL; }