jdk/src/solaris/classes/sun/awt/X11/XWINProtocol.java
author anthony
Fri, 12 Apr 2013 14:33:38 +0400
changeset 16839 d0f2e97b7359
parent 5506 202f599c92aa
child 18178 ee71c923891d
permissions -rw-r--r--
8010297: Missing isLoggable() checks in logging code Summary: Add isLoggable() checks Reviewed-by: anthony, mchung, serb Contributed-by: Laurent Bourges <bourges.laurent@gmail.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     2
 * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.*;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 439
diff changeset
    30
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
class XWINProtocol extends XProtocol implements XStateProtocol, XLayerProtocol {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 439
diff changeset
    33
    final static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWINProtocol");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/* Gnome WM spec  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    XAtom XA_WIN_SUPPORTING_WM_CHECK = XAtom.get("_WIN_SUPPORTING_WM_CHECK");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    XAtom XA_WIN_PROTOCOLS = XAtom.get("_WIN_PROTOCOLS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    XAtom XA_WIN_STATE = XAtom.get("_WIN_STATE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    public boolean supportsState(int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        return doStateProtocol();   // TODO - check for Frame constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    public void setState(XWindowPeer window, int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        if (window.isShowing()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
             * Request state transition from a Gnome WM (_WIN protocol) by sending
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
             * _WIN_STATE ClientMessage to root window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            long win_state = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            if ( (state & Frame.MAXIMIZED_VERT) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
                win_state |= WIN_STATE_MAXIMIZED_VERT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            if ( (state & Frame.MAXIMIZED_HORIZ) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                win_state |= WIN_STATE_MAXIMIZED_HORIZ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            XClientMessageEvent req = new XClientMessageEvent();
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
    60
            req.set_type(XConstants.ClientMessage);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            req.set_window(window.getWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            req.set_message_type(XA_WIN_STATE.getAtom());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            req.set_format(32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            req.set_data(0, (WIN_STATE_MAXIMIZED_HORIZ | WIN_STATE_MAXIMIZED_VERT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            req.set_data(1, win_state);
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
    66
            if (log.isLoggable(PlatformLogger.FINE)) {
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
    67
                log.fine("Sending WIN_STATE to root to change the state to " + win_state);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
    68
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                XlibWrapper.XSendEvent(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                        XlibWrapper.RootWindow(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                            window.getScreenNumber()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                        false,
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
    75
                        XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                        req.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            req.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
             * Specify initial state for a Gnome WM (_WIN protocol) by setting
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
             * WIN_STATE property on the window to the desired state before
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
             * mapping it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            /* Be careful to not wipe out state bits we don't understand */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            long win_state = XA_WIN_STATE.getCard32Property(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            long old_win_state = win_state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
             * In their stupid quest of reinventing every wheel, Gnome WM spec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
             * have its own "minimized" hint (instead of using initial state
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
             * and WM_STATE hints).  This is bogus, but, apparently, some WMs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
             * pay attention.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            if ((state & Frame.ICONIFIED) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                win_state |= WIN_STATE_MINIMIZED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                win_state &= ~WIN_STATE_MINIMIZED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            if ((state & Frame.MAXIMIZED_VERT) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                win_state |= WIN_STATE_MAXIMIZED_VERT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                win_state &= ~WIN_STATE_MAXIMIZED_VERT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            if ((state & Frame.MAXIMIZED_HORIZ) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                win_state |= WIN_STATE_MAXIMIZED_HORIZ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                win_state &= ~WIN_STATE_MAXIMIZED_HORIZ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            if ((old_win_state ^ win_state) != 0) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   116
                if (log.isLoggable(PlatformLogger.FINE)) {
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   117
                    log.fine("Setting WIN_STATE on " + window + " to change the state to " + win_state);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   118
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                XA_WIN_STATE.setCard32Property(window, win_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public int getState(XWindowPeer window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        long win_state = XA_WIN_STATE.getCard32Property(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        int java_state = Frame.NORMAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        if ((win_state & WIN_STATE_MAXIMIZED_VERT) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            java_state |= Frame.MAXIMIZED_VERT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        if ((win_state & WIN_STATE_MAXIMIZED_HORIZ) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            java_state |= Frame.MAXIMIZED_HORIZ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return java_state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public boolean isStateChange(XPropertyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return doStateProtocol() && e.get_atom() == XA_WIN_STATE.getAtom();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public void unshadeKludge(XWindowPeer window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        long win_state = XA_WIN_STATE.getCard32Property(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if ((win_state & WIN_STATE_SHADED) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        win_state &= ~WIN_STATE_SHADED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        XA_WIN_STATE.setCard32Property(window, win_state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public boolean supportsLayer(int layer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        return ((layer == LAYER_ALWAYS_ON_TOP) || (layer == LAYER_NORMAL)) && doLayerProtocol();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public void setLayer(XWindowPeer window, int layer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        if (window.isShowing()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            XClientMessageEvent req = new XClientMessageEvent();
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   156
            req.set_type(XConstants.ClientMessage);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            req.set_window(window.getWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            req.set_message_type(XA_WIN_LAYER.getAtom());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            req.set_format(32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            req.set_data(0, layer == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            req.set_data(1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            req.set_data(2, 0);
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   163
            if (log.isLoggable(PlatformLogger.FINE)) {
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   164
                log.fine("Setting layer " + layer + " by root message : " + req);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   165
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                XlibWrapper.XSendEvent(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                        XlibWrapper.RootWindow(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                            window.getScreenNumber()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                        false,
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   172
                        /*XConstants.SubstructureRedirectMask | */XConstants.SubstructureNotifyMask,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                        req.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            req.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        } else {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   180
            if (log.isLoggable(PlatformLogger.FINE)) {
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   181
                log.fine("Setting layer property to " + layer);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   182
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            XA_WIN_LAYER.setCard32Property(window, layer == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    XAtom XA_WIN_LAYER = XAtom.get("_WIN_LAYER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
/* _WIN_STATE bits */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    final static int WIN_STATE_STICKY          =(1<<0); /* everyone knows sticky            */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    final static int WIN_STATE_MINIMIZED       =(1<<1); /* Reserved - definition is unclear */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    final static int WIN_STATE_MAXIMIZED_VERT  =(1<<2); /* window in maximized V state      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    final static int WIN_STATE_MAXIMIZED_HORIZ =(1<<3); /* window in maximized H state      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    final static int WIN_STATE_HIDDEN          =(1<<4); /* not on taskbar but window visible*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    final static int WIN_STATE_SHADED          =(1<<5); /* shaded (MacOS / Afterstep style) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
/* _WIN_LAYER values */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    final static int WIN_LAYER_ONTOP = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    final static int WIN_LAYER_NORMAL = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    long WinWindow = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    boolean supportChecked = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    void detect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        if (supportChecked) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        WinWindow = checkAnchor(XA_WIN_SUPPORTING_WM_CHECK, XAtom.XA_CARDINAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        supportChecked = true;
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   208
        if (log.isLoggable(PlatformLogger.FINE)) {
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   209
            log.fine("### " + this + " is active: " + (WinWindow != 0));
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   210
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    boolean active() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        detect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        return WinWindow != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    boolean doStateProtocol() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        boolean res = active() && checkProtocol(XA_WIN_PROTOCOLS, XA_WIN_STATE);
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   219
        if (log.isLoggable(PlatformLogger.FINE)) {
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   220
            log.fine("### " + this + " supports state: " + res);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   221
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    boolean doLayerProtocol() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        boolean res = active() && checkProtocol(XA_WIN_PROTOCOLS, XA_WIN_LAYER);
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   227
        if (log.isLoggable(PlatformLogger.FINE)) {
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   228
            log.fine("### " + this + " supports layer: " + res);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   229
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
}