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
26212621 return m_property_read_sub(props, action, arg);
26222622 }
26232623
2624+static 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+
26242651 /// Video fps (RO)
26252652 static int mp_property_fps(void *ctx, struct m_property *prop,
26262653 int action, void *arg)
@@ -3591,6 +3618,8 @@ static const struct m_property mp_properties_base[] = { · 964 unmodified lines
35913618 {"osd-sym-cc", mp_property_osd_sym},
35923619 {"osd-ass-cc", mp_property_osd_ass},
35933620
3621+ {"mouse-pos", mp_property_mouse_pos},
3622+
35943623 // Subs
35953624 {"sid", property_switch_track, .priv = (void *)(const int[]){0, STREAM_SUB}},
35963625 {"secondary-sid", property_switch_track,
@@ -3710,6 +3739,7 @@ static const char *const *const mp_event_property_change[] = { · 113 unmodified lines
37103739 E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1",
37113740 "playlist-count", "playlist/count", "playlist-current-pos",
37123741 "playlist-playing-pos"),
3742+ E(MP_EVENT_INPUT_PROCESSED, "mouse-pos"),
37133743 E(MP_EVENT_CORE_IDLE, "core-idle", "eof-reached"),
37143744 };
37153745 #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