summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-20 19:17:43 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-20 19:17:43 +0200
commit0afb326035e66663a90c4609f21560ce772e9718 (patch)
tree07f443e2bd39745ac7430cff9534529958be9c53 /libvo
parent4a26b4c024498c9b1be4723121d86e0c2b386ed2 (diff)
parent5bb2f9787f557bd91d5eb9021238ed7b131d5fa9 (diff)
downloadmpv-0afb326035e66663a90c4609f21560ce772e9718.tar.bz2
mpv-0afb326035e66663a90c4609f21560ce772e9718.tar.xz
Merge branch 'hr-seek'
* hr-seek: input: add default keybindings Shift+[arrow] for small exact seeks input: support bindings with modifier keys for X input core: audio: make ogg missing audio timing workaround more complex core: add support for precise non-keyframe-limited seeks core: add struct for queued seek info commands: add generic option -> property wrapper options: add "choice" option type, use for -pts-association-mode core: remove looping in update_video(), modify command handling a bit core: seek: use accurate seek mode with audio-only files core: avoid using sh_video->pts as "current pts" libvo: register X11 connection fd in input event system core: timing: add special handling of long frame intervals core: move central play loop to a separate function Conflicts: DOCS/tech/slave.txt
Diffstat (limited to 'libvo')
-rw-r--r--libvo/video_out.c24
-rw-r--r--libvo/video_out.h2
-rw-r--r--libvo/vo_xv.c16
-rw-r--r--libvo/x11_common.c22
-rw-r--r--libvo/x11_common.h2
5 files changed, 41 insertions, 25 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;
}
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 39ea26a53a..36a161aaf5 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -251,6 +251,8 @@ struct vo {
struct vo_x11_state *x11;
struct mp_fifo *key_fifo;
struct input_ctx *input_ctx;
+ int event_fd; // check_events() should be called when this has input
+ int registered_fd; // set to event_fd when registered in input system
// requested position/resolution
int dx;
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:
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 655b1c69d0..596645662c 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -540,12 +540,12 @@ static const struct mp_keymap keysym_map[] = {
{0, 0}
};
-static void vo_x11_putkey_ext(struct vo *vo, int keysym)
+static void vo_x11_putkey_ext(struct vo *vo, int keysym, int modifiers)
{
struct mp_fifo *f = vo->key_fifo;
int mpkey = lookup_keymap_table(keysym_map, keysym);
if (mpkey)
- mplayer_put_key(f, mpkey);
+ mplayer_put_key(f, mpkey + modifiers);
}
#endif
@@ -584,7 +584,7 @@ static const struct mp_keymap keymap[] = {
{0, 0}
};
-void vo_x11_putkey(struct vo *vo, int key)
+static void vo_x11_putkey(struct vo *vo, int key, int modifiers)
{
static const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
int mpkey = 0;
@@ -598,7 +598,7 @@ void vo_x11_putkey(struct vo *vo, int key)
mpkey = lookup_keymap_table(keymap, key);
if (mpkey)
- mplayer_put_key(vo->key_fifo, mpkey);
+ mplayer_put_key(vo->key_fifo, mpkey + modifiers);
}
@@ -814,13 +814,22 @@ int vo_x11_check_events(struct vo *vo)
XLookupString(&Event.xkey, buf, sizeof(buf), &keySym,
&x11->compose_status);
+ int modifiers = 0;
+ if (Event.xkey.state & ShiftMask)
+ modifiers |= KEY_MODIFIER_SHIFT;
+ if (Event.xkey.state & ControlMask)
+ modifiers |= KEY_MODIFIER_CTRL;
+ if (Event.xkey.state & Mod1Mask)
+ modifiers |= KEY_MODIFIER_ALT;
+ if (Event.xkey.state & Mod4Mask)
+ modifiers |= KEY_MODIFIER_META;
#ifdef XF86XK_AudioPause
- vo_x11_putkey_ext(vo, keySym);
+ vo_x11_putkey_ext(vo, keySym, modifiers);
#endif
key =
((keySym & 0xff00) !=
0 ? ((keySym & 0x00ff) + 256) : (keySym));
- vo_x11_putkey(vo, key);
+ vo_x11_putkey(vo, key, modifiers);
ret |= VO_EVENT_KEYPRESS;
}
break;
@@ -1123,6 +1132,7 @@ final:
x11->vo_gc = XCreateGC(mDisplay, x11->window, GCForeground, &xgcv);
XSync(mDisplay, False);
x11->vo_mouse_autohide = 1;
+ vo->event_fd = ConnectionNumber(x11->display);
}
void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index 57b1d79f33..824f55b4c8 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -170,8 +170,6 @@ void xv_setup_colorkeyhandling(struct vo *vo, const char *ck_method_str, const c
int xv_test_ck( void * arg );
int xv_test_ckm( void * arg );
-void vo_x11_putkey(struct vo *vo, int key);
-
#ifdef CONFIG_XF86VM
void vo_vm_switch(struct vo *vo);
void vo_vm_close(struct vo *vo);