updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / sunbird-branded / accelerators.patch
blob164dd2aca5dab419c7feb1c33d29a200ec319b1d
1 --- widget/src/gtk2/nsWindow.cpp 12 Oct 2007 03:02:26 -0000 1.233
2 +++ widget/src/gtk2/nsWindow.cpp 12 Oct 2007 10:18:34 -0000
3 @@ -2176,16 +2176,24 @@ nsWindow::OnContainerFocusOutEvent(GtkWi
5 gFocusWindow = nsnull;
7 mActivatePending = PR_FALSE;
9 LOGFOCUS(("Done with container focus out [%p]\n", (void *)this));
12 +inline PRBool
13 +is_latin_shortcut_key(guint aKeyval)
15 + return ((GDK_0 <= aKeyval && aKeyval <= GDK_9) ||
16 + (GDK_A <= aKeyval && aKeyval <= GDK_Z) ||
17 + (GDK_a <= aKeyval && aKeyval <= GDK_z));
20 gboolean
21 nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
23 LOGFOCUS(("OnKeyPressEvent [%p]\n", (void *)this));
25 #ifdef USE_XIM
26 // if we are in the middle of composing text, XIM gets to see it
27 // before mozilla does.
28 @@ -2252,16 +2260,65 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWi
29 if (event.charCode) {
30 event.keyCode = 0;
31 // if the control, meta, or alt key is down, then we should leave
32 // the isShift flag alone (probably not a printable character)
33 // if none of the other modifier keys are pressed then we need to
34 // clear isShift so the character can be inserted in the editor
36 if (event.isControl || event.isAlt || event.isMeta) {
37 + // Fix for bug 69230:
38 + // if modifier key is pressed and key pressed is not latin character,
39 + // we should try other keyboard layouts to find out correct latin
40 + // character corresponding to pressed key;
41 + // that way shortcuts like Ctrl+C will work no matter what
42 + // keyboard layout is selected
43 + // We don't try to fix up punctuation accelerators here,
44 + // because their location differs between latin layouts
45 + guint savedKeyval = aEvent->keyval;
46 + guint8 savedGroup = aEvent->group;
47 + if (!is_latin_shortcut_key(event.charCode)) {
48 + // We have a non-latin char, try other keyboard groups
49 + GdkKeymapKey *keys;
50 + guint *keyvals;
51 + gint n_entries;
52 + PRUint32 latinCharCode;
53 + if (gdk_keymap_get_entries_for_keycode(NULL,
54 + aEvent->hardware_keycode,
55 + &keys, &keyvals,
56 + &n_entries)) {
57 + gint n;
58 + for (n=0; n<n_entries; n++) {
59 + if (keys[n].group == aEvent->group) {
60 + // Skip keys from the same group
61 + continue;
62 + }
63 + if (is_latin_shortcut_key(keyvals[n])) {
64 + // Latin character found
65 + if (event.isShift)
66 + aEvent->keyval = gdk_keyval_to_upper(keyvals[n]);
67 + else
68 + aEvent->keyval = gdk_keyval_to_lower(keyvals[n]);
69 + aEvent->group = keys[n].group;
70 + latinCharCode = nsConvertCharCodeToUnicode(aEvent);
71 + if (latinCharCode) {
72 + event.charCode = latinCharCode;
73 + break;
74 + }
75 + else {
76 + aEvent->keyval = savedKeyval;
77 + aEvent->group = savedGroup;
78 + }
79 + }
80 + }
81 + g_free(keys);
82 + g_free(keyvals);
83 + }
84 + }
86 // make Ctrl+uppercase functional as same as Ctrl+lowercase
87 // when Ctrl+uppercase(eg.Ctrl+C) is pressed,convert the charCode
88 // from uppercase to lowercase(eg.Ctrl+c),so do Alt and Meta Key
89 // It is hack code for bug 61355, there is same code snip for
90 // Windows platform in widget/src/windows/nsWindow.cpp: See bug 16486
91 // Note: if Shift is pressed at the same time, do not to_lower()
92 // Because Ctrl+Shift has different function with Ctrl
93 if (!event.isShift &&
94 @@ -2278,16 +2335,19 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWi
95 guint savedKeyval = aEvent->keyval;
96 aEvent->keyval = gdk_keymap_lookup_key(gdk_keymap_get_default(), &k);
97 PRUint32 unshiftedCharCode = nsConvertCharCodeToUnicode(aEvent);
98 if (unshiftedCharCode)
99 event.charCode = unshiftedCharCode;
100 else
101 aEvent->keyval = savedKeyval;
104 + aEvent->keyval = savedKeyval;
105 + aEvent->group = savedGroup;
109 // before we dispatch a key, check if it's the context menu key.
110 // If so, send a context menu key event instead.
111 if (is_context_menu_key(event)) {
112 nsMouseEvent contextMenuEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
113 key_event_to_context_menu_event(&event, &contextMenuEvent);