/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
{
private static final PlatformLogger buffersLog = PlatformLogger.getLogger("sun.awt.X11.XComponentPeer.multibuffer");
private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XComponentPeer");
private static final PlatformLogger fontLog = PlatformLogger.getLogger("sun.awt.X11.font.XComponentPeer");
private static final PlatformLogger enableLog = PlatformLogger.getLogger("sun.awt.X11.enable.XComponentPeer");
private static final PlatformLogger shapeLog = PlatformLogger.getLogger("sun.awt.X11.shape.XComponentPeer");
boolean paintPending = false;
boolean isLayouting = false;
boolean enabled;
// Actually used only by XDecoratedPeer
protected int boundsOperation;
// Colors calculated as on Motif using MotifColorUtilties.
// If you use these, call updateMotifColors() in the peer's Constructor and
// setBackground(). Examples are XCheckboxPeer and XButtonPeer.
XComponentPeer() {
}
super(params);
}
}
/**
* Standard peer constructor, with corresponding Component
*/
super(target);
}
}
Color c;
Font f;
if (isInitialReshape()) {
}
// If any of our heavyweight ancestors are disable, we should be too
// See 6176875 for more information
setEnabled(false);
break;
}
}
setVisible(true);
}
}
protected boolean isInitialReshape() {
return true;
}
try {
} finally {
}
}
public boolean isReparentSupported() {
return System.getProperty("sun.awt.X11.XComponentPeer.reparentNotSupported", "false").equals("false");
}
public boolean isObscured() {
return true;
}
}
}
}
return true;
}
public boolean canDetermineObscurity() {
return true;
}
/*************************************************
* FOCUS STUFF
*************************************************/
/**
* Keeps the track of focused state of the _NATIVE_ window
*/
boolean bHasFocus = false;
/**
* Descendants should use this method to determine whether or not native window
* has focus.
*/
final public boolean hasFocus() {
return bHasFocus;
}
/**
* Called when component receives focus
*/
bHasFocus = true;
}
/**
* Called when component loses focus
*/
bHasFocus = false;
}
public boolean isFocusable() {
/* should be implemented by other sub-classes */
return false;
}
try {
}
ctor.setAccessible(true);
return ctor;
}
});
}
}
catch (ClassNotFoundException e) {
throw new NoClassDefFoundError("java.awt.SequencedEvent.");
}
catch (PrivilegedActionException ex) {
throw new NoClassDefFoundError("java.awt.SequencedEvent.");
}
catch (InstantiationException e) {
assert false;
}
catch (IllegalAccessException e) {
assert false;
}
catch (InvocationTargetException e) {
assert false;
}
return null;
}
// TODO: consider moving it to KeyboardFocusManagerPeerImpl
boolean focusedWindowChangeAllowed, long time,
{
{
return true;
}
int result = XKeyboardFocusManagerPeer.
switch (result) {
return false;
// Currently we just generate focus events like we deal with lightweight instead of calling
// XSetInputFocus on native window
/**
* The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
* checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
* been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
* in requests list - and it breaks our requests sequence as first record on WGF should be the last
* focus owner which had focus before WLF. So, we should not add request record for such requests
* but store this component in mostRecent - and return true as before for compatibility.
*/
if (parentWindow == null) {
return rejectFocusRequestHelper("WARNING: Parent window is null");
}
return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
}
/*
* Passing null 'actualFocusedWindow' as we don't want to restore focus on it
* when a component inside a Frame is requesting focus.
* See 6314575 for details.
*/
// If parent window can be made focused and has been made focused(synchronously)
// then we can proceed with children, otherwise we retreat.
return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
}
// Motif compatibility code
// Either lightweight or excessive request - all events are generated.
return true;
}
return false;
}
return false;
}
focusGained((FocusEvent)e);
} else {
focusLost((FocusEvent)e);
}
}
}
/*************************************************
* END OF FOCUS STUFF
*************************************************/
public void setVisible(boolean b) {
xSetVisible(b);
}
public void hide() {
setVisible(false);
}
/**
* @see java.awt.peer.ComponentPeer
*/
if ( p != null ) {
}
}
}
if (repaintNeeded) {
repaint();
}
}
//
//
public boolean isEnabled() {
return enabled;
}
public void enable() {
setEnabled(true);
}
public void disable() {
setEnabled(false);
}
}
repaint();
}
}
// clear rect here to emulate X clears rect before Expose
// paint peer
paint(g);
// allow target to change the picture
}
this.x = x;
this.y = y;
layout();
}
}
Rectangle r = e.getUpdateRect();
if (!(e instanceof IgnorePaintEvent)) {
}
if (true) {
switch(e.getID()) {
case PaintEvent.UPDATE:
}
return;
case PaintEvent.PAINT:
}
return;
}
}
}
Container parent = (target instanceof Container) ? ((Container)target) : (compAccessor.getParent(target));
// Search for parent window
}
} else {
return null;
}
}
/* This method is intended to be over-ridden by peers to perform user interaction */
switch (e.getID()) {
case MouseEvent.MOUSE_PRESSED:
!target.isFocusOwner() &&
{
// Simple windows are non-focusable in X terms but focusable in Java terms.
// As X-non-focusable they don't receive any focus events - we should generate them
// by ourselfves.
// if (parentXWindow.isFocusableWindow() /*&& parentXWindow.isSimpleWindow()*/ &&
// !(getCurrentNativeFocusedWindow() == parentWindow))
// {
// setCurrentNativeFocusedWindow(parentWindow);
// WindowEvent wfg = new WindowEvent(parentWindow, WindowEvent.WINDOW_GAINED_FOCUS);
// parentWindow.dispatchEvent(wfg);
// }
}
break;
}
}
/* This method is intended to be over-ridden by peers to perform user interaction */
}
/* This method is intended to be over-ridden by peers to perform user interaction */
}
/* This method is intended to be over-ridden by peers to perform user interaction */
}
if (winPeer instanceof XFramePeer) {
}
}
}
}
if (e instanceof MouseEvent) {
if (e instanceof MouseWheelEvent) {
}
else
}
else if (e instanceof KeyEvent) {
}
}
// even if target is disabled.
}
else if (e instanceof InputMethodEvent) {
}
switch(id) {
case PaintEvent.PAINT:
// Got native painting
paintPending = false;
// Fallthrough to next statement
case PaintEvent.UPDATE:
// Skip all painting while layouting and all UPDATEs
// while waiting for native paint
if (!isLayouting && !paintPending) {
}
return;
case FocusEvent.FOCUS_LOST:
case FocusEvent.FOCUS_GAINED:
break;
case WindowEvent.WINDOW_LOST_FOCUS:
break;
default:
break;
}
}
/*
* Fix for 6385277.
* We request focus on simple Window by click in order
* the behaviour with what we have on MS Windows.
* handleJavaMouseEvent() would be more suitable place to do this
* but we want Swing to have this functionality also.
*/
{
public void run() {
// Request focus on the EDT of 'parentWindow' because
// XDecoratedPeer.requestWindowFocus() calls client code.
}
}));
}
}
super.handleButtonPressRelease(xev);
}
}
return getMinimumSize();
}
public void layout() {}
return Toolkit.getDefaultToolkit();
}
}
/*
* Draw a 3D rectangle using the Motif colors.
* "Normal" rectangles have shadows on the bottom.
* "Depressed" rectangles (such as pressed buttons) have shadows on the top,
* in which case true should be passed for topShadow.
*/
boolean topShadow) {
}
synchronized (getStateLock()) {
background = c;
}
super.setBackground(c);
repaint();
}
synchronized (getStateLock()) {
foreground = c;
}
repaint();
}
/**
* Gets the font metrics for the specified font.
* @param font the font for which font metrics is to be
* obtained
* @return the font metrics for <code>font</code>
* @see #getFont
* @see #getPeer
* @see java.awt.peer.ComponentPeer#getFontMetrics(Font)
* @see Toolkit#getFontMetrics(Font)
* @since JDK1.0
*/
}
synchronized (getStateLock()) {
if (f == null) {
f = XWindow.getDefaultFont();
}
font = f;
}
// as it stands currently we dont need to do layout or repaint since
// layout is done in the Component upon setFont.
//layout();
// target.repaint();
//repaint()?
}
return font;
}
public void updateCursorImmediately() {
}
this.pSetCursor(cursor, true);
}
/*
* The method changes the cursor.
* @param cursor - a new cursor to change to.
* @param ignoreSubComponents - if {@code true} is passed then
* the new cursor will be installed on window.
* if {@code false} is passed then
* subsequent components will try to handle
* this request and install their cursor.
*/
//ignoreSubComponents not used here
try {
} finally {
}
}
return new ToolkitImage(producer);
}
}
}
}
}
return getPreferredSize();
}
return getMinimumSize();
}
}
public void beginValidate() {
}
public void endValidate() {
}
/**
* DEPRECATED: Replaced by getInsets().
*/
return getInsets();
}
// are waiting for native painting
public boolean isPaintPending() {
return paintPending && isLayouting;
}
public boolean handlesWheelScrolling() {
return false;
}
public void beginLayout() {
// Skip all painting till endLayout
isLayouting = true;
}
public void endLayout() {
{
// if not waiting for native painting repaint damaged area
new Rectangle()));
}
isLayouting = false;
}
return getPeerBackground();
}
int rgbvals[] = new int[3];
return rgbvals;
}
c[BACKGROUND_COLOR] = getWinBackground();
if (c[BACKGROUND_COLOR] == null) {
c[BACKGROUND_COLOR] = super.getWinBackground();
}
if (c[BACKGROUND_COLOR] == null) {
}
/* Calculate Highlight Brightness */
if ((highb > 1.0) ) {
} else {
highb = 1.0f;
}
} else {
if (shadowb < 0.0) {
} else {
shadowb = 0.0f;
}
}
}
/*
c[SHADOW_COLOR] = c[BACKGROUND_COLOR].darker();
int r2 = c[SHADOW_COLOR].getRed();
int g2 = c[SHADOW_COLOR].getGreen();
int b2 = c[SHADOW_COLOR].getBlue();
*/
c[FOREGROUND_COLOR] = getPeerForeground();
if (c[FOREGROUND_COLOR] == null) {
}
/*
if ((c[BACKGROUND_COLOR].equals(c[HIGHLIGHT_COLOR]))
&& (c[BACKGROUND_COLOR].equals(c[SHADOW_COLOR]))) {
c[SHADOW_COLOR] = new Color(c[BACKGROUND_COLOR].getRed() + 75,
c[BACKGROUND_COLOR].getGreen() + 75,
c[BACKGROUND_COLOR].getBlue() + 75);
c[HIGHLIGHT_COLOR] = c[SHADOW_COLOR].brighter();
} else if (c[BACKGROUND_COLOR].equals(c[HIGHLIGHT_COLOR])) {
c[HIGHLIGHT_COLOR] = c[SHADOW_COLOR];
c[SHADOW_COLOR] = c[SHADOW_COLOR].darker();
}
*/
if (! isEnabled()) {
// Reduce the contrast
// Calculate the NTSC gray (NB: REC709 L* might be better!)
// for foreground and background; then multiply the foreground
// by the average lightness
tc = c[FOREGROUND_COLOR];
// 255 * 100 * 2
// This probably means the foreground color is black or white
}
}
return c;
}
/**
* Returns an array of Colors similar to getGUIcolors(), but using the
* System colors. This is useful if pieces of a Component (such as
* the integrated scrollbars of a List) should retain the System color
* instead of the background color set by Component.setBackground().
*/
if (systemColors == null) {
}
return systemColors;
}
/**
* Draw a 3D oval.
*/
int x, int y, int w, int h, boolean raised)
{
g.setColor(c);
}
{
g.setColor(c);
}
/*
* drawXXX() methods are used to print the native components by
* rendering the Motif look ourselves.
* ToDo(aim): needs to query native motif for more accurate color
* information.
*/
int x, int y, int w, int h, boolean raised)
{
g.setColor(c);
}
boolean raised) {
g.setColor(c);
}
int tpts_x[] = new int[3];
int tpts_y[] = new int[3];
}
} else if (v2 < 7) {
// enforce a minimum handle size
v2 = 7;
}
// paint the background slightly darker
{
g.setColor(d);
if (horizontal) {
} else {
}
}
// paint the thumb and arrows in the normal background color
if (v1 > 0) {
if (horizontal) {
} else {
}
}
if (horizontal) {
} else {
}
if (horizontal) {
} else {
}
// // // // draw the "highlighted" edges
// outline & arrows
if (horizontal) {
// arrows
} else {
// arrows
}
// thumb
if (v1 > 0) {
if (horizontal) {
} else {
}
}
// // // // draw the "shadowed" edges
// outline && arrows
if (horizontal) {
// arrows
} else {
// arrows
}
// thumb
if (v1 > 0) {
if (horizontal) {
} else {
}
}
g.setColor(c);
}
/**
* The following multibuffering-related methods delegate to our
* associated GraphicsConfig (X11 or GLX) to handle the appropriate
* native windowing system specific actions.
*/
throws AWTException
{
}
// set the caps first, they're used when creating the bb
}
return backBufferCaps;
}
{
}
if (backBuffer == 0) {
throw new IllegalStateException("Buffers have not been created");
}
}
}
if (backBuffer == 0) {
throw new IllegalStateException("Buffers have not been created");
}
return xBackBuffer;
}
public void destroyBuffers() {
}
backBuffer = 0;
xBackBuffer = null;
}
// End of multi-buffering
}
/* FIX ME - FIX ME need to implement InputMethods
if (parent instanceof java.awt.Frame ||
parent instanceof java.awt.Dialog) {
if (add)
((MInputMethodControl)parent.getPeer()).addTextComponent((MComponentPeer)this);
else
((MInputMethodControl)parent.getPeer()).removeTextComponent((MComponentPeer)this);
}
*/
}
/**
* Returns true if this event is disabled and shouldn't be processed by window
* Currently if target component is disabled the following event will be disabled on window:
* ButtonPress, ButtonRelease, KeyPress, KeyRelease, EnterNotify, LeaveNotify, MotionNotify
*/
enableLog.finest("Component is {1}, checking for disabled event {0}", e, (isEnabled()?"enabled":"disable"));
}
if (!isEnabled()) {
switch (e.get_type()) {
case XConstants.ButtonPress:
case XConstants.ButtonRelease:
case XConstants.KeyPress:
case XConstants.KeyRelease:
case XConstants.EnterNotify:
case XConstants.LeaveNotify:
case XConstants.MotionNotify:
}
return true;
}
}
switch(e.get_type()) {
case XConstants.MapNotify:
case XConstants.UnmapNotify:
return true;
}
return super.isEventDisabled(e);
}
return background;
}
return foreground;
}
return font;
}
}
synchronized(getStateLock()) {
if (boundsOperation == DEFAULT_OPERATION) {
} else if (operation == RESET_OPERATION) {
}
}
}
switch (operation) {
case SET_LOCATION:
return "SET_LOCATION";
case SET_SIZE:
return "SET_SIZE";
case SET_CLIENT_SIZE:
return "SET_CLIENT_SIZE";
default:
case SET_BOUNDS:
return "SET_BOUNDS";
}
}
/**
* Lowers this component at the bottom of the above HW peer. If the above parameter
* is null then the method places this component at the top of the Z-order.
*/
try{
}finally{
}
}
if (peer instanceof XComponentPeer) {
}
// It is lightweight container, it might contain heavyweight components attached to this
// peer
}
}
}
/****** DropTargetPeer implementation ********************/
}
}
}
}
}
}
}
}
/**
* Applies the shape to the X-window.
* @since 1.7
*/
if (XlibUtil.isShapingSupported()) {
"*** INFO: Setting shape: PEER: " + this
+ "; WINDOW: " + getWindow()
+ "; TARGET: " + target
+ "; SHAPE: " + shape);
}
try {
getWindow(),
);
} else {
getWindow(),
0, 0,
0, 0,
);
}
} finally {
}
} else {
}
}
}
if (graphicsConfig != null) {
}
}
// If the new visual differs from the old one, the peer must be
// recreated because X11 does not allow changing the visual on the fly.
// So we even skip the initGraphicsConfiguration() call.
// The initial assignment should happen though, hence the != -1 thing.
return true;
}
return false;
}
}