summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-02 20:48:45 +0100
committerwm4 <wm4@nowhere>2014-11-02 20:55:07 +0100
commit416c86f3cb3535a5b252b8c08a7f4cb253fa495a (patch)
treee4124d52d879ee55ceca6896da16ebf832f49129 /player
parent4e2574f025b9f143140008cbed48f6ee9705f813 (diff)
downloadmpv-416c86f3cb3535a5b252b8c08a7f4cb253fa495a.tar.bz2
mpv-416c86f3cb3535a5b252b8c08a7f4cb253fa495a.tar.xz
command: add window-minimized property (X11 only)
More or less requested by #1237. Should be simple to extend this to other backends.
Diffstat (limited to 'player')
-rw-r--r--player/command.c18
-rw-r--r--player/command.h1
-rw-r--r--player/playloop.c2
3 files changed, 21 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index 391cc5b30a..d97460ab91 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2445,6 +2445,21 @@ static int mp_property_window_scale(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED;
}
+static int mp_property_win_minimized(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 state = 0;
+ if (vo_control(vo, VOCTRL_GET_WIN_STATE, &state) < 1)
+ return M_PROPERTY_UNAVAILABLE;
+
+ return m_property_flag_ro(action, arg, state & VO_WIN_STATE_MINIMIZED);
+}
+
static int mp_property_vo_configured(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -3166,6 +3181,8 @@ static const struct m_property mp_properties[] = {
M_PROPERTY_ALIAS("audio", "aid"),
M_PROPERTY_ALIAS("sub", "sid"),
+ {"window-minimized", mp_property_win_minimized},
+
{"mpv-version", mp_property_version},
{"options", mp_property_options},
@@ -3202,6 +3219,7 @@ static const char *const *const mp_event_property_change[] = {
E(MP_EVENT_CACHE_UPDATE, "cache", "cache-free", "cache-used", "cache-idle",
"demuxer-cache-duration", "demuxer-cache-idle"),
E(MP_EVENT_WIN_RESIZE, "window-scale"),
+ E(MP_EVENT_WIN_STATE, "window-minimized"),
};
#undef E
diff --git a/player/command.h b/player/command.h
index 3469e32948..d4097fee6f 100644
--- a/player/command.h
+++ b/player/command.h
@@ -45,6 +45,7 @@ enum {
INTERNAL_EVENT_BASE = 24,
MP_EVENT_CACHE_UPDATE,
MP_EVENT_WIN_RESIZE,
+ MP_EVENT_WIN_STATE,
};
bool mp_hook_test_completion(struct MPContext *mpctx, char *type);
diff --git a/player/playloop.c b/player/playloop.c
index 85d962fffe..9e1cef957d 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -676,6 +676,8 @@ static void handle_vo_events(struct MPContext *mpctx)
int events = vo ? vo_query_events(vo, VO_EVENTS_USER, true) : 0;
if (events & VO_EVENT_RESIZE)
mp_notify(mpctx, MP_EVENT_WIN_RESIZE, NULL);
+ if (events & VO_EVENT_WIN_STATE)
+ mp_notify(mpctx, MP_EVENT_WIN_STATE, NULL);
}
void add_frame_pts(struct MPContext *mpctx, double pts)