Bug#401957: [PATCH] Pinentry keyboard grab bug
Ed Martin <[email protected]> Tue, 27 May 2008 01:02:15 -0400
| Newsgroups | gmane.linux.debian.devel.bugs.general,gmane.comp.encryption.gpg.gpa.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--Boundary_(ID_T5hbk3SsAqoGG0aZR5u2uA)
Content-type: text/plain; charset=ISO-8859-1; format=flowed
Content-transfer-encoding: 7BIT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I have been experiencing this bug:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=401957
After a bit of research i found out that the cause is that pinentry
tries to grab the keyboard after the window has been mapped, however to
grab the keyboard the window needs to be visible, and there exists a
very small time period between when the window is mapped and when it
appears on screen and is actually visible (see `man XMapWindow`). On a
fast (and probably SMP) system, the application can get the MapNotify
event from X before X makes the window visible, the fix is to grab the
keyboard on the VisibilityNotify event from X (gdk calls it
visibility-notify-event) since thats what we actually care about, i have
attached a patch to do just that and it fixes the bug on my system.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkg7ldAACgkQpTONzi6XgQxkgACdEqPxqq3IgmzDvICe6Hbv2C/j
0EkAoLfaEDfmsr4ETestaRpo4PHxA70v
=nRvx
-----END PGP SIGNATURE-----
--Boundary_(ID_T5hbk3SsAqoGG0aZR5u2uA)
Content-type: text/plain; name=pinentry-gtk-x11-race.diff
Content-transfer-encoding: 7BIT
Content-disposition: inline; filename=pinentry-gtk-x11-race.diff
--- pinentry-0.7.5-old/gtk+-2/pinentry-gtk-2.c 2007-11-19 06:44:07.000000000 -0500
+++ pinentry-0.7.5/gtk+-2/pinentry-gtk-2.c 2008-05-27 00:38:56.000000000 -0400
@@ -260,8 +260,11 @@
G_CALLBACK (constrain_size), NULL);
if (!confirm_mode)
{
+ //we need to grab the keyboard when its visible! not when its mapped (there is a difference)
+ g_object_set(G_OBJECT(win), "events", GDK_VISIBILITY_NOTIFY_MASK | GDK_STRUCTURE_MASK, NULL);
+
g_signal_connect (G_OBJECT (win),
- pinentry->grab ? "map-event" : "focus-in-event",
+ pinentry->grab ? "visibility-notify-event" : "focus-in-event",
G_CALLBACK (grab_keyboard), NULL);
g_signal_connect (G_OBJECT (win),
pinentry->grab ? "unmap-event" : "focus-out-event",
--Boundary_(ID_T5hbk3SsAqoGG0aZR5u2uA)--