< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   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.AWTError;

  29 import java.awt.CheckboxMenuItem;
  30 import java.awt.Color;
  31 import java.awt.Component;
  32 import java.awt.Cursor;
  33 import java.awt.Desktop;
  34 import java.awt.Dialog;
  35 import java.awt.Dimension;
  36 import java.awt.Event;
  37 import java.awt.EventQueue;
  38 import java.awt.FileDialog;
  39 import java.awt.Frame;
  40 import java.awt.GraphicsConfiguration;
  41 import java.awt.GraphicsDevice;
  42 import java.awt.GraphicsEnvironment;
  43 import java.awt.HeadlessException;
  44 import java.awt.Image;
  45 import java.awt.Insets;
  46 import java.awt.Menu;
  47 import java.awt.MenuBar;
  48 import java.awt.MenuItem;
  49 import java.awt.Point;
  50 import java.awt.PopupMenu;
  51 import java.awt.RenderingHints;
  52 import java.awt.Robot;
  53 import java.awt.SystemTray;
  54 import java.awt.Taskbar;
  55 import java.awt.Toolkit;
  56 import java.awt.TrayIcon;
  57 import java.awt.Window;
  58 import java.awt.datatransfer.Clipboard;
  59 import java.awt.dnd.DragGestureEvent;
  60 import java.awt.dnd.DragGestureListener;
  61 import java.awt.dnd.DragGestureRecognizer;
  62 import java.awt.dnd.DragSource;
  63 import java.awt.dnd.DropTarget;
  64 import java.awt.dnd.InvalidDnDOperationException;
  65 import java.awt.dnd.MouseDragGestureRecognizer;
  66 import java.awt.dnd.peer.DragSourceContextPeer;
  67 import java.awt.event.InputEvent;
  68 import java.awt.event.InvocationEvent;
  69 import java.awt.event.KeyEvent;
  70 import java.awt.font.TextAttribute;
  71 import java.awt.im.InputMethodHighlight;
  72 import java.awt.im.spi.InputMethodDescriptor;


 475         return (int) ((CGraphicsDevice) GraphicsEnvironment
 476                 .getLocalGraphicsEnvironment().getDefaultScreenDevice())
 477                 .getXResolution();
 478     }
 479 
 480     @Override
 481     public Insets getScreenInsets(final GraphicsConfiguration gc) {
 482         return ((CGraphicsConfig) gc).getDevice().getScreenInsets();
 483     }
 484 
 485     @Override
 486     public void sync() {
 487         // flush the OGL pipeline (this is a no-op if OGL is not enabled)
 488         OGLRenderQueue.sync();
 489         // setNeedsDisplay() selector was sent to the appropriate CALayer so now
 490         // we have to flush the native selectors queue.
 491         flushNativeSelectors();
 492     }
 493 
 494     @Override
 495     public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
 496         return new CRobot(target, (CGraphicsDevice)screen);



 497     }
 498 
 499     private native boolean isCapsLockOn();
 500 
 501     /*
 502      * NOTE: Among the keys this method is supposed to check,
 503      * only Caps Lock works as a true locking key with OS X.
 504      * There is no Scroll Lock key on modern Apple keyboards,
 505      * and with a PC keyboard plugged in Scroll Lock is simply
 506      * ignored: no LED lights up if you press it.
 507      * The key located at the same position on Apple keyboards
 508      * as Num Lock on PC keyboards is called Clear, doesn't lock
 509      * anything and is used for entirely different purpose.
 510      */
 511     @Override
 512     public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException {
 513         switch (keyCode) {
 514             case KeyEvent.VK_NUM_LOCK:
 515             case KeyEvent.VK_SCROLL_LOCK:
 516             case KeyEvent.VK_KANA_LOCK:


   1 /*
   2  * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   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.AWTError;
  29 import java.awt.AWTException;
  30 import java.awt.CheckboxMenuItem;
  31 import java.awt.Color;
  32 import java.awt.Component;
  33 import java.awt.Cursor;
  34 import java.awt.Desktop;
  35 import java.awt.Dialog;
  36 import java.awt.Dimension;
  37 import java.awt.Event;
  38 import java.awt.EventQueue;
  39 import java.awt.FileDialog;
  40 import java.awt.Frame;
  41 import java.awt.GraphicsConfiguration;
  42 import java.awt.GraphicsDevice;
  43 import java.awt.GraphicsEnvironment;
  44 import java.awt.HeadlessException;
  45 import java.awt.Image;
  46 import java.awt.Insets;
  47 import java.awt.Menu;
  48 import java.awt.MenuBar;
  49 import java.awt.MenuItem;
  50 import java.awt.Point;
  51 import java.awt.PopupMenu;
  52 import java.awt.RenderingHints;

  53 import java.awt.SystemTray;
  54 import java.awt.Taskbar;
  55 import java.awt.Toolkit;
  56 import java.awt.TrayIcon;
  57 import java.awt.Window;
  58 import java.awt.datatransfer.Clipboard;
  59 import java.awt.dnd.DragGestureEvent;
  60 import java.awt.dnd.DragGestureListener;
  61 import java.awt.dnd.DragGestureRecognizer;
  62 import java.awt.dnd.DragSource;
  63 import java.awt.dnd.DropTarget;
  64 import java.awt.dnd.InvalidDnDOperationException;
  65 import java.awt.dnd.MouseDragGestureRecognizer;
  66 import java.awt.dnd.peer.DragSourceContextPeer;
  67 import java.awt.event.InputEvent;
  68 import java.awt.event.InvocationEvent;
  69 import java.awt.event.KeyEvent;
  70 import java.awt.font.TextAttribute;
  71 import java.awt.im.InputMethodHighlight;
  72 import java.awt.im.spi.InputMethodDescriptor;


 475         return (int) ((CGraphicsDevice) GraphicsEnvironment
 476                 .getLocalGraphicsEnvironment().getDefaultScreenDevice())
 477                 .getXResolution();
 478     }
 479 
 480     @Override
 481     public Insets getScreenInsets(final GraphicsConfiguration gc) {
 482         return ((CGraphicsConfig) gc).getDevice().getScreenInsets();
 483     }
 484 
 485     @Override
 486     public void sync() {
 487         // flush the OGL pipeline (this is a no-op if OGL is not enabled)
 488         OGLRenderQueue.sync();
 489         // setNeedsDisplay() selector was sent to the appropriate CALayer so now
 490         // we have to flush the native selectors queue.
 491         flushNativeSelectors();
 492     }
 493 
 494     @Override
 495     public RobotPeer createRobot(GraphicsDevice screen) throws AWTException {
 496         if (screen instanceof CGraphicsDevice) {
 497             return new CRobot((CGraphicsDevice) screen);
 498         }
 499         return super.createRobot(screen);
 500     }
 501 
 502     private native boolean isCapsLockOn();
 503 
 504     /*
 505      * NOTE: Among the keys this method is supposed to check,
 506      * only Caps Lock works as a true locking key with OS X.
 507      * There is no Scroll Lock key on modern Apple keyboards,
 508      * and with a PC keyboard plugged in Scroll Lock is simply
 509      * ignored: no LED lights up if you press it.
 510      * The key located at the same position on Apple keyboards
 511      * as Num Lock on PC keyboards is called Clear, doesn't lock
 512      * anything and is used for entirely different purpose.
 513      */
 514     @Override
 515     public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException {
 516         switch (keyCode) {
 517             case KeyEvent.VK_NUM_LOCK:
 518             case KeyEvent.VK_SCROLL_LOCK:
 519             case KeyEvent.VK_KANA_LOCK:


< prev index next >