src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -173,10 +173,11 @@
             initUIDefaults();
         }
         return uidefaults;
     }
 
+    @Override
     public void loadSystemColors(int[] systemColors) {
         nativeLoadSystemColors(systemColors);
         MotifColorUtilities.loadSystemColors(systemColors);
     }
 

@@ -265,10 +266,11 @@
         } finally {
             awtUnlock();
         }
         PrivilegedAction<Void> a = () -> {
             Thread shutdownThread = new Thread(ThreadGroupUtils.getRootThreadGroup(), "XToolkt-Shutdown-Thread") {
+                    @Override
                     public void run() {
                         XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
                         if (peer != null) {
                             peer.dispose();
                         }

@@ -334,22 +336,25 @@
             });
             toolkitThread.start();
         }
     }
 
+    @Override
     public ButtonPeer createButton(Button target) {
         ButtonPeer peer = new XButtonPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public FramePeer createLightweightFrame(LightweightFrame target) {
         FramePeer peer = new XLightweightFramePeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public FramePeer createFrame(Frame target) {
         FramePeer peer = new XFramePeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }

@@ -527,10 +532,11 @@
         }
     }
 
     static native void awt_toolkit_init();
 
+    @Override
     public void run() {
         awt_toolkit_init();
         run(PRIMARY_LOOP);
     }
 

@@ -667,14 +673,16 @@
     static int getDefaultScreenHeight() {
         initScreenSize();
         return screenHeight;
     }
 
+    @Override
     protected int getScreenWidth() {
         return getDefaultScreenWidth();
     }
 
+    @Override
     protected int getScreenHeight() {
         return getDefaultScreenHeight();
     }
 
     private static Rectangle getWorkArea(long root)

@@ -711,10 +719,11 @@
      * window.
      * Otherwise, i. e. if Xinerama is on or _NET_WM_WORKAREA is
      * not set, we try to calculate the insets ourselves using
      * getScreenInsetsManually method.
      */
+    @Override
     public Insets getScreenInsets(GraphicsConfiguration gc)
     {
         XNETProtocol netProto = XWM.getWM().getNETProtocol();
         if ((netProto == null) || !netProto.active())
         {

@@ -898,10 +907,11 @@
     // Need this for XMenuItemPeer.
     protected static void targetDisposedPeer(Object target, Object peer) {
         SunToolkit.targetDisposedPeer(target, peer);
     }
 
+    @Override
     public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
         return new XRobotPeer(screen.getDefaultConfiguration());
     }
 
 

@@ -909,14 +919,16 @@
      * On X, support for dynamic layout on resizing is governed by the
      * window manager.  If the window manager supports it, it happens
      * automatically.  The setter method for this property is
      * irrelevant on X.
      */
+    @Override
     public void setDynamicLayout(boolean b) {
         dynamicLayoutSetting = b;
     }
 
+    @Override
     protected boolean isDynamicLayoutSet() {
         return dynamicLayoutSetting;
     }
 
     /* Called from isDynamicLayoutActive() and from

@@ -924,28 +936,32 @@
      */
     protected boolean isDynamicLayoutSupported() {
         return XWM.getWM().supportsDynamicLayout();
     }
 
+    @Override
     public boolean isDynamicLayoutActive() {
         return isDynamicLayoutSupported();
     }
 
-
+    @Override
+    @SuppressWarnings("deprecation")
     public FontPeer getFontPeer(String name, int style){
         return new XFontPeer(name, style);
     }
 
+    @Override
     public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
         final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
         if (f != null) {
             return f.createDragSourceContextPeer(dge);
         }
 
         return XDragSourceContextPeer.createDragSourceContextPeer(dge);
     }
 
+    @Override
     @SuppressWarnings("unchecked")
     public <T extends DragGestureRecognizer> T
     createDragGestureRecognizer(Class<T> recognizerClass,
                     DragSource ds,
                     Component c,

@@ -961,92 +977,106 @@
             return (T)new XMouseDragGestureRecognizer(ds, c, srcActions, dgl);
         else
             return null;
     }
 
+    @Override
     public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) {
         XCheckboxMenuItemPeer peer = new XCheckboxMenuItemPeer(target);
         //vb157120: looks like we don't need to map menu items
         //in new menus implementation
         //targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public MenuItemPeer createMenuItem(MenuItem target) {
         XMenuItemPeer peer = new XMenuItemPeer(target);
         //vb157120: looks like we don't need to map menu items
         //in new menus implementation
         //targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public TextFieldPeer createTextField(TextField target) {
         TextFieldPeer  peer = new XTextFieldPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public LabelPeer createLabel(Label target) {
         LabelPeer  peer = new XLabelPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public ListPeer createList(java.awt.List target) {
         ListPeer peer = new XListPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public CheckboxPeer createCheckbox(Checkbox target) {
         CheckboxPeer peer = new XCheckboxPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public ScrollbarPeer createScrollbar(Scrollbar target) {
         XScrollbarPeer peer = new XScrollbarPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public ScrollPanePeer createScrollPane(ScrollPane target) {
         XScrollPanePeer peer = new XScrollPanePeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public TextAreaPeer createTextArea(TextArea target) {
         TextAreaPeer peer = new XTextAreaPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public ChoicePeer createChoice(Choice target) {
         XChoicePeer peer = new XChoicePeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public CanvasPeer createCanvas(Canvas target) {
         XCanvasPeer peer = (isXEmbedServerRequested() ? new XEmbedCanvasPeer(target) : new XCanvasPeer(target));
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public PanelPeer createPanel(Panel target) {
         PanelPeer peer = new XPanelPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public WindowPeer createWindow(Window target) {
         WindowPeer peer = new XWindowPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public DialogPeer createDialog(Dialog target) {
         DialogPeer peer = new XDialogPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }

@@ -1063,10 +1093,11 @@
                                               new GetBooleanAction("sun.awt.disableGtkFileDialogs"));
         }
         return sunAwtDisableGtkFileDialogs.booleanValue();
     }
 
+    @Override
     public FileDialogPeer createFileDialog(FileDialog target) {
         FileDialogPeer peer = null;
         // The current GtkFileChooser is available from GTK+ 2.4
         if (!getSunAwtDisableGtkFileDialogs() && checkGtkVersion(2, 4, 0)) {
             peer = new GtkFileDialogPeer(target);

@@ -1075,30 +1106,34 @@
         }
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public MenuBarPeer createMenuBar(MenuBar target) {
         XMenuBarPeer peer = new XMenuBarPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public MenuPeer createMenu(Menu target) {
         XMenuPeer peer = new XMenuPeer(target);
         //vb157120: looks like we don't need to map menu items
         //in new menus implementation
         //targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public PopupMenuPeer createPopupMenu(PopupMenu target) {
         XPopupMenuPeer peer = new XPopupMenuPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public synchronized MouseInfoPeer getMouseInfoPeer() {
         if (xPeer == null) {
             xPeer = new XMouseInfoPeer();
         }
         return xPeer;

@@ -1115,35 +1150,40 @@
         XEmbedChildProxyPeer peer = new XEmbedChildProxyPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() throws HeadlessException {
         return XKeyboardFocusManagerPeer.getInstance();
     }
 
     /**
      * Returns a new custom cursor.
      */
+    @Override
     public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
       throws IndexOutOfBoundsException {
         return new XCustomCursor(cursor, hotSpot, name);
     }
 
+    @Override
     public TrayIconPeer createTrayIcon(TrayIcon target)
       throws HeadlessException, AWTException
     {
         TrayIconPeer peer = new XTrayIconPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public SystemTrayPeer createSystemTray(SystemTray target) throws HeadlessException {
         SystemTrayPeer peer = new XSystemTrayPeer(target);
         return peer;
     }
 
+    @Override
     public boolean isTraySupported() {
         XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
         if (peer != null) {
             return peer.isAvailable();
         }

@@ -1156,20 +1196,23 @@
     }
 
     /**
      * Returns the supported cursor size
      */
+    @Override
     public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
         return XCustomCursor.getBestCursorSize(
                                                java.lang.Math.max(1,preferredWidth), java.lang.Math.max(1,preferredHeight));
     }
 
 
+    @Override
     public int getMaximumCursorColors() {
         return 2;  // Black and white.
     }
 
+    @Override
     public Map<TextAttribute, ?> mapInputMethodHighlight( InputMethodHighlight highlight) {
         return XInputMethod.mapInputMethodHighlight(highlight);
     }
     @Override
     public boolean getLockingKeyState(int key) {

@@ -1183,10 +1226,11 @@
         } finally {
             awtUnlock();
         }
     }
 
+    @Override
     public  Clipboard getSystemClipboard() {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             security.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION);
         }

@@ -1196,10 +1240,11 @@
             }
         }
         return clipboard;
     }
 
+    @Override
     public Clipboard getSystemSelection() {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             security.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION);
         }

@@ -1209,20 +1254,22 @@
             }
         }
         return selection;
     }
 
+    @Override
     public void beep() {
         awtLock();
         try {
             XlibWrapper.XBell(getDisplay(), 0);
             XlibWrapper.XFlush(getDisplay());
         } finally {
             awtUnlock();
         }
     }
 
+    @Override
     public PrintJob getPrintJob(final Frame frame, final String doctitle,
                                 final Properties props) {
 
         if (frame == null) {
             throw new NullPointerException("frame must not be null");

@@ -1234,10 +1281,11 @@
             printJob = null;
         }
         return printJob;
     }
 
+    @Override
     public PrintJob getPrintJob(final Frame frame, final String doctitle,
                 final JobAttributes jobAttributes,
                 final PageAttributes pageAttributes)
     {
         if (frame == null) {

@@ -1261,10 +1309,11 @@
         } finally {
             awtUnlock();
         }
     }
 
+    @Override
     public int getScreenResolution() {
         long display = getDisplay();
         awtLock();
         try {
             return (int) ((XlibWrapper.DisplayWidth(display,

@@ -1286,17 +1335,19 @@
             screenmodel = config.getColorModel ();
         }
         return screenmodel;
     }
 
+    @Override
     public ColorModel getColorModel() {
         return getStaticColorModel();
     }
 
     /**
      * Returns a new input method adapter descriptor for native input methods.
      */
+    @Override
     public InputMethodDescriptor getInputMethodAdapterDescriptor() throws AWTException {
         return new XInputMethodDescriptor();
     }
 
     /**

@@ -1344,10 +1395,11 @@
         if (awt_multiclick_time == 0) {
             awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
         }
     }
 
+    @Override
     public boolean isFrameStateSupported(int state)
       throws HeadlessException
     {
         if (state == Frame.NORMAL || state == Frame.ICONIFIED) {
             return true;

@@ -1386,10 +1438,11 @@
     private static boolean timeStampUpdated;
     private static long timeStamp;
 
     private static final XEventDispatcher timeFetcher =
     new XEventDispatcher() {
+            @Override
             public void dispatchEvent(XEvent ev) {
                 switch (ev.get_type()) {
                   case XConstants.PropertyNotify:
                       XPropertyEvent xpe = ev.get_xproperty();
 

@@ -1454,10 +1507,11 @@
         } finally {
             awtUnlock();
         }
         return timeStamp;
     }
+    @Override
     protected void initializeDesktopProperties() {
         desktopProperties.put("DnD.Autoscroll.initialDelay",
                               Integer.valueOf(50));
         desktopProperties.put("DnD.Autoscroll.interval",
                               Integer.valueOf(50));

@@ -1512,10 +1566,11 @@
 
     private final static String prefix  = "DnD.Cursor.";
     private final static String postfix = ".32x32";
     private static final String dndPrefix  = "DnD.";
 
+    @Override
     protected Object lazilyLoadDesktopProperty(String name) {
         if (name.startsWith(prefix)) {
             String cursorName = name.substring(prefix.length(), name.length()) + postfix;
 
             try {

@@ -1534,10 +1589,11 @@
         }
 
         return super.lazilyLoadDesktopProperty(name);
     }
 
+    @Override
     public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
         if (name == null) {
             // See JavaDoc for the Toolkit.addPropertyChangeListener() method
             return;
         }

@@ -2032,24 +2088,27 @@
     }
 
     /**
      * @see sun.awt.SunToolkit#needsXEmbedImpl
      */
+    @Override
     protected boolean needsXEmbedImpl() {
         // XToolkit implements supports for XEmbed-client protocol and
         // requires the supports from the embedding host for it to work.
         return true;
     }
 
+    @Override
     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
         return (modalityType == null) ||
                (modalityType == Dialog.ModalityType.MODELESS) ||
                (modalityType == Dialog.ModalityType.DOCUMENT_MODAL) ||
                (modalityType == Dialog.ModalityType.APPLICATION_MODAL) ||
                (modalityType == Dialog.ModalityType.TOOLKIT_MODAL);
     }
 
+    @Override
     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
         return (exclusionType == null) ||
                (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE) ||
                (exclusionType == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) ||
                (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);

@@ -2068,19 +2127,21 @@
                                    boolean removeAllEvents) {
         AWTAccessor.getEventQueueAccessor()
             .removeSourceEvents(queue, source, removeAllEvents);
     }
 
+    @Override
     public boolean isAlwaysOnTopSupported() {
         for (XLayerProtocol proto : XWM.getWM().getProtocols(XLayerProtocol.class)) {
             if (proto.supportsLayer(XLayerProtocol.LAYER_ALWAYS_ON_TOP)) {
                 return true;
             }
         }
         return false;
     }
 
+    @Override
     public boolean useBufferPerWindow() {
         return XToolkit.getBackingStoreType() == XConstants.NotUseful;
     }
 
     /**

@@ -2385,15 +2446,17 @@
     private static boolean oops_move;
 
     /**
      * @inheritDoc
      */
+    @Override
     protected boolean syncNativeQueue(final long timeout) {
         XBaseWindow win = XBaseWindow.getXAWTRootWindow();
 
         if (oops_waiter == null) {
             oops_waiter = new XEventDispatcher() {
+                    @Override
                     public void dispatchEvent(XEvent e) {
                         if (e.get_type() == XConstants.ConfigureNotify) {
                             // OOPS ConfigureNotify event catched
                             oops_updated = true;
                             awtLockNotifyAll();

@@ -2436,17 +2499,19 @@
             removeEventDispatcher(win.getWindow(), oops_waiter);
             eventLog.finer("Exiting syncNativeQueue");
             awtUnlock();
         }
     }
+    @Override
     public void grab(Window w) {
         final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
         if (peer != null) {
             ((XWindowPeer) peer).setGrab(true);
         }
     }
 
+    @Override
     public void ungrab(Window w) {
         final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
         if (peer != null) {
             ((XWindowPeer) peer).setGrab(false);
         }

@@ -2456,18 +2521,21 @@
      * desktop.
      * <p>
      * The methods of java.awt.Desktop class are supported on the Gnome desktop.
      * Check if the running desktop is Gnome by checking the window manager.
      */
+    @Override
     public boolean isDesktopSupported(){
         return XDesktopPeer.isDesktopSupported();
     }
 
+    @Override
     public DesktopPeer createDesktopPeer(Desktop target){
         return new XDesktopPeer();
     }
 
+    @Override
     public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
         return areExtraMouseButtonsEnabled;
     }
 
     @Override