(wayland) Fix some CXX_BUILD issues; possibly not all

This commit is contained in:
twinaphex 2019-04-20 18:42:23 +02:00
parent aa03025dd1
commit 7b3be5eddf

View File

@ -78,7 +78,7 @@ typedef struct output_info
unsigned physical_height;
int refresh_rate;
unsigned scale;
struct wl_list link; // wl->all_outputs
struct wl_list link; /* wl->all_outputs */
} output_info_t;
static int num_active_touches;
@ -157,7 +157,8 @@ static enum gfx_ctx_api wl_api = GFX_CTX_NONE;
/* FIXME: Move this into a header? */
int init_xkb(int fd, size_t size);
int handle_xkb(int code, int value);
void handle_xkb_state_mask(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group);
void handle_xkb_state_mask(uint32_t depressed,
uint32_t latched, uint32_t locked, uint32_t group);
void free_xkb(void);
#endif
@ -215,6 +216,7 @@ static void keyboard_handle_key(void *data,
int value = 1;
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
{
BIT_SET(wl->input.key_state, key);
@ -265,7 +267,8 @@ void keyboard_handle_repeat_info(void *data,
(void)wl_keyboard;
(void)rate;
(void)delay;
/* TODO: Seems like we'll need this to get repeat working. We'll have to do it on our own. */
/* TODO: Seems like we'll need this to get
* repeat working. We'll have to do it on our own. */
}
static const struct wl_keyboard_listener keyboard_listener = {
@ -320,8 +323,10 @@ static void pointer_handle_motion(void *data,
wl_fixed_t sy)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
wl->input.mouse.x = wl_fixed_to_int((wl_fixed_t)wl->buffer_scale * sx);
wl->input.mouse.y = wl_fixed_to_int((wl_fixed_t)wl->buffer_scale * sy);
wl->input.mouse.x = wl_fixed_to_int(
(wl_fixed_t)wl->buffer_scale * sx);
wl->input.mouse.y = wl_fixed_to_int(
(wl_fixed_t)wl->buffer_scale * sy);
}
static void pointer_handle_button(void *data,
@ -332,6 +337,7 @@ static void pointer_handle_button(void *data,
uint32_t state)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
if (state == WL_POINTER_BUTTON_STATE_PRESSED)
{
if (button == BTN_LEFT)
@ -408,8 +414,10 @@ static void touch_handle_down(void *data,
{
active_touch_positions[num_active_touches].active = true;
active_touch_positions[num_active_touches].id = id;
active_touch_positions[num_active_touches].x = (unsigned) wl_fixed_to_int(x);
active_touch_positions[num_active_touches].y = (unsigned) wl_fixed_to_int(y);
active_touch_positions[num_active_touches].x = (unsigned)
wl_fixed_to_int(x);
active_touch_positions[num_active_touches].y = (unsigned)
wl_fixed_to_int(y);
num_active_touches++;
break;
}
@ -430,8 +438,10 @@ static void reorder_touches(void)
{
if (active_touch_positions[j].active)
{
active_touch_positions[i].active = active_touch_positions[j].active;
active_touch_positions[i].id = active_touch_positions[j].id;
active_touch_positions[i].active =
active_touch_positions[j].active;
active_touch_positions[i].id =
active_touch_positions[j].id;
active_touch_positions[i].x = active_touch_positions[j].x;
active_touch_positions[i].y = active_touch_positions[j].y;
active_touch_positions[j].active = false;
@ -440,12 +450,14 @@ static void reorder_touches(void)
active_touch_positions[j].y = (unsigned) 0;
break;
}
if (j == MAX_TOUCHES)
return;
}
}
}
}
static void touch_handle_up(void *data,
struct wl_touch *wl_touch,
uint32_t serial,
@ -457,7 +469,8 @@ static void touch_handle_up(void *data,
for (i = 0; i < MAX_TOUCHES; i++)
{
if (active_touch_positions[i].active && active_touch_positions[i].id == id)
if ( active_touch_positions[i].active &&
active_touch_positions[i].id == id)
{
active_touch_positions[i].active = false;
active_touch_positions[i].id = -1;
@ -480,7 +493,8 @@ static void touch_handle_motion(void *data,
for (i = 0; i < MAX_TOUCHES; i++)
{
if (active_touch_positions[i].active && active_touch_positions[i].id == id)
if ( active_touch_positions[i].active &&
active_touch_positions[i].id == id)
{
active_touch_positions[i].x = (unsigned) wl_fixed_to_int(x);
active_touch_positions[i].y = (unsigned) wl_fixed_to_int(y);
@ -555,7 +569,8 @@ static void seat_handle_capabilities(void *data,
}
static void seat_handle_name(void *data, struct wl_seat *seat, const char *name)
static void seat_handle_name(void *data,
struct wl_seat *seat, const char *name)
{
(void)data;
(void)seat;
@ -582,16 +597,21 @@ bool wayland_context_gettouchpos(void *data, unsigned id,
}
/* Surface callbacks. */
static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height);
static bool gfx_ctx_wl_set_resize(void *data,
unsigned width, unsigned height);
static void wl_surface_enter(void *data, struct wl_surface *wl_surface,
struct wl_output *output)
{
// TODO: track all outputs the surface is on, pick highest scale
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
output_info_t *oi;
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
wl_list_for_each(oi, &wl->all_outputs, link) {
if (oi->output == output) {
/* TODO: track all outputs the surface is on, pick highest scale */
wl_list_for_each(oi, &wl->all_outputs, link)
{
if (oi->output == output)
{
RARCH_LOG("[Wayland]: Entering output #%d, scale %d\n", oi->global_id, oi->scale);
wl->current_output = oi;
wl->last_buffer_scale = wl->buffer_scale;
@ -601,11 +621,16 @@ static void wl_surface_enter(void *data, struct wl_surface *wl_surface,
};
}
static void nop() { }
static void wl_nop(void *a, wl_surface *b, wl_output *c)
{
(void)a;
(void)b;
(void)c;
}
static const struct wl_surface_listener wl_surface_listener = {
wl_surface_enter,
nop,
wl_nop,
};
/* Shell surface callbacks. */
@ -628,16 +653,20 @@ static const struct xdg_surface_listener xdg_surface_listener = {
handle_surface_config,
};
static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
static void handle_toplevel_config(void *data,
struct xdg_toplevel *toplevel,
int32_t width, int32_t height, struct wl_array *states)
{
const uint32_t *state;
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
wl->fullscreen = false;
wl->maximized = false;
const uint32_t *state;
wl_array_for_each(state, states) {
switch (*state) {
wl_array_for_each((void*)state, states)
{
switch (*state)
{
case XDG_TOPLEVEL_STATE_FULLSCREEN:
wl->fullscreen = true;
break;
@ -652,7 +681,8 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
break;
}
}
if (width > 0 && height > 0) {
if (width > 0 && height > 0)
{
wl->prev_width = width;
wl->prev_height = height;
wl->width = width;
@ -662,12 +692,15 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
if (wl->win)
wl_egl_window_resize(wl->win, width, height, 0, 0);
else
wl->win = wl_egl_window_create(wl->surface, wl->width * wl->buffer_scale, wl->height * wl->buffer_scale);
wl->win = wl_egl_window_create(wl->surface,
wl->width * wl->buffer_scale,
wl->height * wl->buffer_scale);
wl->configured = false;
}
static void handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel)
static void handle_toplevel_close(void *data,
struct xdg_toplevel *xdg_toplevel)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
BIT_SET(wl->input.key_state, KEY_ESC);
@ -678,7 +711,8 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = {
handle_toplevel_close,
};
static void zxdg_shell_ping(void *data, struct zxdg_shell_v6 *shell, uint32_t serial)
static void zxdg_shell_ping(void *data,
struct zxdg_shell_v6 *shell, uint32_t serial)
{
zxdg_shell_v6_pong(shell, serial);
}
@ -687,7 +721,8 @@ static const struct zxdg_shell_v6_listener zxdg_shell_v6_listener = {
zxdg_shell_ping,
};
static void handle_zxdg_surface_config(void *data, struct zxdg_surface_v6 *surface,
static void handle_zxdg_surface_config(void *data,
struct zxdg_surface_v6 *surface,
uint32_t serial)
{
zxdg_surface_v6_ack_configure(surface, serial);
@ -697,16 +732,20 @@ static const struct zxdg_surface_v6_listener zxdg_surface_v6_listener = {
handle_zxdg_surface_config,
};
static void handle_zxdg_toplevel_config(void *data, struct zxdg_toplevel_v6 *toplevel,
static void handle_zxdg_toplevel_config(
void *data, struct zxdg_toplevel_v6 *toplevel,
int32_t width, int32_t height, struct wl_array *states)
{
const uint32_t *state;
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
wl->fullscreen = false;
wl->maximized = false;
const uint32_t *state;
wl_array_for_each(state, states) {
switch (*state) {
wl_array_for_each((void*)state, states)
{
switch (*state)
{
case XDG_TOPLEVEL_STATE_FULLSCREEN:
wl->fullscreen = true;
break;
@ -721,7 +760,9 @@ static void handle_zxdg_toplevel_config(void *data, struct zxdg_toplevel_v6 *top
break;
}
}
if (width > 0 && height > 0) {
if (width > 0 && height > 0)
{
wl->prev_width = width;
wl->prev_height = height;
wl->width = width;
@ -731,12 +772,15 @@ static void handle_zxdg_toplevel_config(void *data, struct zxdg_toplevel_v6 *top
if (wl->win)
wl_egl_window_resize(wl->win, width, height, 0, 0);
else
wl->win = wl_egl_window_create(wl->surface, wl->width * wl->buffer_scale, wl->height * wl->buffer_scale);
wl->win = wl_egl_window_create(wl->surface,
wl->width * wl->buffer_scale,
wl->height * wl->buffer_scale);
wl->configured = false;
}
static void handle_zxdg_toplevel_close(void *data, struct zxdg_toplevel_v6 *zxdg_toplevel)
static void handle_zxdg_toplevel_close(void *data,
struct zxdg_toplevel_v6 *zxdg_toplevel)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
BIT_SET(wl->input.key_state, KEY_ESC);
@ -868,7 +912,9 @@ static void registry_handle_global(void *data, struct wl_registry *reg,
id, &wl_compositor_interface, 3);
else if (string_is_equal(interface, "wl_output"))
{
output_info_t *oi = calloc(1, sizeof(output_info_t));
output_info_t *oi = (output_info_t*)
calloc(1, sizeof(output_info_t));
oi->global_id = id;
oi->output = (struct wl_output*)wl_registry_bind(reg,
id, &wl_output_interface, 2);
@ -903,11 +949,13 @@ static void registry_handle_global(void *data, struct wl_registry *reg,
static void registry_handle_global_remove(void *data,
struct wl_registry *registry, uint32_t id)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
output_info_t *oi, *tmp;
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
wl_list_for_each_safe(oi, tmp, &wl->all_outputs, link) {
if (oi->global_id == id) {
wl_list_for_each_safe(oi, tmp, &wl->all_outputs, link)
{
if (oi->global_id == id)
{
wl_list_remove(&oi->link);
free(oi);
break;
@ -1064,7 +1112,7 @@ static void gfx_ctx_wl_check_window(void *data, bool *quit,
bool *resize, unsigned *width, unsigned *height,
bool is_shutdown)
{
// this function works with SCALED sizes, it's used from the renderer
/* this function works with SCALED sizes, it's used from the renderer */
unsigned new_width, new_height;
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
@ -1148,15 +1196,20 @@ static void gfx_ctx_wl_update_title(void *data, void *data2)
video_driver_get_window_title(title, sizeof(title));
if (wl && title[0]) {
if (wl->xdg_toplevel) {
if (wl->deco) {
if (wl && title[0])
{
if (wl->xdg_toplevel)
{
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);
}
else if (wl->zxdg_toplevel) {
if (wl->deco) {
else if (wl->zxdg_toplevel)
{
if (wl->deco)
{
zxdg_toplevel_decoration_v1_set_mode(wl->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
}
zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, title);
@ -1574,7 +1627,8 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
break;
}
if (wl->xdg_shell) {
if (wl->xdg_shell)
{
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);
@ -1584,7 +1638,8 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
xdg_toplevel_set_app_id(wl->xdg_toplevel, "retroarch");
xdg_toplevel_set_title(wl->xdg_toplevel, "RetroArch");
if (wl->deco_manager) {
if (wl->deco_manager)
{
wl->deco = zxdg_decoration_manager_v1_get_toplevel_decoration(
wl->deco_manager, wl->xdg_toplevel);
}
@ -1593,12 +1648,14 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
wl_surface_commit(wl->surface);
wl->configured = true;
while (wl->configured) {
while (wl->configured)
wl_display_dispatch(wl->input.dpy);
}
wl_display_roundtrip(wl->input.dpy);
xdg_wm_base_add_listener(wl->xdg_shell, &xdg_shell_listener, NULL);
} else if (wl->zxdg_shell) {
}
else if (wl->zxdg_shell)
{
wl->zxdg_surface = zxdg_shell_v6_get_xdg_surface(wl->zxdg_shell, wl->surface);
zxdg_surface_v6_add_listener(wl->zxdg_surface, &zxdg_surface_v6_listener, wl);
@ -1608,21 +1665,22 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
zxdg_toplevel_v6_set_app_id(wl->zxdg_toplevel, "retroarch");
zxdg_toplevel_v6_set_title(wl->zxdg_toplevel, "RetroArch");
if (wl->deco_manager) {
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);
wl->configured = true;
while (wl->configured) {
while (wl->configured)
wl_display_dispatch(wl->input.dpy);
}
wl_display_roundtrip(wl->input.dpy);
zxdg_shell_v6_add_listener(wl->zxdg_shell, &zxdg_shell_v6_listener, NULL);
} else if (wl->shell) {
}
else if (wl->shell)
{
wl->shell_surf = wl_shell_get_shell_surface(wl->shell, wl->surface);
wl_shell_surface_add_listener(wl->shell_surf, &shell_surface_listener, wl);
wl_shell_surface_set_toplevel(wl->shell_surf);
@ -1653,12 +1711,14 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
break;
}
if (fullscreen) {
if (wl->xdg_toplevel) {
if (fullscreen)
{
if (wl->xdg_toplevel)
xdg_toplevel_set_fullscreen(wl->xdg_toplevel, NULL);
} else if (wl->zxdg_toplevel) {
else if (wl->zxdg_toplevel)
zxdg_toplevel_v6_set_fullscreen(wl->zxdg_toplevel, NULL);
} else if (wl->shell) {
else if (wl->shell)
{
wl_shell_surface_set_fullscreen(wl->shell_surf,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL);
}
@ -1705,7 +1765,8 @@ static void gfx_ctx_wl_input_driver(void *data,
const input_driver_t **input, void **input_data)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
/* Input is heavily tied to the window stuff on Wayland, so just implement the input driver here. */
/* Input is heavily tied to the window stuff
* on Wayland, so just implement the input driver here. */
if (!input_wl_init(&wl->input, joypad_name))
{
*input = NULL;
@ -1735,11 +1796,14 @@ static bool gfx_ctx_wl_suppress_screensaver(void *data, bool state)
return false;
if (state == (!!wl->idle_inhibitor))
return true;
if (state) {
if (state)
{
RARCH_LOG("[Wayland]: Enabling idle inhibitor\n");
struct zwp_idle_inhibit_manager_v1 *mgr = wl->idle_inhibit_manager;
wl->idle_inhibitor = zwp_idle_inhibit_manager_v1_create_inhibitor(mgr, wl->surface);
} else {
}
else
{
RARCH_LOG("[Wayland]: Disabling the idle inhibitor\n");
zwp_idle_inhibitor_v1_destroy(wl->idle_inhibitor);
wl->idle_inhibitor = NULL;