jdk/src/solaris/classes/sun/awt/X11/XWindow.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 21270 8a0fc12b81a2
child 22584 eed64ee05369
child 23248 3418855fb2c5
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 6826
diff changeset
     2
 * Copyright (c) 2002, 2010, 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: 4371
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: 4371
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: 4371
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
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
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.peer.ComponentPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.lang.ref.WeakReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2810
diff changeset
    37
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.awt.image.PixelConverter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.java2d.SunGraphics2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.java2d.SurfaceData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
public class XWindow extends XBaseWindow implements X11ComponentPeer {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2810
diff changeset
    47
    private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWindow");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2810
diff changeset
    48
    private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XWindow");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2810
diff changeset
    49
    private static PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XWindow");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2810
diff changeset
    50
    private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XWindow");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2810
diff changeset
    51
    private static PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XWindow");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  /* If a motion comes in while a multi-click is pending,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
   * allow a smudge factor so that moving the mouse by a small
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
   * amount does not wipe out the multi-click state variables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private final static int AWT_MULTICLICK_SMUDGE = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    // ButtonXXX events stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    static int rbutton = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static int lastX = 0, lastY = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    static long lastTime = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    static long lastButton = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    static WeakReference lastWindowRef = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    static int clickCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    // used to check if we need to re-create surfaceData.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    int oldWidth = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    int oldHeight = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
    69
    protected PropMwmHints mwm_hints;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
    70
    protected static XAtom wm_protocols;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
    71
    protected static XAtom wm_delete_window;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
    72
    protected static XAtom wm_take_focus;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
    73
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
    74
    private boolean stateChanged; // Indicates whether the value on savedState is valid
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
    75
    private int savedState; // Holds last known state of the top-level window
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
    76
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
    77
    XWindowAttributesData winAttr;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    protected X11GraphicsConfig graphicsConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    protected AwtGraphicsConfigData graphicsConfigData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private boolean reparented;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    XWindow parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    Component target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private static int JAWT_LOCK_ERROR=0x00000001;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private static int JAWT_LOCK_CLIP_CHANGED=0x00000002;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private static int JAWT_LOCK_BOUNDS_CHANGED=0x00000004;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private static int JAWT_LOCK_SURFACE_CHANGED=0x00000008;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    private int drawState = JAWT_LOCK_CLIP_CHANGED |
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    JAWT_LOCK_BOUNDS_CHANGED |
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    JAWT_LOCK_SURFACE_CHANGED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public static final String TARGET = "target",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        REPARENTED = "reparented"; // whether it is reparented by default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    SurfaceData surfaceData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    XRepaintArea paintArea;
116
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   102
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    // fallback default font object
116
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   104
    private static Font defaultFont;
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   105
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   106
    static synchronized Font getDefaultFont() {
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   107
        if (null == defaultFont) {
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   108
            defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   109
        }
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   110
        return defaultFont;
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   111
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   113
    /* A bitmask keeps the button's numbers as Button1Mask, Button2Mask, Button3Mask
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   114
     * which are allowed to
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   115
     * generate the CLICK event after the RELEASE has happened.
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   116
     * There are conditions that must be true for that sending CLICK event:
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   117
     * 1) button was initially PRESSED
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   118
     * 2) no movement or drag has happened until RELEASE
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   119
    */
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   120
    private int mouseButtonClickAllowed = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    native int getNativeColor(Color clr, GraphicsConfiguration gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    native void getWMInsets(long window, long left, long top, long right, long bottom, long border);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    native long getTopWindow(long window, long rootWin);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    native void getWindowBounds(long window, long x, long y, long width, long height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    private native static void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    XWindow(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        super(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    XWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    XWindow(long parentWindow, Rectangle bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        super(new XCreateWindowParams(new Object[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            BOUNDS, bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            PARENT_WINDOW, Long.valueOf(parentWindow)}));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    XWindow(Component target, long parentWindow, Rectangle bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        super(new XCreateWindowParams(new Object[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            BOUNDS, bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            PARENT_WINDOW, Long.valueOf(parentWindow),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            TARGET, target}));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    XWindow(Component target, long parentWindow) {
2643
ea218b1a2000 6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents: 2473
diff changeset
   153
        this(target, parentWindow, new Rectangle(target.getBounds()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    XWindow(Component target) {
2643
ea218b1a2000 6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents: 2473
diff changeset
   157
        this(target, (target.getParent() == null) ? 0 : getParentWindowID(target), new Rectangle(target.getBounds()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    XWindow(Object target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        this(null, 0, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    /* This create is used by the XEmbeddedFramePeer since it has to create the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
       as a child of the netscape window. This netscape window is passed in as wid */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    XWindow(long parentWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        super(new XCreateWindowParams(new Object[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            PARENT_WINDOW, Long.valueOf(parentWindow),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            REPARENTED, Boolean.TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            EMBEDDED, Boolean.TRUE}));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    protected void initGraphicsConfiguration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        graphicsConfig = (X11GraphicsConfig) target.getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        graphicsConfigData = new AwtGraphicsConfigData(graphicsConfig.getAData());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    void preInit(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        super.preInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        reparented = Boolean.TRUE.equals(params.get(REPARENTED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        target = (Component)params.get(TARGET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        initGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        AwtGraphicsConfigData gData = getGraphicsConfigurationData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        X11GraphicsConfig config = (X11GraphicsConfig) getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        XVisualInfo visInfo = gData.get_awt_visInfo();
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   189
        params.putIfNull(EVENT_MASK, XConstants.KeyPressMask | XConstants.KeyReleaseMask
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   190
            | XConstants.FocusChangeMask | XConstants.ButtonPressMask | XConstants.ButtonReleaseMask
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   191
            | XConstants.EnterWindowMask | XConstants.LeaveWindowMask | XConstants.PointerMotionMask
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   192
            | XConstants.ButtonMotionMask | XConstants.ExposureMask | XConstants.StructureNotifyMask);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (target != null) {
2643
ea218b1a2000 6821948: Consider removing the constraints for bounds of untrusted top-level windows
anthony
parents: 2473
diff changeset
   195
            params.putIfNull(BOUNDS, new Rectangle(target.getBounds()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            params.putIfNull(BOUNDS, new Rectangle(0, 0, MIN_SIZE, MIN_SIZE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        params.putIfNull(BORDER_PIXEL, Long.valueOf(0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        getColorModel(); // fix 4948833: this call forces the color map to be initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        params.putIfNull(COLORMAP, gData.get_awt_cmap());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        params.putIfNull(DEPTH, gData.get_awt_depth());
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   203
        params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XConstants.InputOutput));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        params.putIfNull(VISUAL, visInfo.get_visual());
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   205
        params.putIfNull(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWEventMask | XConstants.CWColormap);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        Long parentWindow = (Long)params.get(PARENT_WINDOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        if (parentWindow == null || parentWindow.longValue() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                int screen = visInfo.get_screen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                if (screen != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                    params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), screen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                    params.add(PARENT_WINDOW, XToolkit.getDefaultRootWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        paintArea = new XRepaintArea();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        if (target != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            this.parent = getParentXWindowObject(target.getParent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        params.putIfNull(BACKING_STORE, XToolkit.getBackingStoreType());
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   227
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   228
        XToolkit.awtLock();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   229
        try {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   230
            if (wm_protocols == null) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   231
                wm_protocols = XAtom.get("WM_PROTOCOLS");
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   232
                wm_delete_window = XAtom.get("WM_DELETE_WINDOW");
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   233
                wm_take_focus = XAtom.get("WM_TAKE_FOCUS");
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   234
            }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   235
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   236
        finally {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   237
            XToolkit.awtUnlock();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   238
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   239
        winAttr = new XWindowAttributesData();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   240
        savedState = XUtilConstants.WithdrawnState;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    void postInit(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        super.postInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        setWMClass(getWMClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        surfaceData = graphicsConfig.createSurfaceData(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        Color c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        if (target != null && (c = target.getBackground()) != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            // We need a version of setBackground that does not call repaint !!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            // and one that does not get overridden. The problem is that in postInit
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 21270
diff changeset
   253
            // we call setBackground and we don't have all the stuff initialized to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            // do a full paint for most peers. So we cannot call setBackground in postInit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            // instead we need to call xSetBackground.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            xSetBackground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public GraphicsConfiguration getGraphicsConfiguration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        if (graphicsConfig == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            initGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        return graphicsConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    public AwtGraphicsConfigData getGraphicsConfigurationData() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        if (graphicsConfigData == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            initGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        return graphicsConfigData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    protected String[] getWMClass() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        return new String[] {XToolkit.getCorrectXIDString(getClass().getName()), XToolkit.getAWTAppClassName()};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    void setReparented(boolean newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        reparented = newValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    boolean isReparented() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        return reparented;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    static long getParentWindowID(Component target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        ComponentPeer peer = target.getParent().getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        Component temp = target.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        while (!(peer instanceof XWindow))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            temp = temp.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            peer = temp.getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        if (peer != null && peer instanceof XWindow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            return ((XWindow)peer).getContentWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        else return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    static XWindow getParentXWindowObject(Component target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        if (target == null) return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        Component temp = target.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        if (temp == null) return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        ComponentPeer peer = temp.getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        if (peer == null) return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        while ((peer != null) && !(peer instanceof XWindow))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            temp = temp.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            peer = temp.getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        if (peer != null && peer instanceof XWindow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            return (XWindow) peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        else return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    boolean isParentOf(XWindow win) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        if (!(target instanceof Container) || win == null || win.getTarget() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        }
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 4285
diff changeset
   323
        Container parent = AWTAccessor.getComponentAccessor().getParent(win.target);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        while (parent != null && parent != target) {
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 4285
diff changeset
   325
            parent = AWTAccessor.getComponentAccessor().getParent(parent);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        return (parent == target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    public Object getTarget() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        return target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    public Component getEventSource() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        return target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    public ColorModel getColorModel(int transparency) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        return graphicsConfig.getColorModel (transparency);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    public ColorModel getColorModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        if (graphicsConfig != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            return graphicsConfig.getColorModel ();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            return XToolkit.getStaticColorModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    Graphics getGraphics(SurfaceData surfData, Color afore, Color aback, Font afont) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        if (surfData == null) return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        Component target = (Component) this.target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        /* Fix for bug 4746122. Color and Font shouldn't be null */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        Color bgColor = aback;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        if (bgColor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            bgColor = SystemColor.window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        Color fgColor = afore;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        if (fgColor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            fgColor = SystemColor.windowText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        Font font = afont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        if (font == null) {
116
9c43d9eb1029 6645856: static field XWindowPeer.defaultFont hides XWindow.defaultFont
son
parents: 2
diff changeset
   366
            font = XWindow.getDefaultFont();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        return new SunGraphics2D(surfData, fgColor, bgColor, font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    public Graphics getGraphics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        return getGraphics(surfaceData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                           target.getForeground(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                           target.getBackground(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                           target.getFont());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public FontMetrics getFontMetrics(Font font) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        return Toolkit.getDefaultToolkit().getFontMetrics(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public Rectangle getTargetBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        return target.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * Returns true if the event has been handled and should not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * posted to Java.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    boolean prePostEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    static Method m_sendMessage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    static void sendEvent(final AWTEvent e) {
6826
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 6824
diff changeset
   396
        // The uses of this method imply that the incoming event is system-generated
1fc6a05552f2 6991992: Need to forward-port AWT's part of the fix for 6691674
dcherepanov
parents: 6824
diff changeset
   397
        SunToolkit.setSystemGenerated(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                public void run() {
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 10096
diff changeset
   400
                    AWTAccessor.getAWTEventAccessor().setPosted(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                    ((Component)e.getSource()).dispatchEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            }, PeerEvent.ULTIMATE_PRIORITY_EVENT);
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   404
        if (focusLog.isLoggable(PlatformLogger.Level.FINER) && (e instanceof FocusEvent)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   405
            focusLog.finer("Sending " + e);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   406
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        XToolkit.postEvent(XToolkit.targetToAppContext(e.getSource()), pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
 * Post an event to the event queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
// NOTE: This method may be called by privileged threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    void postEvent(AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        XToolkit.postEvent(XToolkit.targetToAppContext(event.getSource()), event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    static void postEventStatic(AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        XToolkit.postEvent(XToolkit.targetToAppContext(event.getSource()), event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    public void postEventToEventQueue(final AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        //fix for 6239938 : Choice drop-down does not disappear when it loses focus, on XToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        if (!prePostEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            //event hasn't been handled and must be posted to EventQueue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            postEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    // overriden in XCanvasPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    protected boolean doEraseBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    // We need a version of setBackground that does not call repaint !!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    // and one that does not get overridden. The problem is that in postInit
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 21270
diff changeset
   439
    // we call setBackground and we don't have all the stuff initialized to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    // do a full paint for most peers. So we cannot call setBackground in postInit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    final public void xSetBackground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            winBackground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            // fix for 6558510: handle sun.awt.noerasebackground flag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            // see doEraseBackground() and preInit() methods in XCanvasPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            if (!doEraseBackground()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            // 6304250: XAWT: Items in choice show a blue border on OpenGL + Solaris10 when background color is set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            // Note: When OGL is enabled, surfaceData.pixelFor() will not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            // return a pixel value appropriate for passing to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            // XSetWindowBackground().  Therefore, we will use the ColorModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            // for this component in order to calculate a pixel value from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            // the given RGB value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            ColorModel cm = getColorModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            int pixel = PixelConverter.instance.rgbToPixel(c.getRGB(), cm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            XlibWrapper.XSetWindowBackground(XToolkit.getDisplay(), getContentWindow(), pixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    public void setBackground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        xSetBackground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    Color backgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    void winBackground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        backgroundColor = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    public Color getWinBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        Color c = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        if (backgroundColor != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            c = backgroundColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        } else if (parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            c = parent.getWinBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        if (c instanceof SystemColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            c = new Color(c.getRGB());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        return c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    public boolean isEmbedded() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        return embedded;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
21270
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   493
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   494
    public final void repaint(int x, int y, int width, int height) {
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 7668
diff changeset
   495
        if (!isVisible() || getWidth() == 0 || getHeight() == 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        Graphics g = getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        if (g != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            try {
21270
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   501
                g.setClip(x, y, width, height);
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   502
                if (SunToolkit.isDispatchThreadForAppContext(getTarget())) {
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   503
                    paint(g); // The native and target will be painted in place.
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   504
                } else {
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   505
                    paintPeer(g);
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   506
                    postPaintEvent(target, x, y, width, height);
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   507
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                g.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    }
21270
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   513
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 7668
diff changeset
   514
    void repaint() {
21270
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   515
        repaint(0, 0, getWidth(), getHeight());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    }
21270
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   517
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 7668
diff changeset
   518
    public void paint(final Graphics g) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 7668
diff changeset
   519
        // paint peer
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 7668
diff changeset
   520
        paintPeer(g);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 7668
diff changeset
   523
    void paintPeer(final Graphics g) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 7668
diff changeset
   524
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    //used by Peers to avoid flickering withing paint()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    protected void flush(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            XlibWrapper.XFlush(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    public void popup(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        // TBD: grab the pointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        xSetBounds(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    public void handleExposeEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        super.handleExposeEvent(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        XExposeEvent xe = xev.get_xexpose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        if (isEventDisabled(xev)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        int x = xe.get_x();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        int y = xe.get_y();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        int w = xe.get_width();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        int h = xe.get_height();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        Component target = (Component)getEventSource();
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 4285
diff changeset
   552
        AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 4285
diff changeset
   554
        if (!compAccessor.getIgnoreRepaint(target)
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 4285
diff changeset
   555
            && compAccessor.getWidth(target) != 0
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 4285
diff changeset
   556
            && compAccessor.getHeight(target) != 0)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        {
21270
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   558
            postPaintEvent(target, x, y, w, h);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
21270
8a0fc12b81a2 7090424: TestGlyphVectorLayout failed automately with java.lang.StackOverflowError
serb
parents: 18178
diff changeset
   562
    public void postPaintEvent(Component target, int x, int y, int w, int h) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        PaintEvent event = PaintEventDispatcher.getPaintEventDispatcher().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            createPaintEvent(target, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        if (event != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            postEventToEventQueue(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    static int getModifiers(int state, int button, int keyCode) {
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   571
        return getModifiers(state, button, keyCode, 0,  false);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   572
    }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   573
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   574
    static int getModifiers(int state, int button, int keyCode, int type, boolean wheel_mouse) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        int modifiers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   577
        if (((state & XConstants.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            modifiers |= InputEvent.SHIFT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        }
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   580
        if (((state & XConstants.ControlMask) != 0) ^ (keyCode == KeyEvent.VK_CONTROL)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            modifiers |= InputEvent.CTRL_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        if (((state & XToolkit.metaMask) != 0) ^ (keyCode == KeyEvent.VK_META)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            modifiers |= InputEvent.META_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        if (((state & XToolkit.altMask) != 0) ^ (keyCode == KeyEvent.VK_ALT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            modifiers |= InputEvent.ALT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        if (((state & XToolkit.modeSwitchMask) != 0) ^ (keyCode == KeyEvent.VK_ALT_GRAPH)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        }
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   592
        //InputEvent.BUTTON_DOWN_MASK array is starting from BUTTON1_DOWN_MASK on index == 0.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   593
        // button currently reflects a real button number and starts from 1. (except NOBUTTON which is zero )
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   594
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   595
        /* this is an attempt to refactor button IDs in : MouseEvent, InputEvent, XlibWrapper and XWindow.*/
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   596
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   597
        //reflects a button number similar to MouseEvent.BUTTON1, 2, 3 etc.
14888
7ad1550e7050 8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents: 14163
diff changeset
   598
        for (int i = 0; i < XConstants.buttons.length; i ++){
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   599
            //modifier should be added if :
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   600
            // 1) current button is now still in PRESSED state (means that user just pressed mouse but not released yet) or
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   601
            // 2) if Xsystem reports that "state" represents that button was just released. This only happens on RELEASE with 1,2,3 buttons.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   602
            // ONLY one of these conditions should be TRUE to add that modifier.
14888
7ad1550e7050 8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents: 14163
diff changeset
   603
            if (((state & XlibUtil.getButtonMask(i + 1)) != 0) != (button == XConstants.buttons[i])){
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   604
                //exclude wheel buttons from adding their numbers as modifiers
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   605
                if (!wheel_mouse) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   606
                    modifiers |= InputEvent.getMaskForButton(i+1);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   607
                }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   608
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        return modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    static int getXModifiers(AWTKeyStroke stroke) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        int mods = stroke.getModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        int res = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        if ((mods & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   617
            res |= XConstants.ShiftMask;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        if ((mods & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   620
            res |= XConstants.ControlMask;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        if ((mods & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            res |= XToolkit.altMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        if ((mods & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            res |= XToolkit.metaMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        if ((mods & (InputEvent.ALT_GRAPH_DOWN_MASK | InputEvent.ALT_GRAPH_MASK)) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            res |= XToolkit.modeSwitchMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * Returns true if this event is disabled and shouldn't be passed to Java.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * Default implementation returns false for all events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    static int getRightButtonNumber() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        if (rbutton == 0) { // not initialized yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                rbutton = XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), XlibWrapper.ibuffer, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        return rbutton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    static int getMouseMovementSmudge() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        //TODO: It's possible to read corresponding settings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        return AWT_MULTICLICK_SMUDGE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    public void handleButtonPressRelease(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        super.handleButtonPressRelease(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        XButtonEvent xbe = xev.get_xbutton();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        if (isEventDisabled(xev)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        }
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   662
        if (eventLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   663
            eventLog.fine(xbe.toString());
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   664
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        long when;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        int modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        boolean popupTrigger = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        int button=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        boolean wheel_mouse = false;
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   670
        int lbutton = xbe.get_button();
2810
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2805
diff changeset
   671
        /*
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2805
diff changeset
   672
         * Ignore the buttons above 20 due to the bit limit for
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2805
diff changeset
   673
         * InputEvent.BUTTON_DOWN_MASK.
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2805
diff changeset
   674
         * One more bit is reserved for FIRST_HIGH_BIT.
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2805
diff changeset
   675
         */
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2805
diff changeset
   676
        if (lbutton > SunToolkit.MAX_BUTTONS_SUPPORTED) {
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2805
diff changeset
   677
            return;
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2805
diff changeset
   678
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        int type = xev.get_type();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        when = xbe.get_time();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        long jWhen = XToolkit.nowMillisUTC_offset(when);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        int x = xbe.get_x();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        int y = xbe.get_y();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        if (xev.get_xany().get_window() != window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            Point localXY = toLocal(xbe.get_x_root(), xbe.get_y_root());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            x = localXY.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            y = localXY.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   691
        if (type == XConstants.ButtonPress) {
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   692
            //Allow this mouse button to generate CLICK event on next ButtonRelease
14888
7ad1550e7050 8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents: 14163
diff changeset
   693
            mouseButtonClickAllowed |= XlibUtil.getButtonMask(lbutton);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
               multiclick checking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            */
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   698
            if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   699
                eventLog.finest("lastWindow = " + lastWindow + ", lastButton "
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   700
                + lastButton + ", lastTime " + lastTime + ", multiClickTime "
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   701
                + XToolkit.getMultiClickTime());
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   702
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            if (lastWindow == this && lastButton == lbutton && (when - lastTime) < XToolkit.getMultiClickTime()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                clickCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                clickCount = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                lastWindowRef = new WeakReference(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                lastButton = lbutton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                lastX = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                lastY = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            lastTime = when;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
               Check for popup trigger !!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            if (lbutton == getRightButtonNumber() || lbutton > 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                popupTrigger = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                popupTrigger = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   725
        button = XConstants.buttons[lbutton - 1];
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   726
        // 4 and 5 buttons are usually considered assigned to a first wheel
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   727
        if (lbutton == XConstants.buttons[3] ||
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   728
            lbutton == XConstants.buttons[4]) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
            wheel_mouse = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   732
        // mapping extra buttons to numbers starting from 4.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   733
        if ((button > XConstants.buttons[4]) && (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled())){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   734
            return;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   735
        }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   736
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   737
        if (button > XConstants.buttons[4]){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   738
            button -= 2;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   739
        }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   740
        modifiers = getModifiers(xbe.get_state(),button,0, type, wheel_mouse);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        if (!wheel_mouse) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
            MouseEvent me = new MouseEvent((Component)getEventSource(),
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   744
                                           type == XConstants.ButtonPress ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                                           jWhen,modifiers, x, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                                           xbe.get_x_root(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                                           xbe.get_y_root(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                                           clickCount,popupTrigger,button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
            postEventToEventQueue(me);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   752
            if ((type == XConstants.ButtonRelease) &&
14888
7ad1550e7050 8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents: 14163
diff changeset
   753
                ((mouseButtonClickAllowed & XlibUtil.getButtonMask(lbutton)) != 0) ) // No up-button in the drag-state
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                postEventToEventQueue(me = new MouseEvent((Component)getEventSource(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                                                     MouseEvent.MOUSE_CLICKED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                                                     jWhen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                                                     modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                                                     x, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                                                     xbe.get_x_root(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                                                     xbe.get_y_root(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                                                     clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                                                     false, button));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        else {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   768
            if (xev.get_type() == XConstants.ButtonPress) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                MouseWheelEvent mwe = new MouseWheelEvent((Component)getEventSource(),MouseEvent.MOUSE_WHEEL, jWhen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                                                          modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                                                          x, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                                                          xbe.get_x_root(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                                                          xbe.get_y_root(),
5941
1a56de1b70b3 6957166: With XAWT, set arguments properly creating a MouseWheelEvent.
yan
parents: 5506
diff changeset
   774
                                                          1,false,MouseWheelEvent.WHEEL_UNIT_SCROLL,
6824
053f05edc068 6973199: java/awt/Robot/RobotWheelTest/RobotWheelTest.html failed on JDK7 b102 bug passed on b101
dav
parents: 5941
diff changeset
   775
                                                          3,button==4 ?  -1 : 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                postEventToEventQueue(mwe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   780
        /* Update the state variable AFTER the CLICKED event post. */
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   781
        if (type == XConstants.ButtonRelease) {
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   782
            /* Exclude this mouse button from allowed list.*/
14888
7ad1550e7050 8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents: 14163
diff changeset
   783
            mouseButtonClickAllowed &= ~ XlibUtil.getButtonMask(lbutton);
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   784
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    public void handleMotionNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        super.handleMotionNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        XMotionEvent xme = xev.get_xmotion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        if (isEventDisabled(xev)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   794
        int mouseKeyState = 0; //(xme.get_state() & (XConstants.buttonsMask[0] | XConstants.buttonsMask[1] | XConstants.buttonsMask[2]));
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   795
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   796
        //this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   797
        // we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE)
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   798
        // should be passed from XWindow.
14888
7ad1550e7050 8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents: 14163
diff changeset
   799
        final int buttonsNumber = XToolkit.getNumberOfButtonsForMask();
2810
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2805
diff changeset
   800
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2805
diff changeset
   801
        for (int i = 0; i < buttonsNumber; i++){
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   802
            // TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   803
            if ((i != 4) && (i != 5)) {
14888
7ad1550e7050 8005018: X11: focus problems with openjdk 1.7.0 under gnome3 when selected keyboard is not the first in keyboard list
neugens
parents: 14163
diff changeset
   804
                mouseKeyState = mouseKeyState | (xme.get_state() & XlibUtil.getButtonMask(i + 1));
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   805
            }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   806
        }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 447
diff changeset
   807
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        boolean isDragging = (mouseKeyState != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        int mouseEventType = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        if (isDragging) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            mouseEventType = MouseEvent.MOUSE_DRAGGED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            mouseEventType = MouseEvent.MOUSE_MOVED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
           Fix for 6176814 .  Add multiclick checking.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        int x = xme.get_x();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        int y = xme.get_y();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        if (!(lastWindow == this &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
              (xme.get_time() - lastTime) < XToolkit.getMultiClickTime()  &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
              (Math.abs(lastX - x) < AWT_MULTICLICK_SMUDGE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
               Math.abs(lastY - y) < AWT_MULTICLICK_SMUDGE))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
          clickCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
          lastWindowRef = null;
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 439
diff changeset
   830
          mouseButtonClickAllowed = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
          lastTime = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
          lastX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
          lastY = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        long jWhen = XToolkit.nowMillisUTC_offset(xme.get_time());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        int modifiers = getModifiers(xme.get_state(), 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        boolean popupTrigger = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        Component source = (Component)getEventSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        if (xme.get_window() != window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
            Point localXY = toLocal(xme.get_x_root(), xme.get_y_root());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            x = localXY.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
            y = localXY.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        /* Fix for 5039416.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
         * According to canvas.c we shouldn't post any MouseEvent if mouse is dragging and clickCount!=0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        if ((isDragging && clickCount == 0) || !isDragging) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            MouseEvent mme = new MouseEvent(source, mouseEventType, jWhen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                                            modifiers, x, y, xme.get_x_root(), xme.get_y_root(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                                            clickCount, popupTrigger, MouseEvent.NOBUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            postEventToEventQueue(mme);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    // REMIND: need to implement looking for disabled events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    public native boolean x11inputMethodLookupString(long event, long [] keysymArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    native boolean haveCurrentX11InputMethodInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   863
    private boolean mouseAboveMe;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   864
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   865
    public boolean isMouseAbove() {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   866
        synchronized (getStateLock()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   867
            return mouseAboveMe;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   868
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   869
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   870
    protected void setMouseAbove(boolean above) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   871
        synchronized (getStateLock()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   872
            mouseAboveMe = above;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   873
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   874
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   875
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   876
    protected void enterNotify(long window) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   877
        if (window == getWindow()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   878
            setMouseAbove(true);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   879
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   880
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   881
    protected void leaveNotify(long window) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   882
        if (window == getWindow()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   883
            setMouseAbove(false);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   884
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   885
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   886
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    public void handleXCrossingEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        super.handleXCrossingEvent(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        XCrossingEvent xce = xev.get_xcrossing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   891
        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   892
            eventLog.finest(xce.toString());
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   893
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   895
        if (xce.get_type() == XConstants.EnterNotify) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   896
            enterNotify(xce.get_window());
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   897
        } else { // LeaveNotify:
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   898
            leaveNotify(xce.get_window());
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   899
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
   900
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        // Skip event If it was caused by a grab
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        // This is needed because on displays with focus-follows-mouse on MousePress X system generates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        // two XCrossing events with mode != NormalNotify. First of them notifies that the mouse has left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        // current component. Second one notifies that it has entered into the same component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        // This looks like the window under the mouse has actually changed and Java handle these  events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        // accordingly. This leads to impossibility to make a double click on Component (6404708)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        XWindowPeer toplevel = getToplevelXWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        if (toplevel != null && !toplevel.isModalBlocked()){
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   909
            if (xce.get_mode() != XConstants.NotifyNormal) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                // 6404708 : need update cursor in accordance with skipping Leave/EnterNotify event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                // whereas it doesn't need to handled further.
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   912
                if (xce.get_type() == XConstants.EnterNotify) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                    XAwtState.setComponentMouseEntered(getEventSource());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                    XGlobalCursorManager.nativeUpdateCursor(getEventSource());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                } else { // LeaveNotify:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                    XAwtState.setComponentMouseEntered(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        // X sends XCrossing to all hierarchy so if the edge of child equals to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
        // ancestor and mouse enters child, the ancestor will get an event too.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        // From java point the event is bogus as ancestor is obscured, so if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        // the child can get java event itself, we skip it on ancestor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        long childWnd = xce.get_subwindow();
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   926
        if (childWnd != XConstants.None) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
            XBaseWindow child = XToolkit.windowToXWindow(childWnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            if (child != null && child instanceof XWindow &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
                !child.isEventDisabled(xev))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        // Remember old component with mouse to have the opportunity to send it MOUSE_EXITED.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        final Component compWithMouse = XAwtState.getComponentMouseEntered();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        if (toplevel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
            if(!toplevel.isModalBlocked()){
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   939
                if (xce.get_type() == XConstants.EnterNotify) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                    // Change XAwtState's component mouse entered to the up-to-date one before requesting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                    // to update the cursor since XAwtState.getComponentMouseEntered() is used when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                    // cursor is updated (in XGlobalCursorManager.findHeavyweightUnderCursor()).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                    XAwtState.setComponentMouseEntered(getEventSource());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                    XGlobalCursorManager.nativeUpdateCursor(getEventSource());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                } else { // LeaveNotify:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                    XAwtState.setComponentMouseEntered(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            } else {
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 4285
diff changeset
   949
                ((XComponentPeer) AWTAccessor.getComponentAccessor().getPeer(target))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                    .pSetCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        if (isEventDisabled(xev)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        long jWhen = XToolkit.nowMillisUTC_offset(xce.get_time());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
        int modifiers = getModifiers(xce.get_state(),0,0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        int clickCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        boolean popupTrigger = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        int x = xce.get_x();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        int y = xce.get_y();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        if (xce.get_window() != window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
            Point localXY = toLocal(xce.get_x_root(), xce.get_y_root());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
            x = localXY.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
            y = localXY.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        // This code tracks boundary crossing and ensures MOUSE_ENTER/EXIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
        // are posted in alternate pairs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        if (compWithMouse != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
            MouseEvent me = new MouseEvent(compWithMouse,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                MouseEvent.MOUSE_EXITED, jWhen, modifiers, xce.get_x(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount, popupTrigger,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                MouseEvent.NOBUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
            postEventToEventQueue(me);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
            eventLog.finest("Clearing last window ref");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
            lastWindowRef = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        }
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
   981
        if (xce.get_type() == XConstants.EnterNotify) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
            MouseEvent me = new MouseEvent(getEventSource(), MouseEvent.MOUSE_ENTERED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
                jWhen, modifiers, xce.get_x(), xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                popupTrigger, MouseEvent.NOBUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
            postEventToEventQueue(me);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
    public void doLayout(int x, int y, int width, int height) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
    public void handleConfigureNotifyEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
        Rectangle oldBounds = getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        super.handleConfigureNotifyEvent(xev);
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   995
        if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   996
            insLog.finer("Configure, {0}, event disabled: {1}",
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2810
diff changeset
   997
                     xev.get_xconfigure(), isEventDisabled(xev));
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   998
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
        if (isEventDisabled(xev)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
//  if ( Check if it's a resize, a move, or a stacking order change )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
//  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        Rectangle bounds = getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
        if (!bounds.getSize().equals(oldBounds.getSize())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
            postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        if (!bounds.getLocation().equals(oldBounds.getLocation())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
            postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
//  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
    public void handleMapNotifyEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
        super.handleMapNotifyEvent(xev);
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1017
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1018
            log.fine("Mapped {0}", this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1019
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
        if (isEventDisabled(xev)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
        ComponentEvent ce;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
        ce = new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_SHOWN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
        postEventToEventQueue(ce);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    public void handleUnmapNotifyEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
        super.handleUnmapNotifyEvent(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
        if (isEventDisabled(xev)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
        ComponentEvent ce;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        ce = new ComponentEvent(target, ComponentEvent.COMPONENT_HIDDEN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
        postEventToEventQueue(ce);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    private void dumpKeysymArray(XKeyEvent ev) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1041
        if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1042
            keyEventLog.fine("  "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 0))+
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1043
                             "\n        "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 1))+
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1044
                             "\n        "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 2))+
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1045
                             "\n        "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 3)));
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1046
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
       Return unicode character or 0 if no correspondent character found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
       Parameter is a keysym basically from keysymdef.h
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
       XXX: how about vendor keys? Is there some with Unicode value and not in the list?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    */
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1053
    int keysymToUnicode( long keysym, int state ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        return XKeysym.convertKeysym( keysym, state );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    int keyEventType2Id( int xEventType ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        return xEventType == XConstants.KeyPress ? java.awt.event.KeyEvent.KEY_PRESSED :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
               xEventType == XConstants.KeyRelease ? java.awt.event.KeyEvent.KEY_RELEASED : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
    static private long xkeycodeToKeysym(XKeyEvent ev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
        return XKeysym.getKeysym( ev );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
    }
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1063
    private long xkeycodeToPrimaryKeysym(XKeyEvent ev) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1064
        return XKeysym.xkeycode2primary_keysym( ev );
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1065
    }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1066
    static private int primaryUnicode2JavaKeycode(int uni) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1067
        return (uni > 0? sun.awt.ExtendedKeyCodes.getExtendedKeyCodeForChar(uni) : 0);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1068
        //return (uni > 0? uni + 0x01000000 : 0);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1069
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
    void logIncomingKeyEvent(XKeyEvent ev) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1071
        if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1072
            keyEventLog.fine("--XWindow.java:handleKeyEvent:"+ev);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1073
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
        dumpKeysymArray(ev);
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1075
        if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1076
            keyEventLog.fine("XXXXXXXXXXXXXX javakeycode will be most probably:0x"+ Integer.toHexString(XKeysym.getJavaKeycodeOnly(ev)));
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1077
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
    public void handleKeyPress(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
        super.handleKeyPress(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
        XKeyEvent ev = xev.get_xkey();
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1082
        if (eventLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1083
            eventLog.fine(ev.toString());
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1084
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
        if (isEventDisabled(xev)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        handleKeyPress(ev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
    // called directly from this package, unlike handleKeyRelease.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
    // un-final it if you need to override it in a subclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
    final void handleKeyPress(XKeyEvent ev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
        long keysym[] = new long[2];
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1094
        int unicodeKey = 0;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
  1095
        keysym[0] = XConstants.NoSymbol;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1097
        if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
            logIncomingKeyEvent( ev );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        if ( //TODO check if there's an active input method instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
             // without calling a native method. Is it necessary though?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
            haveCurrentX11InputMethodInstance()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
            if (x11inputMethodLookupString(ev.pData, keysym)) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1104
                if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
                    keyEventLog.fine("--XWindow.java XIM did process event; return; dec keysym processed:"+(keysym[0])+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
                                   "; hex keysym processed:"+Long.toHexString(keysym[0])
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
                                   );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
            }else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
                unicodeKey = keysymToUnicode( keysym[0], ev.get_state() );
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1112
                if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
                    keyEventLog.fine("--XWindow.java XIM did NOT process event, hex keysym:"+Long.toHexString(keysym[0])+"\n"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
                                     "                                         unicode key:"+Integer.toHexString((int)unicodeKey));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
        }else  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
            // No input method instance found. For example, there's a Java Input Method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
            // Produce do-it-yourself keysym and perhaps unicode character.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
            keysym[0] = xkeycodeToKeysym(ev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
            unicodeKey = keysymToUnicode( keysym[0], ev.get_state() );
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1122
            if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                keyEventLog.fine("--XWindow.java XIM is absent;             hex keysym:"+Long.toHexString(keysym[0])+"\n"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
                                 "                                         unicode key:"+Integer.toHexString((int)unicodeKey));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
        // Keysym should be converted to Unicode, if possible and necessary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        // and Java KeyEvent keycode should be calculated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
        // For press we should post pressed & typed Java events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
        // Press event might be not processed to this time because
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
        //  (1) either XIM could not handle it or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
        //  (2) it was Latin 1:1 mapping.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
        //
14163
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1135
        // Preserve modifiers to get Java key code for dead keys
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1136
        boolean isDeadKey = isDeadKey(keysym[0]);
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1137
        XKeysym.Keysym2JavaKeycode jkc = isDeadKey ? XKeysym.getJavaKeycode(keysym[0])
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1138
                : XKeysym.getJavaKeycode(ev);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
        if( jkc == null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            jkc = new XKeysym.Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        }
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1142
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1143
        // Take the first keysym from a keysym array associated with the XKeyevent
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1144
        // and convert it to Unicode. Then, even if a Java keycode for the keystroke
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1145
        // is undefined, we still have a guess of what has been engraved on a keytop.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1146
        int unicodeFromPrimaryKeysym = keysymToUnicode( xkeycodeToPrimaryKeysym(ev) ,0);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1147
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1148
        if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
            keyEventLog.fine(">>>Fire Event:"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
               (ev.get_type() == XConstants.KeyPress ? "KEY_PRESSED; " : "KEY_RELEASED; ")+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
               "jkeycode:decimal="+jkc.getJavaKeycode()+
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1152
               ", hex=0x"+Integer.toHexString(jkc.getJavaKeycode())+"; "+
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1153
               " legacy jkeycode: decimal="+XKeysym.getLegacyJavaKeycodeOnly(ev)+
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1154
               ", hex=0x"+Integer.toHexString(XKeysym.getLegacyJavaKeycodeOnly(ev))+"; "
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
            );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        }
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1157
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1158
        int jkeyToReturn = XKeysym.getLegacyJavaKeycodeOnly(ev); // someway backward compatible
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1159
        int jkeyExtended = jkc.getJavaKeycode() == java.awt.event.KeyEvent.VK_UNDEFINED ?
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1160
                           primaryUnicode2JavaKeycode( unicodeFromPrimaryKeysym ) :
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1161
                             jkc.getJavaKeycode();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
        postKeyEvent( java.awt.event.KeyEvent.KEY_PRESSED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                          ev.get_time(),
14163
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1164
                          isDeadKey ? jkeyExtended : jkeyToReturn,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
                          (unicodeKey == 0 ? java.awt.event.KeyEvent.CHAR_UNDEFINED : unicodeKey),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
                          jkc.getKeyLocation(),
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1167
                          ev.get_state(),ev.getPData(), XKeyEvent.getSize(), (long)(ev.get_keycode()),
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1168
                          unicodeFromPrimaryKeysym,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1169
                          jkeyExtended);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1170
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1171
14163
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1172
        if (unicodeKey > 0 && !isDeadKey) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1173
                if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1174
                    keyEventLog.fine("fire _TYPED on "+unicodeKey);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1175
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
                postKeyEvent( java.awt.event.KeyEvent.KEY_TYPED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
                              ev.get_time(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
                              java.awt.event.KeyEvent.VK_UNDEFINED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
                              unicodeKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
                              java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN,
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1181
                              ev.get_state(),ev.getPData(), XKeyEvent.getSize(), (long)0,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1182
                              unicodeFromPrimaryKeysym,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1183
                              java.awt.event.KeyEvent.VK_UNDEFINED);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1184
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
    public void handleKeyRelease(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
        super.handleKeyRelease(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
        XKeyEvent ev = xev.get_xkey();
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1193
        if (eventLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1194
            eventLog.fine(ev.toString());
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1195
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
        if (isEventDisabled(xev)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        handleKeyRelease(ev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
    // un-private it if you need to call it from elsewhere
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
    private void handleKeyRelease(XKeyEvent ev) {
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1203
        int unicodeKey = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1205
        if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
            logIncomingKeyEvent( ev );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
        // Keysym should be converted to Unicode, if possible and necessary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
        // and Java KeyEvent keycode should be calculated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
        // For release we should post released event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
        //
14163
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1212
        // Preserve modifiers to get Java key code for dead keys
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1213
        long keysym = xkeycodeToKeysym(ev);
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1214
        boolean isDeadKey = isDeadKey(keysym);
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1215
        XKeysym.Keysym2JavaKeycode jkc = isDeadKey ? XKeysym.getJavaKeycode(keysym)
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1216
                : XKeysym.getJavaKeycode(ev);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
        if( jkc == null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
            jkc = new XKeysym.Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
        }
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1220
        if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
            keyEventLog.fine(">>>Fire Event:"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
               (ev.get_type() == XConstants.KeyPress ? "KEY_PRESSED; " : "KEY_RELEASED; ")+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
               "jkeycode:decimal="+jkc.getJavaKeycode()+
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1224
               ", hex=0x"+Integer.toHexString(jkc.getJavaKeycode())+"; "+
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1225
               " legacy jkeycode: decimal="+XKeysym.getLegacyJavaKeycodeOnly(ev)+
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1226
               ", hex=0x"+Integer.toHexString(XKeysym.getLegacyJavaKeycodeOnly(ev))+"; "
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
            );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
        // We obtain keysym from IM and derive unicodeKey from it for KeyPress only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
        // We used to cache that value and retrieve it on KeyRelease,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
        // but in case for example of a dead key+vowel pair, a vowel after a deadkey
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
        // might never be cached before.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
        // Also, switching between keyboard layouts, we might cache a wrong letter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
        // That's why we use the same procedure as if there was no IM instance: do-it-yourself unicode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
        unicodeKey = keysymToUnicode( xkeycodeToKeysym(ev), ev.get_state() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1237
        // Take a first keysym from a keysym array associated with the XKeyevent
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1238
        // and convert it to Unicode. Then, even if Java keycode for the keystroke
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1239
        // is undefined, we still will have a guess of what was engraved on a keytop.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1240
        int unicodeFromPrimaryKeysym = keysymToUnicode( xkeycodeToPrimaryKeysym(ev) ,0);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1241
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1242
        int jkeyToReturn = XKeysym.getLegacyJavaKeycodeOnly(ev); // someway backward compatible
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1243
        int jkeyExtended = jkc.getJavaKeycode() == java.awt.event.KeyEvent.VK_UNDEFINED ?
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1244
                           primaryUnicode2JavaKeycode( unicodeFromPrimaryKeysym ) :
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1245
                             jkc.getJavaKeycode();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        postKeyEvent(  java.awt.event.KeyEvent.KEY_RELEASED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
                          ev.get_time(),
14163
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1248
                          isDeadKey ? jkeyExtended : jkeyToReturn,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
                          (unicodeKey == 0 ? java.awt.event.KeyEvent.CHAR_UNDEFINED : unicodeKey),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
                          jkc.getKeyLocation(),
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1251
                          ev.get_state(),ev.getPData(), XKeyEvent.getSize(), (long)(ev.get_keycode()),
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1252
                          unicodeFromPrimaryKeysym,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1253
                          jkeyExtended);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1254
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
14163
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1258
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1259
    private boolean isDeadKey(long keysym){
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1260
        return XKeySymConstants.XK_dead_grave <= keysym && keysym <= XKeySymConstants.XK_dead_semivoiced_sound;
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1261
    }
87f1bc730fe2 8000626: Implement dead key detection for KeyEvent on Linux
alexsch
parents: 13604
diff changeset
  1262
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1263
    /*
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1264
     * XmNiconic and Map/UnmapNotify (that XmNiconic relies on) are
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1265
     * unreliable, since mapping changes can happen for a virtual desktop
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1266
     * switch or MacOS style shading that became quite popular under X as
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1267
     * well.  Yes, it probably should not be this way, as it violates
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1268
     * ICCCM, but reality is that quite a lot of window managers abuse
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1269
     * mapping state.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1270
     */
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1271
    int getWMState() {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1272
        if (stateChanged) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1273
            stateChanged = false;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1274
            WindowPropertyGetter getter =
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1275
                new WindowPropertyGetter(window, XWM.XA_WM_STATE, 0, 1, false,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1276
                                         XWM.XA_WM_STATE);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1277
            try {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1278
                int status = getter.execute();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1279
                if (status != XConstants.Success || getter.getData() == 0) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1280
                    return savedState = XUtilConstants.WithdrawnState;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1281
                }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1282
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1283
                if (getter.getActualType() != XWM.XA_WM_STATE.getAtom() && getter.getActualFormat() != 32) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1284
                    return savedState = XUtilConstants.WithdrawnState;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1285
                }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1286
                savedState = (int)Native.getCard32(getter.getData());
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1287
            } finally {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1288
                getter.dispose();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1289
            }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1290
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1291
        return savedState;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1292
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1293
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1294
    /**
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1295
     * Override this methods to get notifications when top-level window state changes. The state is
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1296
     * meant in terms of ICCCM: WithdrawnState, IconicState, NormalState
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1297
     */
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1298
    protected void stateChanged(long time, int oldState, int newState) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1299
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1300
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1301
    @Override
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1302
    public void handlePropertyNotify(XEvent xev) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1303
        super.handlePropertyNotify(xev);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1304
        XPropertyEvent ev = xev.get_xproperty();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1305
        if (ev.get_atom() == XWM.XA_WM_STATE.getAtom()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1306
            // State has changed, invalidate saved value
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1307
            stateChanged = true;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1308
            stateChanged(ev.get_time(), savedState, getWMState());
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1309
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1310
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1311
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
    public void reshape(Rectangle bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
        reshape(bounds.x, bounds.y, bounds.width, bounds.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
    public void reshape(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
        if (width <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
            width = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
        if (height <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
            height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
        this.x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
        this.y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
        this.width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
        this.height = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
        xSetBounds(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
        // Fixed 6322593, 6304251, 6315137:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
        // XWindow's SurfaceData should be invalidated and recreated as part
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
        // of the process of resizing the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
        // see the evaluation of the bug 6304251 for more information
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
        validateSurface();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
        layout();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
    public void layout() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
    boolean isShowing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
        return visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
    boolean isResizable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
    boolean isLocationByPlatform() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
    void updateSizeHints() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
        updateSizeHints(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
    void updateSizeHints(int x, int y, int width, int height) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
  1355
        long flags = XUtilConstants.PSize | (isLocationByPlatform() ? 0 : (XUtilConstants.PPosition | XUtilConstants.USPosition));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
        if (!isResizable()) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1357
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1358
                log.finer("Window {0} is not resizable", this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1359
            }
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
  1360
            flags |= XUtilConstants.PMinSize | XUtilConstants.PMaxSize;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
        } else {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1362
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1363
                log.finer("Window {0} is resizable", this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1364
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
        setSizeHints(flags, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
    void updateSizeHints(int x, int y) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
  1370
        long flags = isLocationByPlatform() ? 0 : (XUtilConstants.PPosition | XUtilConstants.USPosition);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
        if (!isResizable()) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1372
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1373
                log.finer("Window {0} is not resizable", this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1374
            }
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 116
diff changeset
  1375
            flags |= XUtilConstants.PMinSize | XUtilConstants.PMaxSize | XUtilConstants.PSize;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
        } else {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1377
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1378
                log.finer("Window {0} is resizable", this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1379
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
        setSizeHints(flags, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
2805
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1384
    void validateSurface() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
        if ((width != oldWidth) || (height != oldHeight)) {
2805
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1386
            doValidateSurface();
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1387
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
            oldWidth = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
            oldHeight = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
2805
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1393
    final void doValidateSurface() {
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1394
        SurfaceData oldData = surfaceData;
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1395
        if (oldData != null) {
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1396
            surfaceData = graphicsConfig.createSurfaceData(this);
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1397
            oldData.invalidate();
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1398
        }
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1399
    }
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2643
diff changeset
  1400
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
    public SurfaceData getSurfaceData() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
        return surfaceData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
        SurfaceData oldData = surfaceData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
        surfaceData = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
        if (oldData != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
            oldData.invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
        XToolkit.targetDisposedPeer(target, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
        destroy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
    public Point getLocationOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
        synchronized (target.getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
            Component comp = target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
            while (comp != null && !(comp instanceof Window)) {
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 4285
diff changeset
  1420
                comp = AWTAccessor.getComponentAccessor().getParent(comp);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
            // applets, embedded, etc - translate directly
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
            // XXX: override in subclass?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
            if (comp == null || comp instanceof sun.awt.EmbeddedFrame) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
                return toGlobal(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
                Object wpeer = XToolkit.targetToPeer(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
                if (wpeer == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
                    || !(wpeer instanceof XDecoratedPeer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
                    || ((XDecoratedPeer)wpeer).configure_seen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
                    return toGlobal(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
                // wpeer is an XDecoratedPeer not yet fully adopted by WM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
                Point pt = toOtherWindow(getContentWindow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
                                         ((XDecoratedPeer)wpeer).getContentWindow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
                                         0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
                if (pt == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
                    pt = new Point(((XBaseWindow)wpeer).getAbsoluteX(), ((XBaseWindow)wpeer).getAbsoluteY());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
                pt.x += comp.getX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
                pt.y += comp.getY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
                return pt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
    static void setBData(KeyEvent e, byte[] data) {
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 10096
diff changeset
  1458
        AWTAccessor.getAWTEventAccessor().setBData(e, data);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1461
    public void postKeyEvent(int id, long when, int keyCode, int keyChar,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1462
        int keyLocation, int state, long event, int eventSize, long rawCode,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1463
        int unicodeFromPrimaryKeysym, int extendedKeyCode)
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1464
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
        long jWhen = XToolkit.nowMillisUTC_offset(when);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
        int modifiers = getModifiers(state, 0, keyCode);
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1468
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
        KeyEvent ke = new KeyEvent((Component)getEventSource(), id, jWhen,
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  1470
                                   modifiers, keyCode, (char)keyChar, keyLocation);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
        if (event != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
            byte[] data = Native.toBytes(event, eventSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
            setBData(ke, data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
        }
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 10096
diff changeset
  1475
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 10096
diff changeset
  1476
        AWTAccessor.KeyEventAccessor kea = AWTAccessor.getKeyEventAccessor();
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 10096
diff changeset
  1477
        kea.setRawCode(ke, rawCode);
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 10096
diff changeset
  1478
        kea.setPrimaryLevelUnicode(ke, (long)unicodeFromPrimaryKeysym);
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 10096
diff changeset
  1479
        kea.setExtendedKeyCode(ke, (long)extendedKeyCode);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
        postEventToEventQueue(ke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
    static native int getAWTKeyCodeForKeySym(int keysym);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
    static native int getKeySymForAWTKeyCode(int keycode);
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1485
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1486
    /* These two methods are actually applicable to toplevel windows only.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1487
     * However, the functionality is required by both the XWindowPeer and
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1488
     * XWarningWindow, both of which have the XWindow as a common ancestor.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1489
     * See XWM.setMotifDecor() for details.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1490
     */
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1491
    public PropMwmHints getMWMHints() {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1492
        if (mwm_hints == null) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1493
            mwm_hints = new PropMwmHints();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1494
            if (!XWM.XA_MWM_HINTS.getAtomData(getWindow(), mwm_hints.pData, MWMConstants.PROP_MWM_HINTS_ELEMENTS)) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1495
                mwm_hints.zero();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1496
            }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1497
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1498
        return mwm_hints;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1499
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1500
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1501
    public void setMWMHints(PropMwmHints hints) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1502
        mwm_hints = hints;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1503
        if (hints != null) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1504
            XWM.XA_MWM_HINTS.setAtomData(getWindow(), mwm_hints.pData, MWMConstants.PROP_MWM_HINTS_ELEMENTS);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1505
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1506
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1507
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1508
    protected final void initWMProtocols() {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1509
        wm_protocols.setAtomListProperty(this, getWMProtocols());
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1510
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1511
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1512
    /**
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1513
     * Returns list of protocols which should be installed on this window.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1514
     * Descendants can override this method to add class-specific protocols
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1515
     */
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1516
    protected XAtomList getWMProtocols() {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1517
        // No protocols on simple window
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1518
        return new XAtomList();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1519
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 1962
diff changeset
  1520
4256
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1521
    /**
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1522
     * Indicates if the window is currently in the FSEM.
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1523
     * Synchronization: state lock.
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1524
     */
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1525
    private boolean fullScreenExclusiveModeState = false;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1526
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1527
    // Implementation of the X11ComponentPeer
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1528
    @Override
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1529
    public void setFullScreenExclusiveModeState(boolean state) {
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1530
        synchronized (getStateLock()) {
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1531
            fullScreenExclusiveModeState = state;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1532
        }
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1533
    }
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1534
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1535
    public final boolean isFullScreenExclusiveMode() {
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1536
        synchronized (getStateLock()) {
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1537
            return fullScreenExclusiveModeState;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1538
        }
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1539
    }
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2810
diff changeset
  1540
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
}