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