From 405182af460232cd9ea857a6efa64e91a123b2c6 Mon Sep 17 00:00:00 2001 From: Alexander Preisinger Date: Sun, 19 May 2013 13:04:59 +0200 Subject: wayland: use VOCTRL_SET_CURSOR_VISIBILITY --- video/out/wayland_common.c | 56 +++++++++++++++++++--------------------------- video/out/wayland_common.h | 5 ++--- 2 files changed, 25 insertions(+), 36 deletions(-) (limited to 'video') diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 7c358ab951..332cf68e32 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -321,12 +321,7 @@ static void pointer_handle_enter(void *data, /* Release the left button on pointer enter again * because after moving the shell surface no release event is sent */ mplayer_put_key(wl->vo->key_fifo, MP_MOUSE_BTN0); - - if (wl->window->type == TYPE_FULLSCREEN || wl->vo->opts->cursor_autohide_delay == -2) - hide_cursor(wl); - else if (display->cursor.default_cursor) { - show_cursor(wl); - } + show_cursor(wl); } static void pointer_handle_leave(void *data, @@ -343,12 +338,11 @@ static void pointer_handle_motion(void *data, wl_fixed_t sy_w) { struct vo_wayland_state *wl = data; - struct vo_wayland_display * display = wl->display; - display->cursor.pointer = pointer; + wl->display->cursor.pointer = pointer; - if (wl->window->type == TYPE_FULLSCREEN) - show_cursor(wl); + vo_mouse_movement(wl->vo, wl_fixed_to_int(sx_w), + wl_fixed_to_int(sy_w)); } static void pointer_handle_button(void *data, @@ -523,18 +517,17 @@ static int lookupkey(int key) static void hide_cursor (struct vo_wayland_state *wl) { struct vo_wayland_display *display = wl->display; - if (!display->cursor.pointer || wl->vo->opts->cursor_autohide_delay == -1) + if (!display->cursor.pointer) return; wl_pointer_set_cursor(display->cursor.pointer, display->cursor.serial, NULL, 0, 0); - } static void show_cursor (struct vo_wayland_state *wl) { struct vo_wayland_display *display = wl->display; - if (!display->cursor.pointer || wl->vo->opts->cursor_autohide_delay == -2) + if (!display->cursor.pointer) return; struct wl_buffer *buffer; @@ -548,9 +541,6 @@ static void show_cursor (struct vo_wayland_state *wl) wl_surface_damage(display->cursor.surface, 0, 0, image->width, image->height); wl_surface_commit(display->cursor.surface); - - display->cursor.mouse_timer = GetTimerMS() + wl->vo->opts->cursor_autohide_delay; - display->cursor.mouse_waiting_hide = true; } static void resize_window(struct vo_wayland_state *wl, @@ -743,8 +733,6 @@ static void vo_wayland_fullscreen (struct vo *vo) wl->window->type = TYPE_FULLSCREEN; vo->opts->fs = true; - - hide_cursor(wl); } else { @@ -752,8 +740,6 @@ static void vo_wayland_fullscreen (struct vo *vo) resize_window(wl, 0, wl->window->p_width, wl->window->p_height); wl->window->type = TYPE_TOPLEVEL; vo->opts->fs = false; - - show_cursor(wl); } } @@ -763,14 +749,6 @@ static int vo_wayland_check_events (struct vo *vo) struct wl_display *dp = wl->display->display; int ret; - if (wl->window->type == TYPE_FULLSCREEN && - wl->display->cursor.mouse_waiting_hide && - GetTimerMS() >= wl->display->cursor.mouse_timer) - { - hide_cursor(wl); - wl->display->cursor.mouse_waiting_hide = false; - } - wl_display_dispatch_pending(dp); wl_display_flush(dp); @@ -794,9 +772,6 @@ static int vo_wayland_check_events (struct vo *vo) wl_display_flush(dp); } - if (wl->display->cursor.mouse_waiting_hide) - vo->next_wakeup_time = FFMIN(vo->next_wakeup_time, - wl->display->cursor.mouse_timer); ret = wl->window->events; wl->window->events = 0; @@ -856,8 +831,11 @@ static void vo_wayland_update_screeninfo (struct vo *vo) aspect_save_screenres(vo, opts->screenwidth, opts->screenheight); } -int vo_wayland_control(struct vo *vo, int *events, int request, void *arg) +int vo_wayland_control (struct vo *vo, int *events, int request, void *arg) { + struct vo_wayland_state *wl = vo->wayland; + wl_display_dispatch_pending(wl->display->display); + switch (request) { case VOCTRL_CHECK_EVENTS: *events |= vo_wayland_check_events(vo); @@ -876,11 +854,23 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg) case VOCTRL_UPDATE_SCREENINFO: vo_wayland_update_screeninfo(vo); return VO_TRUE; + case VOCTRL_SET_CURSOR_VISIBILITY: + if (*(bool *)arg) { + if (!wl->display->cursor.visible) + show_cursor(wl); + } + else { + if (wl->display->cursor.visible) + hide_cursor(wl); + } + wl->display->cursor.visible = *(bool *)arg; + return VO_TRUE; } return VO_NOTIMPL; } -bool vo_wayland_config(struct vo *vo, uint32_t d_width, uint32_t d_height, uint32_t flags) +bool vo_wayland_config (struct vo *vo, uint32_t d_width, + uint32_t d_height, uint32_t flags) { struct vo_wayland_window *w = vo->wayland->window; diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h index 3b643f8f49..5d8df2c4bc 100644 --- a/video/out/wayland_common.h +++ b/video/out/wayland_common.h @@ -60,9 +60,8 @@ struct vo_wayland_display { struct wl_cursor_theme *theme; struct wl_surface *surface; - /* save timer and pointer for fading out */ - int mouse_timer; - bool mouse_waiting_hide; + /* pointer for fading out */ + bool visible; struct wl_pointer *pointer; uint32_t serial; } cursor; -- cgit v1.2.3