mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
(Wayland) Cleanups
This commit is contained in:
parent
103982f41d
commit
6a147370d0
@ -318,7 +318,6 @@ void egl_bind_hw_render(egl_ctx_data_t *egl, bool enable)
|
||||
return;
|
||||
if (egl->surf == EGL_NO_SURFACE)
|
||||
return;
|
||||
|
||||
_egl_make_current(egl->dpy, egl->surf,
|
||||
egl->surf,
|
||||
enable ? egl->hw_ctx : egl->ctx);
|
||||
|
@ -40,7 +40,7 @@
|
||||
#define DEFAULT_WINDOWED_WIDTH 640
|
||||
#define DEFAULT_WINDOWED_HEIGHT 480
|
||||
|
||||
// Icon is 16x15 scaled by 16
|
||||
/* Icon is 16x15 scaled by 16 */
|
||||
#define SPLASH_WINDOW_WIDTH 240
|
||||
#define SPLASH_WINDOW_HEIGHT 256
|
||||
|
||||
@ -127,8 +127,8 @@ void xdg_toplevel_handle_configure_common(gfx_ctx_wayland_data_t *wl,
|
||||
height = wl->floating_height;
|
||||
}
|
||||
|
||||
if ( width > 0
|
||||
&& height > 0)
|
||||
if ( (width > 0)
|
||||
&& (height > 0))
|
||||
{
|
||||
wl->width = width;
|
||||
wl->height = height;
|
||||
@ -147,11 +147,7 @@ void xdg_toplevel_handle_configure_common(gfx_ctx_wayland_data_t *wl,
|
||||
}
|
||||
|
||||
void xdg_toplevel_handle_close(void *data,
|
||||
struct xdg_toplevel *xdg_toplevel)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
command_event(CMD_EVENT_QUIT, NULL);
|
||||
}
|
||||
struct xdg_toplevel *xdg_toplevel) { command_event(CMD_EVENT_QUIT, NULL); }
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
void libdecor_frame_handle_configure_common(struct libdecor_frame *frame,
|
||||
@ -218,23 +214,18 @@ void libdecor_frame_handle_configure_common(struct libdecor_frame *frame,
|
||||
}
|
||||
|
||||
void libdecor_frame_handle_close(struct libdecor_frame *frame,
|
||||
void *data)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
command_event(CMD_EVENT_QUIT, NULL);
|
||||
}
|
||||
|
||||
void *data) { command_event(CMD_EVENT_QUIT, NULL); }
|
||||
void libdecor_frame_handle_commit(struct libdecor_frame *frame,
|
||||
void *data)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
}
|
||||
void *data) { }
|
||||
#endif
|
||||
|
||||
|
||||
void gfx_ctx_wl_get_video_size_common(gfx_ctx_wayland_data_t *wl,
|
||||
void gfx_ctx_wl_get_video_size_common(void *data,
|
||||
unsigned *width, unsigned *height)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
if (!wl)
|
||||
return;
|
||||
if (!wl->reported_display_size)
|
||||
{
|
||||
display_output_t *od;
|
||||
@ -367,24 +358,27 @@ void gfx_ctx_wl_destroy_resources_common(gfx_ctx_wayland_data_t *wl)
|
||||
wl->buffer_height = 0;
|
||||
}
|
||||
|
||||
void gfx_ctx_wl_update_title_common(gfx_ctx_wayland_data_t *wl)
|
||||
void gfx_ctx_wl_update_title_common(void *data)
|
||||
{
|
||||
char title[128];
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
|
||||
title[0] = '\0';
|
||||
|
||||
video_driver_get_window_title(title, sizeof(title));
|
||||
|
||||
if (wl)
|
||||
{
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (wl->libdecor)
|
||||
{
|
||||
if (wl && title[0])
|
||||
if (title[0])
|
||||
wl->libdecor_frame_set_title(wl->libdecor_frame, title);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (wl && title[0])
|
||||
if (title[0])
|
||||
{
|
||||
if (wl->deco)
|
||||
zxdg_toplevel_decoration_v1_set_mode(wl->deco,
|
||||
@ -392,13 +386,14 @@ void gfx_ctx_wl_update_title_common(gfx_ctx_wayland_data_t *wl)
|
||||
xdg_toplevel_set_title(wl->xdg_toplevel, title);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool gfx_ctx_wl_get_metrics_common(void *data,
|
||||
enum display_metric_types type, float *value)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
display_output_t *od;
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
output_info_t *oi = wl ? wl->current_output : NULL;
|
||||
|
||||
if (!oi)
|
||||
@ -419,8 +414,8 @@ bool gfx_ctx_wl_get_metrics_common(void *data,
|
||||
break;
|
||||
|
||||
case DISPLAY_METRIC_DPI:
|
||||
*value = (float)oi->width * 25.4f /
|
||||
(float)oi->physical_width;
|
||||
*value = (float)oi->width * 25.4f
|
||||
/ (float)oi->physical_width;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -745,11 +740,12 @@ bool gfx_ctx_wl_init_common(
|
||||
/* Bind SHM based wl_buffer to wl_surface until the vulkan surface is ready.
|
||||
* This shows the window which assigns us a display (wl_output)
|
||||
* which is usefull for HiDPI and auto selecting a display for fullscreen. */
|
||||
if (video_monitor_index == 0 && wl_list_length (&wl->all_outputs) > 1) {
|
||||
if (video_monitor_index == 0 && wl_list_length (&wl->all_outputs) > 1)
|
||||
{
|
||||
if (!wl_draw_splash_screen(wl))
|
||||
RARCH_ERR("[Wayland]: Failed to draw splash screen\n");
|
||||
|
||||
// Make sure splash screen is on screen and sized
|
||||
/* Make sure splash screen is on screen and sized */
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (wl->libdecor)
|
||||
{
|
||||
@ -892,9 +888,8 @@ bool gfx_ctx_wl_suppress_screensaver(void *data, bool state)
|
||||
|
||||
if (!wl->idle_inhibit_manager)
|
||||
return false;
|
||||
if (state == (!!wl->idle_inhibitor))
|
||||
return true;
|
||||
|
||||
if (state != (!!wl->idle_inhibitor))
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
RARCH_LOG("[Wayland]: Enabling idle inhibitor\n");
|
||||
@ -907,17 +902,17 @@ bool gfx_ctx_wl_suppress_screensaver(void *data, bool state)
|
||||
zwp_idle_inhibitor_v1_destroy(wl->idle_inhibitor);
|
||||
wl->idle_inhibitor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
float gfx_ctx_wl_get_refresh_rate(void *data)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
|
||||
if (!wl || !wl->current_output)
|
||||
return false;
|
||||
|
||||
return (float) wl->current_output->refresh_rate / 1000.0f;
|
||||
return (float)wl->current_output->refresh_rate / 1000.0f;
|
||||
}
|
||||
|
||||
bool gfx_ctx_wl_has_focus(void *data)
|
||||
@ -961,8 +956,8 @@ static void shm_buffer_handle_release(void *data,
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void xdg_surface_handle_configure(void *data, struct xdg_surface *surface,
|
||||
uint32_t serial)
|
||||
static void xdg_surface_handle_configure(void *data,
|
||||
struct xdg_surface *surface, uint32_t serial)
|
||||
{
|
||||
xdg_surface_ack_configure(surface, serial);
|
||||
}
|
||||
|
@ -53,12 +53,12 @@ void libdecor_frame_handle_commit(struct libdecor_frame *frame,
|
||||
void *data);
|
||||
#endif
|
||||
|
||||
void gfx_ctx_wl_get_video_size_common(gfx_ctx_wayland_data_t *wl,
|
||||
unsigned *width, unsigned *height);
|
||||
void gfx_ctx_wl_get_video_size_common(void *data, unsigned *width,
|
||||
unsigned *height);
|
||||
|
||||
void gfx_ctx_wl_destroy_resources_common(gfx_ctx_wayland_data_t *wl);
|
||||
|
||||
void gfx_ctx_wl_update_title_common(gfx_ctx_wayland_data_t *wl);
|
||||
void gfx_ctx_wl_update_title_common(void *data);
|
||||
|
||||
bool gfx_ctx_wl_get_metrics_common(void *data,
|
||||
enum display_metric_types type, float *value);
|
||||
|
@ -79,14 +79,6 @@ static void xdg_toplevel_handle_configure(void *data,
|
||||
wl->configured = false;
|
||||
}
|
||||
|
||||
static void gfx_ctx_wl_get_video_size(void *data,
|
||||
unsigned *width, unsigned *height)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
|
||||
gfx_ctx_wl_get_video_size_common(wl, width, height);
|
||||
}
|
||||
|
||||
static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl)
|
||||
{
|
||||
if (!wl)
|
||||
@ -110,7 +102,7 @@ static void gfx_ctx_wl_check_window(void *data, bool *quit,
|
||||
bool *resize, unsigned *width, unsigned *height)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
gfx_ctx_wl_check_window_common(wl, gfx_ctx_wl_get_video_size, quit, resize, width, height);
|
||||
gfx_ctx_wl_check_window_common(wl, gfx_ctx_wl_get_video_size_common, quit, resize, width, height);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height)
|
||||
@ -127,19 +119,6 @@ static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void gfx_ctx_wl_update_title(void *data)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
gfx_ctx_wl_update_title_common(wl);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_wl_get_metrics(void *data,
|
||||
enum display_metric_types type, float *value)
|
||||
{
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
return gfx_ctx_wl_get_metrics_common(wl, type, value);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
static void
|
||||
libdecor_frame_handle_configure(struct libdecor_frame *frame,
|
||||
@ -474,7 +453,7 @@ static bool gfx_ctx_wl_bind_api(void *data,
|
||||
#ifdef HAVE_OPENGL
|
||||
#ifndef EGL_KHR_create_context
|
||||
if ((major * 1000 + minor) >= 3001)
|
||||
return false;
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_EGL
|
||||
if (egl_bind_api(EGL_OPENGL_API))
|
||||
@ -486,7 +465,7 @@ static bool gfx_ctx_wl_bind_api(void *data,
|
||||
#ifdef HAVE_OPENGLES
|
||||
#ifndef EGL_KHR_create_context
|
||||
if (major >= 3)
|
||||
return false;
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_EGL
|
||||
if (egl_bind_api(EGL_OPENGL_ES_API))
|
||||
@ -527,11 +506,10 @@ static const struct wl_callback_listener wl_surface_frame_listener = {
|
||||
static void gfx_ctx_wl_swap_buffers(void *data)
|
||||
{
|
||||
#ifdef HAVE_EGL
|
||||
struct wl_callback *cb;
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned max_swapchain_images = settings->uints.video_max_swapchain_images;
|
||||
struct wl_callback *cb;
|
||||
|
||||
if (max_swapchain_images <= 2)
|
||||
{
|
||||
@ -628,14 +606,14 @@ const gfx_ctx_driver_t gfx_ctx_wayland = {
|
||||
gfx_ctx_wl_bind_api,
|
||||
gfx_ctx_wl_set_swap_interval,
|
||||
gfx_ctx_wl_set_video_mode,
|
||||
gfx_ctx_wl_get_video_size,
|
||||
gfx_ctx_wl_get_video_size_common,
|
||||
gfx_ctx_wl_get_refresh_rate,
|
||||
NULL, /* get_video_output_size */
|
||||
NULL, /* get_video_output_prev */
|
||||
NULL, /* get_video_output_next */
|
||||
gfx_ctx_wl_get_metrics,
|
||||
gfx_ctx_wl_get_metrics_common,
|
||||
NULL,
|
||||
gfx_ctx_wl_update_title,
|
||||
gfx_ctx_wl_update_title_common,
|
||||
gfx_ctx_wl_check_window,
|
||||
gfx_ctx_wl_set_resize,
|
||||
gfx_ctx_wl_has_focus,
|
||||
|
Loading…
x
Reference in New Issue
Block a user