(Wayland) Style nits

This commit is contained in:
twinaphex 2021-12-24 14:29:12 +01:00
parent f0392474f2
commit e1d144e2b8
2 changed files with 143 additions and 131 deletions

View File

@ -87,7 +87,8 @@ static void handle_toplevel_config_common(void *data,
break;
}
}
if (width > 0 && height > 0)
if ( width > 0
&& height > 0)
{
wl->prev_width = width;
wl->prev_height = height;
@ -251,17 +252,14 @@ static void gfx_ctx_wl_update_title(void *data)
video_driver_get_window_title(title, sizeof(title));
#ifdef HAVE_LIBDECOR
if (wl && title[0]) {
if (wl && title[0])
libdecor_frame_set_title(wl->libdecor_frame, title);
}
#else
if (wl && title[0])
{
if (wl->deco)
{
zxdg_toplevel_decoration_v1_set_mode(wl->deco,
ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
}
xdg_toplevel_set_title(wl->xdg_toplevel, title);
}
#endif
@ -272,7 +270,10 @@ static bool gfx_ctx_wl_get_metrics(void *data,
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
if (!wl || !wl->current_output || wl->current_output->physical_width == 0 || wl->current_output->physical_height == 0)
if ( !wl
|| !wl->current_output
|| wl->current_output->physical_width == 0
|| wl->current_output->physical_height == 0)
return false;
switch (type)
@ -286,7 +287,8 @@ static bool gfx_ctx_wl_get_metrics(void *data,
break;
case DISPLAY_METRIC_DPI:
*value = (float)wl->current_output->width * 25.4f / (float)wl->current_output->physical_width;
*value = (float)wl->current_output->width * 25.4f /
(float)wl->current_output->physical_width;
break;
default:
@ -313,21 +315,26 @@ static void
handle_libdecor_frame_configure(struct libdecor_frame *frame,
struct libdecor_configuration *configuration, void *data)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
struct libdecor_state *state;
int width, height;
static const enum libdecor_window_state tiled_states = (
LIBDECOR_WINDOW_STATE_TILED_LEFT | LIBDECOR_WINDOW_STATE_TILED_RIGHT |
LIBDECOR_WINDOW_STATE_TILED_TOP | LIBDECOR_WINDOW_STATE_TILED_BOTTOM
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
struct libdecor_state *state = NULL;
static const enum
libdecor_window_state tiled_states = (
LIBDECOR_WINDOW_STATE_TILED_LEFT
| LIBDECOR_WINDOW_STATE_TILED_RIGHT
| LIBDECOR_WINDOW_STATE_TILED_TOP
| LIBDECOR_WINDOW_STATE_TILED_BOTTOM
);
enum libdecor_window_state window_state;
bool focused = false;
bool tiled = false;
wl->fullscreen = false;
wl->maximized = false;
bool tiled = false;
if (libdecor_configuration_get_window_state(configuration, &window_state)) {
if (libdecor_configuration_get_window_state(
configuration, &window_state))
{
wl->fullscreen = (window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN) != 0;
wl->maximized = (window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED) != 0;
focused = (window_state & LIBDECOR_WINDOW_STATE_ACTIVE) != 0;
@ -335,7 +342,8 @@ handle_libdecor_frame_configure(struct libdecor_frame *frame,
}
if (!libdecor_configuration_get_content_size(configuration, frame,
&width, &height)) {
&width, &height))
{
width = wl->prev_width;
height = wl->prev_height;
}
@ -352,7 +360,8 @@ handle_libdecor_frame_configure(struct libdecor_frame *frame,
if (wl->win)
wl_egl_window_resize(wl->win, wl->width, wl->height, 0, 0);
else
wl->win = wl_egl_window_create(wl->surface,
wl->win = wl_egl_window_create(
wl->surface,
wl->width * wl->buffer_scale,
wl->height * wl->buffer_scale);
#endif
@ -446,8 +455,6 @@ static void *gfx_ctx_wl_init(void *video_driver)
if (!wl)
return NULL;
(void)video_driver;
wl_list_init(&wl->all_outputs);
#ifdef HAVE_EGL
@ -606,7 +613,8 @@ static EGLint *egl_fill_attribs(gfx_ctx_wayland_data_t *wl, EGLint *attr)
*attr++ = EGL_CONTEXT_MINOR_VERSION_KHR;
*attr++ = wl->egl.minor;
/* Technically, we don't have core/compat until 3.2.
* Version 3.1 is either compat or not depending on GL_ARB_compatibility. */
* Version 3.1 is either compat or not depending
* on GL_ARB_compatibility. */
if (version >= 3002)
{
*attr++ = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
@ -627,7 +635,8 @@ static EGLint *egl_fill_attribs(gfx_ctx_wayland_data_t *wl, EGLint *attr)
case GFX_CTX_OPENGL_ES_API:
#ifdef HAVE_OPENGLES
*attr++ = EGL_CONTEXT_CLIENT_VERSION; /* Same as EGL_CONTEXT_MAJOR_VERSION */
*attr++ = EGL_CONTEXT_CLIENT_VERSION;
/* Same as EGL_CONTEXT_MAJOR_VERSION */
*attr++ = wl->egl.major ? (EGLint)wl->egl.major : 2;
#ifdef EGL_KHR_create_context
if (wl->egl.minor > 0)
@ -695,27 +704,32 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
#ifdef HAVE_LIBDECOR
wl->libdecor_context = libdecor_new(wl->input.dpy, &libdecor_interface);
if (wl->libdecor_context) {
if (wl->libdecor_context)
{
wl->libdecor_frame = libdecor_decorate(wl->libdecor_context, wl->surface, &libdecor_frame_interface, wl);
if (wl->libdecor_frame == NULL) {
if (!wl->libdecor_frame)
{
RARCH_ERR("[Wayland]: Failed to crate libdecor frame\n");
goto error;
} else {
}
libdecor_frame_set_app_id(wl->libdecor_frame, "retroarch");
libdecor_frame_set_title(wl->libdecor_frame, "RetroArch");
libdecor_frame_map(wl->libdecor_frame);
}
}
/* Waiting for libdecor to be configured before starting to draw */
wl_surface_commit(wl->surface);
wl->configured = true;
while (wl->configured)
if (libdecor_dispatch(wl->libdecor_context, 0) < 0) {
{
if (libdecor_dispatch(wl->libdecor_context, 0) < 0)
{
RARCH_ERR("[Wayland]: libdecor failed to dispatch\n");
goto error;
};
}
}
#else
wl->xdg_surface = xdg_wm_base_get_xdg_surface(wl->xdg_shell, wl->surface);
xdg_surface_add_listener(wl->xdg_surface, &xdg_surface_listener, wl);
@ -727,10 +741,8 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
xdg_toplevel_set_title(wl->xdg_toplevel, "RetroArch");
if (wl->deco_manager)
{
wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration(
wl->deco_manager, wl->xdg_toplevel);
}
/* Waiting for xdg_toplevel to be configured before starting to draw */
wl_surface_commit(wl->surface);
@ -817,14 +829,13 @@ static bool gfx_ctx_wl_has_focus(void *data)
static bool gfx_ctx_wl_suppress_screensaver(void *data, bool state)
{
(void)data;
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
if (!wl->idle_inhibit_manager)
return false;
if (state == (!!wl->idle_inhibitor))
return true;
if (state)
{
RARCH_LOG("[Wayland]: Enabling idle inhibitor\n");
@ -898,17 +909,16 @@ static bool gfx_ctx_wl_bind_api(void *video_driver,
static void gfx_ctx_wl_swap_buffers(void *data)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
#ifdef HAVE_EGL
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
egl_swap_buffers(&wl->egl);
#endif
}
static void gfx_ctx_wl_bind_hw_render(void *data, bool enable)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
#ifdef HAVE_EGL
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
egl_bind_hw_render(&wl->egl, enable);
#endif
}

View File

@ -243,9 +243,8 @@ static void gfx_ctx_wl_update_title(void *data)
video_driver_get_window_title(title, sizeof(title));
#ifdef HAVE_LIBDECOR
if (wl && title[0]) {
if (wl && title[0])
libdecor_frame_set_title(wl->libdecor_frame, title);
}
#else
if (wl && title[0])
{
@ -306,21 +305,22 @@ static void
handle_libdecor_frame_configure(struct libdecor_frame *frame,
struct libdecor_configuration *configuration, void *data)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
struct libdecor_state *state;
int width, height;
enum libdecor_window_state window_state;
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
bool focused = false;
bool tiled = false;
static const enum libdecor_window_state tiled_states = (
LIBDECOR_WINDOW_STATE_TILED_LEFT | LIBDECOR_WINDOW_STATE_TILED_RIGHT |
LIBDECOR_WINDOW_STATE_TILED_TOP | LIBDECOR_WINDOW_STATE_TILED_BOTTOM
);
enum libdecor_window_state window_state;
bool focused = false;
wl->fullscreen = false;
wl->maximized = false;
bool tiled = false;
if (libdecor_configuration_get_window_state(configuration, &window_state)) {
if (libdecor_configuration_get_window_state(configuration, &window_state))
{
wl->fullscreen = (window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN) != 0;
wl->maximized = (window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED) != 0;
focused = (window_state & LIBDECOR_WINDOW_STATE_ACTIVE) != 0;
@ -328,7 +328,8 @@ handle_libdecor_frame_configure(struct libdecor_frame *frame,
}
if (!libdecor_configuration_get_content_size(configuration, frame,
&width, &height)) {
&width, &height))
{
width = wl->prev_width;
height = wl->prev_height;
}
@ -382,8 +383,6 @@ static void *gfx_ctx_wl_init(void *video_driver)
if (!wl)
return NULL;
(void)video_driver;
wl_list_init(&wl->all_outputs);
frontend_driver_destroy_signal_handler_state();
@ -512,27 +511,32 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
#ifdef HAVE_LIBDECOR
wl->libdecor_context = libdecor_new(wl->input.dpy, &libdecor_interface);
if (wl->libdecor_context) {
if (wl->libdecor_context)
{
wl->libdecor_frame = libdecor_decorate(wl->libdecor_context, wl->surface, &libdecor_frame_interface, wl);
if (wl->libdecor_frame == NULL) {
if (!wl->libdecor_frame)
{
RARCH_ERR("[Wayland/Vulkan]: Failed to crate libdecor frame\n");
goto error;
} else {
}
libdecor_frame_set_app_id(wl->libdecor_frame, "retroarch");
libdecor_frame_set_title(wl->libdecor_frame, "RetroArch");
libdecor_frame_map(wl->libdecor_frame);
}
}
/* Waiting for libdecor to be configured before starting to draw */
wl_surface_commit(wl->surface);
wl->configured = true;
while (wl->configured)
if (libdecor_dispatch(wl->libdecor_context, 0) < 0) {
{
if (libdecor_dispatch(wl->libdecor_context, 0) < 0)
{
RARCH_ERR("[Wayland/Vulkan]: libdecor failed to dispatch\n");
goto error;
};
}
}
#else
wl->xdg_surface = xdg_wm_base_get_xdg_surface(wl->xdg_shell, wl->surface);
xdg_surface_add_listener(wl->xdg_surface, &xdg_surface_listener, wl);
@ -544,10 +548,8 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
xdg_toplevel_set_title(wl->xdg_toplevel, "RetroArch");
if (wl->deco_manager)
{
wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration(
wl->deco_manager, wl->xdg_toplevel);
}
/* Waiting for xdg_toplevel to be configured before starting to draw */
wl_surface_commit(wl->surface);