From f6a24d19906993b975e7be822abbb3cfce719751 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 12 May 2011 13:30:05 -0700 Subject: [PATCH] * term.c (term_mouse_position): Don't assume time_t wraparound. --- src/ChangeLog | 3 +++ src/term.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index a772106c521..21c03ba8220 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2011-05-12 Paul Eggert + * term.c (term_mouse_position): Don't assume time_t wraparound. + Be more systematic about user-interface timestamps. Before, the code sometimes used 'Time', sometimes 'unsigned long', and sometimes 'EMACS_UINT', to represent these timestamps. This @@ -14,6 +16,7 @@ * menu.c (Fx_popup_menu) [!HAVE_X_WINDOWS]: Likewise. * menu.h (xmenu_show): Likewise. * term.c (term_mouse_position): Likewise. + * termhooks.h (struct input_event.timestamp): Likewise. (struct terminal.mouse_position_hook): Likewise. * xmenu.c (create_and_show_popup_menu, xmenu_show): Likewise. diff --git a/src/term.c b/src/term.c index 34320a1ad6d..5fe258caa29 100644 --- a/src/term.c +++ b/src/term.c @@ -2701,6 +2701,7 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, Lisp_Object *y, Time *timeptr) { struct timeval now; + Time sec, usec; *fp = SELECTED_FRAME (); (*fp)->mouse_moved = 0; @@ -2711,7 +2712,9 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, XSETINT (*x, last_mouse_x); XSETINT (*y, last_mouse_y); gettimeofday(&now, 0); - *timeptr = (now.tv_sec * 1000) + (now.tv_usec / 1000); + sec = now.tv_sec; + usec = now.tv_usec; + *timeptr = (sec * 1000) + (usec / 1000); } /* Prepare a mouse-event in *RESULT for placement in the input queue. -- 2.39.2