--- old/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m 2017-10-29 18:24:33.000000000 +0530 +++ new/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m 2017-10-29 18:24:33.000000000 +0530 @@ -884,18 +884,26 @@ NSPoint p = [NSEvent mouseLocation]; NSRect frame = [self.nsWindow frame]; NSRect contentRect = [self.nsWindow contentRectForFrameRect:frame]; - + + JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; + jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; + // Check if the click happened in the non-client area (title bar) if (p.y >= (frame.origin.y + contentRect.size.height)) { - JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; - jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { - // Currently, no need to deliver the whole NSEvent. - static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V"); - JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown); - (*env)->DeleteLocalRef(env, platformWindow); + // Toggle full screen upon double click on title bar. + if([event clickCount] == 2) { + static JNF_MEMBER_CACHE(jm_deliverNCDblClick, jc_CPlatformWindow, "deliverNCDblClick", "()V"); + JNFCallVoidMethod(env, platformWindow, jm_deliverNCDblClick); + } else { + // Currently, no need to deliver the whole NSEvent. + static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V"); + JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown); + } } } + + (*env)->DeleteLocalRef(env, platformWindow); } } --- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java 2017-10-29 18:24:34.000000000 +0530 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java 2017-10-29 18:24:34.000000000 +0530 @@ -1074,6 +1074,13 @@ } } + /* Do toggle full screen upon double click + * on non-client area(i.e., title bar) + */ + private void deliverNCDblClick() { + execute(this::_toggleFullScreenMode); + } + /* * Our focus model is synthetic and only non-simple window * may become natively focusable window.