classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Import ActionEvent dispatching to MenuShortcuts fixes


From: Mark Wielaard
Subject: [cp-patches] FYI: Import ActionEvent dispatching to MenuShortcuts fixes from libgcj gui
Date: Sat, 31 Jul 2004 18:14:03 +0200

Hi,

I am importing the following patch from the libngcj gui branch.

2004-07-31  David Jee  <address@hidden>

        * java/awt/DefaultKeyboardFocusManager.java
        (postProcessKeyEvent): Only activate MenuShortcuts on KEY_PRESSED
        event.  Fix shift modifier checking.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
        (accel_attach): Remove.
        (setupAccelGroup): Remove calls to accel_attach.

It fixes ActionEvent dispatching to MenuShortcuts.

Committed.

Mark
Index: java/awt/DefaultKeyboardFocusManager.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/java/awt/DefaultKeyboardFocusManager.java,v
retrieving revision 1.3
diff -u -r1.3 DefaultKeyboardFocusManager.java
--- java/awt/DefaultKeyboardFocusManager.java   22 Jul 2004 19:45:38 -0000      
1.3
+++ java/awt/DefaultKeyboardFocusManager.java   31 Jul 2004 16:12:08 -0000
@@ -284,10 +284,11 @@
   {
     // Check if this event represents a menu shortcut.
 
-    // MenuShortcuts are activated by Ctrl- KeyEvents.
+    // MenuShortcuts are activated by Ctrl- KeyEvents, only on KEY_PRESSED.
     int modifiers = e.getModifiers ();
-    if ((modifiers & KeyEvent.CTRL_MASK) != 0
-        || (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0)
+    if (e.getID() == KeyEvent.KEY_PRESSED
+        && ((modifiers & KeyEvent.CTRL_MASK) != 0
+            || (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0))
       {
         Window focusedWindow = getGlobalFocusedWindow ();
         if (focusedWindow instanceof Frame)
@@ -313,15 +314,21 @@
 
                         if (shortcut != null)
                           {
-                            // Dispatch a new ActionEvent if this is a
-                            // Shift- KeyEvent and the shortcut requires
-                            // the Shift modifier, or if the shortcut
-                            // doesn't require the Shift modifier.
-                            if ((shortcut.usesShiftModifier ()
-                                 && ((modifiers & KeyEvent.SHIFT_MASK) != 0
-                                     || (modifiers & KeyEvent.SHIFT_DOWN_MASK) 
!= 0)
-                                 || !shortcut.usesShiftModifier ())
-                                && shortcut.getKey () == e.getKeyCode ())
+                            // Dispatch a new ActionEvent if:
+                            //
+                            //     a) this is a Shift- KeyEvent, and the
+                            //        shortcut requires the Shift modifier
+                            //
+                            // or, b) this is not a Shift- KeyEvent, and the
+                            //        shortcut does not require the Shift
+                            //        modifier.
+                            if (shortcut.getKey () == e.getKeyCode ()
+                                && ((shortcut.usesShiftModifier ()
+                                     && ((modifiers & KeyEvent.SHIFT_MASK) != 0
+                                         || (modifiers & 
KeyEvent.SHIFT_DOWN_MASK) != 0))
+                                    || (! shortcut.usesShiftModifier ()
+                                        && (modifiers & KeyEvent.SHIFT_MASK) 
== 0
+                                        && (modifiers & 
KeyEvent.SHIFT_DOWN_MASK) == 0)))
                               {
                                 item.dispatchEvent (new ActionEvent (item,
                                                                      
ActionEvent.ACTION_PERFORMED,
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c,v
retrieving revision 1.13
diff -u -r1.13 gnu_java_awt_peer_gtk_GtkMenuPeer.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c     23 Jul 2004 
13:44:00 -0000      1.13
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c     31 Jul 2004 
16:12:08 -0000
@@ -39,20 +39,6 @@
 #include "gtkpeer.h"
 #include "gnu_java_awt_peer_gtk_GtkMenuPeer.h"
 
-static void
-accel_attach (GtkMenuItem *menu_item,
-             gpointer *user_data __attribute__((unused)))
-{
-  GtkAccelGroup *accel;
-
-  accel = gtk_menu_get_accel_group (GTK_MENU (menu_item->submenu));
-  /* FIXME: update this to use GTK-2.4 GtkActions. */
-#if 0
-  _gtk_accel_group_attach (accel, 
-    G_OBJECT (gtk_widget_get_toplevel (GTK_WIDGET(menu_item))));
-#endif
-}
-
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_setupAccelGroup
   (JNIEnv *env, jobject obj, jobject parent)
 {
@@ -65,14 +51,6 @@
     {
       gtk_menu_set_accel_group (GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu), 
                                gtk_accel_group_new ());
-
-      if (GTK_WIDGET_REALIZED (GTK_WIDGET (ptr1)))
-       accel_attach (GTK_MENU_ITEM (ptr1), NULL);
-      else
-       g_signal_connect (G_OBJECT (ptr1),
-                           "realize",
-                           GTK_SIGNAL_FUNC (accel_attach), 
-                           NULL);
     }
   else
     {

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]