summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-31 21:59:37 +0200
committerwm4 <wm4@nowhere>2013-09-01 20:17:51 +0200
commit6a55fa679373e65d4be838c1cb0724c0d1ed2d20 (patch)
treea19a96cb085f720e16aafda693d3bfacab925076 /mpvcore
parent0c7978cf9caa81d1e6ef7e32458a5ff1834fa004 (diff)
downloadmpv-6a55fa679373e65d4be838c1cb0724c0d1ed2d20.tar.bz2
mpv-6a55fa679373e65d4be838c1cb0724c0d1ed2d20.tar.xz
input: allow window dragging even if mouse is in a mouse area
If the input section is enabled with MP_INPUT_ALLOW_VO_DRAGGING, then the VO will be allowed to drag the window with mouse button down + mouse move even if the mouse is inside the section's mouse area.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/input/input.c15
-rw-r--r--mpvcore/input/input.h2
2 files changed, 13 insertions, 4 deletions
diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c
index 12e07a22dd..f977fd9e9d 100644
--- a/mpvcore/input/input.c
+++ b/mpvcore/input/input.c
@@ -2143,13 +2143,15 @@ void mp_input_set_section_mouse_area(struct input_ctx *ictx, char *name,
input_unlock(ictx);
}
-bool mp_input_test_mouse_active(struct input_ctx *ictx, int x, int y)
+static bool test_mouse(struct input_ctx *ictx, int x, int y, int rej_flags)
{
input_lock(ictx);
bool res = false;
for (int i = 0; i < ictx->num_active_sections; i++) {
- char *name = ictx->active_sections[i].name;
- struct cmd_bind_section *s = get_bind_section(ictx, bstr0(name));
+ struct active_section *as = &ictx->active_sections[i];
+ if (as->flags & rej_flags)
+ continue;
+ struct cmd_bind_section *s = get_bind_section(ictx, bstr0(as->name));
if (s->mouse_area_set && test_rect(&s->mouse_area, x, y)) {
res = true;
break;
@@ -2159,9 +2161,14 @@ bool mp_input_test_mouse_active(struct input_ctx *ictx, int x, int y)
return res;
}
+bool mp_input_test_mouse_active(struct input_ctx *ictx, int x, int y)
+{
+ return test_mouse(ictx, x, y, 0);
+}
+
bool mp_input_test_dragging(struct input_ctx *ictx, int x, int y)
{
- return mp_input_test_mouse_active(ictx, x, y);
+ return test_mouse(ictx, x, y, MP_INPUT_ALLOW_VO_DRAGGING);
}
// builtin: if true, remove all builtin binds, else remove all user binds
diff --git a/mpvcore/input/input.h b/mpvcore/input/input.h
index 022ebb3881..ebdbc76821 100644
--- a/mpvcore/input/input.h
+++ b/mpvcore/input/input.h
@@ -116,6 +116,8 @@ enum mp_input_section_flags {
// other sections for it (like the default section). Instead, an unbound
// key warning will be printed.
MP_INPUT_EXCLUSIVE = 1,
+ // Let mp_input_test_dragging() return true, even if inside the mouse area.
+ MP_INPUT_ALLOW_VO_DRAGGING = 2,
};
struct input_ctx;