diff options
| author | Paul Eggert | 2012-06-22 14:17:42 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-06-22 14:17:42 -0700 |
| commit | d35af63cd671563fd188c3b0a1ef30067027c7aa (patch) | |
| tree | c9e01847ccf788e23794684da9331c3e0defd0d3 /src/term.c | |
| parent | f143bfe38b43ad0a9d817f05c25e418982dca06f (diff) | |
| download | emacs-d35af63cd671563fd188c3b0a1ef30067027c7aa.tar.gz emacs-d35af63cd671563fd188c3b0a1ef30067027c7aa.zip | |
Support higher-resolution time stamps.
Fixes: debbugs:9000
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/term.c b/src/term.c index 5f807181199..1a2524fd297 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 24 | #include <ctype.h> | 24 | #include <ctype.h> |
| 25 | #include <errno.h> | 25 | #include <errno.h> |
| 26 | #include <sys/file.h> | 26 | #include <sys/file.h> |
| 27 | #include <sys/time.h> | ||
| 27 | #include <unistd.h> | 28 | #include <unistd.h> |
| 28 | #include <signal.h> | 29 | #include <signal.h> |
| 29 | #include <setjmp.h> | 30 | #include <setjmp.h> |
| @@ -2611,6 +2612,18 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) | |||
| 2611 | return 0; | 2612 | return 0; |
| 2612 | } | 2613 | } |
| 2613 | 2614 | ||
| 2615 | /* Return the Time that corresponds to T. Wrap around on overflow. */ | ||
| 2616 | static Time | ||
| 2617 | timeval_to_Time (struct timeval const *t) | ||
| 2618 | { | ||
| 2619 | Time s_1000, ms; | ||
| 2620 | |||
| 2621 | s_1000 = t->tv_sec; | ||
| 2622 | s_1000 *= 1000; | ||
| 2623 | ms = t->tv_usec / 1000; | ||
| 2624 | return s_1000 + ms; | ||
| 2625 | } | ||
| 2626 | |||
| 2614 | /* Return the current position of the mouse. | 2627 | /* Return the current position of the mouse. |
| 2615 | 2628 | ||
| 2616 | Set *f to the frame the mouse is in, or zero if the mouse is in no | 2629 | Set *f to the frame the mouse is in, or zero if the mouse is in no |
| @@ -2630,7 +2643,6 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, | |||
| 2630 | Lisp_Object *y, Time *timeptr) | 2643 | Lisp_Object *y, Time *timeptr) |
| 2631 | { | 2644 | { |
| 2632 | struct timeval now; | 2645 | struct timeval now; |
| 2633 | Time sec, usec; | ||
| 2634 | 2646 | ||
| 2635 | *fp = SELECTED_FRAME (); | 2647 | *fp = SELECTED_FRAME (); |
| 2636 | (*fp)->mouse_moved = 0; | 2648 | (*fp)->mouse_moved = 0; |
| @@ -2641,9 +2653,7 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, | |||
| 2641 | XSETINT (*x, last_mouse_x); | 2653 | XSETINT (*x, last_mouse_x); |
| 2642 | XSETINT (*y, last_mouse_y); | 2654 | XSETINT (*y, last_mouse_y); |
| 2643 | gettimeofday(&now, 0); | 2655 | gettimeofday(&now, 0); |
| 2644 | sec = now.tv_sec; | 2656 | *timeptr = timeval_to_Time (&now); |
| 2645 | usec = now.tv_usec; | ||
| 2646 | *timeptr = (sec * 1000) + (usec / 1000); | ||
| 2647 | } | 2657 | } |
| 2648 | 2658 | ||
| 2649 | /* Prepare a mouse-event in *RESULT for placement in the input queue. | 2659 | /* Prepare a mouse-event in *RESULT for placement in the input queue. |
| @@ -2667,7 +2677,7 @@ term_mouse_click (struct input_event *result, Gpm_Event *event, | |||
| 2667 | } | 2677 | } |
| 2668 | } | 2678 | } |
| 2669 | gettimeofday(&now, 0); | 2679 | gettimeofday(&now, 0); |
| 2670 | result->timestamp = (now.tv_sec * 1000) + (now.tv_usec / 1000); | 2680 | result->timestamp = timeval_to_Time (&now); |
| 2671 | 2681 | ||
| 2672 | if (event->type & GPM_UP) | 2682 | if (event->type & GPM_UP) |
| 2673 | result->modifiers = up_modifier; | 2683 | result->modifiers = up_modifier; |