From 58004ea2ef1a14da51b3f46e1c8565c0a3a91ee0 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Wed, 25 Dec 2019 20:52:19 +0200 Subject: command: mouse-pos property: add field "hover" Add a third field: "hover", which is updated from input.c after input keys MP_KEY_MOUSE_LEAVE and MP_KEY_MOUSE_ENTER - which are typically sent by the VO. It's part of mouse-pos and not a new property because it's highly tied to mouse-pos - it makes x/y invalid while the cursor doesn't hover the window. Unike mouse-move, no dummy command was generated, so we add dummy command in order for observer notification to work even while nothing is bound. Like mouse-pos, clients could not detect whether the mouse pointer hovers the window because the OSC force-binds the MOUSE_LEAVE key, and now they can using the hover field. The lua mp.get_mouse_pos() wrapper still returns only x, y because that's what osc.lua needs. Other clients can simply read the property. --- player/command.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index ddaf0615f4..ba234ddc9f 100644 --- a/player/command.c +++ b/player/command.c @@ -2633,12 +2633,13 @@ static int mp_property_mouse_pos(void *ctx, struct m_property *prop, case M_PROPERTY_GET: { struct mpv_node node; - int x, y; - mp_input_get_mouse_pos(mpctx->input, &x, &y); + int x, y, hover; + mp_input_get_mouse_pos(mpctx->input, &x, &y, &hover); node_init(&node, MPV_FORMAT_NODE_MAP, NULL); node_map_add_int64(&node, "x", x); node_map_add_int64(&node, "y", y); + node_map_add_flag(&node, "hover", hover); *(struct mpv_node *)arg = node; return M_PROPERTY_OK; -- cgit v1.2.3