Gtk: Use is_x11 function.

This commit is contained in:
BearOso 2024-10-14 15:49:36 -05:00
parent 1fc9f26522
commit 5b1f20ec52
5 changed files with 12 additions and 9 deletions

View File

@ -28,6 +28,10 @@ inline bool is_wayland()
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
inline bool is_x11()
{
return GDK_IS_X11_DISPLAY(gdk_display_get_default());
}
#endif #endif
#endif #endif

View File

@ -789,7 +789,7 @@ void S9xQueryDrivers()
gui_config->allow_xv = false; gui_config->allow_xv = false;
#if defined(USE_XV) && defined(GDK_WINDOWING_X11) #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(); gui_config->allow_xv = S9xXVDisplayDriver::query_availability();
#endif #endif
@ -797,7 +797,7 @@ void S9xQueryDrivers()
gui_config->allow_xrandr = false; gui_config->allow_xrandr = false;
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY(gdk_display)) if (is_x11())
{ {
Display *dpy = gdk_x11_display_get_xdisplay(gdk_display); Display *dpy = gdk_x11_display_get_xdisplay(gdk_display);
Window xid = gdk_x11_window_get_xid(top_level->window->get_window()->gobj()); Window xid = gdk_x11_window_get_xid(top_level->window->get_window()->gobj());

View File

@ -141,7 +141,7 @@ int S9xVulkanDisplayDriver::init()
} }
} }
#endif #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()); display = gdk_x11_display_get_xdisplay(drawing_area->get_display()->gobj());
xid = gdk_x11_window_get_xid(drawing_area->get_window()->gobj()); xid = gdk_x11_window_get_xid(drawing_area->get_window()->gobj());

View File

@ -87,7 +87,7 @@ int main(int argc, char *argv[])
top_level = new Snes9xWindow(gui_config); top_level = new Snes9xWindow(gui_config);
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
if (!GDK_IS_X11_WINDOW(top_level->window->get_window()->gobj())) if (!is_x11())
XInitThreads(); XInitThreads();
#endif #endif

View File

@ -981,7 +981,7 @@ void Snes9xWindow::reset_screensaver()
GdkDisplay *gdk_display = window->get_display()->gobj(); GdkDisplay *gdk_display = window->get_display()->gobj();
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_WINDOW(gdk_window)) if (is_x11())
{ {
XResetScreenSaver(GDK_DISPLAY_XDISPLAY(gdk_display)); XResetScreenSaver(GDK_DISPLAY_XDISPLAY(gdk_display));
} }
@ -1052,7 +1052,7 @@ Snes9xWindow::get_refresh_rate()
#endif #endif
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
if (!is_wayland()) if (is_x11())
{ {
Window xid = gdk_x11_window_get_xid(gdk_window); Window xid = gdk_x11_window_get_xid(gdk_window);
Display *dpy = gdk_x11_display_get_xdisplay(gdk_display); Display *dpy = gdk_x11_display_get_xdisplay(gdk_display);
@ -1105,8 +1105,7 @@ void Snes9xWindow::set_bypass_compositor(bool bypass)
{ {
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
auto gdk_window = window->get_window()->gobj(); auto gdk_window = window->get_window()->gobj();
if (GDK_IS_X11_WINDOW(gdk_window) && if (is_x11() && config->default_esc_behavior != ESC_TOGGLE_MENUBAR)
config->default_esc_behavior != ESC_TOGGLE_MENUBAR)
{ {
auto gdk_display = window->get_display()->gobj(); auto gdk_display = window->get_display()->gobj();
Display *dpy = gdk_x11_display_get_xdisplay(gdk_display); 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(); GdkDisplay *gdk_display = window->get_display()->gobj();
GdkWindow *gdk_window = window->get_window()->gobj(); GdkWindow *gdk_window = window->get_window()->gobj();
if (!GDK_IS_X11_WINDOW(window->get_window()->gobj())) if (!is_x11())
return; return;
Display *dpy = gdk_x11_display_get_xdisplay(gdk_display); Display *dpy = gdk_x11_display_get_xdisplay(gdk_display);