From a9cc03c06c7443f1b62d5ddce7f6348416794125 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Tue, 6 Nov 2018 18:46:44 -0600 Subject: [PATCH] GTK+: Consolidate includes to compat header. --- gtk/src/gtk_2_3_compat.h | 28 ++++++++++++++++++++++++--- gtk/src/gtk_binding.cpp | 7 ------- gtk/src/gtk_binding.h | 2 +- gtk/src/gtk_builder_window.h | 2 +- gtk/src/gtk_display.cpp | 9 +-------- gtk/src/gtk_display_driver_gtk.cpp | 3 +-- gtk/src/gtk_display_driver_opengl.cpp | 2 +- gtk/src/gtk_display_driver_xv.cpp | 8 +++----- gtk/src/gtk_file.cpp | 2 +- gtk/src/gtk_glx_context.cpp | 12 ++---------- gtk/src/gtk_glx_context.h | 3 +-- gtk/src/gtk_opengl_context.h | 2 +- gtk/src/gtk_preferences.cpp | 9 --------- gtk/src/gtk_preferences.h | 2 +- gtk/src/gtk_s9x.cpp | 5 ----- gtk/src/gtk_s9x.h | 2 -- gtk/src/gtk_s9xwindow.cpp | 15 +++----------- gtk/src/gtk_s9xwindow.h | 2 +- gtk/src/gtk_shader_parameters.cpp | 2 +- gtk/src/gtk_shader_parameters.h | 2 +- gtk/src/gtk_wayland_egl_context.h | 2 +- 21 files changed, 46 insertions(+), 75 deletions(-) diff --git a/gtk/src/gtk_2_3_compat.h b/gtk/src/gtk_2_3_compat.h index 8a32f91e..7f04285d 100644 --- a/gtk/src/gtk_2_3_compat.h +++ b/gtk/src/gtk_2_3_compat.h @@ -3,14 +3,36 @@ #include #include +#include #if GTK_MAJOR_VERSION >= 3 -#define GDK_COMPAT_WINDOW_XID(window) (gdk_x11_window_get_xid (window)) -#else + +#include + +#ifdef GDK_WINDOWING_WAYLAND +#include +#endif + +#else // GTK+ 2.0 + #define GDK_WINDOWING_X11 #define GDK_IS_X11_WINDOW(window) TRUE #define GDK_IS_X11_DISPLAY(display) TRUE -#define GDK_COMPAT_WINDOW_XID(window) (GDK_WINDOW_XWINDOW (window)) +#define gdk_x11_window_get_xid(window) GDK_WINDOW_XWINDOW (window) + +inline void gdk_window_get_geometry (GdkWindow *window, + gint *x, + gint *y, + gint *width, + gint *height) +{ + gdk_window_get_geometry (window, x, y, width, height, NULL); +} + +#endif + +#ifdef GDK_WINDOWING_X11 +#include #endif #endif diff --git a/gtk/src/gtk_binding.cpp b/gtk/src/gtk_binding.cpp index e83dea8d..da9afb83 100644 --- a/gtk/src/gtk_binding.cpp +++ b/gtk/src/gtk_binding.cpp @@ -1,13 +1,6 @@ #include #include #include -#include -#include -#include -#if GTK_MAJOR_VERSION >= 3 -#include -#endif - #include "gtk_s9x.h" #include "gtk_binding.h" diff --git a/gtk/src/gtk_binding.h b/gtk/src/gtk_binding.h index 7f18a3d9..7acad208 100644 --- a/gtk/src/gtk_binding.h +++ b/gtk/src/gtk_binding.h @@ -1,7 +1,7 @@ #ifndef __GTK_BINDING_H #define __GTK_BINDING_H -#include +#include "gtk_2_3_compat.h" #define AXIS_POS 1 #define AXIS_NEG 0 diff --git a/gtk/src/gtk_builder_window.h b/gtk/src/gtk_builder_window.h index 63a4d291..b6625d53 100644 --- a/gtk/src/gtk_builder_window.h +++ b/gtk/src/gtk_builder_window.h @@ -1,7 +1,7 @@ #ifndef __GTK_BUILDER_WINDOW_H #define __GTK_BUILDER_WINDOW_H -#include +#include "gtk_2_3_compat.h" typedef struct { diff --git a/gtk/src/gtk_display.cpp b/gtk/src/gtk_display.cpp index ace8be80..a94b6f3a 100644 --- a/gtk/src/gtk_display.cpp +++ b/gtk/src/gtk_display.cpp @@ -1,11 +1,4 @@ #include "gtk_2_3_compat.h" -#include -#ifdef GDK_WINDOWING_X11 -#include -#endif -#ifdef GDK_WINDOWING_WAYLAND -#include -#endif #include #include "gtk_s9x.h" @@ -1548,7 +1541,7 @@ S9xQueryDrivers () if (GDK_IS_X11_DISPLAY (display)) { Display *dpy = gdk_x11_display_get_xdisplay (gtk_widget_get_display (GTK_WIDGET (top_level->get_window()))); - Window xid = GDK_COMPAT_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (top_level->get_window()))); + Window xid = gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (top_level->get_window()))); gui_config->allow_xrandr = 1; gui_config->xrr_screen_resources = XRRGetScreenResourcesCurrent (dpy, xid); diff --git a/gtk/src/gtk_display_driver_gtk.cpp b/gtk/src/gtk_display_driver_gtk.cpp index fc736cb0..4327341b 100644 --- a/gtk/src/gtk_display_driver_gtk.cpp +++ b/gtk/src/gtk_display_driver_gtk.cpp @@ -1,5 +1,4 @@ -#include -#include +#include "gtk_2_3_compat.h" #include #include "gtk_display.h" #include "gtk_display_driver_gtk.h" diff --git a/gtk/src/gtk_display_driver_opengl.cpp b/gtk/src/gtk_display_driver_opengl.cpp index 69897d12..385a8508 100644 --- a/gtk/src/gtk_display_driver_opengl.cpp +++ b/gtk/src/gtk_display_driver_opengl.cpp @@ -1,4 +1,4 @@ -#include +#include "gtk_2_3_compat.h" #include #include #include diff --git a/gtk/src/gtk_display_driver_xv.cpp b/gtk/src/gtk_display_driver_xv.cpp index 1b2cd3de..05175408 100644 --- a/gtk/src/gtk_display_driver_xv.cpp +++ b/gtk/src/gtk_display_driver_xv.cpp @@ -1,5 +1,3 @@ -#include -#include #include "gtk_2_3_compat.h" #include #include @@ -62,7 +60,7 @@ S9xXVDisplayDriver::create_window (int width, int height) gdk_window_set_user_data (gdk_window, (gpointer) drawing_area); gdk_window_show (gdk_window); - xwindow = GDK_COMPAT_WINDOW_XID (gdk_window); + xwindow = gdk_x11_window_get_xid (gdk_window); output_window_width = width; output_window_height = height; @@ -245,7 +243,7 @@ S9xXVDisplayDriver::init () xv_portid = -1; XvQueryAdaptors (display, - GDK_COMPAT_WINDOW_XID (root), + gdk_x11_window_get_xid (root), &num_adaptors, &adaptors); @@ -414,7 +412,7 @@ S9xXVDisplayDriver::init () } xcolormap = XCreateColormap (display, - GDK_COMPAT_WINDOW_XID (gtk_widget_get_window (drawing_area)), + gdk_x11_window_get_xid (gtk_widget_get_window (drawing_area)), vi->visual, AllocNone); diff --git a/gtk/src/gtk_file.cpp b/gtk/src/gtk_file.cpp index 393e9efe..a83b031e 100644 --- a/gtk/src/gtk_file.cpp +++ b/gtk/src/gtk_file.cpp @@ -1,7 +1,7 @@ #include -#include #include +#include "gtk_2_3_compat.h" #include "gtk_s9x.h" static char buf[PATH_MAX]; diff --git a/gtk/src/gtk_glx_context.cpp b/gtk/src/gtk_glx_context.cpp index 65d9c8ce..139983ab 100644 --- a/gtk/src/gtk_glx_context.cpp +++ b/gtk/src/gtk_glx_context.cpp @@ -73,11 +73,7 @@ bool GTKGLXContext::attach (GtkWidget *widget) vi = glXGetVisualFromFBConfig (display, fbconfig); -#if GTK_MAJOR_VERSION < 3 - gdk_window_get_geometry (parent_gdk_window, &x, &y, &width, &height, NULL); -#else gdk_window_get_geometry (parent_gdk_window, &x, &y, &width, &height); -#endif memset (&window_attr, 0, sizeof (GdkWindowAttr)); window_attr.event_mask = GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK; window_attr.width = width; @@ -89,7 +85,7 @@ bool GTKGLXContext::attach (GtkWidget *widget) gdk_window = gdk_window_new (window, &window_attr, GDK_WA_VISUAL); gdk_window_set_user_data (gdk_window, (gpointer) widget); gdk_window_show (gdk_window); - xid = GDK_COMPAT_WINDOW_XID (gdk_window); + xid = gdk_x11_window_get_xid (gdk_window); return true; } @@ -121,11 +117,7 @@ bool GTKGLXContext::create_context () void GTKGLXContext::resize () { -#if GTK_MAJOR_VERSION < 3 - gdk_window_get_geometry (parent_gdk_window, &x, &y, &width, &height, NULL); -#else gdk_window_get_geometry (parent_gdk_window, &x, &y, &width, &height); -#endif if (window_attr.width == width && window_attr.height == height) return; @@ -137,7 +129,7 @@ void GTKGLXContext::resize () gdk_window = gdk_window_new (parent_gdk_window, &window_attr, GDK_WA_VISUAL); gdk_window_set_user_data (gdk_window, (gpointer) widget); gdk_window_show (gdk_window); - xid = GDK_COMPAT_WINDOW_XID (gdk_window); + xid = gdk_x11_window_get_xid (gdk_window); make_current (); } diff --git a/gtk/src/gtk_glx_context.h b/gtk/src/gtk_glx_context.h index 72c69f30..a274773e 100644 --- a/gtk/src/gtk_glx_context.h +++ b/gtk/src/gtk_glx_context.h @@ -1,8 +1,7 @@ #ifndef __GTK_GLX_CONTEXT_H #define __GTK_GLX_CONTEXT_H -#include -#include +#include "gtk_2_3_compat.h" #include #include "gtk_opengl_context.h" diff --git a/gtk/src/gtk_opengl_context.h b/gtk/src/gtk_opengl_context.h index 9e9cb8f8..7e088e17 100644 --- a/gtk/src/gtk_opengl_context.h +++ b/gtk/src/gtk_opengl_context.h @@ -1,7 +1,7 @@ #ifndef __GTK_OPENGL_CONTEXT_H #define __GTK_OPENGL_CONTEXT_H -#include +#include "gtk_2_3_compat.h" class OpenGLContext { diff --git a/gtk/src/gtk_preferences.cpp b/gtk/src/gtk_preferences.cpp index fb216a31..c414af8b 100644 --- a/gtk/src/gtk_preferences.cpp +++ b/gtk/src/gtk_preferences.cpp @@ -1,11 +1,6 @@ #include #include -#include #include "gtk_2_3_compat.h" -#ifdef GDK_WINDOWING_X11 -#include -#endif - #include "gtk_preferences.h" #include "gtk_config.h" #include "gtk_s9xcore.h" @@ -14,10 +9,6 @@ #include "gtk_display.h" #include "gtk_binding.h" -#if GTK_MAJOR_VERSION >= 3 -#include -#endif - #define SAME_GAME _("Same location as current game") gboolean diff --git a/gtk/src/gtk_preferences.h b/gtk/src/gtk_preferences.h index b872e982..9b104de4 100644 --- a/gtk/src/gtk_preferences.h +++ b/gtk/src/gtk_preferences.h @@ -1,7 +1,7 @@ #ifndef __GTK_PREFERENCES_H #define __GTK_PREFERENCES_H -#include +#include "gtk_2_3_compat.h" #include "gtk_s9x.h" #include "gtk_builder_window.h" diff --git a/gtk/src/gtk_s9x.cpp b/gtk/src/gtk_s9x.cpp index 42669f9d..fd3a7f8e 100644 --- a/gtk/src/gtk_s9x.cpp +++ b/gtk/src/gtk_s9x.cpp @@ -1,11 +1,6 @@ #include #include -#include #include "gtk_2_3_compat.h" -#ifdef GDK_WINDOWING_X11 -#include -#endif - #include "gtk_s9x.h" #include "gtk_control.h" #include "gtk_sound.h" diff --git a/gtk/src/gtk_s9x.h b/gtk/src/gtk_s9x.h index 6920b273..d9e3241f 100644 --- a/gtk/src/gtk_s9x.h +++ b/gtk/src/gtk_s9x.h @@ -1,8 +1,6 @@ #ifndef __GTK_S9X_H #define __GTK_S9X_H -#include - #include "gtk_config.h" #include "gtk_s9xcore.h" #include "gtk_s9xwindow.h" diff --git a/gtk/src/gtk_s9xwindow.cpp b/gtk/src/gtk_s9xwindow.cpp index f416827d..78d26b2d 100644 --- a/gtk/src/gtk_s9xwindow.cpp +++ b/gtk/src/gtk_s9xwindow.cpp @@ -1,12 +1,7 @@ #include "gtk_2_3_compat.h" -#include #ifdef GDK_WINDOWING_X11 -#include #include #endif -#ifdef GDK_WINDOWING_WAYLAND -#include -#endif #include #include @@ -32,10 +27,6 @@ #include "gtk_netplay.h" #endif -#if GTK_MAJOR_VERSION >= 3 -#include -#endif - static gboolean event_main_window_delete (GtkWidget *widget, GdkEvent *event, @@ -1633,7 +1624,7 @@ Snes9xWindow::get_refresh_rate () #ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY (display)) { - Window xid = GDK_COMPAT_WINDOW_XID (gtk_widget_get_window (window)); + Window xid = gdk_x11_window_get_xid (gtk_widget_get_window (window)); Display *dpy = gdk_x11_display_get_xdisplay (gtk_widget_get_display (window)); refresh_rate = XRRGetExactRefreshRate (dpy, xid); } @@ -1741,7 +1732,7 @@ Snes9xWindow::enter_fullscreen_mode () if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (window)))) { set_bypass_compositor (gdk_x11_display_get_xdisplay (gtk_widget_get_display (GTK_WIDGET (window))), - GDK_COMPAT_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window))), + gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (window))), 1); } #endif @@ -1798,7 +1789,7 @@ Snes9xWindow::leave_fullscreen_mode () if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (window)))) { set_bypass_compositor (gdk_x11_display_get_xdisplay (gtk_widget_get_display (GTK_WIDGET (window))), - GDK_COMPAT_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window))), + gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (window))), 0); } #endif diff --git a/gtk/src/gtk_s9xwindow.h b/gtk/src/gtk_s9xwindow.h index 5c04bf26..e31ba301 100644 --- a/gtk/src/gtk_s9xwindow.h +++ b/gtk/src/gtk_s9xwindow.h @@ -1,7 +1,7 @@ #ifndef __GTK_S9XWINDOW_H #define __GTK_S9XWINDOW_H -#include +#include "gtk_2_3_compat.h" #include "port.h" #include "gtk_builder_window.h" diff --git a/gtk/src/gtk_shader_parameters.cpp b/gtk/src/gtk_shader_parameters.cpp index 442c0091..f262dfce 100644 --- a/gtk/src/gtk_shader_parameters.cpp +++ b/gtk/src/gtk_shader_parameters.cpp @@ -1,4 +1,4 @@ -#include +#include "gtk_2_3_compat.h" #include #include diff --git a/gtk/src/gtk_shader_parameters.h b/gtk/src/gtk_shader_parameters.h index f13903fe..a1dc9080 100644 --- a/gtk/src/gtk_shader_parameters.h +++ b/gtk/src/gtk_shader_parameters.h @@ -1,7 +1,7 @@ #ifndef __GTK_SHADER_PARAMETERS_H #define __GTK_SHADER_PARAMETERS_H -#include +#include "gtk_2_3_compat.h" bool gtk_shader_parameters_dialog (GtkWindow *parent); void gtk_shader_parameters_dialog_close (); diff --git a/gtk/src/gtk_wayland_egl_context.h b/gtk/src/gtk_wayland_egl_context.h index a4357e39..b2345702 100644 --- a/gtk/src/gtk_wayland_egl_context.h +++ b/gtk/src/gtk_wayland_egl_context.h @@ -1,7 +1,7 @@ #ifndef __GTK_WAYLAND_EGL_CONTEXT_H #define __GTK_WAYLAND_EGL_CONTEXT_H -#include + #include #include