summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxylosper <darklin20@gmail.com>2015-04-21 00:50:43 +0900
committerxylosper <darklin20@gmail.com>2015-04-21 00:54:29 +0900
commitc64e4e48d97b9af2b241179ee87765e5d17fff95 (patch)
treec6df7a6ef5f2f8955ae14e0956dbd6fa96d5a41a
parentebe2c2b6d19357f73b9fc82de2a47a2aa321e44a (diff)
downloadmpv-c64e4e48d97b9af2b241179ee87765e5d17fff95.tar.bz2
mpv-c64e4e48d97b9af2b241179ee87765e5d17fff95.tar.xz
command: disc-mouse-on-button property
This property indicates whether mouse cursor is located on button or not for disc naviation.
-rw-r--r--DOCS/man/input.rst4
-rw-r--r--player/command.c9
-rw-r--r--player/core.h1
-rw-r--r--player/discnav.c23
-rw-r--r--stream/discnav.h1
-rw-r--r--stream/stream_bluray.c8
-rw-r--r--stream/stream_dvdnav.c9
7 files changed, 49 insertions, 6 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 7209f508d9..4f378d0222 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -919,6 +919,10 @@ Property list
a BD or DVD. Use the ``discnav menu`` command to actually enter or leave
menu mode.
+``disc-mouse-on-button``
+ Return ``yes`` when the mouse cursor is located on a button, or ``no``
+ when cursor is outside of any button for disc navigation.
+
``chapters``
Number of chapters.
diff --git a/player/command.c b/player/command.c
index 6db3b2100b..68ad29f02b 100644
--- a/player/command.c
+++ b/player/command.c
@@ -702,6 +702,14 @@ static int mp_property_disc_menu(void *ctx, struct m_property *prop,
return m_property_flag_ro(action, arg, !!state);
}
+static int mp_property_mouse_on_button(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ bool on = mp_nav_mouse_on_button(mpctx);
+ return m_property_flag_ro(action, arg, on);
+}
+
/// Current chapter (RW)
static int mp_property_chapter(void *ctx, struct m_property *prop,
int action, void *arg)
@@ -3262,6 +3270,7 @@ static const struct m_property mp_properties[] = {
{"playback-time", mp_property_playback_time},
{"disc-title", mp_property_disc_title},
{"disc-menu-active", mp_property_disc_menu},
+ {"disc-mouse-on-button", mp_property_mouse_on_button},
{"chapter", mp_property_chapter},
{"edition", mp_property_edition},
{"disc-titles", mp_property_disc_titles},
diff --git a/player/core.h b/player/core.h
index 23547ac630..9ed452ffad 100644
--- a/player/core.h
+++ b/player/core.h
@@ -373,6 +373,7 @@ void mp_nav_destroy(struct MPContext *mpctx);
void mp_nav_user_input(struct MPContext *mpctx, char *command);
void mp_handle_nav(struct MPContext *mpctx);
int mp_nav_in_menu(struct MPContext *mpctx);
+bool mp_nav_mouse_on_button(struct MPContext *mpctx);
// loadfile.c
void uninit_player(struct MPContext *mpctx, unsigned int mask);
diff --git a/player/discnav.c b/player/discnav.c
index d66b569d4b..719e88ac8f 100644
--- a/player/discnav.c
+++ b/player/discnav.c
@@ -42,6 +42,7 @@ struct mp_nav_state {
bool nav_eof;
bool nav_menu;
bool nav_draining;
+ bool nav_mouse_on_button;
// Accessed by OSD (possibly separate thread)
// Protected by the given lock
@@ -91,6 +92,25 @@ int mp_nav_in_menu(struct MPContext *mpctx)
return mpctx->nav_state ? mpctx->nav_state->nav_menu : -1;
}
+static void update_mouse_on_button(struct MPContext *mpctx)
+{
+ mp_notify_property(mpctx, "disc-mouse-on-button");
+}
+
+static void set_mouse_on_button(struct MPContext *mpctx, bool in)
+{
+ struct mp_nav_state *nav = mpctx->nav_state;
+ if (nav->nav_mouse_on_button != in) {
+ nav->nav_mouse_on_button = in;
+ update_mouse_on_button(mpctx);
+ }
+}
+
+bool mp_nav_mouse_on_button(struct MPContext *mpctx)
+{
+ return mpctx->nav_state ? mpctx->nav_state->nav_mouse_on_button : false;
+}
+
// If a demuxer is accessing the stream, we have to use demux_stream_control()
// to avoid synchronization issues; otherwise access it directly.
static int run_stream_control(struct MPContext *mpctx, int cmd, void *arg)
@@ -129,6 +149,7 @@ void mp_nav_init(struct MPContext *mpctx)
MP_INPUT_ALLOW_VO_DRAGGING | MP_INPUT_ALLOW_HIDE_CURSOR);
update_state(mpctx);
+ update_mouse_on_button(mpctx);
}
void mp_nav_reset(struct MPContext *mpctx)
@@ -159,6 +180,7 @@ void mp_nav_destroy(struct MPContext *mpctx)
talloc_free(mpctx->nav_state);
mpctx->nav_state = NULL;
update_state(mpctx);
+ update_mouse_on_button(mpctx);
}
void mp_nav_user_input(struct MPContext *mpctx, char *command)
@@ -182,6 +204,7 @@ void mp_nav_user_input(struct MPContext *mpctx, char *command)
inp.u.mouse_pos.x = x;
inp.u.mouse_pos.y = y;
run_stream_control(mpctx, STREAM_CTRL_NAV_CMD, &inp);
+ set_mouse_on_button(mpctx, inp.mouse_on_button);
} else {
struct mp_nav_cmd inp = {MP_NAV_CMD_MENU};
inp.u.menu.action = command;
diff --git a/stream/discnav.h b/stream/discnav.h
index e6a063f8e1..b40998d3cb 100644
--- a/stream/discnav.h
+++ b/stream/discnav.h
@@ -80,6 +80,7 @@ struct mp_nav_cmd {
int x, y;
} mouse_pos;
} u;
+ bool mouse_on_button;
};
#endif /* MPLAYER_STREAM_DVDNAV_H */
diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c
index 1718531ecc..adc2e5828b 100644
--- a/stream/stream_bluray.c
+++ b/stream/stream_bluray.c
@@ -455,7 +455,9 @@ static void handle_nav_command(stream_t *s, struct mp_nav_cmd *ev)
bd_vk_key_e key = translate_nav_menu_action(action);
if (key != BD_VK_NONE) {
if (key == BD_VK_MOUSE_ACTIVATE)
- bd_mouse_select(priv->bd, pts, priv->mousex, priv->mousey);
+ ev->mouse_on_button = bd_mouse_select(priv->bd, pts,
+ priv->mousex,
+ priv->mousey);
bd_user_input(priv->bd, pts, key);
} else if (strcmp(action, "menu") == 0) {
if (priv->popup_enabled)
@@ -467,7 +469,9 @@ static void handle_nav_command(stream_t *s, struct mp_nav_cmd *ev)
} case MP_NAV_CMD_MOUSE_POS:
priv->mousex = ev->u.mouse_pos.x;
priv->mousey = ev->u.mouse_pos.y;
- bd_mouse_select(priv->bd, mp_time_us(), priv->mousex, priv->mousey);
+ ev->mouse_on_button = bd_mouse_select(priv->bd, mp_time_us(),
+ priv->mousex,
+ priv->mousey);
break;
case MP_NAV_CMD_SKIP_STILL:
bd_read_skip_still(priv->bd);
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index b94187b3ff..095ba98ddf 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -202,18 +202,19 @@ static void handle_menu_input(stream_t *stream, const char *cmd)
}
}
-static void handle_mouse_pos(stream_t *stream, int x, int y)
+static dvdnav_status_t handle_mouse_pos(stream_t *stream, int x, int y)
{
struct priv *priv = stream->priv;
dvdnav_t *nav = priv->dvdnav;
pci_t *pci = dvdnav_get_current_nav_pci(nav);
if (!pci)
- return;
+ return DVDNAV_STATUS_ERR;
- dvdnav_mouse_select(nav, pci, x, y);
+ dvdnav_status_t status = dvdnav_mouse_select(nav, pci, x, y);
priv->mousex = x;
priv->mousey = y;
+ return status;
}
/**
@@ -305,7 +306,7 @@ static void handle_cmd(stream_t *s, struct mp_nav_cmd *ev)
handle_menu_input(s, ev->u.menu.action);
break;
case MP_NAV_CMD_MOUSE_POS:
- handle_mouse_pos(s, ev->u.mouse_pos.x, ev->u.mouse_pos.y);
+ ev->mouse_on_button = handle_mouse_pos(s, ev->u.mouse_pos.x, ev->u.mouse_pos.y);
break;
}