mirror of
https://github.com/mpv-player/mpv
synced 2024-11-18 21:16:10 +01:00
x11: use mpv internal key auto-repeat handling if possible
Block X11's native key repeat, and use mpv's key repeat handling in input.c instead. No configure check for XKB. Even though it's an extension, it has been part of most (all?) xlibs since 1996. If XKB appears to be missing, just refuse enabling x11. This is a potentially controversial change. mpv will use its own key repeat rate, instead of X11's. This should be better, because seeking will have a standardized "speed" (seek events per seconds when keeping a seek key held down). It will also allow disabling key repears for certain commands, though this is not done anywhere yet. The new behavior can be disabled with the --native-keyrepeat option.
This commit is contained in:
parent
97be5ead14
commit
d853abafc3
2
configure
vendored
2
configure
vendored
@ -1829,7 +1829,7 @@ if test "$_x11" = auto && test "$_x11_headers" = yes ; then
|
||||
else
|
||||
_ld_tmp="$I -lXext -lX11 $_ld_pthread"
|
||||
fi
|
||||
statement_check X11/Xutil.h 'XCreateWindow(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)' $_ld_tmp &&
|
||||
statement_check_broken X11/Xutil.h X11/XKBlib.h 'XCreateWindow(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)' $_ld_tmp &&
|
||||
_x11=yes
|
||||
# Check that there aren't conflicting headers between ApplicationServices
|
||||
# and X11. On versions of Mac OSX prior to 10.7 the deprecated QuickDraw API
|
||||
|
@ -574,6 +574,7 @@ const m_option_t mplayer_opts[]={
|
||||
OPT_INTRANGE("fsmode-dontuse", vo.fsmode, 0, 31, 4096),
|
||||
OPT_INT("colorkey", vo.colorkey, 0),
|
||||
OPT_FLAG_STORE("no-colorkey", vo.colorkey, 0, 0x1000000),
|
||||
OPT_FLAG("native-keyrepeat", vo.native_keyrepeat, 0),
|
||||
OPT_FLOATRANGE("panscan", vo.panscan, 0, 0.0, 1.0),
|
||||
OPT_FLOATRANGE("panscanrange", vo.panscanrange, 0, -19.0, 99.0),
|
||||
OPT_FLAG("force-rgba-osd-rendering", force_rgba_osd, 0),
|
||||
|
@ -17,6 +17,7 @@ typedef struct mp_vo_opts {
|
||||
int stop_screensaver;
|
||||
char *winname;
|
||||
char** fstype_list;
|
||||
int native_keyrepeat;
|
||||
|
||||
float panscan;
|
||||
float panscanrange;
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
#ifdef CONFIG_XSS
|
||||
#include <X11/extensions/scrnsaver.h>
|
||||
@ -450,6 +451,12 @@ int vo_x11_init(struct vo *vo)
|
||||
x11->screen = DefaultScreen(x11->display); // screen ID
|
||||
x11->rootwin = RootWindow(x11->display, x11->screen); // root window ID
|
||||
|
||||
if (!opts->native_keyrepeat) {
|
||||
Bool ok = False;
|
||||
XkbSetDetectableAutoRepeat(x11->display, True, &ok);
|
||||
x11->no_autorepeat = ok;
|
||||
}
|
||||
|
||||
x11->xim = XOpenIM(x11->display, NULL, NULL, NULL);
|
||||
|
||||
init_atoms(vo->x11);
|
||||
@ -629,6 +636,8 @@ void vo_x11_uninit(struct vo *vo)
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
assert(x11);
|
||||
|
||||
mplayer_put_key(vo->key_fifo, MP_INPUT_RELEASE_ALL);
|
||||
|
||||
saver_on(x11);
|
||||
if (x11->window != None)
|
||||
vo_showcursor(vo, x11->display, x11->window);
|
||||
@ -721,6 +730,8 @@ int vo_x11_check_events(struct vo *vo)
|
||||
char buf[100];
|
||||
KeySym keySym = 0;
|
||||
int modifiers = 0;
|
||||
if (x11->no_autorepeat)
|
||||
modifiers |= MP_KEY_STATE_DOWN;
|
||||
if (Event.xkey.state & ShiftMask)
|
||||
modifiers |= MP_KEY_MODIFIER_SHIFT;
|
||||
if (Event.xkey.state & ControlMask)
|
||||
@ -747,8 +758,17 @@ int vo_x11_check_events(struct vo *vo)
|
||||
if (mpkey)
|
||||
mplayer_put_key(vo->key_fifo, mpkey | modifiers);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Releasing all keys in these situations is simpler and ensures no
|
||||
// keys can be get "stuck".
|
||||
case FocusOut:
|
||||
case KeyRelease:
|
||||
{
|
||||
if (x11->no_autorepeat)
|
||||
mplayer_put_key(vo->key_fifo, MP_INPUT_RELEASE_ALL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MotionNotify:
|
||||
vo_mouse_movement(vo, Event.xmotion.x, Event.xmotion.y);
|
||||
vo_x11_unhide_cursor(vo);
|
||||
@ -981,7 +1001,8 @@ static void vo_x11_map_window(struct vo *vo, int x, int y, int w, int h)
|
||||
vo_x11_decoration(vo, 0);
|
||||
// map window
|
||||
vo_x11_selectinput_witherr(vo, x11->display, x11->window,
|
||||
StructureNotifyMask | KeyPressMask |
|
||||
StructureNotifyMask |
|
||||
KeyPressMask | KeyReleaseMask |
|
||||
ButtonPressMask | ButtonReleaseMask |
|
||||
PointerMotionMask | ExposureMask);
|
||||
XMapWindow(x11->display, x11->window);
|
||||
|
@ -44,6 +44,7 @@ struct vo_x11_state {
|
||||
|
||||
XIM xim;
|
||||
XIC xic;
|
||||
bool no_autorepeat;
|
||||
|
||||
GC f_gc; // used to paint background
|
||||
GC vo_gc; // used to paint video
|
||||
|
Loading…
Reference in New Issue
Block a user