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

Print this page




  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;
  54             }
  55             if ( (state & Frame.MAXIMIZED_HORIZ) != 0) {
  56                 win_state |= WIN_STATE_MAXIMIZED_HORIZ;
  57             }
  58 
  59             XClientMessageEvent req = new XClientMessageEvent();
  60             req.set_type(XConstants.ClientMessage);
  61             req.set_window(window.getWindow());
  62             req.set_message_type(XA_WIN_STATE.getAtom());
  63             req.set_format(32);
  64             req.set_data(0, (WIN_STATE_MAXIMIZED_HORIZ | WIN_STATE_MAXIMIZED_VERT));
  65             req.set_data(1, win_state);
  66             if (log.isLoggable(PlatformLogger.FINE)) log.fine("Sending WIN_STATE to root to change the state to " + win_state);


  67             try {
  68                 XToolkit.awtLock();
  69                 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
  70                         XlibWrapper.RootWindow(XToolkit.getDisplay(),
  71                             window.getScreenNumber()),
  72                         false,
  73                         XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
  74                         req.pData);
  75             }
  76             finally {
  77                 XToolkit.awtUnlock();
  78             }
  79             req.dispose();
  80         } else {
  81             /*
  82              * Specify initial state for a Gnome WM (_WIN protocol) by setting
  83              * WIN_STATE property on the window to the desired state before
  84              * mapping it.
  85              */
  86             /* Be careful to not wipe out state bits we don't understand */


  94              * pay attention.
  95              */
  96             if ((state & Frame.ICONIFIED) != 0) {
  97                 win_state |= WIN_STATE_MINIMIZED;
  98             } else {
  99                 win_state &= ~WIN_STATE_MINIMIZED;
 100             }
 101 
 102             if ((state & Frame.MAXIMIZED_VERT) != 0) {
 103                 win_state |= WIN_STATE_MAXIMIZED_VERT;
 104             } else {
 105                 win_state &= ~WIN_STATE_MAXIMIZED_VERT;
 106             }
 107 
 108             if ((state & Frame.MAXIMIZED_HORIZ) != 0) {
 109                 win_state |= WIN_STATE_MAXIMIZED_HORIZ;
 110             } else {
 111                 win_state &= ~WIN_STATE_MAXIMIZED_HORIZ;
 112             }
 113             if ((old_win_state ^ win_state) != 0) {
 114                 if (log.isLoggable(PlatformLogger.FINE)) log.fine("Setting WIN_STATE on " + window + " to change the state to " + win_state);


 115                 XA_WIN_STATE.setCard32Property(window, win_state);
 116             }
 117         }
 118     }
 119 
 120     public int getState(XWindowPeer window) {
 121         long win_state = XA_WIN_STATE.getCard32Property(window);
 122         int java_state = Frame.NORMAL;
 123         if ((win_state & WIN_STATE_MAXIMIZED_VERT) != 0) {
 124             java_state |= Frame.MAXIMIZED_VERT;
 125         }
 126         if ((win_state & WIN_STATE_MAXIMIZED_HORIZ) != 0) {
 127             java_state |= Frame.MAXIMIZED_HORIZ;
 128         }
 129         return java_state;
 130     }
 131 
 132     public boolean isStateChange(XPropertyEvent e) {
 133         return doStateProtocol() && e.get_atom() == XA_WIN_STATE.getAtom();
 134     }


 139             return;
 140         }
 141         win_state &= ~WIN_STATE_SHADED;
 142         XA_WIN_STATE.setCard32Property(window, win_state);
 143     }
 144 
 145     public boolean supportsLayer(int layer) {
 146         return ((layer == LAYER_ALWAYS_ON_TOP) || (layer == LAYER_NORMAL)) && doLayerProtocol();
 147     }
 148 
 149     public void setLayer(XWindowPeer window, int layer) {
 150         if (window.isShowing()) {
 151             XClientMessageEvent req = new XClientMessageEvent();
 152             req.set_type(XConstants.ClientMessage);
 153             req.set_window(window.getWindow());
 154             req.set_message_type(XA_WIN_LAYER.getAtom());
 155             req.set_format(32);
 156             req.set_data(0, layer == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP);
 157             req.set_data(1, 0);
 158             req.set_data(2, 0);
 159             if (log.isLoggable(PlatformLogger.FINE)) log.fine("Setting layer " + layer + " by root message : " + req);


 160             XToolkit.awtLock();
 161             try {
 162                 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
 163                         XlibWrapper.RootWindow(XToolkit.getDisplay(),
 164                             window.getScreenNumber()),
 165                         false,
 166                         /*XConstants.SubstructureRedirectMask | */XConstants.SubstructureNotifyMask,
 167                         req.pData);
 168             }
 169             finally {
 170                 XToolkit.awtUnlock();
 171             }
 172             req.dispose();
 173         } else {
 174             if (log.isLoggable(PlatformLogger.FINE)) log.fine("Setting layer property to " + layer);


 175             XA_WIN_LAYER.setCard32Property(window, layer == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP);
 176         }
 177     }
 178 
 179     XAtom XA_WIN_LAYER = XAtom.get("_WIN_LAYER");
 180 
 181 /* _WIN_STATE bits */
 182     final static int WIN_STATE_STICKY          =(1<<0); /* everyone knows sticky            */
 183     final static int WIN_STATE_MINIMIZED       =(1<<1); /* Reserved - definition is unclear */
 184     final static int WIN_STATE_MAXIMIZED_VERT  =(1<<2); /* window in maximized V state      */
 185     final static int WIN_STATE_MAXIMIZED_HORIZ =(1<<3); /* window in maximized H state      */
 186     final static int WIN_STATE_HIDDEN          =(1<<4); /* not on taskbar but window visible*/
 187     final static int WIN_STATE_SHADED          =(1<<5); /* shaded (MacOS / Afterstep style) */
 188 /* _WIN_LAYER values */
 189     final static int WIN_LAYER_ONTOP = 6;
 190     final static int WIN_LAYER_NORMAL = 4;
 191 
 192     long WinWindow = 0;
 193     boolean supportChecked = false;
 194     void detect() {
 195         if (supportChecked) {
 196             return;
 197         }
 198         WinWindow = checkAnchor(XA_WIN_SUPPORTING_WM_CHECK, XAtom.XA_CARDINAL);
 199         supportChecked = true;
 200         if (log.isLoggable(PlatformLogger.FINE)) log.fine("### " + this + " is active: " + (WinWindow != 0));


 201     }
 202 
 203     boolean active() {
 204         detect();
 205         return WinWindow != 0;
 206     }
 207     boolean doStateProtocol() {
 208         boolean res = active() && checkProtocol(XA_WIN_PROTOCOLS, XA_WIN_STATE);
 209         if (log.isLoggable(PlatformLogger.FINE)) log.fine("### " + this + " supports state: " + res);


 210         return res;
 211     }
 212 
 213     boolean doLayerProtocol() {
 214         boolean res = active() && checkProtocol(XA_WIN_PROTOCOLS, XA_WIN_LAYER);
 215         if (log.isLoggable(PlatformLogger.FINE)) log.fine("### " + this + " supports layer: " + res);


 216         return res;
 217     }
 218 }


  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;
  54             }
  55             if ( (state & Frame.MAXIMIZED_HORIZ) != 0) {
  56                 win_state |= WIN_STATE_MAXIMIZED_HORIZ;
  57             }
  58 
  59             XClientMessageEvent req = new XClientMessageEvent();
  60             req.set_type(XConstants.ClientMessage);
  61             req.set_window(window.getWindow());
  62             req.set_message_type(XA_WIN_STATE.getAtom());
  63             req.set_format(32);
  64             req.set_data(0, (WIN_STATE_MAXIMIZED_HORIZ | WIN_STATE_MAXIMIZED_VERT));
  65             req.set_data(1, win_state);
  66             if (log.isLoggable(PlatformLogger.FINE)) {
  67                 log.fine("Sending WIN_STATE to root to change the state to " + win_state);
  68             }
  69             try {
  70                 XToolkit.awtLock();
  71                 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
  72                         XlibWrapper.RootWindow(XToolkit.getDisplay(),
  73                             window.getScreenNumber()),
  74                         false,
  75                         XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
  76                         req.pData);
  77             }
  78             finally {
  79                 XToolkit.awtUnlock();
  80             }
  81             req.dispose();
  82         } else {
  83             /*
  84              * Specify initial state for a Gnome WM (_WIN protocol) by setting
  85              * WIN_STATE property on the window to the desired state before
  86              * mapping it.
  87              */
  88             /* Be careful to not wipe out state bits we don't understand */


  96              * pay attention.
  97              */
  98             if ((state & Frame.ICONIFIED) != 0) {
  99                 win_state |= WIN_STATE_MINIMIZED;
 100             } else {
 101                 win_state &= ~WIN_STATE_MINIMIZED;
 102             }
 103 
 104             if ((state & Frame.MAXIMIZED_VERT) != 0) {
 105                 win_state |= WIN_STATE_MAXIMIZED_VERT;
 106             } else {
 107                 win_state &= ~WIN_STATE_MAXIMIZED_VERT;
 108             }
 109 
 110             if ((state & Frame.MAXIMIZED_HORIZ) != 0) {
 111                 win_state |= WIN_STATE_MAXIMIZED_HORIZ;
 112             } else {
 113                 win_state &= ~WIN_STATE_MAXIMIZED_HORIZ;
 114             }
 115             if ((old_win_state ^ win_state) != 0) {
 116                 if (log.isLoggable(PlatformLogger.FINE)) {
 117                     log.fine("Setting WIN_STATE on " + window + " to change the state to " + win_state);
 118                 }
 119                 XA_WIN_STATE.setCard32Property(window, win_state);
 120             }
 121         }
 122     }
 123 
 124     public int getState(XWindowPeer window) {
 125         long win_state = XA_WIN_STATE.getCard32Property(window);
 126         int java_state = Frame.NORMAL;
 127         if ((win_state & WIN_STATE_MAXIMIZED_VERT) != 0) {
 128             java_state |= Frame.MAXIMIZED_VERT;
 129         }
 130         if ((win_state & WIN_STATE_MAXIMIZED_HORIZ) != 0) {
 131             java_state |= Frame.MAXIMIZED_HORIZ;
 132         }
 133         return java_state;
 134     }
 135 
 136     public boolean isStateChange(XPropertyEvent e) {
 137         return doStateProtocol() && e.get_atom() == XA_WIN_STATE.getAtom();
 138     }


 143             return;
 144         }
 145         win_state &= ~WIN_STATE_SHADED;
 146         XA_WIN_STATE.setCard32Property(window, win_state);
 147     }
 148 
 149     public boolean supportsLayer(int layer) {
 150         return ((layer == LAYER_ALWAYS_ON_TOP) || (layer == LAYER_NORMAL)) && doLayerProtocol();
 151     }
 152 
 153     public void setLayer(XWindowPeer window, int layer) {
 154         if (window.isShowing()) {
 155             XClientMessageEvent req = new XClientMessageEvent();
 156             req.set_type(XConstants.ClientMessage);
 157             req.set_window(window.getWindow());
 158             req.set_message_type(XA_WIN_LAYER.getAtom());
 159             req.set_format(32);
 160             req.set_data(0, layer == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP);
 161             req.set_data(1, 0);
 162             req.set_data(2, 0);
 163             if (log.isLoggable(PlatformLogger.FINE)) {
 164                 log.fine("Setting layer " + layer + " by root message : " + req);
 165             }
 166             XToolkit.awtLock();
 167             try {
 168                 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
 169                         XlibWrapper.RootWindow(XToolkit.getDisplay(),
 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.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.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);
 219         if (log.isLoggable(PlatformLogger.FINE)) {
 220             log.fine("### " + this + " supports state: " + res);
 221         }
 222         return res;
 223     }
 224 
 225     boolean doLayerProtocol() {
 226         boolean res = active() && checkProtocol(XA_WIN_PROTOCOLS, XA_WIN_LAYER);
 227         if (log.isLoggable(PlatformLogger.FINE)) {
 228             log.fine("### " + this + " supports layer: " + res);
 229         }
 230         return res;
 231     }
 232 }