jdk/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java
author chegar
Mon, 17 Jun 2013 14:09:25 +0100
changeset 18178 ee71c923891d
parent 7668 d4a77089c587
child 23010 6dadb192ad81
permissions -rw-r--r--
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level) Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 6634
diff changeset
     2
 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.LinkedList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2643
diff changeset
    33
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.awt.EmbeddedFrame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
6634
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
    38
import static sun.awt.X11.XConstants.*;
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
    39
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class XEmbeddedFramePeer extends XFramePeer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2643
diff changeset
    42
    private static final PlatformLogger xembedLog = PlatformLogger.getLogger("sun.awt.X11.xembed.XEmbeddedFramePeer");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    LinkedList<AWTKeyStroke> strokes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    XEmbedClientHelper embedder; // Caution - can be null if XEmbed is not supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    public XEmbeddedFramePeer(EmbeddedFrame target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        // Don't specify PARENT_WINDOW param here. Instead we reparent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        // this embedded frame peer to the proper parent window after
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        // an XEventDispatcher is registered to handle XEmbed events
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        super(new XCreateWindowParams(new Object[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            TARGET, target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            VISIBLE, Boolean.TRUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            EMBEDDED, Boolean.TRUE}));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public void preInit(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        super.preInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        strokes = new LinkedList<AWTKeyStroke>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        if (supportsXEmbed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            embedder = new XEmbedClientHelper();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    void postInit(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        super.postInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        if (embedder != null) {
1974
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    67
            // install X11 event dispatcher
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    68
            embedder.setClient(this);
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    69
            // reparent to XEmbed server
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    70
            embedder.install();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        } else if (getParentWindowHandle() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                XlibWrapper.XReparentWindow(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                                            getWindow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                                            getParentWindowHandle(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                                            0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
1974
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    84
    @Override
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    85
    public void dispose() {
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    86
        if (embedder != null) {
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    87
            // uninstall X11 event dispatcher
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    88
            embedder.setClient(null);
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    89
        }
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    90
        super.dispose();
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    91
    }
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
    92
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public void updateMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    protected String getWMName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        return "JavaEmbeddedFrame";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    final long getParentWindowHandle() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        return ((XEmbeddedFrame)target).handle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    boolean supportsXEmbed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        return ((EmbeddedFrame)target).supportsXEmbed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public boolean requestWindowFocus(long time, boolean timeProvided) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        // Should check for active state of host application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        if (embedder != null && embedder.isActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            xembedLog.fine("Requesting focus from embedding host");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            return embedder.requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            xembedLog.fine("Requesting focus from X");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            return super.requestWindowFocus(time, timeProvided);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    protected void requestInitialFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        if (embedder != null && supportsXEmbed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            embedder.requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            super.requestInitialFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    protected boolean isEventDisabled(XEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        if (embedder != null && embedder.isActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            switch (e.get_type()) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 129
diff changeset
   130
              case XConstants.FocusIn:
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 129
diff changeset
   131
              case XConstants.FocusOut:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                  return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        return super.isEventDisabled(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public void handleConfigureNotifyEvent(XEvent xev)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        assert (SunToolkit.isAWTLockHeldByCurrentThread());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        XConfigureEvent xe = xev.get_xconfigure();
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 7668
diff changeset
   142
        if (xembedLog.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            xembedLog.fine(xe.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        // fix for 5063031
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        // if we use super.handleConfigureNotifyEvent() we would get wrong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        // size and position because embedded frame really is NOT a decorated one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        checkIfOnNewScreen(toGlobal(new Rectangle(xe.get_x(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                xe.get_y(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                xe.get_width(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                xe.get_height())));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        Rectangle oldBounds = getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        synchronized (getStateLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            x = xe.get_x();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            y = xe.get_y();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            width = xe.get_width();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            height = xe.get_height();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            dimensions.setClientSize(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            dimensions.setLocation(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        if (!getLocation().equals(oldBounds.getLocation())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            handleMoved(dimensions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        reconfigureContentWindow(dimensions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    protected void traverseOutForward() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        if (embedder != null && embedder.isActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            if (embedder.isApplicationActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                xembedLog.fine("Traversing out Forward");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                embedder.traverseOutForward();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    protected void traverseOutBackward() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        if (embedder != null && embedder.isActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            if (embedder.isApplicationActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                xembedLog.fine("Traversing out Backward");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                embedder.traverseOutBackward();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    // don't use getLocationOnScreen() inherited from XDecoratedPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public Point getLocationOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            return toGlobal(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    // don't use getBounds() inherited from XDecoratedPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return new Rectangle(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public void setBoundsPrivate(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        setBounds(x, y, width, height, SET_BOUNDS | NO_EMBEDDED_CHECK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public Rectangle getBoundsPrivate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        int x = 0, y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        int w = 0, h = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        XWindowAttributes attr = new XWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                getWindow(), attr.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            x = attr.get_x();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            y = attr.get_y();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            w = attr.get_width();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            h = attr.get_height();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        attr.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        return new Rectangle(x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    void registerAccelerator(AWTKeyStroke stroke) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        if (stroke == null) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        strokes.add(stroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        if (embedder != null && embedder.isActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            embedder.registerAccelerator(stroke, strokes.size()-1);
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
    void unregisterAccelerator(AWTKeyStroke stroke) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        if (stroke == null) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        if (embedder != null && embedder.isActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            int index = strokes.indexOf(stroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            embedder.unregisterAccelerator(index);
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
    void notifyStarted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        // Register accelerators
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        if (embedder != null && embedder.isActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            int i = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            Iterator<AWTKeyStroke> iter = strokes.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                embedder.registerAccelerator(iter.next(), i++);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        // Now we know that the the embedder is an XEmbed server, so we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        // reregister the drop target to enable XDnD protocol support via
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        // XEmbed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        updateDropTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
1974
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
   259
    void notifyStopped() {
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
   260
        if (embedder != null && embedder.isActive()) {
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
   261
            for (int i = strokes.size() - 1; i >= 0; i--) {
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
   262
                embedder.unregisterAccelerator(i);
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
   263
            }
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
   264
        }
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
   265
    }
1e1487c04864 6773985: OutOfMemory (PermGen space) under Linux / Firefox when switching bw. applets
art
parents: 439
diff changeset
   266
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    long getFocusTargetWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        return getWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    boolean isXEmbedActive() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        return embedder != null && embedder.isActive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public int getAbsoluteX()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        Point absoluteLoc = XlibUtil.translateCoordinates(getWindow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                                                          XToolkit.getDefaultRootWindow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                                                          new Point(0, 0));
5760
4177643566d5 6961754: JCK tests CvsEventTest0001 and CvsEventTest0002 fail under FF 3.5 on OEL 5
anthony
parents: 5506
diff changeset
   280
        return absoluteLoc != null ? absoluteLoc.x : 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    public int getAbsoluteY()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        Point absoluteLoc = XlibUtil.translateCoordinates(getWindow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                                                          XToolkit.getDefaultRootWindow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                                                          new Point(0, 0));
5760
4177643566d5 6961754: JCK tests CvsEventTest0001 and CvsEventTest0002 fail under FF 3.5 on OEL 5
anthony
parents: 5506
diff changeset
   288
        return absoluteLoc != null ? absoluteLoc.y : 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    public int getWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        return width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    public int getHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        return height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    public Dimension getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        return new Dimension(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    // override XWindowPeer's method to let the embedded frame to block
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    // the containing window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    public void setModalBlocked(Dialog blocker, boolean blocked) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        super.setModalBlocked(blocker, blocked);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        EmbeddedFrame frame = (EmbeddedFrame)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        frame.notifyModalBlocked(blocker, blocked);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }
6634
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   310
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   311
    public void synthesizeFocusInOut(boolean doFocus) {
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   312
        XFocusChangeEvent xev = new XFocusChangeEvent();
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   313
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   314
        XToolkit.awtLock();
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   315
        try {
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   316
            xev.set_type(doFocus ? FocusIn : FocusOut);
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   317
            xev.set_window(getFocusProxy().getWindow());
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   318
            xev.set_mode(NotifyNormal);
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   319
            XlibWrapper.XSendEvent(XToolkit.getDisplay(), getFocusProxy().getWindow(), false,
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   320
                                   NoEventMask, xev.pData);
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   321
        } finally {
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   322
            XToolkit.awtUnlock();
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   323
            xev.dispose();
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   324
        }
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5760
diff changeset
   325
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
}