JBR-1874 Cursor not changing from 'default' to 'text'. Additional fix after reopening.

(cherry picked from commit 5a29d4ade9)
This commit is contained in:
Kirill Kirichenko
2018-11-15 03:09:39 +07:00
committed by alexey.ushakov@jetbrains.com
parent 9dddf3e9cb
commit 69a9f3c24c
3 changed files with 24 additions and 1 deletions

View File

@@ -45,6 +45,12 @@ final class CCursorManager extends LWCursorManager {
return theInstance;
}
private static void resetCurrentCursor() {
if (theInstance != null) {
theInstance.currentCursor = null;
}
}
private volatile Cursor currentCursor;
private CCursorManager() { }

View File

@@ -74,6 +74,7 @@
// NSWindow overrides delegate methods
- (BOOL) canBecomeKeyWindow;
- (void) becomeKeyWindow;
- (BOOL) canBecomeMainWindow;
- (BOOL) worksWhenModal;
- (void)sendEvent:(NSEvent *)event;

View File

@@ -109,7 +109,12 @@ static NSPoint lastTopLeftPoint;
- (void)sendEvent:(NSEvent *)event { \
[(AWTWindow*)[self delegate] sendEvent:event]; \
[super sendEvent:event]; \
}
} \
\
- (void)becomeKeyWindow { \
[super becomeKeyWindow]; \
[(AWTWindow*)[self delegate] becomeKeyWindow]; \
} \
@implementation AWTWindow_Normal
AWT_NS_WINDOW_IMPLEMENTATION
@@ -548,6 +553,17 @@ AWT_ASSERT_APPKIT_THREAD;
return self.isEnabled && (IS(self.styleBits, SHOULD_BECOME_KEY) || [self isSimpleWindowOwnedByEmbeddedFrame]);
}
- (void) becomeKeyWindow {
AWT_ASSERT_APPKIT_THREAD;
// Reset current cursor in CCursorManager such that any following mouse update event
// restores the correct cursor to the frame context specific one.
JNIEnv *env = [ThreadUtilities getJNIEnv];
DECLARE_CLASS(jc_CCursorManager, "sun/lwawt/macosx/CCursorManager");
DECLARE_STATIC_METHOD(sjm_resetCurrentCursor, jc_CCursorManager, "resetCurrentCursor", "()V");
(*env)->CallStaticVoidMethod(env, jc_CCursorManager, sjm_resetCurrentCursor);
}
- (BOOL) canBecomeMainWindow {
AWT_ASSERT_APPKIT_THREAD;
if (!self.isEnabled) {