Java Code Examples for sun.awt.AWTAccessor

The following examples show how to use sun.awt.AWTAccessor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk8u_jdk   Source File: BasicComboPopup.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the JList used in the popup to display
 * the items in the combo box model. This method is called when the UI class
 * is created.
 *
 * @return a <code>JList</code> used to display the combo box items
 */
protected JList createList() {
    return new JList( comboBox.getModel() ) {
        public void processMouseEvent(MouseEvent e)  {
            if (BasicGraphicsUtils.isMenuShortcutKeyDown(e))  {
                // Fix for 4234053. Filter out the Control Key from the list.
                // ie., don't allow CTRL key deselection.
                Toolkit toolkit = Toolkit.getDefaultToolkit();
                MouseEvent newEvent = new MouseEvent(
                                   (Component)e.getSource(), e.getID(), e.getWhen(),
                                   e.getModifiers() ^ toolkit.getMenuShortcutKeyMask(),
                                   e.getX(), e.getY(),
                                   e.getXOnScreen(), e.getYOnScreen(),
                                   e.getClickCount(),
                                   e.isPopupTrigger(),
                                   MouseEvent.NOBUTTON);
                MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
                meAccessor.setCausedByTouchEvent(newEvent,
                    meAccessor.isCausedByTouchEvent(e));
                e = newEvent;
            }
            super.processMouseEvent(e);
        }
    };
}
 
Example 2
Source Project: jdk8u-jdk   Source File: XDialogPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
boolean isFocusedWindowModalBlocker() {
    Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
    XWindowPeer focusedWindowPeer = null;

    if (focusedWindow != null) {
        focusedWindowPeer = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(focusedWindow);
    } else {
        /*
         * For the case when a potential blocked window is not yet focused
         * on the Java level (e.g. it's just been mapped) we're asking for the
         * focused window on the native level.
         */
        focusedWindowPeer = getNativeFocusedWindowPeer();
    }
    synchronized (getStateLock()) {
        if (focusedWindowPeer != null && focusedWindowPeer.modalBlocker == target) {
            return true;
        }
    }
    return super.isFocusedWindowModalBlocker();
}
 
Example 3
Source Project: Bytecoder   Source File: BasicComboPopup.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates the JList used in the popup to display
 * the items in the combo box model. This method is called when the UI class
 * is created.
 *
 * @return a <code>JList</code> used to display the combo box items
 */
protected JList<Object> createList() {
    return new JList<Object>( comboBox.getModel() ) {
        public void processMouseEvent(MouseEvent e)  {
            if (BasicGraphicsUtils.isMenuShortcutKeyDown(e))  {
                // Fix for 4234053. Filter out the Control Key from the list.
                // ie., don't allow CTRL key deselection.
                Toolkit toolkit = Toolkit.getDefaultToolkit();
                MouseEvent newEvent = new MouseEvent(
                                   (Component)e.getSource(), e.getID(), e.getWhen(),
                                   e.getModifiersEx() ^ toolkit.getMenuShortcutKeyMaskEx(),
                                   e.getX(), e.getY(),
                                   e.getXOnScreen(), e.getYOnScreen(),
                                   e.getClickCount(),
                                   e.isPopupTrigger(),
                                   MouseEvent.NOBUTTON);
                MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
                meAccessor.setCausedByTouchEvent(newEvent,
                    meAccessor.isCausedByTouchEvent(e));
                e = newEvent;
            }
            super.processMouseEvent(e);
        }
    };
}
 
Example 4
Source Project: TencentKona-8   Source File: XWindowPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void repositionSecurityWarning() {
    // NOTE: On KWin if the window/border snapping option is enabled,
    // the Java window may be swinging while it's being moved.
    // This doesn't make the application unusable though looks quite ugly.
    // Probobly we need to find some hint to assign to our Security
    // Warning window in order to exclude it from the snapping option.
    // We are not currently aware of existance of such a property.
    if (warningWindow != null) {
        // We can't use the coordinates stored in the XBaseWindow since
        // they are zeros for decorated frames.
        AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
        int x = compAccessor.getX(target);
        int y = compAccessor.getY(target);
        int width = compAccessor.getWidth(target);
        int height = compAccessor.getHeight(target);
        warningWindow.reposition(x, y, width, height);
    }
}
 
Example 5
public void actionPerformed(final ActionEvent e) {
    final Object src = e.getSource();

    final PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
        public Void run() {
            actionPerformedImpl(e);
            return null;
        }
    };

    final AccessControlContext stack = AccessController.getContext();
    final AccessControlContext srcAcc = AWTAccessor.getComponentAccessor().getAccessControlContext((Component)src);
    final AccessControlContext eventAcc = AWTAccessor.getAWTEventAccessor().getAccessControlContext(e);

        if (srcAcc == null) {
            javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc);
        } else {
            javaSecurityAccess.doIntersectionPrivilege(
                new PrivilegedAction<Void>() {
                    public Void run() {
                        javaSecurityAccess.doIntersectionPrivilege(action, eventAcc);
                        return null;
                     }
            }, stack, srcAcc);
        }
}
 
Example 6
Source Project: openjdk-jdk9   Source File: CInputMethod.java    License: GNU General Public License v2.0 6 votes vote down vote up
private LWComponentPeer<?, ?> getNearestNativePeer(Component comp) {
    if (comp==null)
        return null;
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    ComponentPeer peer = acc.getPeer(comp);
    if (peer==null)
        return null;

    while (peer instanceof java.awt.peer.LightweightPeer) {
        comp = comp.getParent();
        if (comp==null)
            return null;
        peer = acc.getPeer(comp);
        if (peer==null)
            return null;
    }

    if (peer instanceof LWComponentPeer)
        return (LWComponentPeer)peer;

    return null;
}
 
Example 7
Source Project: jdk8u-jdk   Source File: XFileDialogPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * handle the selection event
 */
void handleSelection(String file) {

    int index = file.lastIndexOf(java.io.File.separatorChar);

    if (index == -1) {
        savedDir = this.dir;
        savedFile = file;
    } else {
        savedDir = file.substring(0, index+1);
        savedFile = file.substring(index+1);
    }

    String[] fileNames = fileList.getSelectedItems();
    int filesNumber = (fileNames != null) ? fileNames.length : 0;
    File[] files = new File[filesNumber];
    for (int i = 0; i < filesNumber; i++) {
        files[i] = new File(savedDir, fileNames[i]);
    }

    AWTAccessor.FileDialogAccessor fileDialogAccessor = AWTAccessor.getFileDialogAccessor();

    fileDialogAccessor.setDirectory(target, savedDir);
    fileDialogAccessor.setFile(target, savedFile);
    fileDialogAccessor.setFiles(target, files);
}
 
Example 8
Source Project: Bytecoder   Source File: RepaintManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Validate all of the components that have been marked invalid.
 * @see #addInvalidComponent
 */
public void validateInvalidComponents() {
    final java.util.List<Component> ic;
    synchronized(this) {
        if (invalidComponents == null) {
            return;
        }
        ic = invalidComponents;
        invalidComponents = null;
    }
    int n = ic.size();
    for(int i = 0; i < n; i++) {
        final Component c = ic.get(i);
        AccessControlContext stack = AccessController.getContext();
        AccessControlContext acc =
            AWTAccessor.getComponentAccessor().getAccessControlContext(c);
        javaSecurityAccess.doIntersectionPrivilege(
            new PrivilegedAction<Void>() {
                public Void run() {
                    c.validate();
                    return null;
                }
            }, stack, acc);
    }
}
 
Example 9
void forwardKeyEvent(long child, KeyEvent e) {
    byte[] bdata = AWTAccessor.getAWTEventAccessor().getBData(e);
    long data = Native.toData(bdata);
    if (data == 0) {
        return;
    }
    XKeyEvent ke = new XKeyEvent(data);
    ke.set_window(child);
    XToolkit.awtLock();
    try {
        XlibWrapper.XSendEvent(XToolkit.getDisplay(), child, false, XConstants.NoEventMask, data);
    }
    finally {
        XToolkit.awtUnlock();
    }
    XlibWrapper.unsafe.freeMemory(data);
}
 
Example 10
Source Project: openjdk-jdk9   Source File: XWindowPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void recursivelySetIcon(java.util.List<IconInfo> icons) {
    dumpIcons(winAttr.icons);
    setIconHints(icons);
    Window target = (Window)this.target;
    Window[] children = target.getOwnedWindows();
    int cnt = children.length;
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    for (int i = 0; i < cnt; i++) {
        final ComponentPeer childPeer = acc.getPeer(children[i]);
        if (childPeer != null && childPeer instanceof XWindowPeer) {
            if (((XWindowPeer)childPeer).winAttr.iconsInherited) {
                ((XWindowPeer)childPeer).winAttr.icons = icons;
                ((XWindowPeer)childPeer).recursivelySetIcon(icons);
            }
        }
    }
}
 
Example 11
Source Project: openjdk-jdk9   Source File: WToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void ungrab(Window w) {
    final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
    if (peer != null) {
        ((WWindowPeer) peer).ungrab();
    }
}
 
Example 12
Source Project: jdk8u-dev-jdk   Source File: UIManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example 13
Source Project: openjdk-jdk8u   Source File: CWarningWindow.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void updateIconSize() {
    int newSize = -1;

    if (ownerWindow != null) {
        Insets insets = ownerWindow.getInsets();
        int max = Math.max(insets.top, Math.max(insets.bottom,
                Math.max(insets.left, insets.right)));
        if (max < 24) {
            newSize = 0;
        } else if (max < 32) {
            newSize = 1;
        } else if (max < 48) {
            newSize = 2;
        } else {
            newSize = 3;
        }
    }
    // Make sure we have a valid size
    if (newSize == -1) {
        newSize = 0;
    }

    synchronized (lock) {
        if (newSize != currentSize) {
            currentSize = newSize;
            IconInfo ico = getSecurityIconInfo(currentSize, 0);
            AWTAccessor.getWindowAccessor().setSecurityWarningSize(
                ownerWindow, ico.getWidth(), ico.getHeight());
        }
    }
}
 
Example 14
Source Project: openjdk-8   Source File: XDecoratedPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Graphics getGraphics() {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    return getGraphics(content.surfaceData,
                       compAccessor.getForeground(target),
                       compAccessor.getBackground(target),
                       compAccessor.getFont(target));
}
 
Example 15
Source Project: openjdk-jdk9   Source File: XWindowPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void updateShape() {
    // Shape shape = ((Window)target).getShape();
    Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
    if (shape != null) {
        applyShape(Region.getInstance(shape, null));
    }
}
 
Example 16
/**
 * Called exclusively by the native C code.
 */
private void setFileInternal(String directory, String[] filenames) {
    AWTAccessor.FileDialogAccessor accessor = AWTAccessor
            .getFileDialogAccessor();

    if (filenames == null) {
        accessor.setDirectory(fd, null);
        accessor.setFile(fd, null);
        accessor.setFiles(fd, null);
    } else {
        // Fix 6987233: add the trailing slash if it's absent
        String with_separator = directory;
        if (directory != null) {
            with_separator = directory.endsWith(File.separator) ?
                    directory : (directory + File.separator);
        }
        accessor.setDirectory(fd, with_separator);
        accessor.setFile(fd, filenames[0]);

        int filesNumber = (filenames != null) ? filenames.length : 0;
        File[] files = new File[filesNumber];
        for (int i = 0; i < filesNumber; i++) {
            files[i] = new File(directory, filenames[i]);
        }
        accessor.setFiles(fd, files);
    }
}
 
Example 17
Source Project: openjdk-8   Source File: XTextAreaPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setTransferHandler(TransferHandler newHandler) {
    TransferHandler oldHandler = (TransferHandler)
        getClientProperty(AWTAccessor.getClientPropertyKeyAccessor()
                              .getJComponent_TRANSFER_HANDLER());
    putClientProperty(AWTAccessor.getClientPropertyKeyAccessor()
                          .getJComponent_TRANSFER_HANDLER(),
                      newHandler);

    firePropertyChange("transferHandler", oldHandler, newHandler);
}
 
Example 18
@Override
public void setTransferHandler(TransferHandler newHandler) {
    TransferHandler oldHandler = (TransferHandler)
        getClientProperty(AWTAccessor.getClientPropertyKeyAccessor()
                              .getJComponent_TRANSFER_HANDLER());
    putClientProperty(AWTAccessor.getClientPropertyKeyAccessor()
                          .getJComponent_TRANSFER_HANDLER(),
                      newHandler);

    firePropertyChange("transferHandler", oldHandler, newHandler);
}
 
Example 19
Source Project: jdk8u_jdk   Source File: UIManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example 20
void forwardEventToParent(MouseEvent e) {
    MouseEvent newEvent = new MouseEvent(
        getParent(), e.getID(), e.getWhen(), e.getModifiers(),
        e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(),
        e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON );
    MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
    meAccessor.setCausedByTouchEvent(newEvent,
        meAccessor.isCausedByTouchEvent(e));
    getParent().dispatchEvent(newEvent);
}
 
Example 21
Source Project: openjdk-8   Source File: XDialogPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void blockWindows(java.util.List<Window> toBlock) {
    Vector<XWindowPeer> javaToplevels = null;
    XToolkit.awtLock();
    try {
        javaToplevels = XWindowPeer.collectJavaToplevels();
        for (Window w : toBlock) {
            XWindowPeer wp = (XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);
            if (wp != null) {
                wp.setModalBlocked((Dialog)target, true, javaToplevels);
            }
        }
    } finally {
        XToolkit.awtUnlock();
    }
}
 
Example 22
Source Project: jdk8u_jdk   Source File: XPopupMenuPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/************************************************
 *
 * Access to target's fields
 *
 ************************************************/

//Fix for 6267144: PIT: Popup menu label is not shown, XToolkit
Font getTargetFont() {
    if (popupMenuTarget == null) {
        return XWindow.getDefaultFont();
    }
    return AWTAccessor.getMenuComponentAccessor()
               .getFont_NoClientCode(popupMenuTarget);
}
 
Example 23
Source Project: jdk8u_jdk   Source File: WToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void showOrHideTouchKeyboard(Component comp, AWTEvent e) {
    if (!(comp instanceof TextComponent) &&
        !(comp instanceof JTextComponent)) {
        return;
    }

    if ((e instanceof MouseEvent) && isComponentValidForTouchKeyboard(comp)) {
        MouseEvent me = (MouseEvent) e;
        if (me.getID() == MouseEvent.MOUSE_PRESSED) {
            if (AWTAccessor.getMouseEventAccessor().isCausedByTouchEvent(me)) {
                compOnTouchDownEvent = new WeakReference<>(comp);
            } else {
                compOnMousePressedEvent = new WeakReference<>(comp);
            }
        } else if (me.getID() == MouseEvent.MOUSE_RELEASED) {
            if (AWTAccessor.getMouseEventAccessor().isCausedByTouchEvent(me)) {
                if (compOnTouchDownEvent.get() == comp) {
                    showTouchKeyboard(true);
                }
                compOnTouchDownEvent = NULL_COMPONENT_WR;
            } else {
                if (compOnMousePressedEvent.get() == comp) {
                    showTouchKeyboard(false);
                }
                compOnMousePressedEvent = NULL_COMPONENT_WR;
            }
        }
    } else if (e instanceof FocusEvent) {
        FocusEvent fe = (FocusEvent) e;
        if (fe.getID() == FocusEvent.FOCUS_LOST) {
            // Hide the touch keyboard, if not a text component gains focus.
            if (!isComponentValidForTouchKeyboard(fe.getOppositeComponent())) {
                hideTouchKeyboard();
            }
        }
    }
}
 
Example 24
Source Project: openjdk-jdk9   Source File: WTaskbarPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setWindowProgressValue(Window window, int value) {
    WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window);
    if (wp != null) {
        ShellFolder.invoke(() -> {
            setProgressValue(wp.getHWnd(), value);
            return null;
        });
    }
}
 
Example 25
Source Project: dragonwell8_jdk   Source File: XWindowPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void dispose() {
    if (isGrabbed()) {
        if (grabLog.isLoggable(PlatformLogger.Level.FINE)) {
            grabLog.fine("Generating UngrabEvent on {0} because of the window disposal", this);
        }
        postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource()));
    }

    SunToolkit.awtLock();

    try {
        windows.remove(this);
    } finally {
        SunToolkit.awtUnlock();
    }

    if (warningWindow != null) {
        warningWindow.destroy();
    }

    removeRootPropertyEventDispatcher();
    mustControlStackPosition = false;
    super.dispose();

    /*
     * Fix for 6457980.
     * When disposing an owned Window we should implicitly
     * return focus to its decorated owner because it won't
     * receive WM_TAKE_FOCUS.
     */
    if (isSimpleWindow()) {
        if (target == XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow()) {
            Window owner = getDecoratedOwner((Window)target);
            ((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(owner)).requestWindowFocus();
        }
    }
}
 
Example 26
@Override
public void invalidate() {
    synchronized (getTreeLock()) {
        final Container parent = getParent();
        AWTAccessor.getComponentAccessor().setParent(this, null);
        try {
            super.invalidate();
        } finally {
            AWTAccessor.getComponentAccessor().setParent(this, parent);
        }
    }
}
 
Example 27
Source Project: dragonwell8_jdk   Source File: UIManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void initialize() {
    Properties swingProps = loadSwingProperties();
    initializeSystemDefaults(swingProps);
    initializeDefaultLAF(swingProps);
    initializeAuxiliaryLAFs(swingProps);
    initializeInstalledLAFs(swingProps);

    // Install Swing's PaintEventDispatcher
    if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
        sun.awt.PaintEventDispatcher.setPaintEventDispatcher(
                                    new SwingPaintEventDispatcher());
    }
    // Install a hook that will be invoked if no one consumes the
    // KeyEvent.  If the source isn't a JComponent this will process
    // key bindings, if the source is a JComponent it implies that
    // processKeyEvent was already invoked and thus no need to process
    // the bindings again, unless the Component is disabled, in which
    // case KeyEvents will no longer be dispatched to it so that we
    // handle it here.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
            addKeyEventPostProcessor(new KeyEventPostProcessor() {
                public boolean postProcessKeyEvent(KeyEvent e) {
                    Component c = e.getComponent();

                    if ((!(c instanceof JComponent) ||
                         (c != null && !c.isEnabled())) &&
                            JComponent.KeyboardState.shouldProcess(e) &&
                            SwingUtilities.processKeyBindings(e)) {
                        e.consume();
                        return true;
                    }
                    return false;
                }
            });
    AWTAccessor.getComponentAccessor().
        setRequestFocusController(JComponent.focusController);
}
 
Example 28
Source Project: openjdk-jdk9   Source File: WTaskbarPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setWindowIconBadge(Window window, final Image image) {
    WWindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(window);
    if (wp != null) {
        int[] buffer = imageToArray(image);
        ShellFolder.invoke(() -> {
           setOverlayIcon(wp.getHWnd(), buffer,
                            buffer != null ? image.getWidth(null) : 0,
                            buffer != null ? image.getHeight(null) : 0);
           return null;
        });
    }
}
 
Example 29
Source Project: TencentKona-8   Source File: XWindowPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void removeFromTransientFors() {
    // the head of the chain of this window
    XWindowPeer thisChain = this;
    // the head of the current chain
    // nextTransientFor is always not null as this window is in the chain
    XWindowPeer otherChain = nextTransientFor;
    // the set of blockers in this chain: if this dialog blocks some other
    // modal dialogs, their blocked windows should stay in this dialog's chain
    Set<XWindowPeer> thisChainBlockers = new HashSet<XWindowPeer>();
    thisChainBlockers.add(this);
    // current chain iterator in the order from next to prev
    XWindowPeer chainToSplit = prevTransientFor;
    while (chainToSplit != null) {
        XWindowPeer blocker = (XWindowPeer) AWTAccessor.getComponentAccessor().getPeer(chainToSplit.modalBlocker);
        if (thisChainBlockers.contains(blocker)) {
            // add to this dialog's chain
            setToplevelTransientFor(thisChain, chainToSplit, true, false);
            thisChain = chainToSplit;
            thisChainBlockers.add(chainToSplit);
        } else {
            // leave in the current chain
            setToplevelTransientFor(otherChain, chainToSplit, true, false);
            otherChain = chainToSplit;
        }
        chainToSplit = chainToSplit.prevTransientFor;
    }
    restoreTransientFor(thisChain);
    thisChain.prevTransientFor = null;
    restoreTransientFor(otherChain);
    otherChain.prevTransientFor = null;
    nextTransientFor = null;

    XToolkit.XSync();
}
 
Example 30
Source Project: openjdk-8   Source File: XSystemTrayPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void firePropertyChange(final String propertyName,
                                final Object oldValue,
                                final Object newValue) {
    Runnable runnable = new Runnable() {
            public void run() {
                AWTAccessor.getSystemTrayAccessor()
                    .firePropertyChange(target, propertyName, oldValue, newValue);
            }
        };
    invokeOnEachAppContext(runnable);
}