+#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
+
+ int etype = event->type;
+
+ if(etype == MotionNotify) {
+ Time cur_motion_time = event->xmotion.time;
+ int x = event->xmotion.x;
+ int y = event->xmotion.y;
+ if(win->cursorhidden && cur_motion_time - win->player_event_time < IGNORE_MOTION_THRESHOLD_MS) {
+ int diff_x = abs(x - win->mouse_x_orig);
+ int diff_y = abs(y - win->mouse_y_orig);
+ if(diff_x > MOTION_POS_THRESHOLD_PIX || diff_y > MOTION_POS_THRESHOLD_PIX) {
+ WindowShowPlayerCursor(win);
+ }
+ } else {
+ win->mouse_x_orig = x;
+ win->mouse_y_orig = y;
+ }
+ win->player_event_time = cur_motion_time;
+ win->motion_playback_time = win->player->playback_time;
+ } else if(etype == ButtonPress) {
+ 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;
+ }
+}
+