868 if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) { 869 if ([self isBlocked]) { 870 // Move parent windows to front and make sure that a child window is displayed 871 // in front of its nearest parent. 872 if (self.ownerWindow != nil) { 873 JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; 874 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 875 if (platformWindow != NULL) { 876 static JNF_MEMBER_CACHE(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V"); 877 JNFCallVoidMethod(env,platformWindow, jm_orderAboveSiblings); 878 (*env)->DeleteLocalRef(env, platformWindow); 879 } 880 } 881 [self orderChildWindows:YES]; 882 } 883 884 NSPoint p = [NSEvent mouseLocation]; 885 NSRect frame = [self.nsWindow frame]; 886 NSRect contentRect = [self.nsWindow contentRectForFrameRect:frame]; 887 888 // Check if the click happened in the non-client area (title bar) 889 if (p.y >= (frame.origin.y + contentRect.size.height)) { 890 JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; 891 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 892 if (platformWindow != NULL) { 893 // Currently, no need to deliver the whole NSEvent. 894 static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V"); 895 JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown); 896 (*env)->DeleteLocalRef(env, platformWindow); 897 } 898 } 899 } 900 } 901 902 - (void)constrainSize:(NSSize*)size { 903 float minWidth = 0.f, minHeight = 0.f; 904 905 if (IS(self.styleBits, DECORATED)) { 906 NSRect frame = [self.nsWindow frame]; 907 NSRect contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[self.nsWindow styleMask]]; 908 909 float top = frame.size.height - contentRect.size.height; 910 float left = contentRect.origin.x - frame.origin.x; 911 float bottom = contentRect.origin.y - frame.origin.y; 912 float right = frame.size.width - (contentRect.size.width + left); 913 914 // Speculative estimation: 80 - enough for window decorations controls 915 minWidth += left + right + 80; 916 minHeight += top + bottom; 917 } 918 919 minWidth = MAX(1.f, minWidth); | 868 if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) { 869 if ([self isBlocked]) { 870 // Move parent windows to front and make sure that a child window is displayed 871 // in front of its nearest parent. 872 if (self.ownerWindow != nil) { 873 JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; 874 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 875 if (platformWindow != NULL) { 876 static JNF_MEMBER_CACHE(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V"); 877 JNFCallVoidMethod(env,platformWindow, jm_orderAboveSiblings); 878 (*env)->DeleteLocalRef(env, platformWindow); 879 } 880 } 881 [self orderChildWindows:YES]; 882 } 883 884 NSPoint p = [NSEvent mouseLocation]; 885 NSRect frame = [self.nsWindow frame]; 886 NSRect contentRect = [self.nsWindow contentRectForFrameRect:frame]; 887 888 JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; 889 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 890 891 // Check if the click happened in the non-client area (title bar) 892 if (p.y >= (frame.origin.y + contentRect.size.height)) { 893 if (platformWindow != NULL) { 894 // Toggle full screen upon double click on title bar. 895 if([event clickCount] == 2) { 896 static JNF_MEMBER_CACHE(jm_deliverNCDblClick, jc_CPlatformWindow, "deliverNCDblClick", "()V"); 897 JNFCallVoidMethod(env, platformWindow, jm_deliverNCDblClick); 898 } else { 899 // Currently, no need to deliver the whole NSEvent. 900 static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V"); 901 JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown); 902 } 903 } 904 } 905 906 (*env)->DeleteLocalRef(env, platformWindow); 907 } 908 } 909 910 - (void)constrainSize:(NSSize*)size { 911 float minWidth = 0.f, minHeight = 0.f; 912 913 if (IS(self.styleBits, DECORATED)) { 914 NSRect frame = [self.nsWindow frame]; 915 NSRect contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[self.nsWindow styleMask]]; 916 917 float top = frame.size.height - contentRect.size.height; 918 float left = contentRect.origin.x - frame.origin.x; 919 float bottom = contentRect.origin.y - frame.origin.y; 920 float right = frame.size.width - (contentRect.size.width + left); 921 922 // Speculative estimation: 80 - enough for window decorations controls 923 minWidth += left + right + 80; 924 minHeight += top + bottom; 925 } 926 927 minWidth = MAX(1.f, minWidth); |