History

command: new property: mouse-pos

This is a read-only MPV_NODE value with integer fields: x, y. The values are unmodified from mp_input_get_mouse_pos(...). Observer notification of this property is tied to the INPUT_PROCESSED event, which fires after mouse move even if no command is bound (dummy commands are generated if nothing is bound to ensure that mp_input_get_mouse_pos returns the latest values - see ac927e39 ). This allows clients such as JSON IPC to observe mouse position even while the OSC is enabled - the OSC force-binds mouse move for most of the window area, making it impossible for other clients to bind mouse move without breaking the OSC.

Avi Halachmi (:avih) committed 6 years ago

Commit a7686671 parent 799d3d41 file · +30 −0Browse files

Unified · Split

player/command.c+30−0
@@ -2621,6 +2621,33 @@ static int mp_property_osd_ass(void *ctx, struct m_property *prop, · 2620 unmodified lines
2621 return m_property_read_sub(props, action, arg);2621 return m_property_read_sub(props, action, arg);
2622}2622}
2623 2623
2624static int mp_property_mouse_pos(void *ctx, struct m_property *prop,
2625 int action, void *arg)
2626{
2627 MPContext *mpctx = ctx;
2628
2629 switch (action) {
2630 case M_PROPERTY_GET_TYPE:
2631 *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
2632 return M_PROPERTY_OK;
2633
2634 case M_PROPERTY_GET: {
2635 struct mpv_node node;
2636 int x, y;
2637 mp_input_get_mouse_pos(mpctx->input, &x, &y);
2638
2639 node_init(&node, MPV_FORMAT_NODE_MAP, NULL);
2640 node_map_add_int64(&node, "x", x);
2641 node_map_add_int64(&node, "y", y);
2642 *(struct mpv_node *)arg = node;
2643
2644 return M_PROPERTY_OK;
2645 }
2646 }
2647
2648 return M_PROPERTY_NOT_IMPLEMENTED;
2649}
2650
2624/// Video fps (RO)2651/// Video fps (RO)
2625static int mp_property_fps(void *ctx, struct m_property *prop,2652static int mp_property_fps(void *ctx, struct m_property *prop,
2626 int action, void *arg)2653 int action, void *arg)
@@ -3591,6 +3618,8 @@ static const struct m_property mp_properties_base[] = { · 964 unmodified lines
3591 {"osd-sym-cc", mp_property_osd_sym},3618 {"osd-sym-cc", mp_property_osd_sym},
3592 {"osd-ass-cc", mp_property_osd_ass},3619 {"osd-ass-cc", mp_property_osd_ass},
3593 3620
3621 {"mouse-pos", mp_property_mouse_pos},
3622
3594 // Subs3623 // Subs
3595 {"sid", property_switch_track, .priv = (void *)(const int[]){0, STREAM_SUB}},3624 {"sid", property_switch_track, .priv = (void *)(const int[]){0, STREAM_SUB}},
3596 {"secondary-sid", property_switch_track,3625 {"secondary-sid", property_switch_track,
@@ -3710,6 +3739,7 @@ static const char *const *const mp_event_property_change[] = { · 113 unmodified lines
3710 E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1",3739 E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1",
3711 "playlist-count", "playlist/count", "playlist-current-pos",3740 "playlist-count", "playlist/count", "playlist-current-pos",
3712 "playlist-playing-pos"),3741 "playlist-playing-pos"),
3742 E(MP_EVENT_INPUT_PROCESSED, "mouse-pos"),
3713 E(MP_EVENT_CORE_IDLE, "core-idle", "eof-reached"),3743 E(MP_EVENT_CORE_IDLE, "core-idle", "eof-reached"),
3714};3744};
3715#undef E3745#undef E

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t