summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortorque <torque@1>2015-02-16 21:50:57 -0800
committerwm4 <wm4@nowhere>2015-02-18 00:03:16 +0100
commit3b269ac0a04b7575a8ab1a6665d75fc0d0e8589e (patch)
tree9b637249e3225cebe664724280a30918c0e7a8a3
parentfa9b587426d7bd350d92afdb440c396336b2ecfd (diff)
downloadmpv-3b269ac0a04b7575a8ab1a6665d75fc0d0e8589e.tar.bz2
mpv-3b269ac0a04b7575a8ab1a6665d75fc0d0e8589e.tar.xz
input: add MOUSE_ENTER keybinding.
Signed-off-by: wm4 <wm4@nowhere>
-rw-r--r--input/input.c9
-rw-r--r--input/keycodes.c1
-rw-r--r--input/keycodes.h1
-rw-r--r--video/out/cocoa/events_view.m3
-rw-r--r--video/out/w32_common.c4
-rw-r--r--video/out/wayland_common.c1
-rw-r--r--video/out/x11_common.c5
7 files changed, 21 insertions, 3 deletions
diff --git a/input/input.c b/input/input.c
index ecf897a9c2..55344be779 100644
--- a/input/input.c
+++ b/input/input.c
@@ -463,8 +463,11 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section,
if (code == MP_KEY_CLOSE_WIN)
return mp_input_parse_cmd_strv(ictx->log, (const char*[]){"quit", 0});
int msgl = MSGL_WARN;
- if (code == MP_KEY_MOUSE_MOVE || code == MP_KEY_MOUSE_LEAVE)
+ if (code == MP_KEY_MOUSE_MOVE || code == MP_KEY_MOUSE_LEAVE ||
+ code == MP_KEY_MOUSE_ENTER)
+ {
msgl = MSGL_DEBUG;
+ }
char *key_buf = mp_input_get_key_combo_name(&code, 1);
MP_MSG(ictx, msgl, "No bind found for key '%s'.\n", key_buf);
talloc_free(key_buf);
@@ -635,6 +638,10 @@ static void mp_input_feed_key(struct input_ctx *ictx, int code, double scale)
update_mouse_section(ictx);
mp_input_queue_cmd(ictx, get_cmd_from_keys(ictx, NULL, code));
return;
+ } else if (unmod == MP_KEY_MOUSE_ENTER) {
+ update_mouse_section(ictx);
+ mp_input_queue_cmd(ictx, get_cmd_from_keys(ictx, NULL, code));
+ return;
}
double now = mp_time_sec();
// ignore system-doubleclick if we generate these events ourselves
diff --git a/input/keycodes.c b/input/keycodes.c
index e448a9bd31..012fd006ce 100644
--- a/input/keycodes.c
+++ b/input/keycodes.c
@@ -205,6 +205,7 @@ static const struct key_name key_names[] = {
{ MP_KEY_CLOSE_WIN, "CLOSE_WIN" },
{ MP_KEY_MOUSE_MOVE, "MOUSE_MOVE" },
{ MP_KEY_MOUSE_LEAVE, "MOUSE_LEAVE" },
+ { MP_KEY_MOUSE_ENTER, "MOUSE_ENTER" },
{ 0, NULL }
};
diff --git a/input/keycodes.h b/input/keycodes.h
index 3922cfca6e..7b5027691d 100644
--- a/input/keycodes.h
+++ b/input/keycodes.h
@@ -222,6 +222,7 @@
// Generated by input.c (VOs use mp_input_set_mouse_pos())
#define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
#define MP_KEY_MOUSE_LEAVE ((MP_KEY_INTERN+2)|MP_NO_REPEAT_KEY)
+#define MP_KEY_MOUSE_ENTER ((MP_KEY_INTERN+3)|MP_NO_REPEAT_KEY)
#define MP_KEY_DEPENDS_ON_MOUSE_POS(code) \
diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m
index 620de19f84..d6ba9e0ff5 100644
--- a/video/out/cocoa/events_view.m
+++ b/video/out/cocoa/events_view.m
@@ -173,6 +173,9 @@
- (void)mouseEntered:(NSEvent *)event
{
[super mouseEntered:event];
+ if ([self.adapter mouseEnabled]) {
+ [self.adapter putKey:MP_KEY_MOUSE_ENTER withModifiers:0];
+ }
}
- (void)mouseExited:(NSEvent *)event
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index b788054070..1d82825294 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -696,8 +696,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
mp_input_put_key(w32->input_ctx, MP_KEY_MOUSE_LEAVE);
break;
case WM_MOUSEMOVE: {
- if (!w32->tracking)
+ if (!w32->tracking) {
w32->tracking = TrackMouseEvent(&w32->trackEvent);
+ mp_input_put_key(w32->input_ctx, MP_KEY_MOUSE_ENTER);
+ }
// Windows can send spurious mouse events, which would make the mpv
// core unhide the mouse cursor on completely unrelated events. See:
// https://blogs.msdn.com/b/oldnewthing/archive/2003/10/01/55108.aspx
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 843049816e..2d09ad12b0 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -379,6 +379,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 */
+ mp_input_put_key(wl->vo->input_ctx, MP_KEY_MOUSE_ENTER);
mp_input_put_key(wl->vo->input_ctx, MP_MOUSE_BTN0 | MP_KEY_STATE_UP);
show_cursor(wl);
}
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index dcac1788a3..50a4256c8f 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -934,6 +934,9 @@ int vo_x11_check_events(struct vo *vo)
x11->win_drag_button1_down = false;
mp_input_put_key(vo->input_ctx, MP_KEY_MOUSE_LEAVE);
break;
+ case EnterNotify:
+ mp_input_put_key(vo->input_ctx, MP_KEY_MOUSE_ENTER);
+ break;
case ButtonPress:
if (Event.xbutton.button == 1)
x11->win_drag_button1_down = true;
@@ -1332,7 +1335,7 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc)
// map window
int events = StructureNotifyMask | ExposureMask | PropertyChangeMask |
- LeaveWindowMask;
+ LeaveWindowMask | EnterWindowMask;
if (mp_input_mouse_enabled(vo->input_ctx))
events |= PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
if (mp_input_vo_keyboard_enabled(vo->input_ctx))