jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java
author darcy
Thu, 13 Mar 2014 12:40:27 -0700
changeset 23647 41d22f2dbeb5
parent 22567 5816a47fa4dd
child 23660 371d2d8dadc9
permissions -rw-r--r--
8033712: Fix more serial lint warnings in sun.awt Reviewed-by: alanb, serb, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 18178
diff changeset
     2
 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
107
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
    27
import java.awt.Color;
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
    28
import java.awt.Dimension;
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
    29
import java.awt.Font;
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
    30
import java.awt.FontMetrics;
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
    31
import java.awt.Frame;
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
    32
import java.awt.Graphics;
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
    33
import java.awt.Insets;
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
    34
import java.awt.MenuBar;
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
    35
import java.awt.Rectangle;
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
    36
import java.awt.peer.FramePeer;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2453
diff changeset
    37
import sun.util.logging.PlatformLogger;
2453
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
    38
import sun.awt.AWTAccessor;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 129
diff changeset
    40
class XFramePeer extends XDecoratedPeer implements FramePeer {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2453
diff changeset
    41
    private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XFramePeer");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2453
diff changeset
    42
    private static PlatformLogger stateLog = PlatformLogger.getLogger("sun.awt.X11.states");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2453
diff changeset
    43
    private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XFramePeer");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    XMenuBarPeer menubarPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    MenuBar menubar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    int state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private Boolean undecorated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private static final int MENUBAR_HEIGHT_IF_NO_MENUBAR = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private int lastAppliedMenubarHeight = MENUBAR_HEIGHT_IF_NO_MENUBAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    XFramePeer(Frame target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        super(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    XFramePeer(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        super(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    void preInit(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        super.preInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        Frame target = (Frame)(this.target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        // set the window attributes for this Frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        winAttr.initialState = target.getExtendedState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        state = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        undecorated = Boolean.valueOf(target.isUndecorated());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        winAttr.nativeDecor = !target.isUndecorated();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        if (winAttr.nativeDecor) {
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 18178
diff changeset
    70
            winAttr.decorations = XWindowAttributesData.AWT_DECOR_ALL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        } else {
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 18178
diff changeset
    72
            winAttr.decorations = XWindowAttributesData.AWT_DECOR_NONE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        }
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 129
diff changeset
    74
        winAttr.functions = MWMConstants.MWM_FUNC_ALL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        winAttr.isResizable = true; // target.isResizable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        winAttr.title = target.getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        winAttr.initialResizability = target.isResizable();
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
    78
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2453
diff changeset
    79
            log.fine("Frame''s initial attributes: decor {0}, resizable {1}, undecorated {2}, initial state {3}",
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2453
diff changeset
    80
                     Integer.valueOf(winAttr.decorations), Boolean.valueOf(winAttr.initialResizability),
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2453
diff changeset
    81
                     Boolean.valueOf(!winAttr.nativeDecor), Integer.valueOf(winAttr.initialState));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    void postInit(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        super.postInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        setupState(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 107
diff changeset
    90
    @Override
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 107
diff changeset
    91
    boolean isTargetUndecorated() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        if (undecorated != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            return undecorated.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            return ((Frame)target).isUndecorated();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    void setupState(boolean onInit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        if (onInit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            state = winAttr.initialState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if ((state & Frame.ICONIFIED) != 0) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 129
diff changeset
   104
            setInitialState(XUtilConstants.IconicState);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        } else {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 129
diff changeset
   106
            setInitialState(XUtilConstants.NormalState);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        setExtendedState(state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public void setMenuBar(MenuBar mb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        // state_lock should always be the second after awt_lock
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            synchronized(getStateLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                if (mb == menubar) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                if (mb == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    if (menubar != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                        menubarPeer.xSetVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                        menubar = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                        menubarPeer.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                        menubarPeer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    menubar = mb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                    menubarPeer = (XMenuBarPeer) mb.getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                    if (menubarPeer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                        menubarPeer.init((Frame)target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        reshapeMenubarPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    XMenuBarPeer getMenubarPeer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        return menubarPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    int getMenuBarHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if (menubarPeer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            return menubarPeer.getDesiredHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            return MENUBAR_HEIGHT_IF_NO_MENUBAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    void updateChildrenSizes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        super.updateChildrenSizes();
7235
06d6f1977762 6990904: (dav) on oel5.5, Frame doesn't show if the Frame has only a MenuBar as its component.
dav
parents: 5506
diff changeset
   153
        int height = getMenuBarHeight();
06d6f1977762 6990904: (dav) on oel5.5, Frame doesn't show if the Frame has only a MenuBar as its component.
dav
parents: 5506
diff changeset
   154
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        // XWindow.reshape calls XBaseWindow.xSetBounds, which acquires
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        // the AWT lock, so we have to acquire the AWT lock here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        // before getStateLock() to avoid a deadlock with the Toolkit thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        // when this method is called on the EDT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            synchronized(getStateLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                int width = dimensions.getClientSize().width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                if (menubarPeer != null) {
7235
06d6f1977762 6990904: (dav) on oel5.5, Frame doesn't show if the Frame has only a MenuBar as its component.
dav
parents: 5506
diff changeset
   164
                    menubarPeer.reshape(0, 0, width, height);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * In addition to reshaping menubarPeer (by using 'updateChildrenSizes')
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * this method also performs some frame reaction on this (i.e. layouts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * other frame children, if required)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    final void reshapeMenubarPeer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        XToolkit.executeOnEventHandlerThread(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    updateChildrenSizes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                    boolean heightChanged = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                    int height = getMenuBarHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                        // Neither 'XToolkit.awtLock()' nor 'getStateLock()'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                        // is acquired under this call, and it looks to run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                        // thread-safely. I currently see no reason to move
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                        // it under following 'synchronized' clause.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                    synchronized(getStateLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                        if (height != lastAppliedMenubarHeight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                            lastAppliedMenubarHeight = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                            heightChanged = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                    if (heightChanged) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                        // To make frame contents be re-layout (copied from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                        // 'XDecoratedPeer.revalidate()'). These are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                        // 'synchronized', because can recursively call client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                        // methods, which are not supposed to be called with locks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                        // acquired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                        target.invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                        target.validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public void setMaximizedBounds(Rectangle b) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   212
        if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   213
            insLog.fine("Setting maximized bounds to " + b);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   214
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        if (b == null) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        maxBounds = new Rectangle(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            XSizeHints hints = getHints();
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 129
diff changeset
   220
            hints.set_flags(hints.get_flags() | (int)XUtilConstants.PMaxSize);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            if (b.width != Integer.MAX_VALUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                hints.set_max_width(b.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                hints.set_max_width((int)XlibWrapper.DisplayWidth(XToolkit.getDisplay(), XlibWrapper.DefaultScreen(XToolkit.getDisplay())));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            if (b.height != Integer.MAX_VALUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                hints.set_max_height(b.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                hints.set_max_height((int)XlibWrapper.DisplayHeight(XToolkit.getDisplay(), XlibWrapper.DefaultScreen(XToolkit.getDisplay())));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            }
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   231
            if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   232
                insLog.finer("Setting hints, flags " + XlibWrapper.hintsToString(hints.get_flags()));
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   233
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            XlibWrapper.XSetWMNormalHints(XToolkit.getDisplay(), window, hints.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
2453
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   240
    public int getState() {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   241
        synchronized(getStateLock()) {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   242
            return state;
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   243
        }
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   244
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public void setState(int newState) {
2453
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   247
        synchronized(getStateLock()) {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   248
            if (!isShowing()) {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   249
                stateLog.finer("Frame is not showing");
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   250
                state = newState;
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   251
                return;
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   252
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        changeState(newState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    void changeState(int newState) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        int changed = state ^ newState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        int changeIconic = changed & Frame.ICONIFIED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        boolean iconic = (newState & Frame.ICONIFIED) != 0;
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   261
        if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   262
            stateLog.finer("Changing state, old state {0}, new state {1}(iconic {2})",
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2453
diff changeset
   263
                       Integer.valueOf(state), Integer.valueOf(newState), Boolean.valueOf(iconic));
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   264
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        if (changeIconic != 0 && iconic) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   266
            if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   267
                stateLog.finer("Iconifying shell " + getShell() + ", this " + this + ", screen " + getScreenNumber());
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   268
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                int res = XlibWrapper.XIconifyWindow(XToolkit.getDisplay(), getShell(), getScreenNumber());
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   272
                if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   273
                    stateLog.finer("XIconifyWindow returned " + res);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   274
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        if ((changed & ~Frame.ICONIFIED) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            setExtendedState(newState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        if (changeIconic != 0 && !iconic) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   284
            if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   285
                stateLog.finer("DeIconifying " + this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   286
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            xSetVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    void setExtendedState(int newState) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        XWM.getWM().setExtendedState(this, newState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    public void handlePropertyNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        super.handlePropertyNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        XPropertyEvent ev = xev.get_xproperty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   299
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   300
            log.finer("Property change {0}", ev);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   301
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
         * Let's see if this is a window state protocol message, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
         * if it is - decode a new state in terms of java constants.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
         */
107
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
   306
        if (!XWM.getWM().isStateChange(this, ev)) {
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
   307
            stateLog.finer("either not a state atom or state has not been changed");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
107
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
   311
        final int newState = XWM.getWM().getState(this);
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
   312
        int changed = state ^ newState;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        if (changed == 0) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   314
            if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   315
                stateLog.finer("State is the same: " + state);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   316
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        int old_state = state;
107
ed0c7cfb3666 6632140: minor refactoring for XWM
son
parents: 2
diff changeset
   321
        state = newState;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
2453
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   323
        // sync target with peer
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   324
        AWTAccessor.getFrameAccessor().setExtendedState((Frame)target, state);
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 449
diff changeset
   325
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        if ((changed & Frame.ICONIFIED) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            if ((state & Frame.ICONIFIED) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                stateLog.finer("Iconified");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                handleIconify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                stateLog.finer("DeIconified");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                content.purgeIconifiedExposeEvents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                handleDeiconify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        handleStateChange(old_state, state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    // NOTE: This method may be called by privileged threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    public void handleStateChange(int oldState, int newState) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        super.handleStateChange(oldState, newState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        for (ToplevelStateListener topLevelListenerTmp : toplevelStateListeners) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            topLevelListenerTmp.stateChangedJava(oldState, newState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    public void setVisible(boolean vis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        if (vis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            setupState(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            if ((state & Frame.MAXIMIZED_BOTH) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                XWM.getWM().setExtendedState(this, state & ~Frame.MAXIMIZED_BOTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        super.setVisible(vis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        if (vis && maxBounds != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            setMaximizedBounds(maxBounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    void setInitialState(int wm_state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            XWMHints hints = getWMHints();
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 129
diff changeset
   366
            hints.set_flags((int)XUtilConstants.StateHint | hints.get_flags());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            hints.set_initial_state(wm_state);
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   368
            if (stateLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   369
                stateLog.fine("Setting initial WM state on " + this + " to " + wm_state);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 16706
diff changeset
   370
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        if (menubarPeer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            menubarPeer.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        super.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    boolean isMaximized() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        return (state & (Frame.MAXIMIZED_VERT  | Frame.MAXIMIZED_HORIZ)) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    static final int CROSSHAIR_INSET = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    static final int BUTTON_Y = CROSSHAIR_INSET + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    static final int BUTTON_W = 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    static final int BUTTON_H = 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    static final int SYS_MENU_X = CROSSHAIR_INSET + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    static final int SYS_MENU_CONTAINED_X = SYS_MENU_X + 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    static final int SYS_MENU_CONTAINED_Y = BUTTON_Y + 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    static final int SYS_MENU_CONTAINED_W = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    static final int SYS_MENU_CONTAINED_H = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    static final int MAXIMIZE_X_DIFF = CROSSHAIR_INSET + BUTTON_W;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    static final int MAXIMIZE_CONTAINED_X_DIFF = MAXIMIZE_X_DIFF - 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    static final int MAXIMIZE_CONTAINED_Y = BUTTON_Y + 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    static final int MAXIMIZE_CONTAINED_W = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    static final int MAXIMIZE_CONTAINED_H = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    static final int MINIMIZE_X_DIFF = MAXIMIZE_X_DIFF + BUTTON_W;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    static final int MINIMIZE_CONTAINED_X_DIFF = MINIMIZE_X_DIFF - 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    static final int MINIMIZE_CONTAINED_Y = BUTTON_Y + 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    static final int MINIMIZE_CONTAINED_W = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    static final int MINIMIZE_CONTAINED_H = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    static final int TITLE_X = SYS_MENU_X + BUTTON_W;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    static final int TITLE_W_DIFF = BUTTON_W * 3 + CROSSHAIR_INSET * 2 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    static final int TITLE_MID_Y = BUTTON_Y + (BUTTON_H / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    static final int MENUBAR_X = CROSSHAIR_INSET + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    static final int MENUBAR_Y = BUTTON_Y + BUTTON_H;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    static final int HORIZ_RESIZE_INSET = CROSSHAIR_INSET + BUTTON_H;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    static final int VERT_RESIZE_INSET = CROSSHAIR_INSET + BUTTON_W;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * Print the native component by rendering the Motif look ourselves.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * We also explicitly print the MenuBar since a MenuBar isn't a subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * of Component (and thus it has no "print" method which gets called by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * default).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    public void print(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        super.print(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        Frame f = (Frame)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        Insets finsets = f.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        Dimension fsize = f.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        Color bg = f.getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        Color fg = f.getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        Color highlight = bg.brighter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        Color shadow = bg.darker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        // Well, we could query for the currently running window manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        // and base the look on that, or we could just always do dtwm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        // aim, tball, and levenson all agree we'll just do dtwm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        if (hasDecorations(XWindowAttributesData.AWT_DECOR_BORDER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            // top outer -- because we'll most likely be drawing on white paper,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            // for aesthetic reasons, don't make any part of the outer border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            // pure white
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            if (highlight.equals(Color.white)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                g.setColor(new Color(230, 230, 230));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            g.drawLine(0, 0, fsize.width, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            g.drawLine(0, 1, fsize.width - 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            // left outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            // if (highlight.equals(Color.white)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            //     g.setColor(new Color(230, 230, 230));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            // }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            // else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            //     g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            // }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            g.drawLine(0, 0, 0, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            g.drawLine(1, 0, 1, fsize.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            // bottom cross-hair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            g.drawLine(CROSSHAIR_INSET + 1, fsize.height - CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                       fsize.width - CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                       fsize.height - CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            // right cross-hair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            g.drawLine(fsize.width - CROSSHAIR_INSET, CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                       fsize.width - CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                       fsize.height - CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            // bottom outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            g.drawLine(1, fsize.height, fsize.width, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            g.drawLine(2, fsize.height - 1, fsize.width, fsize.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            // right outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            g.drawLine(fsize.width, 1, fsize.width, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            g.drawLine(fsize.width - 1, 2, fsize.width - 1, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            // top cross-hair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            g.drawLine(CROSSHAIR_INSET, CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                       fsize.width - CROSSHAIR_INSET, CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            // left cross-hair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            g.drawLine(CROSSHAIR_INSET, CROSSHAIR_INSET, CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                       fsize.height - CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        if (hasDecorations(XWindowAttributesData.AWT_DECOR_TITLE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            if (hasDecorations(XWindowAttributesData.AWT_DECOR_MENU)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                // system menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                g.setColor(bg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                g.fill3DRect(SYS_MENU_X, BUTTON_Y, BUTTON_W, BUTTON_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                g.fill3DRect(SYS_MENU_CONTAINED_X, SYS_MENU_CONTAINED_Y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                             SYS_MENU_CONTAINED_W, SYS_MENU_CONTAINED_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            // title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            // g.setColor(bg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            g.fill3DRect(TITLE_X, BUTTON_Y, fsize.width - TITLE_W_DIFF, BUTTON_H,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                         true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            if (hasDecorations(XWindowAttributesData.AWT_DECOR_MINIMIZE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                // minimize button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                // g.setColor(bg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                g.fill3DRect(fsize.width - MINIMIZE_X_DIFF, BUTTON_Y, BUTTON_W,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                             BUTTON_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                g.fill3DRect(fsize.width - MINIMIZE_CONTAINED_X_DIFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                             MINIMIZE_CONTAINED_Y, MINIMIZE_CONTAINED_W,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                             MINIMIZE_CONTAINED_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            if (hasDecorations(XWindowAttributesData.AWT_DECOR_MAXIMIZE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                // maximize button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                // g.setColor(bg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                g.fill3DRect(fsize.width - MAXIMIZE_X_DIFF, BUTTON_Y, BUTTON_W,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                             BUTTON_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                g.fill3DRect(fsize.width - MAXIMIZE_CONTAINED_X_DIFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                             MAXIMIZE_CONTAINED_Y, MAXIMIZE_CONTAINED_W,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                             MAXIMIZE_CONTAINED_H, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            // title bar text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            g.setColor(fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            Font sysfont = new Font(Font.SANS_SERIF, Font.PLAIN, 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            g.setFont(sysfont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            FontMetrics sysfm = g.getFontMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            String ftitle = f.getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            g.drawString(ftitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                         ((TITLE_X + TITLE_X + fsize.width - TITLE_W_DIFF) / 2) -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                         (sysfm.stringWidth(ftitle) / 2),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                         TITLE_MID_Y + sysfm.getMaxDescent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        if (f.isResizable() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            hasDecorations(XWindowAttributesData.AWT_DECOR_RESIZEH)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
            // add resize cross hairs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            // upper-left horiz (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            g.drawLine(1, HORIZ_RESIZE_INSET, CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                       HORIZ_RESIZE_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            // upper-left vert (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            g.drawLine(VERT_RESIZE_INSET, 1, VERT_RESIZE_INSET, CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            // upper-right horiz (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            g.drawLine(fsize.width - CROSSHAIR_INSET + 1, HORIZ_RESIZE_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                       fsize.width, HORIZ_RESIZE_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            // upper-right vert (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            g.drawLine(fsize.width - VERT_RESIZE_INSET - 1, 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                       fsize.width - VERT_RESIZE_INSET - 1, CROSSHAIR_INSET + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
            // lower-left horiz (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            g.drawLine(1, fsize.height - HORIZ_RESIZE_INSET - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                       CROSSHAIR_INSET, fsize.height - HORIZ_RESIZE_INSET - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            // lower-left vert (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
            g.drawLine(VERT_RESIZE_INSET, fsize.height - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                       VERT_RESIZE_INSET, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            // lower-right horiz (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            g.drawLine(fsize.width - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                       fsize.height - HORIZ_RESIZE_INSET - 1, fsize.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                       fsize.height - HORIZ_RESIZE_INSET - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            // lower-right vert (shadow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            // g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            g.drawLine(fsize.width - VERT_RESIZE_INSET - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                       fsize.height - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                       fsize.width - VERT_RESIZE_INSET - 1, fsize.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            // upper-left horiz (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            g.drawLine(2, HORIZ_RESIZE_INSET + 1, CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                       HORIZ_RESIZE_INSET + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            // upper-left vert (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            g.drawLine(VERT_RESIZE_INSET + 1, 2, VERT_RESIZE_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                       CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
            // upper-right horiz (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
            g.drawLine(fsize.width - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                       HORIZ_RESIZE_INSET + 1, fsize.width - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                       HORIZ_RESIZE_INSET + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            // upper-right vert (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            g.drawLine(fsize.width - VERT_RESIZE_INSET, 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                       fsize.width - VERT_RESIZE_INSET, CROSSHAIR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            // lower-left horiz (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            g.drawLine(2, fsize.height - HORIZ_RESIZE_INSET, CROSSHAIR_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                       fsize.height - HORIZ_RESIZE_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            // lower-left vert (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            g.drawLine(VERT_RESIZE_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                       fsize.height - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                       VERT_RESIZE_INSET + 1, fsize.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            // lower-right horiz (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            g.drawLine(fsize.width - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                       fsize.height - HORIZ_RESIZE_INSET, fsize.width - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                       fsize.height - HORIZ_RESIZE_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            // lower-right vert (highlight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            // g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            g.drawLine(fsize.width - VERT_RESIZE_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                       fsize.height - CROSSHAIR_INSET + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                       fsize.width - VERT_RESIZE_INSET, fsize.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        XMenuBarPeer peer = menubarPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            Insets insets = getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            Graphics ng = g.create();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            int menubarX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            int menubarY = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            if (hasDecorations(XWindowAttributesData.AWT_DECOR_BORDER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                menubarX += CROSSHAIR_INSET + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                    menubarY += CROSSHAIR_INSET + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            if (hasDecorations(XWindowAttributesData.AWT_DECOR_TITLE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                menubarY += BUTTON_H;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                ng.translate(menubarX, menubarY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                peer.print(ng);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                ng.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    public void setBoundsPrivate(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        setBounds(x, y, width, height, SET_BOUNDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    public Rectangle getBoundsPrivate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        return getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    }
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 7668
diff changeset
   662
16706
4b243017cd27 8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents: 15983
diff changeset
   663
    public void emulateActivation(boolean doActivate) {
4b243017cd27 8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents: 15983
diff changeset
   664
        if (doActivate) {
4b243017cd27 8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents: 15983
diff changeset
   665
            handleWindowFocusIn(0);
4b243017cd27 8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents: 15983
diff changeset
   666
        } else {
4b243017cd27 8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents: 15983
diff changeset
   667
            handleWindowFocusOut(null, 0);
4b243017cd27 8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents: 15983
diff changeset
   668
        }
4b243017cd27 8010375: sun.swing.JLightweightFrame should be implemented for XToolkit
ant
parents: 15983
diff changeset
   669
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
}