JBR-1824 export NSWindow::setIgnoresMouseEvents to java internal API

(cherry picked from commit 4399dc382c)
This commit is contained in:
Anton Tarasov
2019-09-05 12:56:14 +03:00
committed by alexey.ushakov@jetbrains.com
parent d88cfbd52f
commit 560dae73fc
2 changed files with 30 additions and 1 deletions

View File

@@ -1106,6 +1106,17 @@ JNI_COCOA_ENTER(env);
NSView *contentView = OBJC(contentViewPtr);
NSRect frameRect = NSMakeRect(x, y, w, h);
AWTWindow *owner = [OBJC(ownerPtr) delegate];
BOOL isIgnoreMouseEvents = NO;
GET_CPLATFORM_WINDOW_CLASS_RETURN(nil);
DECLARE_FIELD_RETURN(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;", nil);
jobject awtWindow = (*env)->GetObjectField(env, obj, jf_target);
if (awtWindow != NULL) {
DECLARE_CLASS_RETURN(jc_Window, "java/awt/Window", nil);
DECLARE_METHOD_RETURN(jm_isIgnoreMouseEvents, jc_Window, "isIgnoreMouseEvents", "()Z", nil);
isIgnoreMouseEvents = (*env)->CallBooleanMethod(env, awtWindow, jm_isIgnoreMouseEvents) == JNI_TRUE ? YES : NO;
(*env)->DeleteLocalRef(env, awtWindow);
}
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow
@@ -1115,7 +1126,12 @@ JNI_COCOA_ENTER(env);
contentView:contentView];
// the window is released is CPlatformWindow.nativeDispose()
if (window) [window.nsWindow retain];
if (window) {
[window.nsWindow retain];
if (isIgnoreMouseEvents) {
[window.nsWindow setIgnoresMouseEvents:YES];
}
}
}];
JNI_COCOA_EXIT(env);

View File

@@ -3997,6 +3997,19 @@ public class Window extends Container implements Accessible {
hasCustomDecoration = true;
}
private volatile boolean ignoreMouseEvents;
boolean isIgnoreMouseEvents() {
return ignoreMouseEvents;
}
/**
* Set via reflection (JB JdkEx API).
*/
void setIgnoreMouseEvents(boolean ignore) {
ignoreMouseEvents = ignore;
}
// ************************** MIXING CODE *******************************
// A window has an owner, but it does NOT have a container