[FFmpeg-devel] [PATCH 2/2] ffplay: Toggle full screen when double-clicking the video window with the left mouse button.

Vittorio Gambaletta (VittGam) ffmpeg-dev at vittgam.net
Fri Jan 15 16:15:50 CET 2016


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.

Signed-off-by: Vittorio Gambaletta <ffmpeg-dev at 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;
              }
+            {
+                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;
+                }
+            }
          case SDL_MOUSEMOTION:
              if (cursor_hidden) {
                  SDL_ShowCursor(1);


More information about the ffmpeg-devel mailing list