fix to compile with gdk3.2 (latest Debian)

This commit is contained in:
Eric House 2017-11-01 05:16:32 -07:00
parent 61937ac2d0
commit 220918e5cd
3 changed files with 21 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -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;
}