Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 200065
Collapse All | Expand All

(-)mozilla/widget/src/gtk2/nsWindow.cpp.orig (-6 / +67 lines)
Lines 1809-1814 Link Here
1809
    LOGFOCUS(("Done with container focus out [%p]\n", (void *)this));
1809
    LOGFOCUS(("Done with container focus out [%p]\n", (void *)this));
1810
}
1810
}
1811
1811
1812
inline PRBool
1813
is_latin_shortcut_key(guint aKeyval)
1814
{
1815
    return ((GDK_0 <= aKeyval && aKeyval <= GDK_9) ||
1816
            (GDK_A <= aKeyval && aKeyval <= GDK_Z) ||
1817
            (GDK_a <= aKeyval && aKeyval <= GDK_z));
1818
}
1819
1812
gboolean
1820
gboolean
1813
nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
1821
nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
1814
{
1822
{
Lines 1883-1888 Link Here
1883
        // clear isShift so the character can be inserted in the editor
1891
        // clear isShift so the character can be inserted in the editor
1884
1892
1885
        if (event.isControl || event.isAlt || event.isMeta) {
1893
        if (event.isControl || event.isAlt || event.isMeta) {
1894
            GdkEventKey tmpEvent = *aEvent;
1895
1896
            // Fix for bug 69230:
1897
            // if modifier key is pressed and key pressed is not latin character,
1898
            // we should try other keyboard layouts to find out correct latin
1899
            // character corresponding to pressed key;
1900
            // that way shortcuts like Ctrl+C will work no matter what
1901
            // keyboard layout is selected
1902
            // We don't try to fix up punctuation accelerators here,
1903
            // because their location differs between latin layouts
1904
            if (!is_latin_shortcut_key(event.charCode)) {
1905
                // We have a non-latin char, try other keyboard groups
1906
                GdkKeymapKey *keys;
1907
                guint *keyvals;
1908
                gint n_entries;
1909
                PRUint32 latinCharCode;
1910
                gint level;
1911
1912
                if (gdk_keymap_translate_keyboard_state(NULL,
1913
                                                        tmpEvent.hardware_keycode,
1914
                                                        (GdkModifierType)tmpEvent.state,
1915
                                                        tmpEvent.group,
1916
                                                        NULL, NULL, &level, NULL)
1917
                    && gdk_keymap_get_entries_for_keycode(NULL,
1918
                                                          tmpEvent.hardware_keycode,
1919
                                                          &keys, &keyvals,
1920
                                                          &n_entries)) {
1921
                    gint n;
1922
                    for (n=0; n<n_entries; n++) {
1923
                        if (keys[n].group == tmpEvent.group) {
1924
                            // Skip keys from the same group
1925
                            continue;
1926
                        }
1927
                        if (keys[n].level != level) {
1928
                            // Allow only same level keys
1929
                            continue;
1930
                        }
1931
                        if (is_latin_shortcut_key(keyvals[n])) {
1932
                            // Latin character found
1933
                            if (event.isShift)
1934
                                tmpEvent.keyval = gdk_keyval_to_upper(keyvals[n]);
1935
                            else
1936
                                tmpEvent.keyval = gdk_keyval_to_lower(keyvals[n]);
1937
                            tmpEvent.group = keys[n].group;
1938
                            latinCharCode = nsConvertCharCodeToUnicode(&tmpEvent);
1939
                            if (latinCharCode) {
1940
                                event.charCode = latinCharCode;
1941
                                break;
1942
                            }
1943
                        }
1944
                    }
1945
                    g_free(keys);
1946
                    g_free(keyvals);
1947
                }
1948
            }
1949
1886
           // make Ctrl+uppercase functional as same as Ctrl+lowercase
1950
           // make Ctrl+uppercase functional as same as Ctrl+lowercase
1887
           // when Ctrl+uppercase(eg.Ctrl+C) is pressed,convert the charCode
1951
           // when Ctrl+uppercase(eg.Ctrl+C) is pressed,convert the charCode
1888
           // from uppercase to lowercase(eg.Ctrl+c),so do Alt and Meta Key
1952
           // from uppercase to lowercase(eg.Ctrl+c),so do Alt and Meta Key
Lines 1900-1913 Link Here
1900
           // bugs 50255 and 351310)
1964
           // bugs 50255 and 351310)
1901
           if (!event.isControl && event.isShift &&
1965
           if (!event.isControl && event.isShift &&
1902
               (event.charCode < GDK_0 || event.charCode > GDK_9)) {
1966
               (event.charCode < GDK_0 || event.charCode > GDK_9)) {
1903
               GdkKeymapKey k = { aEvent->hardware_keycode, aEvent->group, 0 };
1967
               GdkKeymapKey k = { tmpEvent.hardware_keycode, tmpEvent.group, 0 };
1904
               guint savedKeyval = aEvent->keyval;
1968
               tmpEvent.keyval = gdk_keymap_lookup_key(gdk_keymap_get_default(), &k);
1905
               aEvent->keyval = gdk_keymap_lookup_key(gdk_keymap_get_default(), &k);
1969
               PRUint32 unshiftedCharCode = nsConvertCharCodeToUnicode(&tmpEvent);
1906
               PRUint32 unshiftedCharCode = nsConvertCharCodeToUnicode(aEvent);
1907
               if (unshiftedCharCode)
1970
               if (unshiftedCharCode)
1908
                   event.charCode = unshiftedCharCode;
1971
                   event.charCode = unshiftedCharCode;
1909
               else
1910
                   aEvent->keyval = savedKeyval;
1911
           }
1972
           }
1912
        }
1973
        }
1913
    }
1974
    }

Return to bug 200065