Use GTK_MAJOR_VERSION macro instead of custom one.

This commit is contained in:
Brandon Wright 2018-04-28 11:59:17 -05:00
parent f2dcb275d2
commit 99f7e63972
8 changed files with 23 additions and 21 deletions

View File

@ -199,7 +199,6 @@ GTK3_WARNING=no
if test yes = "$with_gtk3" -a no = "$with_gtk2"; then if test yes = "$with_gtk3" -a no = "$with_gtk2"; then
GTK_VERSION="gtk+-3.0" GTK_VERSION="gtk+-3.0"
GTK3_WARNING=yes GTK3_WARNING=yes
CFLAGS="$CFLAGS -DUSE_GTK3"
else else
GTK_VERSION="gtk+-2.0 >= 2.16" GTK_VERSION="gtk+-2.0 >= 2.16"
fi fi

View File

@ -1,9 +1,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#ifdef USE_GTK3 #if GTK_MAJOR_VERSION >= 3
#include <gdk/gdkkeysyms-compat.h> #include <gdk/gdkkeysyms-compat.h>
#endif #endif

View File

@ -770,7 +770,7 @@ S9xOpenGLDisplayDriver::create_window (int width, int height)
XMapWindow (display, xwindow); XMapWindow (display, xwindow);
XSync (display, False); XSync (display, False);
#if USE_GTK3 #if GTK_MAJOR_VERSION >= 3
gdk_window = gdk_x11_window_foreign_new_for_display (gtk_widget_get_display (drawing_area), xwindow); gdk_window = gdk_x11_window_foreign_new_for_display (gtk_widget_get_display (drawing_area), xwindow);
#else #else
gdk_window = gdk_window_foreign_new (xwindow); gdk_window = gdk_window_foreign_new (xwindow);

View File

@ -76,7 +76,7 @@ S9xXVDisplayDriver::create_window (int width, int height)
XMapWindow (display, xwindow); XMapWindow (display, xwindow);
XSync (display, False); XSync (display, False);
#if USE_GTK3 #if GTK_MAJOR_VERSION >= 3
gdk_window = gdk_x11_window_foreign_new_for_display (gtk_widget_get_display (drawing_area), xwindow); gdk_window = gdk_x11_window_foreign_new_for_display (gtk_widget_get_display (drawing_area), xwindow);
#else #else
gdk_window = gdk_window_foreign_new (xwindow); gdk_window = gdk_window_foreign_new (xwindow);

View File

@ -2,9 +2,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#ifdef USE_GTK3
#include <gdk/gdkkeysyms-compat.h>
#endif
#include "gtk_preferences.h" #include "gtk_preferences.h"
#include "gtk_config.h" #include "gtk_config.h"
@ -14,6 +11,10 @@
#include "gtk_display.h" #include "gtk_display.h"
#include "gtk_binding.h" #include "gtk_binding.h"
#if GTK_MAJOR_VERSION >= 3
#include <gdk/gdkkeysyms-compat.h>
#endif
#define SAME_GAME _("Same location as current game") #define SAME_GAME _("Same location as current game")
gboolean gboolean
@ -565,7 +566,7 @@ event_about_clicked (GtkButton *widget, gpointer data)
gtk_widget_hide (about_dialog->get_widget ("preferences_splash")); gtk_widget_hide (about_dialog->get_widget ("preferences_splash"));
#ifdef USE_GTK3 #if GTK_MAJOR_VERSION >= 3
GtkCssProvider *provider; GtkCssProvider *provider;
GtkStyleContext *context; GtkStyleContext *context;

View File

@ -36,7 +36,7 @@
extern Snes9xWindow *top_level; extern Snes9xWindow *top_level;
extern Snes9xConfig *gui_config; extern Snes9xConfig *gui_config;
#ifdef USE_GTK3 #if GTK_MAJOR_VERSION >= 3
#define GDK_COMPAT_WINDOW_XID(window) (gdk_x11_window_get_xid (window)) #define GDK_COMPAT_WINDOW_XID(window) (gdk_x11_window_get_xid (window))
#else #else
#define GDK_COMPAT_WINDOW_XID(window) (GDK_WINDOW_XWINDOW (window)) #define GDK_COMPAT_WINDOW_XID(window) (GDK_WINDOW_XWINDOW (window))

View File

@ -1,9 +1,6 @@
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#ifdef USE_GTK3
#include <gdk/gdkkeysyms-compat.h>
#endif
#include <cairo.h> #include <cairo.h>
#ifdef USE_XV #ifdef USE_XV
@ -24,6 +21,10 @@
#include "gtk_netplay.h" #include "gtk_netplay.h"
#endif #endif
#if GTK_MAJOR_VERSION >= 3
#include <gdk/gdkkeysyms-compat.h>
#endif
static gboolean static gboolean
event_main_window_delete (GtkWidget *widget, event_main_window_delete (GtkWidget *widget,
GdkEvent *event, GdkEvent *event,
@ -133,7 +134,7 @@ event_open_netplay (GtkWidget *widget, gpointer data)
return TRUE; return TRUE;
} }
#ifdef USE_GTK3 #if GTK_MAJOR_VERSION >= 3
static gboolean static gboolean
event_drawingarea_draw (GtkWidget *widget, event_drawingarea_draw (GtkWidget *widget,
cairo_t *cr, cairo_t *cr,
@ -147,9 +148,9 @@ event_drawingarea_draw (GtkWidget *widget,
return FALSE; return FALSE;
} }
#endif
#ifndef USE_GTK3 #else
static gboolean static gboolean
event_drawingarea_expose (GtkWidget *widget, event_drawingarea_expose (GtkWidget *widget,
GdkEventExpose *event, GdkEventExpose *event,
@ -623,13 +624,13 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
} }
drawing_area = GTK_DRAWING_AREA (get_widget ("drawingarea")); drawing_area = GTK_DRAWING_AREA (get_widget ("drawingarea"));
#ifndef USE_GTK3 #if GTK_MAJOR_VERSION < 3
gtk_widget_set_double_buffered (GTK_WIDGET (drawing_area), FALSE); gtk_widget_set_double_buffered (GTK_WIDGET (drawing_area), FALSE);
#endif #endif
gtk_widget_realize (window); gtk_widget_realize (window);
gtk_widget_realize (GTK_WIDGET (drawing_area)); gtk_widget_realize (GTK_WIDGET (drawing_area));
#ifndef USE_GTK3 #if GTK_MAJOR_VERSION < 3
gdk_window_set_back_pixmap (gtk_widget_get_window (window), NULL, FALSE); gdk_window_set_back_pixmap (gtk_widget_get_window (window), NULL, FALSE);
gdk_window_set_back_pixmap (gtk_widget_get_window (GTK_WIDGET (drawing_area)), NULL, FALSE); gdk_window_set_back_pixmap (gtk_widget_get_window (GTK_WIDGET (drawing_area)), NULL, FALSE);
#endif #endif
@ -646,7 +647,7 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
gtk_widget_hide (get_widget ("sync_clients_separator")); gtk_widget_hide (get_widget ("sync_clients_separator"));
#endif #endif
#ifdef USE_GTK3 #if GTK_MAJOR_VERSION >= 3
g_signal_connect_data (drawing_area, g_signal_connect_data (drawing_area,
"draw", "draw",
G_CALLBACK (event_drawingarea_draw), G_CALLBACK (event_drawingarea_draw),
@ -1966,7 +1967,7 @@ Snes9xWindow::get_cairo (void)
GtkWidget *drawing_area = GTK_WIDGET (this->drawing_area); GtkWidget *drawing_area = GTK_WIDGET (this->drawing_area);
#ifndef USE_GTK3 #if GTK_MAJOR_VERSION < 3
cr = gdk_cairo_create (gtk_widget_get_window (drawing_area)); cr = gdk_cairo_create (gtk_widget_get_window (drawing_area));
#else #else
GtkAllocation allocation; GtkAllocation allocation;
@ -1988,7 +1989,7 @@ Snes9xWindow::release_cairo (void)
{ {
if (cairo_owned) if (cairo_owned)
{ {
#ifndef USE_GTK3 #if GTK_MAJOR_VERSION < 3
cairo_destroy (cr); cairo_destroy (cr);
#else #else
gdk_window_end_draw_frame (gtk_widget_get_window (GTK_WIDGET (drawing_area)), gdk_drawing_context); gdk_window_end_draw_frame (gtk_widget_get_window (GTK_WIDGET (drawing_area)), gdk_drawing_context);

View File

@ -83,7 +83,7 @@ class Snes9xWindow : public GtkBuilderWindow
GtkWidget *recent_menu; GtkWidget *recent_menu;
cairo_t *cr; cairo_t *cr;
int cairo_owned; int cairo_owned;
#ifdef USE_GTK3 #if GTK_MAJOR_VERSION >= 3
GdkDrawingContext *gdk_drawing_context; GdkDrawingContext *gdk_drawing_context;
cairo_region_t *cairo_region; cairo_region_t *cairo_region;
#endif #endif