Search in sources :

Example 1 with ComponentPeer

use of java.awt.peer.ComponentPeer in project intellij-community by JetBrains.

the class WindowManagerImpl method updateFrameBounds.

private int updateFrameBounds(IdeFrameImpl frame) {
    int extendedState = frame.getExtendedState();
    if (SystemInfo.isMacOSLion) {
        @SuppressWarnings("deprecation") ComponentPeer peer = frame.getPeer();
        if (peer instanceof FramePeer) {
            // frame.state is not updated by jdk so get it directly from peer
            extendedState = ((FramePeer) peer).getState();
        }
    }
    boolean isMaximized = extendedState == Frame.MAXIMIZED_BOTH || isFullScreenSupportedInCurrentOS() && frame.isInFullScreen();
    boolean usePreviousBounds = isMaximized && myFrameBounds != null && frame.getBounds().contains(new Point((int) myFrameBounds.getCenterX(), (int) myFrameBounds.getCenterY()));
    if (!usePreviousBounds) {
        myFrameBounds = frame.getBounds();
    }
    return extendedState;
}
Also used : FramePeer(java.awt.peer.FramePeer) ComponentPeer(java.awt.peer.ComponentPeer)

Example 2 with ComponentPeer

use of java.awt.peer.ComponentPeer in project intellij-community by JetBrains.

the class X11UiUtil method hasWindowProperty.

private static boolean hasWindowProperty(JFrame frame, long name, long expected) {
    if (X11 == null)
        return false;
    try {
        @SuppressWarnings("deprecation") ComponentPeer peer = frame.getPeer();
        long window = (Long) X11.getWindow.invoke(peer);
        long[] values = X11.getLongArrayProperty(window, name, XA_ATOM);
        if (values != null) {
            for (long value : values) {
                if (value == expected)
                    return true;
            }
        }
        return false;
    } catch (Throwable t) {
        LOG.info("cannot check window property", t);
        return false;
    }
}
Also used : ComponentPeer(java.awt.peer.ComponentPeer)

Example 3 with ComponentPeer

use of java.awt.peer.ComponentPeer in project intellij-community by JetBrains.

the class X11UiUtil method toggleFullScreenMode.

public static void toggleFullScreenMode(JFrame frame) {
    if (X11 == null)
        return;
    try {
        @SuppressWarnings("deprecation") ComponentPeer peer = frame.getPeer();
        long window = (Long) X11.getWindow.invoke(peer);
        long screen = (Long) X11.getScreenNumber.invoke(peer);
        long rootWindow = X11.getRootWindow(screen);
        X11.sendClientMessage(rootWindow, window, X11.NET_WM_STATE, NET_WM_STATE_TOGGLE, X11.NET_WM_STATE_FULLSCREEN);
    } catch (Throwable t) {
        LOG.info("cannot toggle mode", t);
    }
}
Also used : ComponentPeer(java.awt.peer.ComponentPeer)

Example 4 with ComponentPeer

use of java.awt.peer.ComponentPeer in project intellij-community by JetBrains.

the class Win7TaskBar method getHandle.

private static WinDef.HWND getHandle(IdeFrame frame) {
    try {
        ComponentPeer peer = ((Component) frame).getPeer();
        Method getHWnd = peer.getClass().getMethod("getHWnd");
        return new WinDef.HWND(new Pointer((Long) getHWnd.invoke(peer)));
    } catch (Throwable e) {
        LOG.error(e);
        return null;
    }
}
Also used : Pointer(com.sun.jna.Pointer) Method(java.lang.reflect.Method) ComponentPeer(java.awt.peer.ComponentPeer)

Example 5 with ComponentPeer

use of java.awt.peer.ComponentPeer in project jdk8u_jdk by JetBrains.

the class Queue method coalescePaintEvent.

private boolean coalescePaintEvent(PaintEvent e) {
    ComponentPeer sourcePeer = ((Component) e.getSource()).peer;
    if (sourcePeer != null) {
        sourcePeer.coalescePaintEvent(e);
    }
    EventQueueItem[] cache = ((Component) e.getSource()).eventCache;
    if (cache == null) {
        return false;
    }
    int index = eventToCacheIndex(e);
    if (index != -1 && cache[index] != null) {
        PaintEvent merged = mergePaintEvents(e, (PaintEvent) cache[index].event);
        if (merged != null) {
            cache[index].event = merged;
            return true;
        }
    }
    return false;
}
Also used : ComponentPeer(java.awt.peer.ComponentPeer)

Aggregations

ComponentPeer (java.awt.peer.ComponentPeer)41 LightweightPeer (java.awt.peer.LightweightPeer)10 Component (java.awt.Component)5 Container (java.awt.Container)3 InputContext (java.awt.im.InputContext)2 ConstrainableGraphics (sun.awt.ConstrainableGraphics)2 Pointer (com.sun.jna.Pointer)1 BufferCapabilities (java.awt.BufferCapabilities)1 HeadlessException (java.awt.HeadlessException)1 AffineTransform (java.awt.geom.AffineTransform)1 ColorModel (java.awt.image.ColorModel)1 FramePeer (java.awt.peer.FramePeer)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 TooManyListenersException (java.util.TooManyListenersException)1 AppContext (sun.awt.AppContext)1 CausedFocusEvent (sun.awt.CausedFocusEvent)1 SunToolkit (sun.awt.SunToolkit)1 WindowClosingListener (sun.awt.WindowClosingListener)1 SunDropTargetEvent (sun.awt.dnd.SunDropTargetEvent)1