Subject: bug#8664: Being more-systematic about user-interface timestamps

From: Paul Eggert <[email-masked]>
Date: Sat, 14 May 2011 02:10:27 -0700

On 05/13/11 01:53, Eli Zaretskii wrote:
>> +#ifdef HAVE_X_WINDOWS
>> +# include <X11/X.h>
>> +#else
>> +typedef unsigned long Time;
>> +#endif
> 
> Wouldn't this clash with the typedef in w32gui.h?

Yes, thanks, good catch.  Proposed fix below.

> This needs a corresponding change in all the functions used as
> mouse_position_hook on different platforms.  You made such a change
> only in 2 of them: term_mouse_position and XTmouse_position.

Thanks for that too.  For NextStep a change is needed, also proposed below.

No change should be needed for w32's hooks, since there's no actual change
to the data type there.  For documentation purposes it might be nice to
run through the hooks and change 'unsigned long' to 'Time' where
appropriate, but that's not essential.  Normally I'm reluctant to mess
with the w32 code as I can't easily test it.

Fixups, following up to the user-interface timestamp change.
* nsterm.m (last_mouse_movement_time, ns_mouse_position): Use Time
for UI timestamps, instead of unsigned long.
* w32gui.h (Time): Define by including "systime.h" rather than by
declaring it ourselves.  (Bug#8664)
=== modified file 'src/nsterm.m'
--- src/nsterm.m	2011-04-03 08:30:57 +0000
+++ src/nsterm.m	2011-05-14 08:56:08 +0000
@@ -158,7 +158,7 @@
 /* display update */
 NSPoint last_mouse_motion_position;
 static NSRect last_mouse_glyph;
-static unsigned long last_mouse_movement_time = 0;
+static Time last_mouse_movement_time = 0;
 static Lisp_Object last_mouse_motion_frame;
 static EmacsScroller *last_mouse_scroll_bar = nil;
 static struct frame *ns_updating_frame;
@@ -1789,7 +1789,7 @@
 static void
 ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
                    enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y,
-                   unsigned long *time)
+                   Time *time)
 /* --------------------------------------------------------------------------
     External (hook): inform emacs about mouse position and hit parts.
     If a scrollbar is being dragged, set bar_window, part, x, y, time.
@@ -6531,5 +6531,3 @@
   /* Tell emacs about this window system. */
   Fprovide (intern ("ns"), Qnil);
 }
-
-

=== modified file 'src/w32gui.h'
--- src/w32gui.h	2011-01-25 04:08:28 +0000
+++ src/w32gui.h	2011-05-14 09:01:32 +0000
@@ -20,6 +20,8 @@
 #define EMACS_W32GUI_H
 #include <windows.h>

+#include "systime.h" /* for Time */
+
 /* Local memory management for menus.  */
 #define local_heap (GetProcessHeap ())
 #define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n)))
@@ -47,7 +49,6 @@

 typedef XGCValues * GC;
 typedef COLORREF Color;
-typedef DWORD Time;
 typedef HWND Window;
 typedef HDC Display;  /* HDC so it doesn't conflict with xpm lib.  */
 typedef HCURSOR Cursor;
@@ -147,4 +148,3 @@

 #endif /* EMACS_W32GUI_H */
-