Hi,
On 16/01/2016 21:25:00 CET, Marton Balint wrote:
On Fri, 15 Jan 2016, Vittorio Gambaletta (VittGam) wrote:
Now that the seek only happens with the right mouse button, it makes
sense to toggle full screen when double-clicking with the left mouse
button, like other video players do.
I am not against this.
Signed-off-by: Vittorio Gambaletta <ffmpeg-...@vittgam.net>
---
ffplay.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/ffplay.c b/ffplay.c
index 2fa7165..582ca39 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -3473,6 +3473,24 @@ static void event_loop(VideoState *cur_stream)
do_exit(cur_stream);
break;
}
+ {
Whitespace and indentation seems messed up in this patch as well.
+ static int mouse_left_click_status = 0;
+ static double mouse_left_click_last_x, mouse_left_click_last_y;
+ if (event.button.button == SDL_BUTTON_LEFT) {
+ if (mouse_left_click_status == 1 && av_gettime_relative() -
cursor_last_shown <= 500000
+ && fabs(event.button.x - mouse_left_click_last_x) <= 1 &&
fabs(event.button.y - mouse_left_click_last_y) <= 1) {
+ toggle_full_screen(cur_stream);
+ cur_stream->force_refresh = 1;
+ mouse_left_click_status = 0;
+ } else {
+ mouse_left_click_status = 1;
+ mouse_left_click_last_x = event.button.x;
+ mouse_left_click_last_y = event.button.y;
+ }
+ } else {
+ mouse_left_click_status = 0;
+ }
+ }
I don't think we need the complex stuff about not clicking too far out of the
first click, what are the chances of a fast moving mouse with double clicking?
Slim to none I guess. Are you aware of a case when this matters?
I don't know, I just looked at how the click counter is implemented in SDL2 and
emulated that behaviour with SDL1. But it can be overkill, yes; in fact VLC
does not seem to check this.
By the way, VLC doesn't even clear the status/timestamp when clicking another
button, so maybe that is overkill too.
I think it is enough if you just store the timestamp of the last left click in
an int64_t and check the time difference next time the user do a left click,
this way you can detect double clicking with a single variable and you don't
have to use cursor_last_shown which is updated on every motion as well.
Right, also I didn't think twice about the fact that cursor_last_shown is
updated on motion too.
Thanks for the suggestions, I will send an updated patch soon.
Cheers,
Vittorio
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel