diff options
Diffstat (limited to 'libvo/video_out.c')
-rw-r--r-- | libvo/video_out.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/libvo/video_out.c b/libvo/video_out.c index 763527a4c1..3e2e108d4b 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -35,6 +35,8 @@ #include "geometry.h" #include "old_vo_wrapper.h" #include "input/input.h" +#include "mp_fifo.h" + #include "mp_msg.h" @@ -352,8 +354,12 @@ void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration) void vo_check_events(struct vo *vo) { - if (!vo->config_ok) + if (!vo->config_ok) { + if (vo->registered_fd != -1) + mp_input_rm_key_fd(vo->input_ctx, vo->registered_fd); + vo->registered_fd = -1; return; + } vo->driver->check_events(vo); } @@ -365,6 +371,8 @@ void vo_seek_reset(struct vo *vo) void vo_destroy(struct vo *vo) { + if (vo->registered_fd != -1) + mp_input_rm_key_fd(vo->input_ctx, vo->registered_fd); vo->driver->uninit(vo); talloc_free(vo); } @@ -393,6 +401,8 @@ struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11, .x11 = x11, .key_fifo = key_fifo, .input_ctx = input_ctx, + .event_fd = -1, + .registered_fd = -1, }; // first try the preferred drivers, with their optional subdevice param: if (vo_list && vo_list[0]) @@ -441,6 +451,13 @@ struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11, return NULL; } +static int event_fd_callback(void *ctx, int fd) +{ + struct vo *vo = ctx; + vo_check_events(vo); + return mplayer_get_key(vo->key_fifo, 0); +} + int vo_config(struct vo *vo, uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) @@ -467,6 +484,11 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height, title, format); vo->config_ok = (ret == 0); vo->config_count += vo->config_ok; + if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) { + mp_input_add_key_fd(vo->input_ctx, vo->event_fd, 1, event_fd_callback, + NULL, vo); + vo->registered_fd = vo->event_fd; + } return ret; } |