< prev index next >

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

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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.*;
  29 import java.awt.Dialog.ModalityType;
  30 import java.awt.event.*;
  31 import java.awt.peer.WindowPeer;
  32 import java.beans.*;
  33 import java.lang.reflect.InvocationTargetException;
  34 
  35 import javax.swing.*;
  36 
  37 import sun.awt.*;
  38 import sun.awt.AWTAccessor.ComponentAccessor;
  39 import sun.java2d.SurfaceData;
  40 import sun.java2d.opengl.CGLSurfaceData;
  41 import sun.lwawt.*;
  42 import sun.util.logging.PlatformLogger;
  43 
  44 import com.apple.laf.*;
  45 import com.apple.laf.ClientPropertyApplicator.Property;
  46 import com.sun.awt.AWTUtilities;

  47 
  48 public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
  49     private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
  50     private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
  51     private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
  52     private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
  53     private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
  54     private static native void nativeSetNSWindowLocationByPlatform(long nsWindowPtr);
  55     private static native void nativeSetNSWindowStandardFrame(long nsWindowPtr,
  56             double x, double y, double w, double h);
  57     private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH);
  58     private static native void nativePushNSWindowToBack(long nsWindowPtr);
  59     private static native void nativePushNSWindowToFront(long nsWindowPtr);
  60     private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title);
  61     private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
  62     private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
  63     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
  64     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
  65     private static native void nativeSynthesizeMouseEnteredExitedEvents();
  66     private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr, int eventType);


 158     static ClientPropertyApplicator<JRootPane, CPlatformWindow> CLIENT_PROPERTY_APPLICATOR = new ClientPropertyApplicator<JRootPane, CPlatformWindow>(new Property[] {
 159         new Property<CPlatformWindow>(WINDOW_DOCUMENT_MODIFIED) { public void applyProperty(final CPlatformWindow c, final Object value) {
 160             c.setStyleBits(DOCUMENT_MODIFIED, value == null ? false : Boolean.parseBoolean(value.toString()));
 161         }},
 162         new Property<CPlatformWindow>(WINDOW_BRUSH_METAL_LOOK) { public void applyProperty(final CPlatformWindow c, final Object value) {
 163             c.setStyleBits(TEXTURED, Boolean.parseBoolean(value.toString()));
 164         }},
 165         new Property<CPlatformWindow>(WINDOW_ALPHA) { public void applyProperty(final CPlatformWindow c, final Object value) {
 166             AWTUtilities.setWindowOpacity(c.target, value == null ? 1.0f : Float.parseFloat(value.toString()));
 167         }},
 168         new Property<CPlatformWindow>(WINDOW_SHADOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
 169             c.setStyleBits(HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString()));
 170         }},
 171         new Property<CPlatformWindow>(WINDOW_MINIMIZABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 172             c.setStyleBits(MINIMIZABLE, Boolean.parseBoolean(value.toString()));
 173         }},
 174         new Property<CPlatformWindow>(WINDOW_CLOSEABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 175             c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString()));
 176         }},
 177         new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 178             c.setStyleBits(ZOOMABLE, Boolean.parseBoolean(value.toString()));







 179         }},
 180         new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 181             c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString()));







 182         }},
 183         new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
 184             nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
 185         }},
 186         new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 187             if (value == null || !(value instanceof java.io.File)) {
 188                 nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null);
 189                 return;
 190             }
 191 
 192             final String filename = ((java.io.File)value).getAbsolutePath();
 193             nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
 194         }}
 195     }) {
 196         @SuppressWarnings("deprecation")
 197         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
 198             Component root = SwingUtilities.getRoot(p);
 199             final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
 200             if (root == null || acc.getPeer(root) == null) return null;
 201             return (CPlatformWindow)((LWWindowPeer)acc.getPeer(root)).getPlatformWindow();
 202         }
 203     };
 204 
 205     // Bounds of the native widget but in the Java coordinate system.
 206     // In order to keep it up-to-date we will update them on
 207     // 1) setting native bounds via nativeSetBounds() call
 208     // 2) getting notification from the native level via deliverMoveResizeEvent()
 209     private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
 210     private volatile boolean isFullScreenMode;
 211     private boolean isFullScreenAnimationOn;
 212 


 213     private Window target;
 214     private LWWindowPeer peer;
 215     protected CPlatformView contentView;
 216     protected CPlatformWindow owner;
 217     protected boolean visible = false; // visibility status from native perspective
 218     private boolean undecorated; // initialized in getInitialStyleBits()
 219     private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
 220     private CPlatformResponder responder;
 221 
 222     public CPlatformWindow() {
 223         super(0, true);
 224     }
 225 
 226     /*
 227      * Delegate initialization (create native window and all the
 228      * related resources).
 229      */
 230     @Override // PlatformWindow
 231     public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) {
 232         initializeBase(_target, _peer, _owner, new CPlatformView());


 291 
 292         final boolean isFrame = (target instanceof Frame);
 293         final boolean isDialog = (target instanceof Dialog);
 294         final boolean isPopup = (target.getType() == Window.Type.POPUP);
 295         if (isDialog) {
 296             styleBits = SET(styleBits, MINIMIZABLE, false);
 297         }
 298 
 299         // Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always is undecorated.
 300         {
 301             this.undecorated = isFrame ? ((Frame)target).isUndecorated() : (isDialog ? ((Dialog)target).isUndecorated() : true);
 302             if (this.undecorated) styleBits = SET(styleBits, DECORATED, false);
 303         }
 304 
 305         // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
 306         {
 307             final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
 308             styleBits = SET(styleBits, RESIZABLE, resizable);
 309             if (!resizable) {
 310                 styleBits = SET(styleBits, ZOOMABLE, false);


 311             }
 312         }
 313 
 314         if (target.isAlwaysOnTop()) {
 315             styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
 316         }
 317 
 318         if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
 319             styleBits = SET(styleBits, MODAL_EXCLUDED, true);
 320         }
 321 
 322         // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
 323         if (isPopup) {
 324             styleBits = SET(styleBits, TEXTURED, false);
 325             // Popups in applets don't activate applet's process
 326             styleBits = SET(styleBits, NONACTIVATING, true);
 327             styleBits = SET(styleBits, IS_POPUP, true);
 328         }
 329 
 330         if (Window.Type.UTILITY.equals(target.getType())) {


 663         final long nsWindowPtr = getNSWindowPtr();
 664         nativePushNSWindowToBack(nsWindowPtr);
 665     }
 666 
 667     @Override  // PlatformWindow
 668     public void toFront() {
 669         final long nsWindowPtr = getNSWindowPtr();
 670         LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
 671         Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
 672         final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
 673         if( w != null && acc.getPeer(w) != null
 674                 && ((LWWindowPeer)acc.getPeer(w)).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
 675                 && !lwcToolkit.isApplicationActive()) {
 676             lwcToolkit.activateApplicationIgnoringOtherApps();
 677         }
 678         updateFocusabilityForAutoRequestFocus(false);
 679         nativePushNSWindowToFront(nsWindowPtr);
 680         updateFocusabilityForAutoRequestFocus(true);
 681     }
 682 














 683     @Override
 684     public void setResizable(final boolean resizable) {

 685         setStyleBits(RESIZABLE, resizable);

 686     }
 687 
 688     @Override
 689     public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
 690         nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH);
 691     }
 692 
 693     @Override
 694     public boolean rejectFocusRequest(FocusEvent.Cause cause) {
 695         // Cross-app activation requests are not allowed.
 696         if (cause != FocusEvent.Cause.MOUSE_EVENT &&
 697             !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive())
 698         {
 699             focusLogger.fine("the app is inactive, so the request is rejected");
 700             return true;
 701         }
 702         return false;
 703     }
 704 
 705     @Override


1057         } else if (target.getType() == Window.Type.POPUP) {
1058             CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel);
1059         }
1060     }
1061 
1062     // ----------------------------------------------------------------------
1063     //                          NATIVE CALLBACKS
1064     // ----------------------------------------------------------------------
1065 
1066     private void windowDidBecomeMain() {
1067         if (checkBlockingAndOrder()) return;
1068         // If it's not blocked, make sure it's above its siblings
1069         orderAboveSiblings();
1070     }
1071 
1072     private void windowWillEnterFullScreen() {
1073         isFullScreenAnimationOn = true;
1074     }
1075 
1076     private void windowDidEnterFullScreen() {

1077         isFullScreenAnimationOn = false;
1078     }
1079 
1080     private void windowWillExitFullScreen() {
1081         isFullScreenAnimationOn = true;
1082     }
1083 
1084     private void windowDidExitFullScreen() {

1085         isFullScreenAnimationOn = false;
1086     }
1087 }


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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 com.apple.eawt.FullScreenAdapter;
  29 import com.apple.eawt.FullScreenUtilities;
  30 import com.apple.eawt.event.FullScreenEvent;
  31 import java.awt.*;
  32 import java.awt.Dialog.ModalityType;
  33 import java.awt.event.*;

  34 import java.beans.*;
  35 import java.lang.reflect.InvocationTargetException;
  36 
  37 import javax.swing.*;
  38 
  39 import sun.awt.*;
  40 import sun.awt.AWTAccessor.ComponentAccessor;
  41 import sun.java2d.SurfaceData;
  42 import sun.java2d.opengl.CGLSurfaceData;
  43 import sun.lwawt.*;
  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 import sun.lwawt.LWWindowPeer.PeerType;
  50 
  51 public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
  52     private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
  53     private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
  54     private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
  55     private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
  56     private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
  57     private static native void nativeSetNSWindowLocationByPlatform(long nsWindowPtr);
  58     private static native void nativeSetNSWindowStandardFrame(long nsWindowPtr,
  59             double x, double y, double w, double h);
  60     private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH);
  61     private static native void nativePushNSWindowToBack(long nsWindowPtr);
  62     private static native void nativePushNSWindowToFront(long nsWindowPtr);
  63     private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title);
  64     private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
  65     private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
  66     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
  67     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
  68     private static native void nativeSynthesizeMouseEnteredExitedEvents();
  69     private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr, int eventType);


 161     static ClientPropertyApplicator<JRootPane, CPlatformWindow> CLIENT_PROPERTY_APPLICATOR = new ClientPropertyApplicator<JRootPane, CPlatformWindow>(new Property[] {
 162         new Property<CPlatformWindow>(WINDOW_DOCUMENT_MODIFIED) { public void applyProperty(final CPlatformWindow c, final Object value) {
 163             c.setStyleBits(DOCUMENT_MODIFIED, value == null ? false : Boolean.parseBoolean(value.toString()));
 164         }},
 165         new Property<CPlatformWindow>(WINDOW_BRUSH_METAL_LOOK) { public void applyProperty(final CPlatformWindow c, final Object value) {
 166             c.setStyleBits(TEXTURED, Boolean.parseBoolean(value.toString()));
 167         }},
 168         new Property<CPlatformWindow>(WINDOW_ALPHA) { public void applyProperty(final CPlatformWindow c, final Object value) {
 169             AWTUtilities.setWindowOpacity(c.target, value == null ? 1.0f : Float.parseFloat(value.toString()));
 170         }},
 171         new Property<CPlatformWindow>(WINDOW_SHADOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
 172             c.setStyleBits(HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString()));
 173         }},
 174         new Property<CPlatformWindow>(WINDOW_MINIMIZABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 175             c.setStyleBits(MINIMIZABLE, Boolean.parseBoolean(value.toString()));
 176         }},
 177         new Property<CPlatformWindow>(WINDOW_CLOSEABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 178             c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString()));
 179         }},
 180         new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 181             boolean zoomable = Boolean.parseBoolean(value.toString());
 182             if (c.target instanceof RootPaneContainer
 183                     && c.getPeer().getPeerType() == PeerType.FRAME) {
 184                 if (c.isInFullScreen && !zoomable) {
 185                     c.toggleFullScreen();
 186                 }
 187             }
 188             c.setStyleBits(ZOOMABLE, zoomable);
 189         }},
 190         new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 191             boolean fullscrenable = Boolean.parseBoolean(value.toString());
 192             if (c.target instanceof RootPaneContainer
 193                     && c.getPeer().getPeerType() == PeerType.FRAME) {
 194                 if (c.isInFullScreen && !fullscrenable) {
 195                     c.toggleFullScreen();
 196                 }
 197             }
 198             c.setStyleBits(FULLSCREENABLE, fullscrenable);
 199         }},
 200         new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
 201             nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
 202         }},
 203         new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) {
 204             if (value == null || !(value instanceof java.io.File)) {
 205                 nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), null);
 206                 return;
 207             }
 208 
 209             final String filename = ((java.io.File)value).getAbsolutePath();
 210             nativeSetNSWindowRepresentedFilename(c.getNSWindowPtr(), filename);
 211         }}
 212     }) {
 213         @SuppressWarnings("deprecation")
 214         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
 215             Component root = SwingUtilities.getRoot(p);
 216             final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
 217             if (root == null || acc.getPeer(root) == null) return null;
 218             return (CPlatformWindow)((LWWindowPeer)acc.getPeer(root)).getPlatformWindow();
 219         }
 220     };
 221 
 222     // Bounds of the native widget but in the Java coordinate system.
 223     // In order to keep it up-to-date we will update them on
 224     // 1) setting native bounds via nativeSetBounds() call
 225     // 2) getting notification from the native level via deliverMoveResizeEvent()
 226     private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0);
 227     private volatile boolean isFullScreenMode;
 228     private boolean isFullScreenAnimationOn;
 229 
 230     private volatile boolean isInFullScreen;
 231 
 232     private Window target;
 233     private LWWindowPeer peer;
 234     protected CPlatformView contentView;
 235     protected CPlatformWindow owner;
 236     protected boolean visible = false; // visibility status from native perspective
 237     private boolean undecorated; // initialized in getInitialStyleBits()
 238     private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
 239     private CPlatformResponder responder;
 240     
 241     public CPlatformWindow() {
 242         super(0, true);
 243     }
 244 
 245     /*
 246      * Delegate initialization (create native window and all the
 247      * related resources).
 248      */
 249     @Override // PlatformWindow
 250     public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) {
 251         initializeBase(_target, _peer, _owner, new CPlatformView());


 310 
 311         final boolean isFrame = (target instanceof Frame);
 312         final boolean isDialog = (target instanceof Dialog);
 313         final boolean isPopup = (target.getType() == Window.Type.POPUP);
 314         if (isDialog) {
 315             styleBits = SET(styleBits, MINIMIZABLE, false);
 316         }
 317 
 318         // Either java.awt.Frame or java.awt.Dialog can be undecorated, however java.awt.Window always is undecorated.
 319         {
 320             this.undecorated = isFrame ? ((Frame)target).isUndecorated() : (isDialog ? ((Dialog)target).isUndecorated() : true);
 321             if (this.undecorated) styleBits = SET(styleBits, DECORATED, false);
 322         }
 323 
 324         // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
 325         {
 326             final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
 327             styleBits = SET(styleBits, RESIZABLE, resizable);
 328             if (!resizable) {
 329                 styleBits = SET(styleBits, ZOOMABLE, false);
 330             } else {
 331                 setCanFullscreen(true);
 332             }
 333         }
 334 
 335         if (target.isAlwaysOnTop()) {
 336             styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
 337         }
 338 
 339         if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
 340             styleBits = SET(styleBits, MODAL_EXCLUDED, true);
 341         }
 342 
 343         // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
 344         if (isPopup) {
 345             styleBits = SET(styleBits, TEXTURED, false);
 346             // Popups in applets don't activate applet's process
 347             styleBits = SET(styleBits, NONACTIVATING, true);
 348             styleBits = SET(styleBits, IS_POPUP, true);
 349         }
 350 
 351         if (Window.Type.UTILITY.equals(target.getType())) {


 684         final long nsWindowPtr = getNSWindowPtr();
 685         nativePushNSWindowToBack(nsWindowPtr);
 686     }
 687 
 688     @Override  // PlatformWindow
 689     public void toFront() {
 690         final long nsWindowPtr = getNSWindowPtr();
 691         LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
 692         Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
 693         final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
 694         if( w != null && acc.getPeer(w) != null
 695                 && ((LWWindowPeer)acc.getPeer(w)).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
 696                 && !lwcToolkit.isApplicationActive()) {
 697             lwcToolkit.activateApplicationIgnoringOtherApps();
 698         }
 699         updateFocusabilityForAutoRequestFocus(false);
 700         nativePushNSWindowToFront(nsWindowPtr);
 701         updateFocusabilityForAutoRequestFocus(true);
 702     }
 703 
 704     private void setCanFullscreen(final boolean canFullScreen) {
 705         if (target instanceof RootPaneContainer
 706                 && getPeer().getPeerType() == PeerType.FRAME) {
 707 
 708             if (isInFullScreen && !canFullScreen) {
 709                 toggleFullScreen();
 710             }
 711 
 712             final RootPaneContainer rpc = (RootPaneContainer) target;
 713             rpc.getRootPane().putClientProperty(
 714                     CPlatformWindow.WINDOW_FULLSCREENABLE, canFullScreen);
 715         }
 716     }
 717 
 718     @Override
 719     public void setResizable(final boolean resizable) {
 720         setCanFullscreen(resizable);
 721         setStyleBits(RESIZABLE, resizable);
 722         setStyleBits(ZOOMABLE, resizable);
 723     }
 724 
 725     @Override
 726     public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
 727         nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH);
 728     }
 729 
 730     @Override
 731     public boolean rejectFocusRequest(FocusEvent.Cause cause) {
 732         // Cross-app activation requests are not allowed.
 733         if (cause != FocusEvent.Cause.MOUSE_EVENT &&
 734             !((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive())
 735         {
 736             focusLogger.fine("the app is inactive, so the request is rejected");
 737             return true;
 738         }
 739         return false;
 740     }
 741 
 742     @Override


1094         } else if (target.getType() == Window.Type.POPUP) {
1095             CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel);
1096         }
1097     }
1098 
1099     // ----------------------------------------------------------------------
1100     //                          NATIVE CALLBACKS
1101     // ----------------------------------------------------------------------
1102 
1103     private void windowDidBecomeMain() {
1104         if (checkBlockingAndOrder()) return;
1105         // If it's not blocked, make sure it's above its siblings
1106         orderAboveSiblings();
1107     }
1108 
1109     private void windowWillEnterFullScreen() {
1110         isFullScreenAnimationOn = true;
1111     }
1112 
1113     private void windowDidEnterFullScreen() {
1114         isInFullScreen = true;
1115         isFullScreenAnimationOn = false;
1116     }
1117 
1118     private void windowWillExitFullScreen() {
1119         isFullScreenAnimationOn = true;
1120     }
1121 
1122     private void windowDidExitFullScreen() {
1123         isInFullScreen = false;
1124         isFullScreenAnimationOn = false;
1125     }
1126 }
< prev index next >