From: Bernhard Herzog <bh@intevation.de>
To: emacs-devel@gnu.org
Subject: Fix for timestamp related popup-menu problem with some X servers
Date: Mon, 22 Mar 2010 20:02:46 +0100 [thread overview]
Message-ID: <s9zocigji21.fsf@thoe.hq.intevation.de> (raw)
[-- 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 --]
reply other threads:[~2010-03-22 19:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s9zocigji21.fsf@thoe.hq.intevation.de \
--to=bh@intevation.de \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.