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

Print this page




 383 
 384         // These DnD properties must be set, otherwise Swing ends up spewing NPEs
 385         // all over the place. The values came straight off of MToolkit.
 386         desktopProperties.put("DnD.Autoscroll.initialDelay", new Integer(50));
 387         desktopProperties.put("DnD.Autoscroll.interval", new Integer(50));
 388         desktopProperties.put("DnD.Autoscroll.cursorHysteresis", new Integer(5));
 389 
 390         desktopProperties.put("DnD.isDragImageSupported", new Boolean(true));
 391 
 392         // Register DnD cursors
 393         desktopProperties.put("DnD.Cursor.CopyDrop", new NamedCursor("DnD.Cursor.CopyDrop"));
 394         desktopProperties.put("DnD.Cursor.MoveDrop", new NamedCursor("DnD.Cursor.MoveDrop"));
 395         desktopProperties.put("DnD.Cursor.LinkDrop", new NamedCursor("DnD.Cursor.LinkDrop"));
 396         desktopProperties.put("DnD.Cursor.CopyNoDrop", new NamedCursor("DnD.Cursor.CopyNoDrop"));
 397         desktopProperties.put("DnD.Cursor.MoveNoDrop", new NamedCursor("DnD.Cursor.MoveNoDrop"));
 398         desktopProperties.put("DnD.Cursor.LinkNoDrop", new NamedCursor("DnD.Cursor.LinkNoDrop"));
 399     }
 400 
 401     @Override
 402     protected boolean syncNativeQueue(long timeout) {
 403         return nativeSyncQueue(timeout);






















 404     }
 405 
 406     @Override
 407     public native void beep();
 408 
 409     @Override
 410     public int getScreenResolution() throws HeadlessException {
 411         return (int) ((CGraphicsDevice) GraphicsEnvironment
 412                 .getLocalGraphicsEnvironment().getDefaultScreenDevice())
 413                 .getXResolution();
 414     }
 415 
 416     @Override
 417     public Insets getScreenInsets(final GraphicsConfiguration gc) {
 418         return ((CGraphicsConfig) gc).getDevice().getScreenInsets();
 419     }
 420 
 421     @Override
 422     public void sync() {
 423         // TODO Auto-generated method stub


 791      ************************/
 792 
 793     static native long createAWTRunLoopMediator();
 794     /**
 795      * Method to run a nested run-loop. The nested loop is spinned in the javaRunLoop mode, so selectors sent
 796      * by [JNFRunLoop performOnMainThreadWaiting] are processed.
 797      * @param mediator a native pointer to the mediator object created by createAWTRunLoopMediator
 798      * @param processEvents if true - dispatches event while in the nested loop. Used in DnD.
 799      *                      Additional attention is needed when using this feature as we short-circuit normal event
 800      *                      processing which could break Appkit.
 801      *                      (One known example is when the window is resized with the mouse)
 802      *
 803      *                      if false - all events come after exit form the nested loop
 804      */
 805     static void doAWTRunLoop(long mediator, boolean processEvents) {
 806         doAWTRunLoopImpl(mediator, processEvents, inAWT);
 807     }
 808     private static native void doAWTRunLoopImpl(long mediator, boolean processEvents, boolean inAWT);
 809     static native void stopAWTRunLoop(long mediator);
 810 
 811     private native boolean nativeSyncQueue(long timeout);











 812 
 813     @Override
 814     public Clipboard createPlatformClipboard() {
 815         return new CClipboard("System");
 816     }
 817 
 818     @Override
 819     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
 820         return (exclusionType == null) ||
 821             (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE) ||
 822             (exclusionType == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) ||
 823             (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
 824     }
 825 
 826     @Override
 827     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
 828         //TODO: FileDialog blocks excluded windows...
 829         //TODO: Test: 2 file dialogs, separate AppContexts: a) Dialog 1 blocked, shouldn't be. Frame 4 blocked (shouldn't be).
 830         return (modalityType == null) ||
 831             (modalityType == Dialog.ModalityType.MODELESS) ||




 383 
 384         // These DnD properties must be set, otherwise Swing ends up spewing NPEs
 385         // all over the place. The values came straight off of MToolkit.
 386         desktopProperties.put("DnD.Autoscroll.initialDelay", new Integer(50));
 387         desktopProperties.put("DnD.Autoscroll.interval", new Integer(50));
 388         desktopProperties.put("DnD.Autoscroll.cursorHysteresis", new Integer(5));
 389 
 390         desktopProperties.put("DnD.isDragImageSupported", new Boolean(true));
 391 
 392         // Register DnD cursors
 393         desktopProperties.put("DnD.Cursor.CopyDrop", new NamedCursor("DnD.Cursor.CopyDrop"));
 394         desktopProperties.put("DnD.Cursor.MoveDrop", new NamedCursor("DnD.Cursor.MoveDrop"));
 395         desktopProperties.put("DnD.Cursor.LinkDrop", new NamedCursor("DnD.Cursor.LinkDrop"));
 396         desktopProperties.put("DnD.Cursor.CopyNoDrop", new NamedCursor("DnD.Cursor.CopyNoDrop"));
 397         desktopProperties.put("DnD.Cursor.MoveNoDrop", new NamedCursor("DnD.Cursor.MoveNoDrop"));
 398         desktopProperties.put("DnD.Cursor.LinkNoDrop", new NamedCursor("DnD.Cursor.LinkNoDrop"));
 399     }
 400 
 401     @Override
 402     protected boolean syncNativeQueue(long timeout) {
 403         long startTime = System.currentTimeMillis();
 404         long waitTime = 500;
 405         while (System.currentTimeMillis() - startTime < timeout) {
 406             switch (nativeSyncQueue(waitTime)) {
 407                 case RESULT_EVENTS_PROCESSED:
 408                     return true;
 409                 case RESULT_NO_EVENTS:
 410                     return false;
 411                 case RESULT_TIMEOUT:
 412                     if (EventQueue.isDispatchThread()) {
 413                         // Deadlocked. Have to return and let EDT process some events
 414                         return false;
 415                     } else {
 416                         // The timeout is too low, because deadlock is impossible.
 417                         // Make another attempt to flush with bigger timeout.
 418                         waitTime += 100;
 419                     }
 420                     break;
 421                 default:
 422                     throw new AssertionError("Invalid result of nativeSyncQueue");
 423             }
 424         }
 425         return false;
 426     }
 427 
 428     @Override
 429     public native void beep();
 430 
 431     @Override
 432     public int getScreenResolution() throws HeadlessException {
 433         return (int) ((CGraphicsDevice) GraphicsEnvironment
 434                 .getLocalGraphicsEnvironment().getDefaultScreenDevice())
 435                 .getXResolution();
 436     }
 437 
 438     @Override
 439     public Insets getScreenInsets(final GraphicsConfiguration gc) {
 440         return ((CGraphicsConfig) gc).getDevice().getScreenInsets();
 441     }
 442 
 443     @Override
 444     public void sync() {
 445         // TODO Auto-generated method stub


 813      ************************/
 814 
 815     static native long createAWTRunLoopMediator();
 816     /**
 817      * Method to run a nested run-loop. The nested loop is spinned in the javaRunLoop mode, so selectors sent
 818      * by [JNFRunLoop performOnMainThreadWaiting] are processed.
 819      * @param mediator a native pointer to the mediator object created by createAWTRunLoopMediator
 820      * @param processEvents if true - dispatches event while in the nested loop. Used in DnD.
 821      *                      Additional attention is needed when using this feature as we short-circuit normal event
 822      *                      processing which could break Appkit.
 823      *                      (One known example is when the window is resized with the mouse)
 824      *
 825      *                      if false - all events come after exit form the nested loop
 826      */
 827     static void doAWTRunLoop(long mediator, boolean processEvents) {
 828         doAWTRunLoopImpl(mediator, processEvents, inAWT);
 829     }
 830     private static native void doAWTRunLoopImpl(long mediator, boolean processEvents, boolean inAWT);
 831     static native void stopAWTRunLoop(long mediator);
 832 
 833     /* Result codes for the nativeSyncQueue method */
 834     private static final int RESULT_EVENTS_PROCESSED = 1;
 835     private static final int RESULT_NO_EVENTS = 0;
 836     private static final int RESULT_TIMEOUT = -1;
 837     /**
 838      * Posts a dummy event and waits for it to complete.
 839      * @param timeout the timeout
 840      * @return RESULT_EVENTS_PROCESSED if some events were processed during waiting
 841      *         RESULT_NO_EVENTS if no events were processed during waiting
 842      *         RESULT_TIMEOUT if interrupted by timeout
 843      */
 844     private native int nativeSyncQueue(long timeout);
 845 
 846     @Override
 847     public Clipboard createPlatformClipboard() {
 848         return new CClipboard("System");
 849     }
 850 
 851     @Override
 852     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
 853         return (exclusionType == null) ||
 854             (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE) ||
 855             (exclusionType == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) ||
 856             (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
 857     }
 858 
 859     @Override
 860     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
 861         //TODO: FileDialog blocks excluded windows...
 862         //TODO: Test: 2 file dialogs, separate AppContexts: a) Dialog 1 blocked, shouldn't be. Frame 4 blocked (shouldn't be).
 863         return (modalityType == null) ||
 864             (modalityType == Dialog.ModalityType.MODELESS) ||