GTK+: Fix GTK+ 2.0 compatibility again.

This commit is contained in:
Brandon Wright 2018-11-06 18:04:10 -06:00
parent 528839a13b
commit 0f15a398f9
13 changed files with 49 additions and 55 deletions

View File

@ -53,7 +53,8 @@ snes9x_gtk_SOURCES = \
src/snes_ntsc_config.h \
src/snes_ntsc.h \
src/snes_ntsc_impl.h \
src/snes_ntsc.c
src/snes_ntsc.c \
src/gtk_2_3_compat.h
if HQ2X
snes9x_gtk_SOURCES += \

16
gtk/src/gtk_2_3_compat.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef __GTK_2_3_COMPAT_H
#define __GTK_2_3_COMPAT_H
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#if GTK_MAJOR_VERSION >= 3
#define GDK_COMPAT_WINDOW_XID(window) (gdk_x11_window_get_xid (window))
#else
#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))
#endif
#endif

View File

@ -1,3 +1,4 @@
#include "gtk_2_3_compat.h"
#include <gdk/gdk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
@ -1560,22 +1561,6 @@ S9xQueryDrivers ()
bool8
S9xDeinitUpdate (int width, int height)
{
GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (top_level->get_window ()));
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_WINDOW (gdk_window) && gui_config->hw_accel == 0)
{
gtk_widget_queue_draw (GTK_WIDGET (top_level->drawing_area));
return TRUE;
}
#endif
return S9xRealDeinitUpdate (width, height);
}
bool8
S9xRealDeinitUpdate (int width, int height)
{
int yoffset = 0;

View File

@ -123,7 +123,6 @@ void S9xDisplayClearBuffers ();
void S9xReinitDisplay ();
void S9xDisplayReconfigure ();
void S9xQueryDrivers ();
bool8 S9xRealDeinitUpdate (int width, int height);
S9xDisplayDriver *S9xDisplayGetDriver ();

View File

@ -656,7 +656,7 @@ int S9xOpenGLDisplayDriver::query_availability ()
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (gdk_display))
{
Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display);
if (glXQueryExtension (dpy, NULL, NULL) == True)
{

View File

@ -7,6 +7,8 @@
#include <epoxy/gl.h>
#include "gtk_opengl_context.h"
#include "gtk_2_3_compat.h"
#ifdef GDK_WINDOWING_X11
#include "gtk_glx_context.h"
#endif

View File

@ -1,5 +1,6 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "gtk_2_3_compat.h"
#include <X11/extensions/XShm.h>
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvlib.h>

View File

@ -3,6 +3,7 @@
#include "gtk_s9x.h"
#include "gtk_glx_context.h"
#include "gtk_2_3_compat.h"
GTKGLXContext::GTKGLXContext ()
{
@ -72,8 +73,13 @@ bool GTKGLXContext::attach (GtkWidget *widget)
vi = glXGetVisualFromFBConfig (display, fbconfig);
gdk_window_get_geometry (window, &x, &y, &width, &height);
#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;
window_attr.height = height;
window_attr.wclass = GDK_INPUT_OUTPUT;
@ -115,7 +121,11 @@ 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;

View File

@ -1,6 +1,7 @@
#include <string>
#include <stdlib.h>
#include <gdk/gdkkeysyms.h>
#include "gtk_2_3_compat.h"
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif

View File

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

View File

@ -36,15 +36,6 @@
extern Snes9xWindow *top_level;
extern Snes9xConfig *gui_config;
#if GTK_MAJOR_VERSION >= 3
#define GDK_COMPAT_WINDOW_XID(window) (gdk_x11_window_get_xid (window))
#else
#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))
#endif
int S9xOpenROM (const char *filename);
void S9xNoROMLoaded ();
void S9xROMLoaded ();

View File

@ -1,13 +1,14 @@
#include "gtk_2_3_compat.h"
#include <gdk/gdk.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#include <X11/Xatom.h>
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif
#include <gdk/gdkkeysyms.h>
#include <cairo.h>
#include <X11/Xatom.h>
#ifdef USE_XV
#include <X11/extensions/XShm.h>
@ -623,6 +624,7 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
#if GTK_MAJOR_VERSION < 3
gtk_widget_set_double_buffered (GTK_WIDGET (drawing_area), FALSE);
gtk_widget_set_app_paintable (GTK_WIDGET (drawing_area), TRUE);
#endif
if (config->use_headerbar)
@ -789,29 +791,14 @@ Snes9xWindow::expose ()
config->window_height = get_height ();
}
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_WINDOW (gtk_widget_get_window (window)))
{
if (is_paused ()
if (is_paused ()
#ifdef NETPLAY_SUPPORT
|| NetPlay.Paused
#endif
)
{
S9xDeinitUpdate (last_width, last_height);
}
return;
}
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_WINDOW (gtk_widget_get_window (window)))
{
if (config->hw_accel == HWA_NONE || is_paused ())
S9xRealDeinitUpdate (last_width, last_height);
S9xDeinitUpdate (last_width, last_height);
}
#endif
}
void

View File

@ -7425,11 +7425,11 @@
<property name="resize_mode">queue</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkVBox">
<object class="GtkVBox" id="vbox_saved_states">
<property name="visible">True</property>
<property name="spacing">5</property>
<child>
<object class="GtkTable">
<object class="GtkTable" id="relative_state_table">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">10</property>
@ -7438,7 +7438,7 @@
<property name="column_spacing">10</property>
<property name="row_spacing">5</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="cur555">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@ -7471,7 +7471,7 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="cur556">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@ -7504,7 +7504,7 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="cur557">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@ -7537,7 +7537,7 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="cur558">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@ -7570,7 +7570,7 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="cur559">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@ -7603,7 +7603,7 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="cur560">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>