1
------------------------------------------------------------
3
fixes bug: https://launchpad.net/bugs/903566
4
committer: Christopher James Halse Rogers <raof@ubuntu.com>
6
timestamp: Sun 2012-02-05 21:43:22 +1100
8
Keybindings: Use KeyEventToString everywhere
10
We had two different keybinding → string mappings happening: one when
11
setting the keybinding in preferences, and one when processing keys.
12
This could (and, indeed, does) result in summoning keybindings not
15
Also works around bug #903566. A proper fix (possibly in GTK♯) should
16
still be investigated.
18
Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs
19
Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs
20
Do.Platform/src/Do.Platform/IKeyBindingService.cs
21
Do/src/Do.Core/Controller.cs
22
Do/src/Do.UI/KeybindingTreeView.cs
24
=== modified file 'Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs'
25
Index: Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs
26
===================================================================
27
--- Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs.orig 2011-03-20 20:56:41.000000000 +1100
28
+++ Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 2012-03-18 21:06:19.956714068 +1100
31
/// A <see cref="System.String"/> in the form "<Modifier>key"
33
- public string KeyEventToString (Gdk.EventKey evnt) {
34
+ public string KeyEventToString (uint keycode, uint modifierCode) {
35
+ // FIXME: This should really use Gtk.Accelerator.Name (key, modifier)
36
+ // Beware of bug #903566 when doing that!
39
- if ((evnt.State & Gdk.ModifierType.ControlMask) != 0) {
40
+ if ((modifierCode & (uint)Gdk.ModifierType.ControlMask) != 0) {
41
modifier += "<Control>";
43
- if ((evnt.State & Gdk.ModifierType.SuperMask) != 0) {
44
+ if ((modifierCode & (uint)Gdk.ModifierType.SuperMask) != 0) {
45
modifier += "<Super>";
47
- if ((evnt.State & Gdk.ModifierType.Mod1Mask) != 0) {
48
+ if ((modifierCode & (uint)Gdk.ModifierType.Mod1Mask) != 0) {
51
- if ((evnt.State & Gdk.ModifierType.ShiftMask) != 0) {
52
+ if ((modifierCode & (uint)Gdk.ModifierType.ShiftMask) != 0) {
53
modifier += "<Shift>";
54
//if we're pressing shift, and the key is ISO_Left_Tab,
56
- if (evnt.Key == Gdk.Key.ISO_Left_Tab)
57
+ if (keycode == (uint)Gdk.Key.ISO_Left_Tab)
58
return string.Format ("{0}{1}", modifier, Gdk.Key.Tab);
60
- return string.Format ("{0}{1}", modifier, Gtk.Accelerator.Name (evnt.KeyValue, Gdk.ModifierType.None));
61
+ return string.Format ("{0}{1}", modifier, Gtk.Accelerator.Name (keycode, Gdk.ModifierType.None));
65
Index: Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs
66
===================================================================
67
--- Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs.orig 2009-08-20 20:19:16.000000000 +1000
68
+++ Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs 2012-03-18 21:02:51.200703571 +1100
70
public bool SetKeyString (KeyBinding binding, string keyString) {
73
- public string KeyEventToString (Gdk.EventKey evnt) {
74
+ public string KeyEventToString (uint keycode, uint modifierCode) {
77
public List<KeyBinding> Bindings { get { return new List<KeyBinding> (); } }
78
Index: Do.Platform/src/Do.Platform/IKeyBindingService.cs
79
===================================================================
80
--- Do.Platform/src/Do.Platform/IKeyBindingService.cs.orig 2009-08-20 20:19:16.000000000 +1000
81
+++ Do.Platform/src/Do.Platform/IKeyBindingService.cs 2012-03-18 21:02:51.200703571 +1100
83
bool RegisterKeyBinding (KeyBinding evnt);
84
bool SetKeyString (KeyBinding binding, string keyString);
85
List<KeyBinding> Bindings { get; }
86
- string KeyEventToString (EventKey evnt);
87
+ string KeyEventToString (uint keycode, uint modifierCode);
90
Index: Do/src/Do.Core/Controller.cs
91
===================================================================
92
--- Do/src/Do.Core/Controller.cs.orig 2011-03-20 20:56:38.000000000 +1100
93
+++ Do/src/Do.Core/Controller.cs 2012-03-18 21:02:51.200703571 +1100
95
} else if (key == Key.Delete ||
96
key == Key.BackSpace) {
97
OnDeleteKeyPressEvent (evnt);
98
- } else if (Services.Keybinder.Bindings.Any (k => k.KeyString == Services.Keybinder.KeyEventToString (evnt))) {
99
+ } else if (Services.Keybinder.Bindings.Any (k => k.KeyString == Services.Keybinder.KeyEventToString (evnt.KeyValue, (uint)evnt.State))) {
100
// User set keybindings
101
- Services.Keybinder.Bindings.First (k => k.KeyString == Services.Keybinder.KeyEventToString (evnt)).Callback (evnt);
102
+ Services.Keybinder.Bindings.First (k => k.KeyString == Services.Keybinder.KeyEventToString (evnt.KeyValue, (uint)evnt.State)).Callback (evnt);
104
OnInputKeyPressEvent (evnt);
106
Index: Do/src/Do.UI/KeybindingTreeView.cs
107
===================================================================
108
--- Do/src/Do.UI/KeybindingTreeView.cs.orig 2011-03-19 21:03:28.000000000 +1100
109
+++ Do/src/Do.UI/KeybindingTreeView.cs 2012-03-18 21:02:51.200703571 +1100
112
store = Model as ListStore;
113
store.GetIter (out iter, new TreePath (args.PathString));
115
- string realKey = Gtk.Accelerator.Name (args.AccelKey, args.AccelMods);
117
+ string realKey = Services.Keybinder.KeyEventToString (args.AccelKey, (uint)args.AccelMods);
119
if (args.AccelKey == (uint) Gdk.Key.Super_L || args.AccelKey == (uint) Gdk.Key.Super_R) {
120
//setting CellRenderAccelMode to "Other" ignores the Super key as a modifier