From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bernhard Herzog Newsgroups: gmane.emacs.devel Subject: Fix for timestamp related popup-menu problem with some X servers Date: Mon, 22 Mar 2010 20:02:46 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1269284612 27584 80.91.229.12 (22 Mar 2010 19:03:32 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Mar 2010 19:03:32 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 22 20:03:28 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NtmuN-0000gx-QB for ged-emacs-devel@m.gmane.org; Mon, 22 Mar 2010 20:03:28 +0100 Original-Received: from localhost ([127.0.0.1]:42582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NtmuN-0006b1-Ce for ged-emacs-devel@m.gmane.org; Mon, 22 Mar 2010 15:03:27 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ntmtt-00063G-HV for emacs-devel@gnu.org; Mon, 22 Mar 2010 15:02:57 -0400 Original-Received: from [140.186.70.92] (port=54635 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ntmts-00061S-3q for emacs-devel@gnu.org; Mon, 22 Mar 2010 15:02:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ntmtq-0004IW-2l for emacs-devel@gnu.org; Mon, 22 Mar 2010 15:02:55 -0400 Original-Received: from aktaia.intevation.org ([212.95.126.10]:39027 helo=kolab.intevation.de) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ntmtp-0004IL-MG for emacs-devel@gnu.org; Mon, 22 Mar 2010 15:02:54 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by kolab.intevation.de (Postfix) with ESMTP id B031994D16B for ; Mon, 22 Mar 2010 20:02:50 +0100 (CET) X-Virus-Scanned: by amavisd-new at intevation.de Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by kolab.intevation.de (Postfix) with ESMTP id 8373194D178 for ; Mon, 22 Mar 2010 20:02:49 +0100 (CET) Original-Received: from beroe.hq.intevation.de (aktaia.hq.intevation.de [192.168.11.254]) by kolab.intevation.de (Postfix) with ESMTP id 75DD694D16B for ; Mon, 22 Mar 2010 20:02:49 +0100 (CET) Original-Received: from thoe.hq.intevation.de (thoe.hq.intevation.de [192.168.11.35]) by beroe.hq.intevation.de (Postfix) with SMTP id 6915B5ED4F for ; Mon, 22 Mar 2010 20:02:49 +0100 (CET) Original-Received: (nullmailer pid 7863 invoked by uid 10008); Mon, 22 Mar 2010 19:02:49 -0000 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:122500 Archived-At: --=-=-= Content-Transfer-Encoding: quoted-printable 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: is undefined. This is exactly the same problem as described in http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D4930.=20 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 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=20the button event. AFAICT, last_event_timestamp is the timestamp From=20the 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: =3D=3D=3D modified file 'src/menu.c' =2D-- 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 =20 +/* 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; =20 Lisp_Object menu_items; @@ -1320,7 +1325,7 @@ #else /* MSDOS and X11 */ selection =3D xmenu_show (f, xpos, ypos, for_click, keymaps, title, &error_name, =2D INTEGERP (timestamp) ? XUINT (timestamp) : 0); + last_event_timestamp); #endif =20 UNBLOCK_INPUT; Regards Bernhard --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iD8DBQFLp77W0vCiU5+ISsgRApQDAKDJDjE4cYUZywSab74wKoPoqgiodwCgju0Z 8fntWlggC+ssrVw+IZUzlzU= =jYo3 -----END PGP SIGNATURE----- --=-=-=--