Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37513217
en ru br
Репозитории ALT
S:2.53.17.1-alt1
5.1: 1.1.18-alt2
4.1: 1.1.16-alt0.M41.1
+updates:1.1.13-alt0.M41.1
4.0: 1.1.12-alt0.M40.1
www.altlinux.org/Changes

Группа :: Сети/WWW
Пакет: seamonkey

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: firefox-3.0-fix-layout-shortcuts.patch
Скачать


Index: widget/src/gtk2/nsWindow.cpp
===================================================================
RCS file: /cvsroot/mozilla/widget/src/gtk2/nsWindow.cpp,v
retrieving revision 1.145.2.14
diff -u -8 -p -r1.145.2.14 nsWindow.cpp
--- widget/src/gtk2/nsWindow.cpp	8 Nov 2007 03:22:32 -0000	1.145.2.14
+++ widget/src/gtk2/nsWindow.cpp	27 Nov 2007 16:16:52 -0000
@@ -1810,16 +1810,24 @@ nsWindow::OnContainerFocusOutEvent(GtkWi
 
     gFocusWindow = nsnull;
 
     mActivatePending = PR_FALSE;
 
     LOGFOCUS(("Done with container focus out [%p]\n", (void *)this));
 }
 
+inline PRBool
+is_latin_shortcut_key(guint aKeyval)
+{
+    return ((GDK_0 <= aKeyval && aKeyval <= GDK_9) ||
+            (GDK_A <= aKeyval && aKeyval <= GDK_Z) ||
+            (GDK_a <= aKeyval && aKeyval <= GDK_z));
+}
+
 gboolean
 nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
 {
     LOGFOCUS(("OnKeyPressEvent [%p]\n", (void *)this));
 
 #ifdef USE_XIM
     // if we are in the middle of composing text, XIM gets to see it
     // before mozilla does.
@@ -1884,16 +1892,72 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWi
     if (event.charCode) {
         event.keyCode = 0;
         // if the control, meta, or alt key is down, then we should leave
         // the isShift flag alone (probably not a printable character)
         // if none of the other modifier keys are pressed then we need to
         // clear isShift so the character can be inserted in the editor
 
         if (event.isControl || event.isAlt || event.isMeta) {
+            GdkEventKey tmpEvent = *aEvent;
+
+            // Fix for bug 69230:
+            // if modifier key is pressed and key pressed is not latin character,
+            // we should try other keyboard layouts to find out correct latin
+            // character corresponding to pressed key;
+            // that way shortcuts like Ctrl+C will work no matter what
+            // keyboard layout is selected
+            // We don't try to fix up punctuation accelerators here,
+            // because their location differs between latin layouts
+            if (!is_latin_shortcut_key(event.charCode)) {
+                // We have a non-latin char, try other keyboard groups
+                GdkKeymapKey *keys;
+                guint *keyvals;
+                gint n_entries;
+                PRUint32 latinCharCode;
+                gint level;
+
+                if (gdk_keymap_translate_keyboard_state(NULL,
+                                                        tmpEvent.hardware_keycode,
+                                                        (GdkModifierType)tmpEvent.state,
+                                                        tmpEvent.group,
+                                                        NULL, NULL, &level, NULL)
+                    && gdk_keymap_get_entries_for_keycode(NULL,
+                                                          tmpEvent.hardware_keycode,
+                                                          &keys, &keyvals,
+                                                          &n_entries)) {
+                    gint n;
+                    for (n=0; n<n_entries; n++) {
+                        if (keys[n].group == tmpEvent.group) {
+                            // Skip keys from the same group
+                            continue;
+                        }
+                        if (keys[n].level != level) {
+                            // Allow only same level keys
+                            continue;
+                        }
+                        if (is_latin_shortcut_key(keyvals[n])) {
+                            // Latin character found
+                            if (event.isShift)
+                                tmpEvent.keyval = gdk_keyval_to_upper(keyvals[n]);
+                            else
+                                tmpEvent.keyval = gdk_keyval_to_lower(keyvals[n]);
+                            tmpEvent.group = keys[n].group;
+                            latinCharCode = nsConvertCharCodeToUnicode(&tmpEvent);
+                            if (latinCharCode) {
+                                event.charCode = latinCharCode;
+                                break;
+                            }
+                        }
+                    }
+                    g_free(keys);
+                    g_free(keyvals);
+                }
+            }
+
            // make Ctrl+uppercase functional as same as Ctrl+lowercase
            // when Ctrl+uppercase(eg.Ctrl+C) is pressed,convert the charCode
            // from uppercase to lowercase(eg.Ctrl+c),so do Alt and Meta Key
            // It is hack code for bug 61355, there is same code snip for
            // Windows platform in widget/src/windows/nsWindow.cpp: See bug 16486
            // Note: if Shift is pressed at the same time, do not to_lower()
            // Because Ctrl+Shift has different function with Ctrl
            if (!event.isShift &&
@@ -1901,24 +1965,21 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWi
                event.charCode <= GDK_Z)
             event.charCode = gdk_keyval_to_lower(event.charCode);
 
            // Keep the characters unshifted for shortcuts and accesskeys and
            // make sure that numbers are always passed as such (among others:
            // bugs 50255 and 351310)
            if (!event.isControl && event.isShift &&
                (event.charCode < GDK_0 || event.charCode > GDK_9)) {
-               GdkKeymapKey k = { aEvent->hardware_keycode, aEvent->group, 0 };
-               guint savedKeyval = aEvent->keyval;
-               aEvent->keyval = gdk_keymap_lookup_key(gdk_keymap_get_default(), &k);
-               PRUint32 unshiftedCharCode = nsConvertCharCodeToUnicode(aEvent);
+               GdkKeymapKey k = { tmpEvent.hardware_keycode, tmpEvent.group, 0 };
+               tmpEvent.keyval = gdk_keymap_lookup_key(gdk_keymap_get_default(), &k);
+               PRUint32 unshiftedCharCode = nsConvertCharCodeToUnicode(&tmpEvent);
                if (unshiftedCharCode)
                    event.charCode = unshiftedCharCode;
-               else
-                   aEvent->keyval = savedKeyval;
            }
         }
     }
 
     // before we dispatch a key, check if it's the context menu key.
     // If so, send a context menu key event instead.
     if (is_context_menu_key(event)) {
         nsMouseEvent contextMenuEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin