jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
changeset 39511 a7ad23d3d161
parent 38987 ffe8b158dd6a
child 40446 cf666940a804
equal deleted inserted replaced
39510:b61e0e7ee904 39511:a7ad23d3d161
     1 /*
     1 /*
     2  * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    52 // have to do a bit of tracking. This variable points to a window
    52 // have to do a bit of tracking. This variable points to a window
    53 // which had been the key window just before a new key window
    53 // which had been the key window just before a new key window
    54 // was set. It would be nil if the new key window isn't an AWT
    54 // was set. It would be nil if the new key window isn't an AWT
    55 // window or the app currently has no key window.
    55 // window or the app currently has no key window.
    56 static AWTWindow* lastKeyWindow = nil;
    56 static AWTWindow* lastKeyWindow = nil;
       
    57 
       
    58 // This variable contains coordinates of a window's top left
       
    59 // which was positioned via java.awt.Window.setLocationByPlatform.
       
    60 // It would be NSZeroPoint if 'Location by Platform' is not used.
       
    61 static NSPoint lastTopLeftPoint;
    57 
    62 
    58 // --------------------------------------------------------------
    63 // --------------------------------------------------------------
    59 // NSWindow/NSPanel descendants implementation
    64 // NSWindow/NSPanel descendants implementation
    60 #define AWT_NS_WINDOW_IMPLEMENTATION                            \
    65 #define AWT_NS_WINDOW_IMPLEMENTATION                            \
    61 - (id) initWithDelegate:(AWTWindow *)delegate                   \
    66 - (id) initWithDelegate:(AWTWindow *)delegate                   \
  1082     JNF_COCOA_EXIT(env);
  1087     JNF_COCOA_EXIT(env);
  1083 }
  1088 }
  1084 
  1089 
  1085 /*
  1090 /*
  1086  * Class:     sun_lwawt_macosx_CPlatformWindow
  1091  * Class:     sun_lwawt_macosx_CPlatformWindow
       
  1092  * Method:    nativeSetNSWindowLocationByPlatform
       
  1093  * Signature: (J)V
       
  1094  */
       
  1095 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowLocationByPlatform
       
  1096 (JNIEnv *env, jclass clazz, jlong windowPtr)
       
  1097 {
       
  1098     JNF_COCOA_ENTER(env);
       
  1099 
       
  1100     NSWindow *nsWindow = OBJC(windowPtr);
       
  1101     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
       
  1102 
       
  1103         if (NSEqualPoints(lastTopLeftPoint, NSZeroPoint)) {
       
  1104             // This is the first usage of lastTopLeftPoint. So invoke cascadeTopLeftFromPoint
       
  1105             // twice to avoid positioning the window's top left to zero-point, since it may
       
  1106             // cause negative user experience.
       
  1107             lastTopLeftPoint = [nsWindow cascadeTopLeftFromPoint:lastTopLeftPoint];
       
  1108         }
       
  1109         lastTopLeftPoint = [nsWindow cascadeTopLeftFromPoint:lastTopLeftPoint];
       
  1110     }];
       
  1111 
       
  1112     JNF_COCOA_EXIT(env);
       
  1113 }
       
  1114 
       
  1115 /*
       
  1116  * Class:     sun_lwawt_macosx_CPlatformWindow
  1087  * Method:    nativeSetNSWindowMinMax
  1117  * Method:    nativeSetNSWindowMinMax
  1088  * Signature: (JDDDD)V
  1118  * Signature: (JDDDD)V
  1089  */
  1119  */
  1090 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinMax
  1120 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinMax
  1091 (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH)
  1121 (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH)