]> uap-core.de Git - uwplayer.git/commitdiff
enable/disable fullscreen with double click
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 16 Jan 2022 10:25:15 +0000 (11:25 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 16 Jan 2022 10:25:15 +0000 (11:25 +0100)
application/window.c

index fe8148199b4aa63ff371641bdd57cb9f85e24036..17bda64e7d5d2f7f54d64d5bdb86b51d56d49411 100644 (file)
@@ -168,6 +168,8 @@ static void playerEH(Widget widget, XtPointer data, XEvent *event, Boolean *disp
 #define IGNORE_MOTION_THRESHOLD_MS 1000
 #define MOTION_POS_THRESHOLD_PIX   5
 
+#define DOUBLE_CLICK_TIME_MS       500
+
 void WindowHandlePlayerEvent(MainWindow *win, XEvent *event) {
     // event handler for intercepted player mouse events
     // win->player is not NULL
@@ -191,7 +193,14 @@ void WindowHandlePlayerEvent(MainWindow *win, XEvent *event) {
         win->player_event_time = cur_motion_time;
         win->motion_playback_time = win->player->playback_time;
     } else if(etype == ButtonPress) {
-        win->player_event_time = event->xbutton.time;
+        Time t = event->xbutton.time;
+        if(t - win->button_press_time < DOUBLE_CLICK_TIME_MS) {
+            // double click
+            WindowFullscreen(main_window, !win->fullscreen);
+            win->button_press_time = 0;
+        } else {
+            win->button_press_time = t;
+        }
     } else if(etype == ButtonRelease) {
         win->player_event_time = event->xbutton.time;
     }
@@ -533,7 +542,7 @@ void WindowHidePlayerCursor(MainWindow *win) {
 void WindowShowPlayerCursor(MainWindow *win) {
     if(win->cursorhidden && win->player && win->player->window != 0) {
         XDefineCursor(XtDisplay(win->player_widget), XtWindow(win->player_widget), None);
-        win->cursorhidden = False;
         XFlush(XtDisplay(win->player_widget));
     }
+    win->cursorhidden = False;
 }