jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java
changeset 3938 ef327bd847c0
parent 2453 35e5fab82613
child 4214 0fa32d38146b
equal deleted inserted replaced
3934:487e1aa949c4 3938:ef327bd847c0
    32 import java.awt.Graphics;
    32 import java.awt.Graphics;
    33 import java.awt.Insets;
    33 import java.awt.Insets;
    34 import java.awt.MenuBar;
    34 import java.awt.MenuBar;
    35 import java.awt.Rectangle;
    35 import java.awt.Rectangle;
    36 import java.awt.peer.FramePeer;
    36 import java.awt.peer.FramePeer;
    37 import java.util.logging.Level;
    37 import sun.util.logging.PlatformLogger;
    38 import java.util.logging.Logger;
       
    39 import sun.awt.AWTAccessor;
    38 import sun.awt.AWTAccessor;
    40 
    39 
    41 class XFramePeer extends XDecoratedPeer implements FramePeer {
    40 class XFramePeer extends XDecoratedPeer implements FramePeer {
    42     private static Logger log = Logger.getLogger("sun.awt.X11.XFramePeer");
    41     private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XFramePeer");
    43     private static Logger stateLog = Logger.getLogger("sun.awt.X11.states");
    42     private static PlatformLogger stateLog = PlatformLogger.getLogger("sun.awt.X11.states");
    44     private static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XFramePeer");
    43     private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XFramePeer");
    45 
    44 
    46     XMenuBarPeer menubarPeer;
    45     XMenuBarPeer menubarPeer;
    47     MenuBar menubar;
    46     MenuBar menubar;
    48     int state;
    47     int state;
    49     private Boolean undecorated;
    48     private Boolean undecorated;
    74         }
    73         }
    75         winAttr.functions = MWMConstants.MWM_FUNC_ALL;
    74         winAttr.functions = MWMConstants.MWM_FUNC_ALL;
    76         winAttr.isResizable = true; // target.isResizable();
    75         winAttr.isResizable = true; // target.isResizable();
    77         winAttr.title = target.getTitle();
    76         winAttr.title = target.getTitle();
    78         winAttr.initialResizability = target.isResizable();
    77         winAttr.initialResizability = target.isResizable();
    79         if (log.isLoggable(Level.FINE)) {
    78         if (log.isLoggable(PlatformLogger.FINE)) {
    80             log.log(Level.FINE, "Frame''s initial attributes: decor {0}, resizable {1}, undecorated {2}, initial state {3}",
    79             log.fine("Frame''s initial attributes: decor {0}, resizable {1}, undecorated {2}, initial state {3}",
    81                      new Object[] {Integer.valueOf(winAttr.decorations), Boolean.valueOf(winAttr.initialResizability),
    80                      Integer.valueOf(winAttr.decorations), Boolean.valueOf(winAttr.initialResizability),
    82                                    Boolean.valueOf(!winAttr.nativeDecor), Integer.valueOf(winAttr.initialState)});
    81                      Boolean.valueOf(!winAttr.nativeDecor), Integer.valueOf(winAttr.initialState));
    83         }
    82         }
    84     }
    83     }
    85 
    84 
    86     void postInit(XCreateWindowParams params) {
    85     void postInit(XCreateWindowParams params) {
    87         super.postInit(params);
    86         super.postInit(params);
   206             }
   205             }
   207         );
   206         );
   208     }
   207     }
   209 
   208 
   210     public void setMaximizedBounds(Rectangle b) {
   209     public void setMaximizedBounds(Rectangle b) {
   211         if (insLog.isLoggable(Level.FINE)) insLog.fine("Setting maximized bounds to " + b);
   210         if (insLog.isLoggable(PlatformLogger.FINE)) insLog.fine("Setting maximized bounds to " + b);
   212         if (b == null) return;
   211         if (b == null) return;
   213         maxBounds = new Rectangle(b);
   212         maxBounds = new Rectangle(b);
   214         XToolkit.awtLock();
   213         XToolkit.awtLock();
   215         try {
   214         try {
   216             XSizeHints hints = getHints();
   215             XSizeHints hints = getHints();
   223             if (b.height != Integer.MAX_VALUE) {
   222             if (b.height != Integer.MAX_VALUE) {
   224                 hints.set_max_height(b.height);
   223                 hints.set_max_height(b.height);
   225             } else {
   224             } else {
   226                 hints.set_max_height((int)XlibWrapper.DisplayHeight(XToolkit.getDisplay(), XlibWrapper.DefaultScreen(XToolkit.getDisplay())));
   225                 hints.set_max_height((int)XlibWrapper.DisplayHeight(XToolkit.getDisplay(), XlibWrapper.DefaultScreen(XToolkit.getDisplay())));
   227             }
   226             }
   228             if (insLog.isLoggable(Level.FINER)) insLog.finer("Setting hints, flags " + XlibWrapper.hintsToString(hints.get_flags()));
   227             if (insLog.isLoggable(PlatformLogger.FINER)) insLog.finer("Setting hints, flags " + XlibWrapper.hintsToString(hints.get_flags()));
   229             XlibWrapper.XSetWMNormalHints(XToolkit.getDisplay(), window, hints.pData);
   228             XlibWrapper.XSetWMNormalHints(XToolkit.getDisplay(), window, hints.pData);
   230         } finally {
   229         } finally {
   231             XToolkit.awtUnlock();
   230             XToolkit.awtUnlock();
   232         }
   231         }
   233     }
   232     }
   251 
   250 
   252     void changeState(int newState) {
   251     void changeState(int newState) {
   253         int changed = state ^ newState;
   252         int changed = state ^ newState;
   254         int changeIconic = changed & Frame.ICONIFIED;
   253         int changeIconic = changed & Frame.ICONIFIED;
   255         boolean iconic = (newState & Frame.ICONIFIED) != 0;
   254         boolean iconic = (newState & Frame.ICONIFIED) != 0;
   256         stateLog.log(Level.FINER, "Changing state, old state {0}, new state {1}(iconic {2})",
   255         stateLog.finer("Changing state, old state {0}, new state {1}(iconic {2})",
   257                      new Object[] {Integer.valueOf(state), Integer.valueOf(newState), Boolean.valueOf(iconic)});
   256                        Integer.valueOf(state), Integer.valueOf(newState), Boolean.valueOf(iconic));
   258         if (changeIconic != 0 && iconic) {
   257         if (changeIconic != 0 && iconic) {
   259             if (stateLog.isLoggable(Level.FINER)) stateLog.finer("Iconifying shell " + getShell() + ", this " + this + ", screen " + getScreenNumber());
   258             if (stateLog.isLoggable(PlatformLogger.FINER)) stateLog.finer("Iconifying shell " + getShell() + ", this " + this + ", screen " + getScreenNumber());
   260             XToolkit.awtLock();
   259             XToolkit.awtLock();
   261             try {
   260             try {
   262                 int res = XlibWrapper.XIconifyWindow(XToolkit.getDisplay(), getShell(), getScreenNumber());
   261                 int res = XlibWrapper.XIconifyWindow(XToolkit.getDisplay(), getShell(), getScreenNumber());
   263                 if (stateLog.isLoggable(Level.FINER)) stateLog.finer("XIconifyWindow returned " + res);
   262                 if (stateLog.isLoggable(PlatformLogger.FINER)) stateLog.finer("XIconifyWindow returned " + res);
   264             }
   263             }
   265             finally {
   264             finally {
   266                 XToolkit.awtUnlock();
   265                 XToolkit.awtUnlock();
   267             }
   266             }
   268         }
   267         }
   269         if ((changed & ~Frame.ICONIFIED) != 0) {
   268         if ((changed & ~Frame.ICONIFIED) != 0) {
   270             setExtendedState(newState);
   269             setExtendedState(newState);
   271         }
   270         }
   272         if (changeIconic != 0 && !iconic) {
   271         if (changeIconic != 0 && !iconic) {
   273             if (stateLog.isLoggable(Level.FINER)) stateLog.finer("DeIconifying " + this);
   272             if (stateLog.isLoggable(PlatformLogger.FINER)) stateLog.finer("DeIconifying " + this);
   274             xSetVisible(true);
   273             xSetVisible(true);
   275         }
   274         }
   276     }
   275     }
   277 
   276 
   278     void setExtendedState(int newState) {
   277     void setExtendedState(int newState) {
   281 
   280 
   282     public void handlePropertyNotify(XEvent xev) {
   281     public void handlePropertyNotify(XEvent xev) {
   283         super.handlePropertyNotify(xev);
   282         super.handlePropertyNotify(xev);
   284         XPropertyEvent ev = xev.get_xproperty();
   283         XPropertyEvent ev = xev.get_xproperty();
   285 
   284 
   286         log.log(Level.FINER, "Property change {0}", new Object[] {ev});
   285         log.finer("Property change {0}", ev);
   287         /*
   286         /*
   288          * Let's see if this is a window state protocol message, and
   287          * Let's see if this is a window state protocol message, and
   289          * if it is - decode a new state in terms of java constants.
   288          * if it is - decode a new state in terms of java constants.
   290          */
   289          */
   291         if (!XWM.getWM().isStateChange(this, ev)) {
   290         if (!XWM.getWM().isStateChange(this, ev)) {
   346         XToolkit.awtLock();
   345         XToolkit.awtLock();
   347         try {
   346         try {
   348             XWMHints hints = getWMHints();
   347             XWMHints hints = getWMHints();
   349             hints.set_flags((int)XUtilConstants.StateHint | hints.get_flags());
   348             hints.set_flags((int)XUtilConstants.StateHint | hints.get_flags());
   350             hints.set_initial_state(wm_state);
   349             hints.set_initial_state(wm_state);
   351             if (stateLog.isLoggable(Level.FINE)) stateLog.fine("Setting initial WM state on " + this + " to " + wm_state);
   350             if (stateLog.isLoggable(PlatformLogger.FINE)) stateLog.fine("Setting initial WM state on " + this + " to " + wm_state);
   352             XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData);
   351             XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData);
   353         }
   352         }
   354         finally {
   353         finally {
   355             XToolkit.awtUnlock();
   354             XToolkit.awtUnlock();
   356         }
   355         }