GTK+: Consolidate includes to compat header.

This commit is contained in:
Brandon Wright 2018-11-06 18:46:44 -06:00
parent 0f15a398f9
commit a9cc03c06c
21 changed files with 46 additions and 75 deletions

View File

@ -3,14 +3,36 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#if GTK_MAJOR_VERSION >= 3 #if GTK_MAJOR_VERSION >= 3
#define GDK_COMPAT_WINDOW_XID(window) (gdk_x11_window_get_xid (window))
#else #include <gdk/gdkkeysyms-compat.h>
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif
#else // GTK+ 2.0
#define GDK_WINDOWING_X11 #define GDK_WINDOWING_X11
#define GDK_IS_X11_WINDOW(window) TRUE #define GDK_IS_X11_WINDOW(window) TRUE
#define GDK_IS_X11_DISPLAY(display) 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 <gdk/gdkx.h>
#endif #endif
#endif #endif

View File

@ -1,13 +1,6 @@
#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/gdkkeysyms.h>
#if GTK_MAJOR_VERSION >= 3
#include <gdk/gdkkeysyms-compat.h>
#endif
#include "gtk_s9x.h" #include "gtk_s9x.h"
#include "gtk_binding.h" #include "gtk_binding.h"

View File

@ -1,7 +1,7 @@
#ifndef __GTK_BINDING_H #ifndef __GTK_BINDING_H
#define __GTK_BINDING_H #define __GTK_BINDING_H
#include <gdk/gdk.h> #include "gtk_2_3_compat.h"
#define AXIS_POS 1 #define AXIS_POS 1
#define AXIS_NEG 0 #define AXIS_NEG 0

View File

@ -1,7 +1,7 @@
#ifndef __GTK_BUILDER_WINDOW_H #ifndef __GTK_BUILDER_WINDOW_H
#define __GTK_BUILDER_WINDOW_H #define __GTK_BUILDER_WINDOW_H
#include <gtk/gtk.h> #include "gtk_2_3_compat.h"
typedef struct typedef struct
{ {

View File

@ -1,11 +1,4 @@
#include "gtk_2_3_compat.h" #include "gtk_2_3_compat.h"
#include <gdk/gdk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif
#include <sched.h> #include <sched.h>
#include "gtk_s9x.h" #include "gtk_s9x.h"
@ -1548,7 +1541,7 @@ S9xQueryDrivers ()
if (GDK_IS_X11_DISPLAY (display)) if (GDK_IS_X11_DISPLAY (display))
{ {
Display *dpy = gdk_x11_display_get_xdisplay (gtk_widget_get_display (GTK_WIDGET (top_level->get_window()))); 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->allow_xrandr = 1;
gui_config->xrr_screen_resources = XRRGetScreenResourcesCurrent (dpy, xid); gui_config->xrr_screen_resources = XRRGetScreenResourcesCurrent (dpy, xid);

View File

@ -1,5 +1,4 @@
#include <gtk/gtk.h> #include "gtk_2_3_compat.h"
#include <gdk/gdk.h>
#include <cairo.h> #include <cairo.h>
#include "gtk_display.h" #include "gtk_display.h"
#include "gtk_display_driver_gtk.h" #include "gtk_display_driver_gtk.h"

View File

@ -1,4 +1,4 @@
#include <gtk/gtk.h> #include "gtk_2_3_compat.h"
#include <dlfcn.h> #include <dlfcn.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>

View File

@ -1,5 +1,3 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "gtk_2_3_compat.h" #include "gtk_2_3_compat.h"
#include <X11/extensions/XShm.h> #include <X11/extensions/XShm.h>
#include <X11/extensions/Xv.h> #include <X11/extensions/Xv.h>
@ -62,7 +60,7 @@ S9xXVDisplayDriver::create_window (int width, int height)
gdk_window_set_user_data (gdk_window, (gpointer) drawing_area); gdk_window_set_user_data (gdk_window, (gpointer) drawing_area);
gdk_window_show (gdk_window); 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_width = width;
output_window_height = height; output_window_height = height;
@ -245,7 +243,7 @@ S9xXVDisplayDriver::init ()
xv_portid = -1; xv_portid = -1;
XvQueryAdaptors (display, XvQueryAdaptors (display,
GDK_COMPAT_WINDOW_XID (root), gdk_x11_window_get_xid (root),
&num_adaptors, &num_adaptors,
&adaptors); &adaptors);
@ -414,7 +412,7 @@ S9xXVDisplayDriver::init ()
} }
xcolormap = XCreateColormap (display, 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, vi->visual,
AllocNone); AllocNone);

View File

@ -1,7 +1,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <gtk/gtk.h>
#include <errno.h> #include <errno.h>
#include "gtk_2_3_compat.h"
#include "gtk_s9x.h" #include "gtk_s9x.h"
static char buf[PATH_MAX]; static char buf[PATH_MAX];

View File

@ -73,11 +73,7 @@ bool GTKGLXContext::attach (GtkWidget *widget)
vi = glXGetVisualFromFBConfig (display, fbconfig); 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); gdk_window_get_geometry (parent_gdk_window, &x, &y, &width, &height);
#endif
memset (&window_attr, 0, sizeof (GdkWindowAttr)); memset (&window_attr, 0, sizeof (GdkWindowAttr));
window_attr.event_mask = GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK; window_attr.event_mask = GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK;
window_attr.width = width; 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 = gdk_window_new (window, &window_attr, GDK_WA_VISUAL);
gdk_window_set_user_data (gdk_window, (gpointer) widget); gdk_window_set_user_data (gdk_window, (gpointer) widget);
gdk_window_show (gdk_window); gdk_window_show (gdk_window);
xid = GDK_COMPAT_WINDOW_XID (gdk_window); xid = gdk_x11_window_get_xid (gdk_window);
return true; return true;
} }
@ -121,11 +117,7 @@ bool GTKGLXContext::create_context ()
void GTKGLXContext::resize () 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); gdk_window_get_geometry (parent_gdk_window, &x, &y, &width, &height);
#endif
if (window_attr.width == width && window_attr.height == height) if (window_attr.width == width && window_attr.height == height)
return; return;
@ -137,7 +129,7 @@ void GTKGLXContext::resize ()
gdk_window = gdk_window_new (parent_gdk_window, &window_attr, GDK_WA_VISUAL); gdk_window = gdk_window_new (parent_gdk_window, &window_attr, GDK_WA_VISUAL);
gdk_window_set_user_data (gdk_window, (gpointer) widget); gdk_window_set_user_data (gdk_window, (gpointer) widget);
gdk_window_show (gdk_window); gdk_window_show (gdk_window);
xid = GDK_COMPAT_WINDOW_XID (gdk_window); xid = gdk_x11_window_get_xid (gdk_window);
make_current (); make_current ();
} }

View File

@ -1,8 +1,7 @@
#ifndef __GTK_GLX_CONTEXT_H #ifndef __GTK_GLX_CONTEXT_H
#define __GTK_GLX_CONTEXT_H #define __GTK_GLX_CONTEXT_H
#include <gtk/gtk.h> #include "gtk_2_3_compat.h"
#include <gdk/gdkx.h>
#include <epoxy/glx.h> #include <epoxy/glx.h>
#include "gtk_opengl_context.h" #include "gtk_opengl_context.h"

View File

@ -1,7 +1,7 @@
#ifndef __GTK_OPENGL_CONTEXT_H #ifndef __GTK_OPENGL_CONTEXT_H
#define __GTK_OPENGL_CONTEXT_H #define __GTK_OPENGL_CONTEXT_H
#include <gtk/gtk.h> #include "gtk_2_3_compat.h"
class OpenGLContext class OpenGLContext
{ {

View File

@ -1,11 +1,6 @@
#include <string> #include <string>
#include <stdlib.h> #include <stdlib.h>
#include <gdk/gdkkeysyms.h>
#include "gtk_2_3_compat.h" #include "gtk_2_3_compat.h"
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include "gtk_preferences.h" #include "gtk_preferences.h"
#include "gtk_config.h" #include "gtk_config.h"
#include "gtk_s9xcore.h" #include "gtk_s9xcore.h"
@ -14,10 +9,6 @@
#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

View File

@ -1,7 +1,7 @@
#ifndef __GTK_PREFERENCES_H #ifndef __GTK_PREFERENCES_H
#define __GTK_PREFERENCES_H #define __GTK_PREFERENCES_H
#include <gtk/gtk.h> #include "gtk_2_3_compat.h"
#include "gtk_s9x.h" #include "gtk_s9x.h"
#include "gtk_builder_window.h" #include "gtk_builder_window.h"

View File

@ -1,11 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include <gdk/gdk.h>
#include "gtk_2_3_compat.h" #include "gtk_2_3_compat.h"
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include "gtk_s9x.h" #include "gtk_s9x.h"
#include "gtk_control.h" #include "gtk_control.h"
#include "gtk_sound.h" #include "gtk_sound.h"

View File

@ -1,8 +1,6 @@
#ifndef __GTK_S9X_H #ifndef __GTK_S9X_H
#define __GTK_S9X_H #define __GTK_S9X_H
#include <gtk/gtk.h>
#include "gtk_config.h" #include "gtk_config.h"
#include "gtk_s9xcore.h" #include "gtk_s9xcore.h"
#include "gtk_s9xwindow.h" #include "gtk_s9xwindow.h"

View File

@ -1,12 +1,7 @@
#include "gtk_2_3_compat.h" #include "gtk_2_3_compat.h"
#include <gdk/gdk.h>
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#endif #endif
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <cairo.h> #include <cairo.h>
@ -32,10 +27,6 @@
#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,
@ -1633,7 +1624,7 @@ Snes9xWindow::get_refresh_rate ()
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (display)) 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)); Display *dpy = gdk_x11_display_get_xdisplay (gtk_widget_get_display (window));
refresh_rate = XRRGetExactRefreshRate (dpy, xid); 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)))) 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))), 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); 1);
} }
#endif #endif
@ -1798,7 +1789,7 @@ Snes9xWindow::leave_fullscreen_mode ()
if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (window)))) 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))), 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); 0);
} }
#endif #endif

View File

@ -1,7 +1,7 @@
#ifndef __GTK_S9XWINDOW_H #ifndef __GTK_S9XWINDOW_H
#define __GTK_S9XWINDOW_H #define __GTK_S9XWINDOW_H
#include <gtk/gtk.h> #include "gtk_2_3_compat.h"
#include "port.h" #include "port.h"
#include "gtk_builder_window.h" #include "gtk_builder_window.h"

View File

@ -1,4 +1,4 @@
#include <gtk/gtk.h> #include "gtk_2_3_compat.h"
#include <vector> #include <vector>
#include <math.h> #include <math.h>

View File

@ -1,7 +1,7 @@
#ifndef __GTK_SHADER_PARAMETERS_H #ifndef __GTK_SHADER_PARAMETERS_H
#define __GTK_SHADER_PARAMETERS_H #define __GTK_SHADER_PARAMETERS_H
#include <gtk/gtk.h> #include "gtk_2_3_compat.h"
bool gtk_shader_parameters_dialog (GtkWindow *parent); bool gtk_shader_parameters_dialog (GtkWindow *parent);
void gtk_shader_parameters_dialog_close (); void gtk_shader_parameters_dialog_close ();

View File

@ -1,7 +1,7 @@
#ifndef __GTK_WAYLAND_EGL_CONTEXT_H #ifndef __GTK_WAYLAND_EGL_CONTEXT_H
#define __GTK_WAYLAND_EGL_CONTEXT_H #define __GTK_WAYLAND_EGL_CONTEXT_H
#include <gdk/gdkwayland.h>
#include <wayland-egl.h> #include <wayland-egl.h>
#include <epoxy/egl.h> #include <epoxy/egl.h>