mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-26 21:00:21 +00:00
command: add ambient-light property
make it observable to make it usable as a replacement for --gamma-auto.
This commit is contained in:
@@ -2849,6 +2849,9 @@ Property list
|
||||
``focused``
|
||||
Whether the window has focus. Might not be supported by all VOs.
|
||||
|
||||
``ambient-light``
|
||||
Ambient lighting condition in lux. (macOS only)
|
||||
|
||||
``display-names``
|
||||
Names of the displays that the mpv window covers. On X11, these
|
||||
are the xrandr names (LVDS1, HDMI1, DP1, VGA1, etc.). On Windows, these
|
||||
|
||||
@@ -2778,6 +2778,18 @@ static void update_hidpi_window_scale(struct MPContext *mpctx, bool hidpi_scale)
|
||||
vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s);
|
||||
}
|
||||
|
||||
static int mp_property_ambient_light(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
MPContext *mpctx = ctx;
|
||||
struct vo *vo = mpctx->video_out;
|
||||
double lux;
|
||||
if (!vo || vo_control(vo, VOCTRL_GET_AMBIENT_LUX, &lux) < 1)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
return m_property_double_ro(action, arg, lux);
|
||||
}
|
||||
|
||||
static int mp_property_focused(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
@@ -4373,6 +4385,7 @@ static const struct m_property mp_properties_base[] = {
|
||||
{"estimated-display-fps", mp_property_estimated_display_fps},
|
||||
{"vsync-jitter", mp_property_vsync_jitter},
|
||||
{"display-hidpi-scale", mp_property_hidpi_scale},
|
||||
{"ambient-light", mp_property_ambient_light},
|
||||
|
||||
{"working-directory", mp_property_cwd},
|
||||
|
||||
@@ -4460,6 +4473,7 @@ static const char *const *const mp_event_property_change[] = {
|
||||
"display-height"),
|
||||
E(MP_EVENT_WIN_STATE2, "display-hidpi-scale"),
|
||||
E(MP_EVENT_FOCUS, "focused"),
|
||||
E(MP_EVENT_AMBIENT_LIGHTING_CHANGED, "ambient-light"),
|
||||
E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1",
|
||||
"playlist-count", "playlist/count", "playlist-current-pos",
|
||||
"playlist-playing-pos"),
|
||||
|
||||
@@ -101,6 +101,7 @@ enum {
|
||||
MP_EVENT_WIN_STATE,
|
||||
MP_EVENT_WIN_STATE2,
|
||||
MP_EVENT_FOCUS,
|
||||
MP_EVENT_AMBIENT_LIGHTING_CHANGED,
|
||||
MP_EVENT_CHANGE_PLAYLIST,
|
||||
MP_EVENT_CORE_IDLE,
|
||||
MP_EVENT_DURATION_UPDATE,
|
||||
|
||||
@@ -859,6 +859,8 @@ static void handle_vo_events(struct MPContext *mpctx)
|
||||
mp_notify(mpctx, MP_EVENT_WIN_STATE2, NULL);
|
||||
if (events & VO_EVENT_FOCUS)
|
||||
mp_notify(mpctx, MP_EVENT_FOCUS, NULL);
|
||||
if (events & VO_EVENT_AMBIENT_LIGHTING_CHANGED)
|
||||
mp_notify(mpctx, MP_EVENT_AMBIENT_LIGHTING_CHANGED, NULL);
|
||||
}
|
||||
|
||||
static void handle_sstep(struct MPContext *mpctx)
|
||||
|
||||
@@ -54,7 +54,7 @@ enum {
|
||||
|
||||
// Set of events the player core may be interested in.
|
||||
VO_EVENTS_USER = VO_EVENT_RESIZE | VO_EVENT_WIN_STATE | VO_EVENT_DPI |
|
||||
VO_EVENT_INITIAL_UNBLOCK | VO_EVENT_FOCUS,
|
||||
VO_EVENT_INITIAL_UNBLOCK | VO_EVENT_FOCUS | VO_EVENT_AMBIENT_LIGHTING_CHANGED,
|
||||
};
|
||||
|
||||
enum mp_voctrl {
|
||||
|
||||
Reference in New Issue
Block a user