From 4f610adfc29a2aa2f1159ded016ca4f8960c52e9 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 14 Dec 2010 21:58:47 +0200 Subject: libvo: register X11 connection fd in input event system Register the X11 connection fd in the input system so that mp_input_get_cmd() can immediately wake up and handle keyboard or other X events. The callback calls vo_check_events() and tells the input system to handle any input possibly recorded during that. Before this was done for vo_xv only; this commit generalizes it to all VOs that call vo_x11_create_vo_window() - those are hopefully ones that will handle all X events in check_events(). The callback is only kept registered while the vo is properly configured. At other times calling check_events() would not clear pending input and so could lead to a busy loop. --- libvo/vo_xv.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'libvo/vo_xv.c') diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 0dbc600847..63221782e2 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -61,9 +61,6 @@ Buffer allocation: #include "subopt-helper.h" -#include "input/input.h" -#include "mp_fifo.h" - #include "libavutil/common.h" static const vo_info_t info = { @@ -104,7 +101,6 @@ struct xvctx { struct vo_rect src_rect; struct vo_rect dst_rect; uint32_t max_width, max_height; // zero means: not set - int event_fd_registered; // for uninit called from preinit int mode_switched; int osd_objects_drawn; void (*draw_alpha_fnc)(void *ctx, int x0, int y0, int w, int h, @@ -645,19 +641,10 @@ static void uninit(struct vo *vo) if (ctx->mode_switched) vo_vm_close(vo); #endif - if (ctx->event_fd_registered) - mp_input_rm_key_fd(vo->input_ctx, ConnectionNumber(vo->x11->display)); // uninit() shouldn't get called unless initialization went past vo_init() vo_x11_uninit(vo); } -static int x11_fd_callback(void *ctx, int fd) -{ - struct vo *vo = ctx; - check_events(vo); - return mplayer_get_key(vo->key_fifo, 0); -} - static int preinit(struct vo *vo, const char *arg) { XvPortID xv_p; @@ -780,9 +767,6 @@ static int preinit(struct vo *vo, const char *arg) ctx->fo = XvListImageFormats(x11->display, x11->xv_port, (int *) &ctx->formats); - mp_input_add_key_fd(vo->input_ctx, ConnectionNumber(x11->display), 1, - x11_fd_callback, NULL, vo); - ctx->event_fd_registered = 1; return 0; error: -- cgit v1.2.3