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

Print this page




  60     // the easy way and just support up to 5 mouse buttons,
  61     // like Windows.
  62     private static final int BUTTONS = 5;
  63 
  64     private static native void initIDs();
  65 
  66     private static CInputMethodDescriptor sInputMethodDescriptor;
  67 
  68     static {
  69         System.err.flush();
  70         java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Object>() {
  71             public Object run() {
  72                 System.loadLibrary("awt");
  73                 System.loadLibrary("fontmanager");
  74                 return null;
  75             }
  76         });
  77         if (!GraphicsEnvironment.isHeadless()) {
  78             initIDs();
  79         }






  80     }
  81 






  82     public LWCToolkit() {
  83         SunToolkit.setDataTransfererClassName("sun.lwawt.macosx.CDataTransferer");
  84 
  85         areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
  86         //set system property if not yet assigned
  87         System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
  88     }
  89 
  90     /*
  91      * System colors with default initial values, overwritten by toolkit if system values differ and are available.
  92      */
  93     private final static int NUM_APPLE_COLORS = 3;
  94     public final static int KEYBOARD_FOCUS_COLOR = 0;
  95     public final static int INACTIVE_SELECTION_BACKGROUND_COLOR = 1;
  96     public final static int INACTIVE_SELECTION_FOREGROUND_COLOR = 2;
  97     private static int[] appleColors = {
  98         0xFF808080, // keyboardFocusColor = Color.gray;
  99         0xFFC0C0C0, // secondarySelectedControlColor
 100         0xFF303030, // controlDarkShadowColor
 101     };


 684      * Returns true if the application (one of its windows) owns keyboard focus.
 685      */
 686     public native boolean isApplicationActive();
 687 
 688     /************************
 689      * Native methods section
 690      ************************/
 691 
 692     static native long createAWTRunLoopMediator();
 693     /**
 694      * Method to run a nested run-loop. The nested loop is spinned in the javaRunLoop mode, so selectors sent
 695      * by [JNFRunLoop performOnMainThreadWaiting] are processed.
 696      * @param mediator a native pointer to the mediator object created by createAWTRunLoopMediator
 697      * @param processEvents if true - dispatches event while in the nested loop. Used in DnD.
 698      *                      Additional attention is needed when using this feature as we short-circuit normal event
 699      *                      processing which could break Appkit.
 700      *                      (One known example is when the window is resized with the mouse)
 701      *
 702      *                      if false - all events come after exit form the nested loop
 703      */
 704     static native void doAWTRunLoop(long mediator, boolean processEvents);



 705     static native void stopAWTRunLoop(long mediator);
 706 
 707     private native boolean nativeSyncQueue(long timeout);
 708 
 709     @Override
 710     public Clipboard createPlatformClipboard() {
 711         return new CClipboard("System");
 712     }
 713 
 714     @Override
 715     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
 716         return (exclusionType == null) ||
 717             (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE) ||
 718             (exclusionType == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) ||
 719             (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
 720     }
 721 
 722     @Override
 723     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
 724         //TODO: FileDialog blocks excluded windows...




  60     // the easy way and just support up to 5 mouse buttons,
  61     // like Windows.
  62     private static final int BUTTONS = 5;
  63 
  64     private static native void initIDs();
  65 
  66     private static CInputMethodDescriptor sInputMethodDescriptor;
  67 
  68     static {
  69         System.err.flush();
  70         java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Object>() {
  71             public Object run() {
  72                 System.loadLibrary("awt");
  73                 System.loadLibrary("fontmanager");
  74                 return null;
  75             }
  76         });
  77         if (!GraphicsEnvironment.isHeadless()) {
  78             initIDs();
  79         }
  80         inAWT = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
  81             @Override
  82             public Boolean run() {
  83                 return !Boolean.parseBoolean(System.getProperty("javafx.embed.singleThread", "false"));
  84             }
  85         });
  86     }
  87 
  88     /*
  89      * If true  we operate in normal mode and nested runloop is executed in JavaRunLoopMode
  90      * If false we operate in singleThreaded FX/AWT interop mode and nested loop uses NSDefaultRunLoopMode
  91      */
  92     private static final boolean inAWT;
  93 
  94     public LWCToolkit() {
  95         SunToolkit.setDataTransfererClassName("sun.lwawt.macosx.CDataTransferer");
  96 
  97         areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
  98         //set system property if not yet assigned
  99         System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
 100     }
 101 
 102     /*
 103      * System colors with default initial values, overwritten by toolkit if system values differ and are available.
 104      */
 105     private final static int NUM_APPLE_COLORS = 3;
 106     public final static int KEYBOARD_FOCUS_COLOR = 0;
 107     public final static int INACTIVE_SELECTION_BACKGROUND_COLOR = 1;
 108     public final static int INACTIVE_SELECTION_FOREGROUND_COLOR = 2;
 109     private static int[] appleColors = {
 110         0xFF808080, // keyboardFocusColor = Color.gray;
 111         0xFFC0C0C0, // secondarySelectedControlColor
 112         0xFF303030, // controlDarkShadowColor
 113     };


 696      * Returns true if the application (one of its windows) owns keyboard focus.
 697      */
 698     public native boolean isApplicationActive();
 699 
 700     /************************
 701      * Native methods section
 702      ************************/
 703 
 704     static native long createAWTRunLoopMediator();
 705     /**
 706      * Method to run a nested run-loop. The nested loop is spinned in the javaRunLoop mode, so selectors sent
 707      * by [JNFRunLoop performOnMainThreadWaiting] are processed.
 708      * @param mediator a native pointer to the mediator object created by createAWTRunLoopMediator
 709      * @param processEvents if true - dispatches event while in the nested loop. Used in DnD.
 710      *                      Additional attention is needed when using this feature as we short-circuit normal event
 711      *                      processing which could break Appkit.
 712      *                      (One known example is when the window is resized with the mouse)
 713      *
 714      *                      if false - all events come after exit form the nested loop
 715      */
 716     static void doAWTRunLoop(long mediator, boolean processEvents) {
 717         doAWTRunLoopImpl(mediator, processEvents, inAWT);
 718     }
 719     static private native void doAWTRunLoopImpl(long mediator, boolean processEvents, boolean inAWT);
 720     static native void stopAWTRunLoop(long mediator);
 721 
 722     private native boolean nativeSyncQueue(long timeout);
 723 
 724     @Override
 725     public Clipboard createPlatformClipboard() {
 726         return new CClipboard("System");
 727     }
 728 
 729     @Override
 730     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
 731         return (exclusionType == null) ||
 732             (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE) ||
 733             (exclusionType == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) ||
 734             (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
 735     }
 736 
 737     @Override
 738     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
 739         //TODO: FileDialog blocks excluded windows...