Get rid of multiple definition of wayland show mouse function

This commit is contained in:
twinaphex 2020-07-17 13:59:13 +02:00
parent 5e2c38060b
commit e8e9a7b1d3
4 changed files with 21 additions and 47 deletions

View File

@ -609,9 +609,6 @@ static void gfx_ctx_wl_set_swap_interval(void *data, int swap_interval)
#endif
}
/* Forward declaration */
void gfx_ctx_wl_show_mouse(void *data, bool state);
static bool gfx_ctx_wl_set_video_mode(void *data,
unsigned width, unsigned height,
bool fullscreen)
@ -894,26 +891,6 @@ static void gfx_ctx_wl_set_flags(void *data, uint32_t flags)
wl->core_hw_context_enable = true;
}
void gfx_ctx_wl_show_mouse(void *data, bool state)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
if (!wl->wl_pointer)
return;
if (state)
{
struct wl_cursor_image *image = wl->cursor.default_cursor->images[0];
wl_pointer_set_cursor(wl->wl_pointer, wl->cursor.serial, wl->cursor.surface, image->hotspot_x, image->hotspot_y);
wl_surface_attach(wl->cursor.surface, wl_cursor_image_get_buffer(image), 0, 0);
wl_surface_damage(wl->cursor.surface, 0, 0, image->width, image->height);
wl_surface_commit(wl->cursor.surface);
}
else
wl_pointer_set_cursor(wl->wl_pointer, wl->cursor.serial, NULL, 0, 0);
wl->cursor.visible = state;
}
static float gfx_ctx_wl_get_refresh_rate(void *data)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;

View File

@ -451,9 +451,6 @@ static void gfx_ctx_wl_set_swap_interval(void *data, int swap_interval)
}
}
/* Forward declaration */
void gfx_ctx_wl_show_mouse(void *data, bool state);
static bool gfx_ctx_wl_set_video_mode(void *data,
unsigned width, unsigned height,
bool fullscreen)
@ -688,26 +685,6 @@ static void gfx_ctx_wl_set_flags(void *data, uint32_t flags)
wl->core_hw_context_enable = true;
}
void gfx_ctx_wl_show_mouse(void *data, bool state)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
if (!wl->wl_pointer)
return;
if (state)
{
struct wl_cursor_image *image = wl->cursor.default_cursor->images[0];
wl_pointer_set_cursor(wl->wl_pointer, wl->cursor.serial, wl->cursor.surface, image->hotspot_x, image->hotspot_y);
wl_surface_attach(wl->cursor.surface, wl_cursor_image_get_buffer(image), 0, 0);
wl_surface_damage(wl->cursor.surface, 0, 0, image->width, image->height);
wl_surface_commit(wl->cursor.surface);
}
else
wl_pointer_set_cursor(wl->wl_pointer, wl->cursor.serial, NULL, 0, 0);
wl->cursor.visible = state;
}
static float gfx_ctx_wl_get_refresh_rate(void *data)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;

View File

@ -135,7 +135,25 @@ void keyboard_handle_repeat_info(void *data,
* repeat working. We'll have to do it on our own. */
}
void gfx_ctx_wl_show_mouse(void *data, bool state);
void gfx_ctx_wl_show_mouse(void *data, bool state)
{
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
if (!wl->wl_pointer)
return;
if (state)
{
struct wl_cursor_image *image = wl->cursor.default_cursor->images[0];
wl_pointer_set_cursor(wl->wl_pointer, wl->cursor.serial, wl->cursor.surface, image->hotspot_x, image->hotspot_y);
wl_surface_attach(wl->cursor.surface, wl_cursor_image_get_buffer(image), 0, 0);
wl_surface_damage(wl->cursor.surface, 0, 0, image->width, image->height);
wl_surface_commit(wl->cursor.surface);
}
else
wl_pointer_set_cursor(wl->wl_pointer, wl->cursor.serial, NULL, 0, 0);
wl->cursor.visible = state;
}
static void pointer_handle_enter(void *data,
struct wl_pointer *pointer,

View File

@ -177,6 +177,8 @@ void handle_xkb_state_mask(uint32_t depressed,
void free_xkb(void);
#endif
void gfx_ctx_wl_show_mouse(void *data, bool state);
void handle_toplevel_close(void *data,
struct xdg_toplevel *xdg_toplevel);