-
Bug
-
Resolution: Fixed
-
P3
-
8u31
-
Mac OS X 10.10
If you create a new window from a keyboard shortcut and then receive at least one KeyEvent in the new window, then when the new window is closed the keyboard shortcut KeyEvent will be delivered for a second time.
The problem comes from the method (void)sendJavaKeyEvent:(NSEvent *)theEvent isDown:(BOOL)isDown in GlassViewDelegate.m at line 616. At the start of this method the incoming event is tested against the last event in case it has resulted from (BOOL)performKeyEquivalent:(NSEvent *)theEvent so that the duplicate event can be ignored as below: -
if (theEvent == s_lastKeyEvent) {
// this must be a keyDown: generated by performKeyEquivalent: which returns NO by design
return;
}
The problem is that s_lastKeyEvent is a static and so when key events are processed in the new window this value gets overriden. So that when processing of events continues when the new window has closed it no longer has the value from the original keyboard shortcut.
The solution is to make s_lastKeyEvent an instance variable so that it is tracked on a per delegate basis.
There is no need to make s_modifierFlags an instance variable as the modifiers need to be tracked across delegates.
I have implemented and tested this chanegh and it fixes the problem.
The problem comes from the method (void)sendJavaKeyEvent:(NSEvent *)theEvent isDown:(BOOL)isDown in GlassViewDelegate.m at line 616. At the start of this method the incoming event is tested against the last event in case it has resulted from (BOOL)performKeyEquivalent:(NSEvent *)theEvent so that the duplicate event can be ignored as below: -
if (theEvent == s_lastKeyEvent) {
// this must be a keyDown: generated by performKeyEquivalent: which returns NO by design
return;
}
The problem is that s_lastKeyEvent is a static and so when key events are processed in the new window this value gets overriden. So that when processing of events continues when the new window has closed it no longer has the value from the original keyboard shortcut.
The solution is to make s_lastKeyEvent an instance variable so that it is tracked on a per delegate basis.
There is no need to make s_modifierFlags an instance variable as the modifiers need to be tracked across delegates.
I have implemented and tested this chanegh and it fixes the problem.