shithub: puzzles

Download patch

ref: cfcd8cf8c5dda9e3c14cd7df67a4e4f6caaaca3a
parent: d952a3b6ffb62e56f29760cfe843e5c0fc43c96a
author: Jacob Nevins <jacobn@chiark.greenend.org.uk>
date: Mon Jun 26 18:01:51 EDT 2006

Since r6711, puzzles built with Gtk 1.2 would take double actions when a menu
accelerator key (N/U/R/Q) was pressed -- once for the menu accelerator, and
once more in key_event().
This workaround, while unlovely, should at least not break in future (since the
things it relies on are unlikely to change).

[originally from svn r6745]
[r6711 == 077aa510c78f3273bd0d4ca4f1ca14780822ebf9]

--- a/gtk.c
+++ b/gtk.c
@@ -518,6 +518,16 @@
     if (!fe->pixmap)
         return TRUE;
 
+#if !GTK_CHECK_VERSION(2,0,0)
+    /* Gtk 1.2 passes a key event to this function even if it's also
+     * defined as an accelerator.
+     * Gtk 2 doesn't do this, and this function appears not to exist there. */
+    if (fe->accelgroup &&
+        gtk_accel_group_get_entry(fe->accelgroup,
+        event->keyval, event->state))
+        return TRUE;
+#endif
+
     if (event->keyval == GDK_Up)
         keyval = shift | ctrl | CURSOR_UP;
     else if (event->keyval == GDK_KP_Up || event->keyval == GDK_KP_8)