all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Fix for timestamp related popup-menu problem with some X servers
@ 2010-03-22 19:02 Bernhard Herzog
  0 siblings, 0 replies; only message in thread
From: Bernhard Herzog @ 2010-03-22 19:02 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2636 bytes --]


Hi,

I'm regularly running into a problem with the popup menus bound by
default to C-down-mouse-1 and other events.  The symptom is that instead
of a popup menu, I only get the error message: <C-mouse-1> is undefined.
This is exactly the same problem as described in
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4930. 

The root cause is as described in there in message #16:

   Emacs lisp ints are only 30 bits wide.  Timestamps come in from
   XButtonEvent and make_lispy_event calls make_lispy_position, which
   uses make_number to stash away the event timestamp.  Unfortunately
   this will truncate the top two bits of the timestamp.  This is
   subsequently passed to gtk_menu_popup via
   xmenu_show/create_and_show_popup_menu.  It ends up going to
   XGrab<xxx> which appears to be failing when given such a truncated
   timestamp.

So, whether this defect can be observed depends on the value of the
timestamp.  That timestamp is a 32 bit value giving the time since an
X-server dependent point in time in milliseconds.  This means it will
wrap around about every 50 days.

Different servers seem to choose different starting points for the
timestamp.  Some may reset the timer when the server is reset or
started, others, including one I regularly use at work (the one coming
with Debian etch), apparently base the timestamp on the system time,
which has the effect that for a quarter of the 50 days the timestamps
are small enough and the popup menus work, and the rest of the time,
they don't.

Anyway, to cut the story short, below is a patch to fix this problem.
It uses last_event_timestamp from keyboard.c instead of the timestamp
From the button event.  AFAICT, last_event_timestamp is the timestamp
From the button event, most of the time anyway, because usually the
button event that will lead to the popup-menu being displayed is the
last one that was processed.

Here's the patch:

=== modified file 'src/menu.c'
--- src/menu.c	2010-01-13 08:35:10 +0000
+++ src/menu.c	2010-03-21 15:57:51 +0000
@@ -61,6 +61,11 @@
 #define HAVE_BOXES 1
 #endif
 
+/* The timestamp of the last input event Emacs received from the X server.  */
+/* Defined in keyboard.c.  */
+extern unsigned long last_event_timestamp;
+
+
 extern Lisp_Object QCtoggle, QCradio;
 
 Lisp_Object menu_items;
@@ -1320,7 +1325,7 @@
 #else /* MSDOS and X11 */
   selection = xmenu_show (f, xpos, ypos, for_click,
 			  keymaps, title, &error_name,
-			  INTEGERP (timestamp) ? XUINT (timestamp) : 0);
+			  last_event_timestamp);
 #endif
 
   UNBLOCK_INPUT;


Regards

   Bernhard

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-03-22 19:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-22 19:02 Fix for timestamp related popup-menu problem with some X servers Bernhard Herzog

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.