src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java

Print this page




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.lwawt.macosx;
  27 
  28 import java.awt.BufferCapabilities.FlipContents;
  29 import java.awt.*;
  30 import java.awt.Dialog.ModalityType;
  31 import java.awt.event.*;
  32 import java.awt.peer.WindowPeer;
  33 import java.beans.*;

  34 import java.util.List;
  35 
  36 import javax.swing.*;
  37 
  38 import sun.awt.*;
  39 import sun.java2d.SurfaceData;
  40 import sun.java2d.opengl.CGLSurfaceData;
  41 import sun.lwawt.*;
  42 import sun.lwawt.LWWindowPeer.PeerType;
  43 import sun.util.logging.PlatformLogger;
  44 
  45 import com.apple.laf.*;
  46 import com.apple.laf.ClientPropertyApplicator.Property;
  47 import com.sun.awt.AWTUtilities;
  48 
  49 public final class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
  50     private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
  51     private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
  52     private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
  53     private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);


 854     }
 855 
 856     public CPlatformView getContentView() {
 857         return contentView;
 858     }
 859 
 860     @Override
 861     public long getLayerPtr() {
 862         return contentView.getWindowLayerPtr();
 863     }
 864 
 865     private void validateSurface() {
 866         SurfaceData surfaceData = getSurfaceData();
 867         if (surfaceData instanceof CGLSurfaceData) {
 868             ((CGLSurfaceData)surfaceData).validate();
 869         }
 870     }
 871 
 872     private void flushBuffers() {
 873         if (isVisible() && !nativeBounds.isEmpty()) {
 874             LWCToolkit.getLWCToolkit().flushPendingEventsOnAppkit(target);









 875         }
 876     }
 877 
 878     /*************************************************************
 879      * Callbacks from the AWTWindow and AWTView objc classes.
 880      *************************************************************/
 881     private void deliverWindowFocusEvent(boolean gained){
 882         // Fix for 7150349: ingore "gained" notifications when the app is inactive.
 883         if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) {
 884             focusLogger.fine("the app is inactive, so the notification is ignored");
 885             return;
 886         }
 887         responder.handleWindowFocusEvent(gained);
 888     }
 889 
 890     private void deliverMoveResizeEvent(int x, int y, int width, int height) {
 891         // when the content view enters the full-screen mode, the native
 892         // move/resize notifications contain a bounds smaller than
 893         // the whole screen and therefore we ignore the native notifications
 894         // and the content view itself creates correct synthetic notifications




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.lwawt.macosx;
  27 
  28 import java.awt.BufferCapabilities.FlipContents;
  29 import java.awt.*;
  30 import java.awt.Dialog.ModalityType;
  31 import java.awt.event.*;
  32 import java.awt.peer.WindowPeer;
  33 import java.beans.*;
  34 import java.lang.reflect.InvocationTargetException;
  35 import java.util.List;
  36 
  37 import javax.swing.*;
  38 
  39 import sun.awt.*;
  40 import sun.java2d.SurfaceData;
  41 import sun.java2d.opengl.CGLSurfaceData;
  42 import sun.lwawt.*;
  43 import sun.lwawt.LWWindowPeer.PeerType;
  44 import sun.util.logging.PlatformLogger;
  45 
  46 import com.apple.laf.*;
  47 import com.apple.laf.ClientPropertyApplicator.Property;
  48 import com.sun.awt.AWTUtilities;
  49 
  50 public final class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
  51     private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
  52     private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
  53     private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
  54     private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);


 855     }
 856 
 857     public CPlatformView getContentView() {
 858         return contentView;
 859     }
 860 
 861     @Override
 862     public long getLayerPtr() {
 863         return contentView.getWindowLayerPtr();
 864     }
 865 
 866     private void validateSurface() {
 867         SurfaceData surfaceData = getSurfaceData();
 868         if (surfaceData instanceof CGLSurfaceData) {
 869             ((CGLSurfaceData)surfaceData).validate();
 870         }
 871     }
 872 
 873     private void flushBuffers() {
 874         if (isVisible() && !nativeBounds.isEmpty()) {
 875             try {
 876                 LWCToolkit.invokeAndWait(new Runnable() {
 877                     @Override
 878                     public void run() {
 879                         //Posting an empty to flush the EventQueue without blocking the main thread
 880                     }
 881                 }, target);
 882             } catch (InterruptedException | InvocationTargetException e) {
 883                 e.printStackTrace();
 884             }
 885         }
 886     }
 887 
 888     /*************************************************************
 889      * Callbacks from the AWTWindow and AWTView objc classes.
 890      *************************************************************/
 891     private void deliverWindowFocusEvent(boolean gained){
 892         // Fix for 7150349: ingore "gained" notifications when the app is inactive.
 893         if (gained && !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive()) {
 894             focusLogger.fine("the app is inactive, so the notification is ignored");
 895             return;
 896         }
 897         responder.handleWindowFocusEvent(gained);
 898     }
 899 
 900     private void deliverMoveResizeEvent(int x, int y, int width, int height) {
 901         // when the content view enters the full-screen mode, the native
 902         // move/resize notifications contain a bounds smaller than
 903         // the whole screen and therefore we ignore the native notifications
 904         // and the content view itself creates correct synthetic notifications