src/java.desktop/unix/classes/sun/awt/X11/XWINProtocol.java

Print this page




  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 
  26 
  27 package sun.awt.X11;
  28 
  29 import java.awt.*;
  30 import sun.util.logging.PlatformLogger;
  31 
  32 class XWINProtocol extends XProtocol implements XStateProtocol, XLayerProtocol {
  33     final static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWINProtocol");
  34 
  35 /* Gnome WM spec  */
  36     XAtom XA_WIN_SUPPORTING_WM_CHECK = XAtom.get("_WIN_SUPPORTING_WM_CHECK");
  37     XAtom XA_WIN_PROTOCOLS = XAtom.get("_WIN_PROTOCOLS");
  38     XAtom XA_WIN_STATE = XAtom.get("_WIN_STATE");
  39 
  40     public boolean supportsState(int state) {
  41         return doStateProtocol();   // TODO - check for Frame constants
  42     }
  43 
  44     public void setState(XWindowPeer window, int state) {
  45         if (window.isShowing()) {
  46             /*
  47              * Request state transition from a Gnome WM (_WIN protocol) by sending
  48              * _WIN_STATE ClientMessage to root window.
  49              */
  50             long win_state = 0;
  51 
  52             if ( (state & Frame.MAXIMIZED_VERT) != 0) {
  53                 win_state |= WIN_STATE_MAXIMIZED_VERT;


 170                             window.getScreenNumber()),
 171                         false,
 172                         /*XConstants.SubstructureRedirectMask | */XConstants.SubstructureNotifyMask,
 173                         req.pData);
 174             }
 175             finally {
 176                 XToolkit.awtUnlock();
 177             }
 178             req.dispose();
 179         } else {
 180             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 181                 log.fine("Setting layer property to " + layer);
 182             }
 183             XA_WIN_LAYER.setCard32Property(window, layer == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP);
 184         }
 185     }
 186 
 187     XAtom XA_WIN_LAYER = XAtom.get("_WIN_LAYER");
 188 
 189 /* _WIN_STATE bits */
 190     final static int WIN_STATE_STICKY          =(1<<0); /* everyone knows sticky            */
 191     final static int WIN_STATE_MINIMIZED       =(1<<1); /* Reserved - definition is unclear */
 192     final static int WIN_STATE_MAXIMIZED_VERT  =(1<<2); /* window in maximized V state      */
 193     final static int WIN_STATE_MAXIMIZED_HORIZ =(1<<3); /* window in maximized H state      */
 194     final static int WIN_STATE_HIDDEN          =(1<<4); /* not on taskbar but window visible*/
 195     final static int WIN_STATE_SHADED          =(1<<5); /* shaded (MacOS / Afterstep style) */
 196 /* _WIN_LAYER values */
 197     final static int WIN_LAYER_ONTOP = 6;
 198     final static int WIN_LAYER_NORMAL = 4;
 199 
 200     long WinWindow = 0;
 201     boolean supportChecked = false;
 202     void detect() {
 203         if (supportChecked) {
 204             return;
 205         }
 206         WinWindow = checkAnchor(XA_WIN_SUPPORTING_WM_CHECK, XAtom.XA_CARDINAL);
 207         supportChecked = true;
 208         if (log.isLoggable(PlatformLogger.Level.FINE)) {
 209             log.fine("### " + this + " is active: " + (WinWindow != 0));
 210         }
 211     }
 212 
 213     boolean active() {
 214         detect();
 215         return WinWindow != 0;
 216     }
 217     boolean doStateProtocol() {
 218         boolean res = active() && checkProtocol(XA_WIN_PROTOCOLS, XA_WIN_STATE);


  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 
  26 
  27 package sun.awt.X11;
  28 
  29 import java.awt.*;
  30 import sun.util.logging.PlatformLogger;
  31 
  32 class XWINProtocol extends XProtocol implements XStateProtocol, XLayerProtocol {
  33     static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWINProtocol");
  34 
  35 /* Gnome WM spec  */
  36     XAtom XA_WIN_SUPPORTING_WM_CHECK = XAtom.get("_WIN_SUPPORTING_WM_CHECK");
  37     XAtom XA_WIN_PROTOCOLS = XAtom.get("_WIN_PROTOCOLS");
  38     XAtom XA_WIN_STATE = XAtom.get("_WIN_STATE");
  39 
  40     public boolean supportsState(int state) {
  41         return doStateProtocol();   // TODO - check for Frame constants
  42     }
  43 
  44     public void setState(XWindowPeer window, int state) {
  45         if (window.isShowing()) {
  46             /*
  47              * Request state transition from a Gnome WM (_WIN protocol) by sending
  48              * _WIN_STATE ClientMessage to root window.
  49              */
  50             long win_state = 0;
  51 
  52             if ( (state & Frame.MAXIMIZED_VERT) != 0) {
  53                 win_state |= WIN_STATE_MAXIMIZED_VERT;


 170                             window.getScreenNumber()),
 171                         false,
 172                         /*XConstants.SubstructureRedirectMask | */XConstants.SubstructureNotifyMask,
 173                         req.pData);
 174             }
 175             finally {
 176                 XToolkit.awtUnlock();
 177             }
 178             req.dispose();
 179         } else {
 180             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 181                 log.fine("Setting layer property to " + layer);
 182             }
 183             XA_WIN_LAYER.setCard32Property(window, layer == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP);
 184         }
 185     }
 186 
 187     XAtom XA_WIN_LAYER = XAtom.get("_WIN_LAYER");
 188 
 189 /* _WIN_STATE bits */
 190     static final int WIN_STATE_STICKY          =(1<<0); /* everyone knows sticky            */
 191     static final int WIN_STATE_MINIMIZED       =(1<<1); /* Reserved - definition is unclear */
 192     static final int WIN_STATE_MAXIMIZED_VERT  =(1<<2); /* window in maximized V state      */
 193     static final int WIN_STATE_MAXIMIZED_HORIZ =(1<<3); /* window in maximized H state      */
 194     static final int WIN_STATE_HIDDEN          =(1<<4); /* not on taskbar but window visible*/
 195     static final int WIN_STATE_SHADED          =(1<<5); /* shaded (MacOS / Afterstep style) */
 196 /* _WIN_LAYER values */
 197     static final int WIN_LAYER_ONTOP = 6;
 198     static final int WIN_LAYER_NORMAL = 4;
 199 
 200     long WinWindow = 0;
 201     boolean supportChecked = false;
 202     void detect() {
 203         if (supportChecked) {
 204             return;
 205         }
 206         WinWindow = checkAnchor(XA_WIN_SUPPORTING_WM_CHECK, XAtom.XA_CARDINAL);
 207         supportChecked = true;
 208         if (log.isLoggable(PlatformLogger.Level.FINE)) {
 209             log.fine("### " + this + " is active: " + (WinWindow != 0));
 210         }
 211     }
 212 
 213     boolean active() {
 214         detect();
 215         return WinWindow != 0;
 216     }
 217     boolean doStateProtocol() {
 218         boolean res = active() && checkProtocol(XA_WIN_PROTOCOLS, XA_WIN_STATE);