diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java index 84469bd649f..5cd03b1b062 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java @@ -1,5 +1,5 @@ /* - * 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 @@ -24,15 +24,18 @@ */ package sun.awt.X11; -import java.util.Vector; -import java.awt.*; -import java.awt.peer.*; -import java.awt.event.*; -import sun.awt.im.*; -import sun.awt.*; -import java.util.logging.*; -import java.lang.reflect.Field; -import java.util.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.MenuBar; +import java.awt.Rectangle; +import java.awt.peer.FramePeer; +import java.util.logging.Level; +import java.util.logging.Logger; class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { private static Logger log = Logger.getLogger("sun.awt.X11.XFramePeer"); @@ -285,19 +288,20 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { * Let's see if this is a window state protocol message, and * if it is - decode a new state in terms of java constants. */ - Integer newState = XWM.getWM().isStateChange(this, ev); - if (newState == null) { + if (!XWM.getWM().isStateChange(this, ev)) { + stateLog.finer("either not a state atom or state has not been changed"); return; } - int changed = state ^ newState.intValue(); + final int newState = XWM.getWM().getState(this); + int changed = state ^ newState; if (changed == 0) { stateLog.finer("State is the same: " + state); return; } int old_state = state; - state = newState.intValue(); + state = newState; if ((changed & Frame.ICONIFIED) != 0) { if ((state & Frame.ICONIFIED) != 0) { diff --git a/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java index 8ae5334cba3..f61c476e57e 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-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 @@ -26,17 +26,15 @@ package sun.awt.X11; -import java.awt.*; +import java.awt.Frame; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.logging.LogManager; -import java.awt.*; -import java.awt.image.*; -import java.util.*; -class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol { - final static Logger log = Logger.getLogger("sun.awt.X11.XNETProtocol"); +final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol +{ + private final static Logger log = Logger.getLogger("sun.awt.X11.XNETProtocol"); private final static Logger iconLog = Logger.getLogger("sun.awt.X11.icon.XNETProtocol"); + private static Logger stateLog = Logger.getLogger("sun.awt.X11.states.XNETProtocol"); /** * XStateProtocol @@ -276,6 +274,7 @@ class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol { boolean doStateProtocol() { boolean res = active() && checkProtocol(XA_NET_SUPPORTED, XA_NET_WM_STATE); + stateLog.finer("doStateProtocol() returns " + res); return res; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java index b94d01f2257..069568519d8 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -1,5 +1,5 @@ /* - * 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 @@ -25,11 +25,9 @@ package sun.awt.X11; import java.awt.*; -import java.awt.event.*; -import java.awt.peer.*; -import java.beans.PropertyChangeListener; -import sun.awt.*; -import java.util.*; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.datatransfer.Clipboard; import java.awt.dnd.DragSource; import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragGestureEvent; @@ -37,20 +35,27 @@ import java.awt.dnd.DragGestureRecognizer; import java.awt.dnd.MouseDragGestureRecognizer; import java.awt.dnd.InvalidDnDOperationException; import java.awt.dnd.peer.DragSourceContextPeer; -import java.awt.image.*; -import java.security.*; import java.awt.im.InputMethodHighlight; import java.awt.im.spi.InputMethodDescriptor; -import java.awt.datatransfer.Clipboard; +import java.awt.image.ColorModel; +import java.awt.peer.*; +import java.beans.PropertyChangeListener; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.LookAndFeel; import javax.swing.UIDefaults; -import java.util.logging.*; +import sun.awt.*; import sun.font.FontManager; import sun.misc.PerformanceLogger; import sun.print.PrintJob2D; -import java.lang.reflect.*; -public class XToolkit extends UNIXToolkit implements Runnable, XConstants { +public final class XToolkit extends UNIXToolkit implements Runnable, XConstants +{ private static Logger log = Logger.getLogger("sun.awt.X11.XToolkit"); private static Logger eventLog = Logger.getLogger("sun.awt.X11.event.XToolkit"); private static final Logger timeoutTaskLog = Logger.getLogger("sun.awt.X11.timeoutTask.XToolkit"); @@ -1871,9 +1876,7 @@ public class XToolkit extends UNIXToolkit implements Runnable, XConstants { } public boolean isAlwaysOnTopSupported() { - Iterator iter = XWM.getWM().getProtocols(XLayerProtocol.class).iterator(); - while (iter.hasNext()) { - XLayerProtocol proto = (XLayerProtocol)iter.next(); + for (XLayerProtocol proto : XWM.getWM().getProtocols(XLayerProtocol.class)) { if (proto.supportsLayer(XLayerProtocol.LAYER_ALWAYS_ON_TOP)) { return true; } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWM.java b/jdk/src/solaris/classes/sun/awt/X11/XWM.java index 68d1ff73e5f..d8e0d6b031d 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XWM.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XWM.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-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,20 +31,23 @@ package sun.awt.X11; import sun.misc.Unsafe; -import java.util.regex.*; +import java.awt.Insets; import java.awt.Frame; import java.awt.Rectangle; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; import java.util.logging.Level; -import java.util.logging.LogManager; import java.util.logging.Logger; -import java.awt.Insets; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Class incapsulating knowledge about window managers in general * Descendants should provide some information about specific window manager. */ -class XWM implements MWMConstants, XUtilConstants { +final class XWM implements MWMConstants, XUtilConstants +{ private final static Logger log = Logger.getLogger("sun.awt.X11.XWM"); private final static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XWM"); @@ -1026,21 +1029,21 @@ class XWM implements MWMConstants, XUtilConstants { /*****************************************************************************\ * Protocols support */ - HashMap, Collection> protocolsMap = new HashMap, Collection>(); + private HashMap, Collection> protocolsMap = new HashMap, Collection>(); /** * Returns all protocols supporting given protocol interface */ - Collection getProtocols(Class protocolInterface) { - Collection res = protocolsMap.get(protocolInterface); + Collection getProtocols(Class protocolInterface) { + Collection res = (Collection) protocolsMap.get(protocolInterface); if (res != null) { - return (Collection)res; + return res; } else { - return new LinkedList(); + return new LinkedList(); } } - void addProtocol(Class protocolInterface, XProtocol protocol) { - Collection protocols = getProtocols(protocolInterface); + private void addProtocol(Class protocolInterface, T protocol) { + Collection protocols = getProtocols(protocolInterface); protocols.add(protocol); protocolsMap.put(protocolInterface, protocols); } @@ -1085,9 +1088,7 @@ class XWM implements MWMConstants, XUtilConstants { } /* FALLTROUGH */ case Frame.MAXIMIZED_BOTH: - Iterator iter = getProtocols(XStateProtocol.class).iterator(); - while (iter.hasNext()) { - XStateProtocol proto = (XStateProtocol)iter.next(); + for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { if (proto.supportsState(state)) { return true; } @@ -1105,10 +1106,8 @@ class XWM implements MWMConstants, XUtilConstants { int getExtendedState(XWindowPeer window) { - Iterator iter = getProtocols(XStateProtocol.class).iterator(); int state = 0; - while (iter.hasNext()) { - XStateProtocol proto = (XStateProtocol)iter.next(); + for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { state |= proto.getState(window); } if (state != 0) { @@ -1127,18 +1126,17 @@ class XWM implements MWMConstants, XUtilConstants { /* * Check if property change is a window state protocol message. - * If it is - return the new state as Integer, otherwise return null */ - Integer isStateChange(XDecoratedPeer window, XPropertyEvent e) { + boolean isStateChange(XDecoratedPeer window, XPropertyEvent e) { if (!window.isShowing()) { stateLog.finer("Window is not showing"); - return null; + return false; } int wm_state = window.getWMState(); if (wm_state == XlibWrapper.WithdrawnState) { stateLog.finer("WithdrawnState"); - return null; + return false; } else { stateLog.finer("Window WM_STATE is " + wm_state); } @@ -1147,26 +1145,26 @@ class XWM implements MWMConstants, XUtilConstants { is_state_change = true; } - Iterator iter = getProtocols(XStateProtocol.class).iterator(); - while (iter.hasNext()) { - XStateProtocol proto = (XStateProtocol)iter.next(); + for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { is_state_change |= proto.isStateChange(e); + stateLog.finest(proto + ": is state changed = " + is_state_change); } - int res = 0; + return is_state_change; + } - if (is_state_change) { - if (wm_state == XlibWrapper.IconicState) { - res = Frame.ICONIFIED; - } else { - res = Frame.NORMAL; - } - res |= getExtendedState(window); - } - if (is_state_change) { - return Integer.valueOf(res); + /* + * Returns current state (including extended) of a given window. + */ + int getState(XDecoratedPeer window) { + int res = 0; + final int wm_state = window.getWMState(); + if (wm_state == XlibWrapper.IconicState) { + res = Frame.ICONIFIED; } else { - return null; + res = Frame.NORMAL; } + res |= getExtendedState(window); + return res; } /*****************************************************************************\ @@ -1180,9 +1178,7 @@ class XWM implements MWMConstants, XUtilConstants { * in XLayerProtocol */ void setLayer(XWindowPeer window, int layer) { - Iterator iter = getProtocols(XLayerProtocol.class).iterator(); - while (iter.hasNext()) { - XLayerProtocol proto = (XLayerProtocol)iter.next(); + for (XLayerProtocol proto : getProtocols(XLayerProtocol.class)) { if (proto.supportsLayer(layer)) { proto.setLayer(window, layer); } @@ -1191,9 +1187,7 @@ class XWM implements MWMConstants, XUtilConstants { } void setExtendedState(XWindowPeer window, int state) { - Iterator iter = getProtocols(XStateProtocol.class).iterator(); - while (iter.hasNext()) { - XStateProtocol proto = (XStateProtocol)iter.next(); + for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { if (proto.supportsState(state)) { proto.setState(window, state); break; @@ -1239,9 +1233,7 @@ class XWM implements MWMConstants, XUtilConstants { void unshadeKludge(XDecoratedPeer window) { assert(window.isShowing()); - Iterator iter = getProtocols(XStateProtocol.class).iterator(); - while (iter.hasNext()) { - XStateProtocol proto = (XStateProtocol)iter.next(); + for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { proto.unshadeKludge(window); } XToolkit.XSync();