From a47e9773d65ea78fb57d492dad2bff670ebcacb5 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Tue, 16 Oct 2018 17:26:24 -0500 Subject: [PATCH] Software Wayland mostly works. --- gtk/src/gtk_display.cpp | 25 +++++++++++++++++++++---- gtk/src/gtk_display.h | 1 + gtk/src/gtk_s9x.h | 3 +++ gtk/src/gtk_s9xwindow.cpp | 17 +++++++++++++---- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/gtk/src/gtk_display.cpp b/gtk/src/gtk_display.cpp index fce472db..7616e55b 100644 --- a/gtk/src/gtk_display.cpp +++ b/gtk/src/gtk_display.cpp @@ -1577,10 +1577,12 @@ S9xDisplayReconfigure (void) void S9xQueryDrivers (void) { -#if defined(USE_XV) && defined(GDK_WINDOWING_X11) - gui_config->allow_xv = S9xXVDisplayDriver::query_availability (); -#else + GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (top_level->get_window())); + gui_config->allow_xv = 0; +#if defined(USE_XV) && defined(GDK_WINDOWING_X11) + if (GDK_IS_X11_DISPLAY (display)) + gui_config->allow_xv = S9xXVDisplayDriver::query_availability (); #endif #ifdef USE_OPENGL @@ -1591,7 +1593,6 @@ S9xQueryDrivers (void) gui_config->allow_xrandr = 0; #ifdef GDK_WINDOWING_X11 - GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (top_level->get_window())); if (GDK_IS_X11_DISPLAY (display)) { int error_base_p, event_base_p; @@ -1612,6 +1613,22 @@ S9xQueryDrivers (void) bool8 S9xDeinitUpdate (int width, int height) +{ + GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (top_level->get_window ())); + +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_X11_WINDOW (gdk_window)) + { + return S9xRealDeinitUpdate (width, height); + } +#endif + + gtk_widget_queue_draw (GTK_WIDGET (top_level->drawing_area)); + return TRUE; +} + +bool8 +S9xRealDeinitUpdate (int width, int height) { int yoffset = 0; diff --git a/gtk/src/gtk_display.h b/gtk/src/gtk_display.h index 989da4fc..d2174241 100644 --- a/gtk/src/gtk_display.h +++ b/gtk/src/gtk_display.h @@ -111,6 +111,7 @@ void S9xDisplayClearBuffers (void); void S9xReinitDisplay (void); void S9xDisplayReconfigure (void); void S9xQueryDrivers (void); +bool8 S9xRealDeinitUpdate (int width, int height); S9xDisplayDriver *S9xDisplayGetDriver (void); diff --git a/gtk/src/gtk_s9x.h b/gtk/src/gtk_s9x.h index 054422ac..c2ef0134 100644 --- a/gtk/src/gtk_s9x.h +++ b/gtk/src/gtk_s9x.h @@ -39,6 +39,9 @@ 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 diff --git a/gtk/src/gtk_s9xwindow.cpp b/gtk/src/gtk_s9xwindow.cpp index 592e0635..4e2480ff 100644 --- a/gtk/src/gtk_s9xwindow.cpp +++ b/gtk/src/gtk_s9xwindow.cpp @@ -765,14 +765,23 @@ Snes9xWindow::expose (void) config->window_height = get_height (); } - if (is_paused () +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_X11_WINDOW (gtk_widget_get_window (window))) + { + if (is_paused () #ifdef NETPLAY_SUPPORT || NetPlay.Paused #endif - ) - { - S9xDeinitUpdate (last_width, last_height); + ) + { + S9xDeinitUpdate (last_width, last_height); + } + + return; } +#endif + + S9xRealDeinitUpdate (last_width, last_height); return; }