diff options
author | wm4 <wm4@nowhere> | 2014-01-04 01:11:51 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-01-04 01:27:28 +0100 |
commit | 0702f642d576ee085f65bb1363b1b61f84150e51 (patch) | |
tree | 59de1c5bac7dbaaceef3654ec5e8dd438942a92c /video | |
parent | e3ab2ac112c39bb1e3780ac78d94346642ae973a (diff) | |
download | mpv-0702f642d576ee085f65bb1363b1b61f84150e51.tar.bz2 mpv-0702f642d576ee085f65bb1363b1b61f84150e51.tar.xz |
vo: add vo_drop_files()
Intended to be used for GUI drag & drop.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/vo.c | 25 | ||||
-rw-r--r-- | video/out/vo.h | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/video/out/vo.c b/video/out/vo.c index 99efc9eec9..689b6b6da1 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -619,3 +619,28 @@ void vo_mouse_movement(struct vo *vo, int posx, int posy) vo_control(vo, VOCTRL_WINDOW_TO_OSD_COORDS, p); mp_input_set_mouse_pos(vo->input_ctx, p[0], p[1]); } + +static void run_cmd(struct vo *vo, const char **cmd) +{ + mp_cmd_t *cmdt = mp_input_parse_cmd_strv(vo->log, + MP_ON_OSD_AUTO, + cmd, "<window>"); + mp_input_queue_cmd(vo->input_ctx, cmdt); +} + +// Handle drag & drop event of a list of files on the VO window. +void vo_drop_files(struct vo *vo, int num_files, char **files) +{ + for (int i = 0; i < num_files; i++) { + const char *cmd[] = { + "loadfile", + files[i], + /* Start playing the dropped files right away */ + (i == 0) ? "replace" : "append", + NULL + }; + + MP_VERBOSE(vo, "received dropped file: %s\n", files[i]); + run_cmd(vo, cmd); + } +} diff --git a/video/out/vo.h b/video/out/vo.h index 351dd3f0ae..2309e905d1 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -309,6 +309,7 @@ struct mp_keymap { int lookup_keymap_table(const struct mp_keymap *map, int key); void vo_mouse_movement(struct vo *vo, int posx, int posy); +void vo_drop_files(struct vo *vo, int num_files, char **files); struct mp_osd_res; void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src, |