src/solaris/classes/sun/awt/X11/XNETProtocol.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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


  91               case 0:
  92                   return;
  93               case Frame.MAXIMIZED_HORIZ:
  94                   req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
  95                   req.set_data(2, 0);
  96                   break;
  97               case Frame.MAXIMIZED_VERT:
  98                   req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
  99                   req.set_data(2, 0);
 100                   break;
 101               case Frame.MAXIMIZED_BOTH:
 102                   req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
 103                   req.set_data(2, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
 104                   break;
 105               default:
 106                   return;
 107             }
 108             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 109                 log.fine("Requesting state on " + window + " for " + state);
 110             }
 111             req.set_type((int)XConstants.ClientMessage);
 112             req.set_window(window.getWindow());
 113             req.set_message_type(XA_NET_WM_STATE.getAtom());
 114             req.set_format(32);
 115             req.set_data(0, _NET_WM_STATE_TOGGLE);
 116             XToolkit.awtLock();
 117             try {
 118                 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
 119                         XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()),
 120                         false,
 121                         XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
 122                         req.pData);
 123             }
 124             finally {
 125                 XToolkit.awtUnlock();
 126             }
 127         } finally {
 128             req.dispose();
 129         }
 130     }
 131 


 164 
 165     /*
 166      * Work around for 4775545.
 167      */
 168     public void unshadeKludge(XWindowPeer window) {
 169         XAtomList net_wm_state = window.getNETWMState();
 170         net_wm_state.remove(XA_NET_WM_STATE_SHADED);
 171         window.setNETWMState(net_wm_state);
 172     }
 173 
 174     /**
 175      * XLayerProtocol
 176      */
 177     public boolean supportsLayer(int layer) {
 178         return ((layer == LAYER_ALWAYS_ON_TOP) || (layer == LAYER_NORMAL)) && doLayerProtocol();
 179     }
 180 
 181     public void requestState(XWindow window, XAtom state, boolean isAdd) {
 182         XClientMessageEvent req = new XClientMessageEvent();
 183         try {
 184             req.set_type((int)XConstants.ClientMessage);
 185             req.set_window(window.getWindow());
 186             req.set_message_type(XA_NET_WM_STATE.getAtom());
 187             req.set_format(32);
 188             req.set_data(0, isAdd ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE);
 189             req.set_data(1, state.getAtom());
 190             // Fix for 6735584: req.data[2] must be set to 0 when only one property is changed
 191             req.set_data(2, 0);
 192             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 193                 log.fine("Setting _NET_STATE atom {0} on {1} for {2}", state, window, Boolean.valueOf(isAdd));
 194             }
 195             XToolkit.awtLock();
 196             try {
 197                 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
 198                         XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()),
 199                         false,
 200                         XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
 201                         req.pData);
 202             }
 203             finally {
 204                 XToolkit.awtUnlock();


   1 /*
   2  * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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


  91               case 0:
  92                   return;
  93               case Frame.MAXIMIZED_HORIZ:
  94                   req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
  95                   req.set_data(2, 0);
  96                   break;
  97               case Frame.MAXIMIZED_VERT:
  98                   req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
  99                   req.set_data(2, 0);
 100                   break;
 101               case Frame.MAXIMIZED_BOTH:
 102                   req.set_data(1, XA_NET_WM_STATE_MAXIMIZED_HORZ.getAtom());
 103                   req.set_data(2, XA_NET_WM_STATE_MAXIMIZED_VERT.getAtom());
 104                   break;
 105               default:
 106                   return;
 107             }
 108             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 109                 log.fine("Requesting state on " + window + " for " + state);
 110             }
 111             req.set_type(XConstants.ClientMessage);
 112             req.set_window(window.getWindow());
 113             req.set_message_type(XA_NET_WM_STATE.getAtom());
 114             req.set_format(32);
 115             req.set_data(0, _NET_WM_STATE_TOGGLE);
 116             XToolkit.awtLock();
 117             try {
 118                 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
 119                         XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()),
 120                         false,
 121                         XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
 122                         req.pData);
 123             }
 124             finally {
 125                 XToolkit.awtUnlock();
 126             }
 127         } finally {
 128             req.dispose();
 129         }
 130     }
 131 


 164 
 165     /*
 166      * Work around for 4775545.
 167      */
 168     public void unshadeKludge(XWindowPeer window) {
 169         XAtomList net_wm_state = window.getNETWMState();
 170         net_wm_state.remove(XA_NET_WM_STATE_SHADED);
 171         window.setNETWMState(net_wm_state);
 172     }
 173 
 174     /**
 175      * XLayerProtocol
 176      */
 177     public boolean supportsLayer(int layer) {
 178         return ((layer == LAYER_ALWAYS_ON_TOP) || (layer == LAYER_NORMAL)) && doLayerProtocol();
 179     }
 180 
 181     public void requestState(XWindow window, XAtom state, boolean isAdd) {
 182         XClientMessageEvent req = new XClientMessageEvent();
 183         try {
 184             req.set_type(XConstants.ClientMessage);
 185             req.set_window(window.getWindow());
 186             req.set_message_type(XA_NET_WM_STATE.getAtom());
 187             req.set_format(32);
 188             req.set_data(0, isAdd ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE);
 189             req.set_data(1, state.getAtom());
 190             // Fix for 6735584: req.data[2] must be set to 0 when only one property is changed
 191             req.set_data(2, 0);
 192             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 193                 log.fine("Setting _NET_STATE atom {0} on {1} for {2}", state, window, Boolean.valueOf(isAdd));
 194             }
 195             XToolkit.awtLock();
 196             try {
 197                 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
 198                         XlibWrapper.RootWindow(XToolkit.getDisplay(), window.getScreenNumber()),
 199                         false,
 200                         XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
 201                         req.pData);
 202             }
 203             finally {
 204                 XToolkit.awtUnlock();