提交 7b0264f6 编写于 作者: S son

6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont

Summary: unnedded code has been removed.  Added getter for XWindow.defaultFont to initialize it lazily.
Reviewed-by: dav
上级 e7590d65
/*
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -31,17 +31,13 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.DefaultKeyboardFocusManager;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.KeyboardFocusManager;
import java.awt.MenuBar;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.SystemColor;
import java.awt.Toolkit;
......@@ -60,12 +56,9 @@ import java.awt.event.InvocationEvent;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
import java.awt.peer.CanvasPeer;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer;
import java.awt.peer.PanelPeer;
import java.awt.peer.WindowPeer;
import java.lang.reflect.*;
import java.security.*;
import java.util.Collection;
......@@ -821,7 +814,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
public void setFont(Font f) {
synchronized (getStateLock()) {
if (f == null) {
f = defaultFont;
f = XWindow.getDefaultFont();
}
font = f;
}
......
/*
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -218,7 +218,7 @@ public class XMenuItemPeer implements MenuItemPeer {
Font getTargetFont() {
if (target == null) {
return XWindow.defaultFont;
return XWindow.getDefaultFont();
}
try {
return (Font)m_getFont.invoke(target, new Object[0]);
......@@ -227,7 +227,7 @@ public class XMenuItemPeer implements MenuItemPeer {
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return XWindow.defaultFont;
return XWindow.getDefaultFont();
}
String getTargetLabel() {
......
/*
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -187,7 +187,7 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer {
//Fix for 6267144: PIT: Popup menu label is not shown, XToolkit
Font getTargetFont() {
if (popupMenuTarget == null) {
return XWindow.defaultFont;
return XWindow.getDefaultFont();
}
try {
return (Font)m_getFont.invoke(popupMenuTarget, new Object[0]);
......@@ -196,7 +196,7 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer {
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return XWindow.defaultFont;
return XWindow.getDefaultFont();
}
String getTargetLabel() {
......
/*
* Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -31,11 +31,8 @@ import java.awt.peer.TrayIconPeer;
import sun.awt.*;
import java.awt.image.*;
import java.text.BreakIterator;
import java.util.Vector;
import java.lang.reflect.Field;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.AbstractQueue;
import java.util.concurrent.ArrayBlockingQueue;
import java.security.AccessController;
import java.security.PrivilegedAction;
......@@ -629,7 +626,7 @@ public class XTrayIconPeer implements TrayIconPeer {
final static int TOOLTIP_MAX_LENGTH = 64;
final static int TOOLTIP_MOUSE_CURSOR_INDENT = 5;
final static Color TOOLTIP_BACKGROUND_COLOR = new Color(255, 255, 220);
final static Font TOOLTIP_TEXT_FONT = XWindow.defaultFont;
final static Font TOOLTIP_TEXT_FONT = XWindow.getDefaultFont();
Tooltip(XTrayIconPeer xtiPeer, Frame parent) {
super(parent, Color.black);
......
/*
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -92,8 +92,16 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
SurfaceData surfaceData;
XRepaintArea paintArea;
// fallback default font object
final static Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
private static Font defaultFont;
static synchronized Font getDefaultFont() {
if (null == defaultFont) {
defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
}
return defaultFont;
}
/*
* Keeps all buttons which were pressed at the time of the last mouse
......@@ -333,7 +341,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
}
Font font = afont;
if (font == null) {
font = defaultFont;
font = XWindow.getDefaultFont();
}
return new SunGraphics2D(surfData, fgColor, bgColor, font);
}
......@@ -902,13 +910,11 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
super.handleConfigureNotifyEvent(xev);
insLog.log(Level.FINER, "Configure, {0}, event disabled: {1}",
new Object[] {xev, isEventDisabled(xev)});
new Object[] {xev.get_xconfigure(), isEventDisabled(xev)});
if (isEventDisabled(xev)) {
return;
}
long eventWindow = xev.get_xany().get_window();
// if ( Check if it's a resize, a move, or a stacking order change )
// {
Rectangle bounds = getBounds();
......@@ -982,7 +988,6 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
// called directly from this package, unlike handleKeyRelease.
// un-final it if you need to override it in a subclass.
final void handleKeyPress(XKeyEvent ev) {
int keycode = java.awt.event.KeyEvent.VK_UNDEFINED;
long keysym[] = new long[2];
char unicodeKey = 0;
keysym[0] = NoSymbol;
......@@ -1066,7 +1071,6 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
}
// un-private it if you need to call it from elsewhere
private void handleKeyRelease(XKeyEvent ev) {
int keycode = java.awt.event.KeyEvent.VK_UNDEFINED;
long keysym[] = new long[2];
char unicodeKey = 0;
keysym[0] = NoSymbol;
......
/*
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -112,9 +112,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
PARENT_WINDOW, Long.valueOf(0)}));
}
// fallback default font object
static Font defaultFont;
/*
* This constant defines icon size recommended for using.
* Apparently, we should use XGetIconSizes which should
......@@ -162,10 +159,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
Font f = target.getFont();
if (f == null) {
if (defaultFont == null) {
defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
}
f = defaultFont;
f = XWindow.getDefaultFont();
target.setFont(f);
// we should not call setFont because it will call a repaint
// which the peer may not be ready to do yet.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册