From 5b1f20ec52de2284aa780200932d3c401d6fdd92 Mon Sep 17 00:00:00 2001 From: BearOso Date: Mon, 14 Oct 2024 15:49:36 -0500 Subject: [PATCH] Gtk: Use is_x11 function. --- gtk/src/gtk_compat.h | 4 ++++ gtk/src/gtk_display.cpp | 4 ++-- gtk/src/gtk_display_driver_vulkan.cpp | 2 +- gtk/src/gtk_s9x.cpp | 2 +- gtk/src/gtk_s9xwindow.cpp | 9 ++++----- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/gtk/src/gtk_compat.h b/gtk/src/gtk_compat.h index c642bd09..03a158a7 100644 --- a/gtk/src/gtk_compat.h +++ b/gtk/src/gtk_compat.h @@ -28,6 +28,10 @@ inline bool is_wayland() #ifdef GDK_WINDOWING_X11 #include +inline bool is_x11() +{ + return GDK_IS_X11_DISPLAY(gdk_display_get_default()); +} #endif #endif diff --git a/gtk/src/gtk_display.cpp b/gtk/src/gtk_display.cpp index 2d9601d1..c47ff334 100644 --- a/gtk/src/gtk_display.cpp +++ b/gtk/src/gtk_display.cpp @@ -789,7 +789,7 @@ void S9xQueryDrivers() gui_config->allow_xv = false; #if defined(USE_XV) && defined(GDK_WINDOWING_X11) - if (GDK_IS_X11_DISPLAY(gdk_display)) + if (is_x11()) gui_config->allow_xv = S9xXVDisplayDriver::query_availability(); #endif @@ -797,7 +797,7 @@ void S9xQueryDrivers() gui_config->allow_xrandr = false; #ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY(gdk_display)) + if (is_x11()) { Display *dpy = gdk_x11_display_get_xdisplay(gdk_display); Window xid = gdk_x11_window_get_xid(top_level->window->get_window()->gobj()); diff --git a/gtk/src/gtk_display_driver_vulkan.cpp b/gtk/src/gtk_display_driver_vulkan.cpp index 02a91a97..67838eaf 100644 --- a/gtk/src/gtk_display_driver_vulkan.cpp +++ b/gtk/src/gtk_display_driver_vulkan.cpp @@ -141,7 +141,7 @@ int S9xVulkanDisplayDriver::init() } } #endif - if (GDK_IS_X11_WINDOW(drawing_area->get_window()->gobj())) + if (is_x11()) { display = gdk_x11_display_get_xdisplay(drawing_area->get_display()->gobj()); xid = gdk_x11_window_get_xid(drawing_area->get_window()->gobj()); diff --git a/gtk/src/gtk_s9x.cpp b/gtk/src/gtk_s9x.cpp index 577c7d47..95eda956 100644 --- a/gtk/src/gtk_s9x.cpp +++ b/gtk/src/gtk_s9x.cpp @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) top_level = new Snes9xWindow(gui_config); #ifdef GDK_WINDOWING_X11 - if (!GDK_IS_X11_WINDOW(top_level->window->get_window()->gobj())) + if (!is_x11()) XInitThreads(); #endif diff --git a/gtk/src/gtk_s9xwindow.cpp b/gtk/src/gtk_s9xwindow.cpp index fe4e8595..cf8a13ba 100644 --- a/gtk/src/gtk_s9xwindow.cpp +++ b/gtk/src/gtk_s9xwindow.cpp @@ -981,7 +981,7 @@ void Snes9xWindow::reset_screensaver() GdkDisplay *gdk_display = window->get_display()->gobj(); #ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_WINDOW(gdk_window)) + if (is_x11()) { XResetScreenSaver(GDK_DISPLAY_XDISPLAY(gdk_display)); } @@ -1052,7 +1052,7 @@ Snes9xWindow::get_refresh_rate() #endif #ifdef GDK_WINDOWING_X11 - if (!is_wayland()) + if (is_x11()) { Window xid = gdk_x11_window_get_xid(gdk_window); Display *dpy = gdk_x11_display_get_xdisplay(gdk_display); @@ -1105,8 +1105,7 @@ void Snes9xWindow::set_bypass_compositor(bool bypass) { #ifdef GDK_WINDOWING_X11 auto gdk_window = window->get_window()->gobj(); - if (GDK_IS_X11_WINDOW(gdk_window) && - config->default_esc_behavior != ESC_TOGGLE_MENUBAR) + if (is_x11() && config->default_esc_behavior != ESC_TOGGLE_MENUBAR) { auto gdk_display = window->get_display()->gobj(); Display *dpy = gdk_x11_display_get_xdisplay(gdk_display); @@ -1124,7 +1123,7 @@ void Snes9xWindow::set_custom_video_mode(bool enable) GdkDisplay *gdk_display = window->get_display()->gobj(); GdkWindow *gdk_window = window->get_window()->gobj(); - if (!GDK_IS_X11_WINDOW(window->get_window()->gobj())) + if (!is_x11()) return; Display *dpy = gdk_x11_display_get_xdisplay(gdk_display);