mirror of https://github.com/snes9xgit/snes9x.git
Gtk: Use a Wayland check function.
This commit is contained in:
parent
b19e31c83f
commit
0c228f0e0c
|
@ -20,6 +20,10 @@
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
#include <gdk/gdkwayland.h>
|
#include <gdk/gdkwayland.h>
|
||||||
|
inline bool is_wayland()
|
||||||
|
{
|
||||||
|
return GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
|
|
@ -912,7 +912,7 @@ static void S9xInitDriver()
|
||||||
{
|
{
|
||||||
// Only OpenGL is supported on Wayland
|
// Only OpenGL is supported on Wayland
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default()))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
if (gui_config->display_driver != "vulkan")
|
if (gui_config->display_driver != "vulkan")
|
||||||
gui_config->display_driver = "opengl";
|
gui_config->display_driver = "opengl";
|
||||||
|
|
|
@ -346,13 +346,13 @@ void S9xOpenGLDisplayDriver::refresh()
|
||||||
void S9xOpenGLDisplayDriver::resize()
|
void S9xOpenGLDisplayDriver::resize()
|
||||||
{
|
{
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_WINDOW(gdk_window))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
((WaylandEGLContext *)context)->resize(get_metrics(*drawing_area));
|
((WaylandEGLContext *)context)->resize(get_metrics(*drawing_area));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
if (GDK_IS_X11_WINDOW(gdk_window))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
context->resize();
|
context->resize();
|
||||||
}
|
}
|
||||||
|
@ -371,7 +371,7 @@ bool S9xOpenGLDisplayDriver::create_context()
|
||||||
GdkDisplay *gdk_display = drawing_area->get_display()->gobj();
|
GdkDisplay *gdk_display = drawing_area->get_display()->gobj();
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_WINDOW(gdk_window))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
wl_surface *surface = gdk_wayland_window_get_wl_surface(drawing_area->get_window()->gobj());
|
wl_surface *surface = gdk_wayland_window_get_wl_surface(drawing_area->get_window()->gobj());
|
||||||
wl_display *display = gdk_wayland_display_get_wl_display(drawing_area->get_display()->gobj());
|
wl_display *display = gdk_wayland_display_get_wl_display(drawing_area->get_display()->gobj());
|
||||||
|
@ -381,7 +381,7 @@ bool S9xOpenGLDisplayDriver::create_context()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
if (GDK_IS_X11_WINDOW(gdk_window))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
if (!glx.attach(gdk_x11_display_get_xdisplay(gdk_display), gdk_x11_window_get_xid(gdk_window)))
|
if (!glx.attach(gdk_x11_display_get_xdisplay(gdk_display), gdk_x11_window_get_xid(gdk_window)))
|
||||||
return false;
|
return false;
|
||||||
|
@ -494,23 +494,7 @@ void S9xOpenGLDisplayDriver::deinit()
|
||||||
|
|
||||||
int S9xOpenGLDisplayDriver::query_availability()
|
int S9xOpenGLDisplayDriver::query_availability()
|
||||||
{
|
{
|
||||||
GdkDisplay *gdk_display = gdk_display_get_default();
|
return 1;
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
|
||||||
if (GDK_IS_WAYLAND_DISPLAY(gdk_display))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
|
||||||
if (GDK_IS_X11_DISPLAY(gdk_display))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool S9xOpenGLDisplayDriver::is_ready()
|
bool S9xOpenGLDisplayDriver::is_ready()
|
||||||
|
@ -526,7 +510,7 @@ bool S9xOpenGLDisplayDriver::is_ready()
|
||||||
void S9xOpenGLDisplayDriver::shrink()
|
void S9xOpenGLDisplayDriver::shrink()
|
||||||
{
|
{
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_WINDOW(gdk_window))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
((WaylandEGLContext *)context)->shrink();
|
((WaylandEGLContext *)context)->shrink();
|
||||||
}
|
}
|
||||||
|
@ -536,7 +520,7 @@ void S9xOpenGLDisplayDriver::shrink()
|
||||||
void S9xOpenGLDisplayDriver::regrow()
|
void S9xOpenGLDisplayDriver::regrow()
|
||||||
{
|
{
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_WINDOW(gdk_window))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
((WaylandEGLContext *)context)->regrow();
|
((WaylandEGLContext *)context)->regrow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ void S9xVulkanDisplayDriver::refresh()
|
||||||
int new_width, new_height;
|
int new_width, new_height;
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_WINDOW(drawing_area->get_window()->gobj()))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
std::tie(new_width, new_height) = wayland_surface->get_size_for_metrics(get_metrics(*drawing_area));
|
std::tie(new_width, new_height) = wayland_surface->get_size_for_metrics(get_metrics(*drawing_area));
|
||||||
context->swapchain->set_desired_size(new_width, new_height);
|
context->swapchain->set_desired_size(new_width, new_height);
|
||||||
|
@ -110,7 +110,7 @@ void S9xVulkanDisplayDriver::refresh()
|
||||||
current_height = new_height;
|
current_height = new_height;
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_WINDOW(drawing_area->get_window()->gobj()))
|
if (is_wayland())
|
||||||
wayland_surface->resize(get_metrics(*drawing_area));
|
wayland_surface->resize(get_metrics(*drawing_area));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ int S9xVulkanDisplayDriver::init()
|
||||||
context = std::make_unique<Vulkan::Context>();
|
context = std::make_unique<Vulkan::Context>();
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_WINDOW(drawing_area->get_window()->gobj()))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
wayland_surface = std::make_unique<WaylandSurface>();
|
wayland_surface = std::make_unique<WaylandSurface>();
|
||||||
wl_surface *surface = gdk_wayland_window_get_wl_surface(drawing_area->get_window()->gobj());
|
wl_surface *surface = gdk_wayland_window_get_wl_surface(drawing_area->get_window()->gobj());
|
||||||
|
@ -270,7 +270,7 @@ bool S9xVulkanDisplayDriver::is_ready()
|
||||||
void S9xVulkanDisplayDriver::shrink()
|
void S9xVulkanDisplayDriver::shrink()
|
||||||
{
|
{
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_WINDOW(drawing_area->get_window()->gobj()))
|
if (is_wayland())
|
||||||
wayland_surface->shrink();
|
wayland_surface->shrink();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ void S9xVulkanDisplayDriver::shrink()
|
||||||
void S9xVulkanDisplayDriver::regrow()
|
void S9xVulkanDisplayDriver::regrow()
|
||||||
{
|
{
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_WINDOW(drawing_area->get_window()->gobj()))
|
if (is_wayland())
|
||||||
wayland_surface->regrow();
|
wayland_surface->regrow();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
|
@ -280,16 +280,14 @@ bool Snes9xWindow::button_press(GdkEventButton *event)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->button >= 1 && event->button <= 3)
|
S9xReportButton(BINDING_MOUSE_BUTTON0 + event->button - 1, true);
|
||||||
S9xReportButton(BINDING_MOUSE_BUTTON0 + event->button - 1, true);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Snes9xWindow::button_release(GdkEventButton *event)
|
bool Snes9xWindow::button_release(GdkEventButton *event)
|
||||||
{
|
{
|
||||||
if (event->button >= 1 && event->button <= 3)
|
S9xReportButton(BINDING_MOUSE_BUTTON0 + event->button - 1, false);
|
||||||
S9xReportButton(BINDING_MOUSE_BUTTON0 + event->button - 1, false);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1054,7 +1052,7 @@ Snes9xWindow::get_refresh_rate()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
if (GDK_IS_X11_DISPLAY(gdk_display))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
@ -1063,7 +1061,7 @@ Snes9xWindow::get_refresh_rate()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_WAYLAND
|
#ifdef GDK_WINDOWING_WAYLAND
|
||||||
if (GDK_IS_WAYLAND_DISPLAY(gdk_display))
|
if (is_wayland())
|
||||||
{
|
{
|
||||||
GdkMonitor *monitor = gdk_display_get_monitor_at_window(gdk_display, gdk_window);
|
GdkMonitor *monitor = gdk_display_get_monitor_at_window(gdk_display, gdk_window);
|
||||||
refresh_rate = (double)gdk_monitor_get_refresh_rate(monitor) / 1000.0;
|
refresh_rate = (double)gdk_monitor_get_refresh_rate(monitor) / 1000.0;
|
||||||
|
|
Loading…
Reference in New Issue