jdk/src/java.desktop/unix/classes/sun/awt/X11/XBaseWindow.java
author alexsch
Fri, 13 Nov 2015 18:36:14 +0400
changeset 34395 2ac7e99f7f4a
parent 32865 f9cb6e427f9e
child 35658 48bccfa61aef
permissions -rw-r--r--
8137571: Linux HiDPI Graphics support Reviewed-by: flar, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 18178
diff changeset
     2
 * Copyright (c) 2003, 2014, 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: 4214
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: 4214
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: 4214
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4214
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 sun.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.*;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3288
diff changeset
    31
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
    33
public class XBaseWindow {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3288
diff changeset
    34
    private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XBaseWindow");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3288
diff changeset
    35
    private static final PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XBaseWindow");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3288
diff changeset
    36
    private static final PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XBaseWindow");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3288
diff changeset
    37
    private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XBaseWindow");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3288
diff changeset
    38
    private static final PlatformLogger grabLog = PlatformLogger.getLogger("sun.awt.X11.grab.XBaseWindow");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    public static final String
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        PARENT_WINDOW = "parent window", // parent window, Long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        BOUNDS = "bounds", // bounds of the window, Rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        OVERRIDE_REDIRECT = "overrideRedirect", // override_redirect setting, Boolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        EVENT_MASK = "event mask", // event mask, Integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        VALUE_MASK = "value mask", // value mask, Long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        BORDER_PIXEL = "border pixel", // border pixel value, Integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        COLORMAP = "color map", // color map, Long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        DEPTH = "visual depth", // depth, Integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        VISUAL_CLASS = "visual class", // visual class, Integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        VISUAL = "visual", // visual, Long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        EMBEDDED = "embedded", // is embedded?, Boolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        DELAYED = "delayed", // is creation delayed?, Boolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        PARENT = "parent", // parent peer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        BACKGROUND_PIXMAP = "pixmap", // background pixmap
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        VISIBLE = "visible", // whether it is visible by default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        SAVE_UNDER = "save under", // save content under this window
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        BACKING_STORE = "backing store", // enables double buffering
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        BIT_GRAVITY = "bit gravity"; // copy old content on geometry change
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private XCreateWindowParams delayedParams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    Set<Long> children = new HashSet<Long>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    long window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    boolean visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    boolean mapped;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    boolean embedded;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    Rectangle maxBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    volatile XBaseWindow parentWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private boolean disposed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private long screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private XSizeHints hints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private XWMHints wmHints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 25859
diff changeset
    75
    static final int MIN_SIZE = 1;
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 25859
diff changeset
    76
    static final int DEF_LOCATION = 1;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private static XAtom wm_client_leader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    static enum InitialiseState {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        INITIALISING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        NOT_INITIALISED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        INITIALISED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        FAILED_INITIALISATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private InitialiseState initialising;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    int x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    int y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    int width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    int height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    void awtLock() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    void awtUnlock() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    void awtLockNotifyAll() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        XToolkit.awtLockNotifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    void awtLockWait() throws InterruptedException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        XToolkit.awtLockWait();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    // To prevent errors from overriding obsolete methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    protected final void init(long parentWindow, Rectangle bounds) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    protected final void preInit() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    protected final void postInit() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    // internal lock for synchronizing state changes and paint calls, initialized in preInit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    // the order with other locks: AWTLock -> stateLock
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    static class StateLock extends Object { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    protected StateLock state_lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Called for delayed inits during construction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    void instantPreInit(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        state_lock = new StateLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        initialising = InitialiseState.NOT_INITIALISED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Called before window creation, descendants should override to initialize the data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * initialize params.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    void preInit(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        state_lock = new StateLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        initialising = InitialiseState.NOT_INITIALISED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        embedded = Boolean.TRUE.equals(params.get(EMBEDDED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        visible = Boolean.TRUE.equals(params.get(VISIBLE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        Object parent = params.get(PARENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        if (parent instanceof XBaseWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            parentWindow = (XBaseWindow)parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            Long parentWindowID = (Long)params.get(PARENT_WINDOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            if (parentWindowID != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                parentWindow = XToolkit.windowToXWindow(parentWindowID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        Long eventMask = (Long)params.get(EVENT_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        if (eventMask != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            long mask = eventMask.longValue();
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   151
            mask |= XConstants.SubstructureNotifyMask;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            params.put(EVENT_MASK, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        screen = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Called after window creation, descendants should override to initialize Window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * with class-specific values and perform post-initialization actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    void postInit(XCreateWindowParams params) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   163
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   164
            log.fine("WM name is " + getWMName());
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   165
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        updateWMName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        // Set WM_CLIENT_LEADER property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        initClientLeader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * Creates window using parameters <code>params</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * If params contain flag DELAYED doesn't do anything.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Note: Descendants can call this method to create the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * at the time different to instance construction.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    protected final void init(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        initialising = InitialiseState.INITIALISING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            if (!Boolean.TRUE.equals(params.get(DELAYED))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                preInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                create(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                postInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                instantPreInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                delayedParams = params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            initialising = InitialiseState.INITIALISED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            awtLockNotifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        } catch (RuntimeException re) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            initialising = InitialiseState.FAILED_INITIALISATION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            awtLockNotifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            throw re;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        } catch (Throwable t) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3288
diff changeset
   203
            log.warning("Exception during peer initialization", t);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            initialising = InitialiseState.FAILED_INITIALISATION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            awtLockNotifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public boolean checkInitialised() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            switch (initialising) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
              case INITIALISED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                  return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
              case INITIALISING:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                  try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                      while (initialising != InitialiseState.INITIALISED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                          awtLockWait();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                  } catch (InterruptedException ie) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                      return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                  return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
              case NOT_INITIALISED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
              case FAILED_INITIALISATION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                  return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
              default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                  return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * Creates an invisible InputOnly window without an associated Component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    XBaseWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        this(new XCreateWindowParams());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * Creates normal child window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    XBaseWindow(long parentWindow, Rectangle bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        this(new XCreateWindowParams(new Object[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            BOUNDS, bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            PARENT_WINDOW, Long.valueOf(parentWindow)}));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * Creates top-level window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    XBaseWindow(Rectangle bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        this(new XCreateWindowParams(new Object[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            BOUNDS, bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public XBaseWindow (XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        init(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    /* This create is used by the XEmbeddedFramePeer since it has to create the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
       as a child of the netscape window. This netscape window is passed in as wid */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    XBaseWindow(long parentWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        this(new XCreateWindowParams(new Object[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            PARENT_WINDOW, Long.valueOf(parentWindow),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            EMBEDDED, Boolean.TRUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * Verifies that all required parameters are set. If not, sets them to default values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * Verifies values of critical parameters, adjust their values when needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @throws IllegalArgumentException if params is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    protected void checkParams(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        if (params == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            throw new IllegalArgumentException("Window creation parameters are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        params.putIfNull(PARENT_WINDOW, Long.valueOf(XToolkit.getDefaultRootWindow()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        params.putIfNull(BOUNDS, new Rectangle(DEF_LOCATION, DEF_LOCATION, MIN_SIZE, MIN_SIZE));
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   286
        params.putIfNull(DEPTH, Integer.valueOf((int)XConstants.CopyFromParent));
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   287
        params.putIfNull(VISUAL, Long.valueOf(XConstants.CopyFromParent));
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 18178
diff changeset
   288
        params.putIfNull(VISUAL_CLASS, Integer.valueOf(XConstants.InputOnly));
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   289
        params.putIfNull(VALUE_MASK, Long.valueOf(XConstants.CWEventMask));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        Rectangle bounds = (Rectangle)params.get(BOUNDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        bounds.width = Math.max(MIN_SIZE, bounds.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        bounds.height = Math.max(MIN_SIZE, bounds.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        Long eventMaskObj = (Long)params.get(EVENT_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        long eventMask = eventMaskObj != null ? eventMaskObj.longValue() : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        // We use our own synthetic grab see XAwtState.getGrabWindow()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        // (see X vol. 1, 8.3.3.2)
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   298
        eventMask |= XConstants.PropertyChangeMask | XConstants.OwnerGrabButtonMask;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        params.put(EVENT_MASK, Long.valueOf(eventMask));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    /**
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   303
     * Returns scale factor of the window. It is used to convert native
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   304
     * coordinates to local and vice verse.
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   305
     */
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   306
    protected int getScale() {
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   307
        return 1;
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   308
    }
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   309
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   310
    protected int scaleUp(int x) {
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   311
        return x;
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   312
    }
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   313
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   314
    protected int scaleDown(int x) {
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   315
        return x;
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   316
    }
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   317
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   318
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * Creates window with parameters specified by <code>params</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @see #init
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    private final void create(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            XSetWindowAttributes xattr = new XSetWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                checkParams(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                long value_mask = ((Long)params.get(VALUE_MASK)).longValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                Long eventMask = (Long)params.get(EVENT_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                xattr.set_event_mask(eventMask.longValue());
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   333
                value_mask |= XConstants.CWEventMask;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                Long border_pixel = (Long)params.get(BORDER_PIXEL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                if (border_pixel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                    xattr.set_border_pixel(border_pixel.longValue());
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   338
                    value_mask |= XConstants.CWBorderPixel;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                Long colormap = (Long)params.get(COLORMAP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                if (colormap != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                    xattr.set_colormap(colormap.longValue());
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   344
                    value_mask |= XConstants.CWColormap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                Long background_pixmap = (Long)params.get(BACKGROUND_PIXMAP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                if (background_pixmap != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                    xattr.set_background_pixmap(background_pixmap.longValue());
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   349
                    value_mask |= XConstants.CWBackPixmap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                Long parentWindow = (Long)params.get(PARENT_WINDOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                Rectangle bounds = (Rectangle)params.get(BOUNDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                Integer depth = (Integer)params.get(DEPTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                Integer visual_class = (Integer)params.get(VISUAL_CLASS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                Long visual = (Long)params.get(VISUAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                Boolean overrideRedirect = (Boolean)params.get(OVERRIDE_REDIRECT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                if (overrideRedirect != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                    xattr.set_override_redirect(overrideRedirect.booleanValue());
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   360
                    value_mask |= XConstants.CWOverrideRedirect;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                Boolean saveUnder = (Boolean)params.get(SAVE_UNDER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                if (saveUnder != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                    xattr.set_save_under(saveUnder.booleanValue());
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   366
                    value_mask |= XConstants.CWSaveUnder;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                Integer backingStore = (Integer)params.get(BACKING_STORE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                if (backingStore != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                    xattr.set_backing_store(backingStore.intValue());
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   372
                    value_mask |= XConstants.CWBackingStore;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                Integer bitGravity = (Integer)params.get(BIT_GRAVITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                if (bitGravity != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                    xattr.set_bit_gravity(bitGravity.intValue());
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   378
                    value_mask |= XConstants.CWBitGravity;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   381
                if (log.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                    log.fine("Creating window for " + this + " with the following attributes: \n" + params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                window = XlibWrapper.XCreateWindow(XToolkit.getDisplay(),
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   385
                                                   parentWindow.longValue(),
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   386
                                                   scaleUp(bounds.x),
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   387
                                                   scaleUp(bounds.y),
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   388
                                                   scaleUp(bounds.width),
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   389
                                                   scaleUp(bounds.height),
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   390
                                                   0, // border
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   391
                                                   depth.intValue(), // depth
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   392
                                                   visual_class.intValue(), // class
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   393
                                                   visual.longValue(), // visual
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   394
                                                   value_mask,  // value mask
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   395
                                                   xattr.pData); // attributes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                if (window == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                    throw new IllegalStateException("Couldn't create window because of wrong parameters. Run with NOISY_AWT to see details");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                XToolkit.addToWinMap(window, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                xattr.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    public XCreateWindowParams getDelayedParams() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        return delayedParams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    protected String getWMName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        return XToolkit.getCorrectXIDString(getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    protected void initClientLeader() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            if (wm_client_leader == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                wm_client_leader = XAtom.get("WM_CLIENT_LEADER");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            wm_client_leader.setWindowProperty(this, getXAWTRootWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    static XRootWindow getXAWTRootWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        return XRootWindow.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    void destroy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            if (hints != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                XlibWrapper.XFree(hints.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                hints = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            XToolkit.removeFromWinMap(getWindow(), this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            XlibWrapper.XDestroyWindow(XToolkit.getDisplay(), getWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            if (XPropertyCache.isCachingSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                XPropertyCache.clearCache(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            window = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            if( !isDisposed() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                setDisposed( true );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            XAwtState.getGrabWindow(); // Magic - getGrabWindow clear state if grabbing window is disposed of.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    void flush() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            XlibWrapper.XFlush(XToolkit.getDisplay());
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * Helper function to set W
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    public final void setWMHints(XWMHints hints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    public XWMHints getWMHints() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        if (wmHints == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            wmHints = new XWMHints(XlibWrapper.XAllocWMHints());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
//              XlibWrapper.XGetWMHints(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
//                                      getWindow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
//                                      wmHints.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        return wmHints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * Call this method under AWTLock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * The lock should be acquired untill all operations with XSizeHints are completed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    public XSizeHints getHints() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        if (hints == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            long p_hints = XlibWrapper.XAllocSizeHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            hints = new XSizeHints(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
//              XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), getWindow(), p_hints, XlibWrapper.larg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            // TODO: Shouldn't we listen for WM updates on this property?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        return hints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    public void setSizeHints(long flags, int x, int y, int width, int height) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   503
        if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   504
            insLog.finer("Setting hints, flags " + XlibWrapper.hintsToString(flags));
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   505
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            XSizeHints hints = getHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
            // Note: if PPosition is not set in flags this means that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            // we want to reset PPosition in hints.  This is necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            // for locationByPlatform functionality
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   512
            if ((flags & XUtilConstants.PPosition) != 0) {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   513
                hints.set_x(scaleUp(x));
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   514
                hints.set_y(scaleUp(y));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            }
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   516
            if ((flags & XUtilConstants.PSize) != 0) {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   517
                hints.set_width(scaleUp(width));
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   518
                hints.set_height(scaleUp(height));
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   519
            } else if ((hints.get_flags() & XUtilConstants.PSize) != 0) {
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   520
                flags |= XUtilConstants.PSize;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            }
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   522
            if ((flags & XUtilConstants.PMinSize) != 0) {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   523
                hints.set_min_width(scaleUp(width));
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   524
                hints.set_min_height(scaleUp(height));
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   525
            } else if ((hints.get_flags() & XUtilConstants.PMinSize) != 0) {
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   526
                flags |= XUtilConstants.PMinSize;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                //Fix for 4320050: Minimum size for java.awt.Frame is not being enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                //We don't need to reset minimum size if it's already set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            }
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   530
            if ((flags & XUtilConstants.PMaxSize) != 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                if (maxBounds != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                    if (maxBounds.width != Integer.MAX_VALUE) {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   533
                        hints.set_max_width(scaleUp(maxBounds.width));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                        hints.set_max_width(XToolkit.getDefaultScreenWidth());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                    if (maxBounds.height != Integer.MAX_VALUE) {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   538
                        hints.set_max_height(scaleUp(maxBounds.height));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                        hints.set_max_height(XToolkit.getDefaultScreenHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                } else {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   543
                    hints.set_max_width(scaleUp(width));
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   544
                    hints.set_max_height(scaleUp(height));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                }
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   546
            } else if ((hints.get_flags() & XUtilConstants.PMaxSize) != 0) {
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   547
                flags |= XUtilConstants.PMaxSize;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                if (maxBounds != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                    if (maxBounds.width != Integer.MAX_VALUE) {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   550
                        hints.set_max_width(scaleUp(maxBounds.width));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                    } else {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   552
                        hints.set_max_width(scaleUp(XToolkit.getDefaultScreenWidth()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                    if (maxBounds.height != Integer.MAX_VALUE) {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   555
                        hints.set_max_height(scaleUp(maxBounds.height));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                    } else {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   557
                        hints.set_max_height(scaleUp(XToolkit.getDefaultScreenHeight()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                    // Leave intact
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            }
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   563
            flags |= XUtilConstants.PWinGravity;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            hints.set_flags(flags);
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 18178
diff changeset
   565
            hints.set_win_gravity(XConstants.NorthWestGravity);
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   566
            if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   567
                insLog.finer("Setting hints, resulted flags " + XlibWrapper.hintsToString(flags) +
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   568
                             ", values " + hints);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   569
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            XlibWrapper.XSetWMNormalHints(XToolkit.getDisplay(), getWindow(), hints.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    public boolean isMinSizeSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        XSizeHints hints = getHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        long flags = hints.get_flags();
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   579
        return ((flags & XUtilConstants.PMinSize) == XUtilConstants.PMinSize);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * This lock object can be used to protect instance data from concurrent access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * by two threads. If both state lock and AWT lock are taken, AWT Lock should be taken first.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    Object getStateLock() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        return state_lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    public long getWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        return window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    public long getContentWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        return window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    public XBaseWindow getContentXWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        return XToolkit.windowToXWindow(getContentWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        return new Rectangle(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    public Dimension getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        return new Dimension(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    public void toFront() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            XlibWrapper.XRaiseWindow(XToolkit.getDisplay(), getWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    public void xRequestFocus(long time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        try {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   620
            if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   621
                focusLog.finer("XSetInputFocus on " + Long.toHexString(getWindow()) + " with time " + time);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   622
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            XlibWrapper.XSetInputFocus2(XToolkit.getDisplay(), getWindow(), time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    public void xRequestFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        try {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   631
            if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   632
                focusLog.finer("XSetInputFocus on " + Long.toHexString(getWindow()));
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   633
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
             XlibWrapper.XSetInputFocus(XToolkit.getDisplay(), getWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    public static long xGetInputFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            return XlibWrapper.XGetInputFocus(XToolkit.getDisplay());
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    public void xSetVisible(boolean visible) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   650
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   651
            log.fine("Setting visible on " + this + " to " + visible);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   652
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            this.visible = visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            if (visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                XlibWrapper.XMapWindow(XToolkit.getDisplay(), getWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), getWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            XlibWrapper.XFlush(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    boolean isMapped() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        return mapped;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    void updateWMName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        String name = getWMName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                name = " ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            XAtom nameAtom = XAtom.get(XAtom.XA_WM_NAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            nameAtom.setProperty(getWindow(), name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            XAtom netNameAtom = XAtom.get("_NET_WM_NAME");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            netNameAtom.setPropertyUTF8(getWindow(), name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    void setWMClass(String[] cl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        if (cl.length != 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            throw new IllegalArgumentException("WM_CLASS_NAME consists of exactly two strings");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            XAtom xa = XAtom.get(XAtom.XA_WM_CLASS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            xa.setProperty8(getWindow(), cl[0] + '\0' + cl[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    boolean isVisible() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        return visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    static long getScreenOfWindow(long window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            return XlibWrapper.getScreenOfWindow(XToolkit.getDisplay(), window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    long getScreenNumber() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            return XlibWrapper.XScreenNumberOfScreen(getScreen());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    long getScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        if (screen == -1) { // Not initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
            screen = getScreenOfWindow(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        return screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    public void xSetBounds(Rectangle bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        xSetBounds(bounds.x, bounds.y, bounds.width, bounds.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    public void xSetBounds(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        if (getWindow() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            insLog.warning("Attempt to resize uncreated window");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
            throw new IllegalStateException("Attempt to resize uncreated window");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        }
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   737
        if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   738
            insLog.fine("Setting bounds on " + this + " to (" + x + ", " + y + "), " + width + "x" + height);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   739
        }
6637
64ecd501905b 6987945: XDecoratedPeer shouldn't allow to resize a frame to zero size
omajid
parents: 5506
diff changeset
   740
        width = Math.max(MIN_SIZE, width);
64ecd501905b 6987945: XDecoratedPeer shouldn't allow to resize a frame to zero size
omajid
parents: 5506
diff changeset
   741
        height = Math.max(MIN_SIZE, height);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        try {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   744
            XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getWindow(),
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   745
                                          scaleUp(x), scaleUp(y),
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   746
                                          scaleUp(width), scaleUp(height));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * Translate coordinates from one window into another.  Optimized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * for XAWT - uses cached data when possible.  Preferable over
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     * pure XTranslateCoordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * @return coordinates relative to dst, or null if error happened
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    static Point toOtherWindow(long src, long dst, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        Point rpt = new Point(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        // Check if both windows belong to XAWT - then no X calls are necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        XBaseWindow srcPeer = XToolkit.windowToXWindow(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        XBaseWindow dstPeer = XToolkit.windowToXWindow(dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        if (srcPeer != null && dstPeer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
            // (x, y) is relative to src
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            rpt.x = x + srcPeer.getAbsoluteX() - dstPeer.getAbsoluteX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            rpt.y = y + srcPeer.getAbsoluteY() - dstPeer.getAbsoluteY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        } else if (dstPeer != null && XlibUtil.isRoot(src, dstPeer.getScreenNumber())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            // from root into peer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            rpt.x = x - dstPeer.getAbsoluteX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
            rpt.y = y - dstPeer.getAbsoluteY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        } else if (srcPeer != null && XlibUtil.isRoot(dst, srcPeer.getScreenNumber())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            // from peer into root
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
            rpt.x = x + srcPeer.getAbsoluteX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            rpt.y = y + srcPeer.getAbsoluteY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        } else {
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   779
            int scale = srcPeer == null ? 1 : srcPeer.getScale();
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
   780
            rpt = XlibUtil.translateCoordinates(src, dst, new Point(x, y), scale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        return rpt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * Convert to global coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    Rectangle toGlobal(Rectangle rec) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        Point p = toGlobal(rec.getLocation());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        Rectangle newRec = new Rectangle(rec);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        if (p != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            newRec.setLocation(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        return newRec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    Point toGlobal(Point pt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        Point p = toGlobal(pt.x, pt.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        if (p != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            return p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
            return new Point(pt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    Point toGlobal(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        long root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            root = XlibWrapper.RootWindow(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                    getScreenNumber());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        Point p = toOtherWindow(getContentWindow(), root, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        if (p != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
            return p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
            return new Point(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * Convert to local coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    Point toLocal(Point pt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        Point p = toLocal(pt.x, pt.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        if (p != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
            return p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
            return new Point(pt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    Point toLocal(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        long root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            root = XlibWrapper.RootWindow(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                    getScreenNumber());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        Point p = toOtherWindow(root, getContentWindow(), x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        if (p != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
            return p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            return new Point(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * We should always grab both keyboard and pointer to control event flow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     * on popups. This also simplifies synthetic grab implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     * The active grab overrides activated automatic grab.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    public boolean grabInput() {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   858
        if (grabLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   859
            grabLog.fine("Grab input on {0}", this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   860
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
            if (XAwtState.getGrabWindow() == this &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                XAwtState.isManualGrab())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                grabLog.fine("    Already Grabbed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            //6273031: PIT. Choice drop down does not close once it is right clicked to show a popup menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            //remember previous window having grab and if it's not null ungrab it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
            XBaseWindow prevGrabWindow = XAwtState.getGrabWindow();
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   873
            final int eventMask = (int) (XConstants.ButtonPressMask | XConstants.ButtonReleaseMask
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   874
                | XConstants.EnterWindowMask | XConstants.LeaveWindowMask | XConstants.PointerMotionMask
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   875
                | XConstants.ButtonMotionMask);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            final int ownerEvents = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
2471
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   879
            //6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   880
            //process on Linux
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   881
            //The user must pass the sun.awt.disablegrab property to disable
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   882
            //taking grabs. This prevents hanging of the GUI when a breakpoint
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   883
            //is hit while a popup window taking the grab is open.
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   884
            if (!XToolkit.getSunAwtDisableGrab()) {
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   885
                int ptrGrab = XlibWrapper.XGrabPointer(XToolkit.getDisplay(),
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   886
                        getContentWindow(), ownerEvents, eventMask, XConstants.GrabModeAsync,
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   887
                        XConstants.GrabModeAsync, XConstants.None, (XWM.isMotif() ? XToolkit.arrowCursor : XConstants.None),
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   888
                        XConstants.CurrentTime);
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   889
                // Check grab results to be consistent with X server grab
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   890
                if (ptrGrab != XConstants.GrabSuccess) {
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   891
                    XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime);
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   892
                    XAwtState.setGrabWindow(null);
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   893
                    grabLog.fine("    Grab Failure - mouse");
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   894
                    return false;
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   895
                }
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   896
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   897
                int keyGrab = XlibWrapper.XGrabKeyboard(XToolkit.getDisplay(),
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   898
                        getContentWindow(), ownerEvents, XConstants.GrabModeAsync, XConstants.GrabModeAsync,
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   899
                        XConstants.CurrentTime);
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   900
                if (keyGrab != XConstants.GrabSuccess) {
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   901
                    XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime);
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   902
                    XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime);
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   903
                    XAwtState.setGrabWindow(null);
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   904
                    grabLog.fine("    Grab Failure - keyboard");
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   905
                    return false;
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   906
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            if (prevGrabWindow != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                prevGrabWindow.ungrabInputImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            XAwtState.setGrabWindow(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            grabLog.fine("    Grab - success");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
    static void ungrabInput() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
            XBaseWindow grabWindow = XAwtState.getGrabWindow();
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   923
            if (grabLog.isLoggable(PlatformLogger.Level.FINE)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   924
                grabLog.fine("UnGrab input on {0}", grabWindow);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
   925
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            if (grabWindow != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                grabWindow.ungrabInputImpl();
2471
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   928
                if (!XToolkit.getSunAwtDisableGrab()) {
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   929
                    XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime);
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   930
                    XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime);
71401ceec494 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
anthony
parents: 1962
diff changeset
   931
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                XAwtState.setGrabWindow(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                // we need to call XFlush() here to force ungrab
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                // see 6384219 for details
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                XlibWrapper.XFlush(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
    // called from ungrabInput, used in popup windows to hide theirselfs in ungrabbing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
    void ungrabInputImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    static void checkSecurity() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        if (XToolkit.isSecurityWarningEnabled() && XToolkit.isToolkitThread()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            StackTraceElement stack[] = (new Throwable()).getStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            log.warning(stack[1] + ": Security violation: calling user code on toolkit thread");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
    public Set<Long> getChildren() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        synchronized (getStateLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
            return new HashSet<Long>(children);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
    // -------------- Event handling ----------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    public void handleMapNotifyEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        mapped = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
    public void handleUnmapNotifyEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        mapped = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    public void handleReparentNotifyEvent(XEvent xev) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   967
        if (eventLog.isLoggable(PlatformLogger.Level.FINER)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
            XReparentEvent msg = xev.get_xreparent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            eventLog.finer(msg.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
    public void handlePropertyNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
        XPropertyEvent msg = xev.get_xproperty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        if (XPropertyCache.isCachingSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            XPropertyCache.clearCache(window, XAtom.get(msg.get_atom()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        }
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   977
        if (eventLog.isLoggable(PlatformLogger.Level.FINER)) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3288
diff changeset
   978
            eventLog.finer("{0}", msg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
    public void handleDestroyNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        XAnyEvent xany = xev.get_xany();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
        if (xany.get_window() == getWindow()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
            XToolkit.removeFromWinMap(getWindow(), this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
            if (XPropertyCache.isCachingSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                XPropertyCache.clearCache(getWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
        if (xany.get_window() != getWindow()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
            synchronized (getStateLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                children.remove(xany.get_window());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    public void handleCreateNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
        XAnyEvent xany = xev.get_xany();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
        if (xany.get_window() != getWindow()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
            synchronized (getStateLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                children.add(xany.get_window());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
    public void handleClientMessage(XEvent xev) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1007
        if (eventLog.isLoggable(PlatformLogger.Level.FINER)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
            XClientMessageEvent msg = xev.get_xclient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
            eventLog.finer(msg.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
    public void handleVisibilityEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
    public void handleKeyPress(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
    public void handleKeyRelease(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
    public void handleExposeEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * Activate automatic grab on first ButtonPress,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * deactivate on full mouse release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    public void handleButtonPressRelease(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
        XButtonEvent xbe = xev.get_xbutton();
2810
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2471
diff changeset
  1027
        /*
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2471
diff changeset
  1028
         * 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: 2471
diff changeset
  1029
         * InputEvent.BUTTON_DOWN_MASK.
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2471
diff changeset
  1030
         * One more bit is reserved for FIRST_HIGH_BIT.
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2471
diff changeset
  1031
         */
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2471
diff changeset
  1032
        if (xbe.get_button() > SunToolkit.MAX_BUTTONS_SUPPORTED) {
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2471
diff changeset
  1033
            return;
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2471
diff changeset
  1034
        }
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 439
diff changeset
  1035
        int buttonState = 0;
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: 13652
diff changeset
  1036
        buttonState = xbe.get_state() & XConstants.ALL_BUTTONS_MASK;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
        switch (xev.get_type()) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1038
        case XConstants.ButtonPress:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
            if (buttonState == 0) {
13652
42544e68dc39 6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents: 7668
diff changeset
  1040
                XWindowPeer parent = getToplevelXWindow();
42544e68dc39 6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents: 7668
diff changeset
  1041
                // See 6385277, 6981400.
42544e68dc39 6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents: 7668
diff changeset
  1042
                if (parent != null && parent.isFocusableWindow()) {
42544e68dc39 6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents: 7668
diff changeset
  1043
                    // A click in a client area drops the actual focused window retaining.
42544e68dc39 6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents: 7668
diff changeset
  1044
                    parent.setActualFocusedWindow(null);
42544e68dc39 6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents: 7668
diff changeset
  1045
                    parent.requestWindowFocus(xbe.get_time(), true);
42544e68dc39 6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents: 7668
diff changeset
  1046
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
                XAwtState.setAutoGrabWindow(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
            break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1050
        case XConstants.ButtonRelease:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
            if (isFullRelease(buttonState, xbe.get_button())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
                XAwtState.setAutoGrabWindow(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
    public void handleMotionNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
    public void handleXCrossingEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
    public void handleConfigureNotifyEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
        XConfigureEvent xe = xev.get_xconfigure();
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1063
        if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1064
            insLog.finer("Configure, {0}", xe);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1065
        }
34395
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
  1066
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
  1067
        x = scaleDown(xe.get_x());
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
  1068
        y = scaleDown(xe.get_y());
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
  1069
        width = scaleDown(xe.get_width());
2ac7e99f7f4a 8137571: Linux HiDPI Graphics support
alexsch
parents: 32865
diff changeset
  1070
        height = scaleDown(xe.get_height());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
     * Checks ButtonRelease released all Mouse buttons
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
    static boolean isFullRelease(int buttonState, int button) {
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: 13652
diff changeset
  1076
        final int buttonsNumber = XToolkit.getNumberOfButtonsForMask();
2810
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2471
diff changeset
  1077
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2471
diff changeset
  1078
        if (button < 0 || button > buttonsNumber) {
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 439
diff changeset
  1079
            return buttonState == 0;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 439
diff changeset
  1080
        } else {
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: 13652
diff changeset
  1081
            return buttonState == XlibUtil.getButtonMask(button);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
    static boolean isGrabbedEvent(XEvent ev, XBaseWindow target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
        switch (ev.get_type()) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1087
          case XConstants.ButtonPress:
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1088
          case XConstants.ButtonRelease:
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1089
          case XConstants.MotionNotify:
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1090
          case XConstants.KeyPress:
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1091
          case XConstants.KeyRelease:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
              return true;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1093
          case XConstants.LeaveNotify:
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1094
          case XConstants.EnterNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
              // We shouldn't dispatch this events to the grabbed components (see 6317481)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
              // But this logic is important if the grabbed component is top-level (see realSync)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
              return (target instanceof XWindowPeer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
              return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
     * Dispatches event to the grab Window or event source window depending
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
     * on whether the grab is active and on the event type
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
    static void dispatchToWindow(XEvent ev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        XBaseWindow target = XAwtState.getGrabWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        if (target == null || !isGrabbedEvent(ev, target)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            target = XToolkit.windowToXWindow(ev.get_xany().get_window());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
        if (target != null && target.checkInitialised()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
            target.dispatchEvent(ev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    public void dispatchEvent(XEvent xev) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
  1117
        if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1118
            eventLog.finest(xev.toString());
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 14888
diff changeset
  1119
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
        int type = xev.get_type();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
        if (isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
        switch (type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
        {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1128
          case XConstants.VisibilityNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
              handleVisibilityEvent(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1131
          case XConstants.ClientMessage:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
              handleClientMessage(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1134
          case XConstants.Expose :
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1135
          case XConstants.GraphicsExpose :
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
              handleExposeEvent(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1138
          case XConstants.ButtonPress:
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1139
          case XConstants.ButtonRelease:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
              handleButtonPressRelease(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1143
          case XConstants.MotionNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
              handleMotionNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1146
          case XConstants.KeyPress:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
              handleKeyPress(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1149
          case XConstants.KeyRelease:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
              handleKeyRelease(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1152
          case XConstants.EnterNotify:
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1153
          case XConstants.LeaveNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
              handleXCrossingEvent(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1156
          case XConstants.ConfigureNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
              handleConfigureNotifyEvent(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1159
          case XConstants.MapNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
              handleMapNotifyEvent(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1162
          case XConstants.UnmapNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
              handleUnmapNotifyEvent(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1165
          case XConstants.ReparentNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
              handleReparentNotifyEvent(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1168
          case XConstants.PropertyNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
              handlePropertyNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1171
          case XConstants.DestroyNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
              handleDestroyNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
  1174
          case XConstants.CreateNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
              handleCreateNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
    protected boolean isEventDisabled(XEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
    int getX() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
        return x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
    int getY() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
        return y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
    int getWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
        return width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
    int getHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
        return height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
    void setDisposed(boolean d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        disposed = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
    boolean isDisposed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
        return disposed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    public int getAbsoluteX() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
        XBaseWindow pw = getParentWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
        if (pw != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
            return pw.getAbsoluteX() + getX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
            // Overridden for top-levels as their (x,y) is Java (x, y), not native location
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
            return getX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
    public int getAbsoluteY() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
        XBaseWindow pw = getParentWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
        if (pw != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
            return pw.getAbsoluteY() + getY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
            return getY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
    public XBaseWindow getParentWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
        return parentWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
    public XWindowPeer getToplevelXWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
        XBaseWindow bw = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
        while (bw != null && !(bw instanceof XWindowPeer)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
            bw = bw.getParentWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
        return (XWindowPeer)bw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        return super.toString() + "(" + Long.toString(getWindow(), 16) + ")";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
     * Returns whether the given point is inside of the window.  Coordinates are local.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
    public boolean contains(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
        return x >= 0 && y >= 0 && x < getWidth() && y < getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
     * Returns whether the given point is inside of the window.  Coordinates are global.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
    public boolean containsGlobal(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        return x >= getAbsoluteX() && y >= getAbsoluteY() && x < (getAbsoluteX()+getWidth()) && y < (getAbsoluteY()+getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
}