summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2021-04-12 12:51:41 -0500
committerDudemanguy <random342@airmail.cc>2021-05-06 17:36:55 +0000
commita88fdfde0c91c16c84e6057b19bdc2fb9e666e24 (patch)
tree64bb28b8c231040510adfef3630a62bac592e5ae /player
parent8edfe70b83acba3de91d41bf1c46921e969ea265 (diff)
downloadmpv-a88fdfde0c91c16c84e6057b19bdc2fb9e666e24.tar.bz2
mpv-a88fdfde0c91c16c84e6057b19bdc2fb9e666e24.tar.xz
command: add display-width/display-height property
For some reason, this never existed before. Add VOCTRL_GET_DISPLAY_RES and use it to obtain the current display's resolution from each vo/windowing backend if applicable. Users can then access the current display resolution as display-width and display-height as per the client api. Note that macOS/cocoa was not attempted in this commit since the author has no clue how to write swift.
Diffstat (limited to 'player')
-rw-r--r--player/command.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/player/command.c b/player/command.c
index d1cd1c7010..7e6e5170ef 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2412,6 +2412,23 @@ static int mp_property_vsync_jitter(void *ctx, struct m_property *prop,
return m_property_double_ro(action, arg, stddev);
}
+static int mp_property_display_resolution(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ struct vo *vo = mpctx->video_out;
+ if (!vo)
+ return M_PROPERTY_UNAVAILABLE;
+ int res[2];
+ if (vo_control(vo, VOCTRL_GET_DISPLAY_RES, &res) <= 0)
+ return M_PROPERTY_UNAVAILABLE;
+ if (strcmp(prop->name, "display-width") == 0) {
+ return m_property_int_ro(action, arg, res[0]);
+ } else {
+ return m_property_int_ro(action, arg, res[1]);
+ }
+}
+
static int mp_property_hidpi_scale(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -3528,6 +3545,8 @@ static const struct m_property mp_properties_base[] = {
{"total-avsync-change", mp_property_total_avsync_change},
{"mistimed-frame-count", mp_property_mistimed_frame_count},
{"vsync-ratio", mp_property_vsync_ratio},
+ {"display-width", mp_property_display_resolution},
+ {"display-height", mp_property_display_resolution},
{"decoder-frame-drop-count", mp_property_frame_drop_dec},
{"frame-drop-count", mp_property_frame_drop_vo},
{"vo-delayed-frame-count", mp_property_vo_delayed_frame_count},
@@ -3743,7 +3762,8 @@ static const char *const *const mp_event_property_change[] = {
"demuxer-cache-state"),
E(MP_EVENT_WIN_RESIZE, "current-window-scale", "osd-width", "osd-height",
"osd-par", "osd-dimensions"),
- E(MP_EVENT_WIN_STATE, "display-names", "display-fps"),
+ E(MP_EVENT_WIN_STATE, "display-names", "display-fps" "display-width",
+ "display-height"),
E(MP_EVENT_WIN_STATE2, "display-hidpi-scale"),
E(MP_EVENT_FOCUS, "focused"),
E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1",