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

Print this page


   1 /*
   2  * Copyright (c) 2011, 2012, 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


 334  * The method returns true if some events were processed during that timeout.
 335  * @see sun.awt.SunToolkit#syncNativeQueue(long)
 336  */
 337     @Override
 338     protected boolean syncNativeQueue(long timeout) {
 339         return nativeSyncQueue(timeout);
 340     }
 341 
 342     @Override
 343     public native void beep();
 344 
 345     @Override
 346     public int getScreenResolution() throws HeadlessException {
 347         return (int) ((CGraphicsDevice) GraphicsEnvironment
 348                 .getLocalGraphicsEnvironment().getDefaultScreenDevice())
 349                 .getXResolution();
 350     }
 351 
 352     @Override
 353     public Insets getScreenInsets(final GraphicsConfiguration gc) {
 354         final CGraphicsConfig cgc = (CGraphicsConfig) gc;
 355         final int displayId = cgc.getDevice().getCGDisplayID();
 356         Rectangle fullScreen, workArea;
 357         final long screen = CWrapper.NSScreen.screenByDisplayId(displayId);
 358         try {
 359             fullScreen = CWrapper.NSScreen.frame(screen).getBounds();
 360             workArea = CWrapper.NSScreen.visibleFrame(screen).getBounds();
 361         } finally {
 362             CWrapper.NSObject.release(screen);
 363         }
 364         // Convert between Cocoa's coordinate system and Java.
 365         int bottom = workArea.y - fullScreen.y;
 366         int top = fullScreen.height - workArea.height - bottom;
 367         int left = workArea.x - fullScreen.x;
 368         int right = fullScreen.width - workArea.width - left;
 369         return  new Insets(top, left, bottom, right);
 370     }
 371 
 372     @Override
 373     public void sync() {
 374         // TODO Auto-generated method stub
 375 
 376     }
 377 
 378     @Override
 379     public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
 380         return new CRobot(target, (CGraphicsDevice)screen);
 381     }
 382 
 383     private native boolean isCapsLockOn();
 384 
 385     /*
 386      * NOTE: Among the keys this method is supposed to check,
 387      * only Caps Lock works as a true locking key with OS X.
 388      * There is no Scroll Lock key on modern Apple keyboards,
 389      * and with a PC keyboard plugged in Scroll Lock is simply


   1 /*
   2  * Copyright (c) 2011, 2013, 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


 334  * The method returns true if some events were processed during that timeout.
 335  * @see sun.awt.SunToolkit#syncNativeQueue(long)
 336  */
 337     @Override
 338     protected boolean syncNativeQueue(long timeout) {
 339         return nativeSyncQueue(timeout);
 340     }
 341 
 342     @Override
 343     public native void beep();
 344 
 345     @Override
 346     public int getScreenResolution() throws HeadlessException {
 347         return (int) ((CGraphicsDevice) GraphicsEnvironment
 348                 .getLocalGraphicsEnvironment().getDefaultScreenDevice())
 349                 .getXResolution();
 350     }
 351 
 352     @Override
 353     public Insets getScreenInsets(final GraphicsConfiguration gc) {
 354         return ((CGraphicsConfig) gc).getDevice().getScreenInsets();















 355     }
 356 
 357     @Override
 358     public void sync() {
 359         // TODO Auto-generated method stub
 360 
 361     }
 362 
 363     @Override
 364     public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
 365         return new CRobot(target, (CGraphicsDevice)screen);
 366     }
 367 
 368     private native boolean isCapsLockOn();
 369 
 370     /*
 371      * NOTE: Among the keys this method is supposed to check,
 372      * only Caps Lock works as a true locking key with OS X.
 373      * There is no Scroll Lock key on modern Apple keyboards,
 374      * and with a PC keyboard plugged in Scroll Lock is simply