jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java
author omajid
Mon, 04 Jun 2012 16:39:12 -0400
changeset 12829 506020af237a
parent 11093 e753252dc8a9
child 13604 31089af1a447
permissions -rw-r--r--
7043963: AWT workaround missing for Mutter. Reviewed-by: art, anthony Contributed-by: Denis Lila <dlila@redhat.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     2
 * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.dnd.DropTarget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.dnd.DropTargetListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.image.ImageObserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.image.ImageProducer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.image.VolatileImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.lang.reflect.*;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
    39
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import static sun.awt.X11.XEmbedHelper.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.security.action.GetBooleanAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener, KeyEventPostProcessor, ModalityListener, WindowIDProvider {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
    47
    private static final PlatformLogger xembedLog = PlatformLogger.getLogger("sun.awt.X11.xembed.XEmbedCanvasPeer");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    boolean applicationActive; // Whether the application is active(has focus)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    XEmbedServer xembed = new XEmbedServer(); // Helper object, contains XEmbed intrinsics
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    Map<Long, AWTKeyStroke> accelerators = new HashMap<Long, AWTKeyStroke>(); // Maps accelerator ID into AWTKeyStroke
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    Map<AWTKeyStroke, Long> accel_lookup = new HashMap<AWTKeyStroke, Long>(); // Maps AWTKeyStroke into accelerator ID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    Set<GrabbedKey> grabbed_keys = new HashSet<GrabbedKey>(); // A set of keys grabbed by client
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    Object ACCEL_LOCK = accelerators; // Lock object for working with accelerators;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    Object GRAB_LOCK = grabbed_keys; // Lock object for working with keys grabbed by client
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    XEmbedCanvasPeer() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    XEmbedCanvasPeer(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        super(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    XEmbedCanvasPeer(Component target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        super(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    protected void postInit(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        super.postInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        installActivateListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        installAcceleratorListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        installModalityListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        // XEmbed canvas should be non-traversable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        // FIXME: Probably should be removed and enforced setting of it by the users
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        target.setFocusTraversalKeysEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    protected void preInit(XCreateWindowParams params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        super.preInit(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        params.put(EVENT_MASK,
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
    83
                   XConstants.KeyPressMask       | XConstants.KeyReleaseMask
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
    84
                   | XConstants.FocusChangeMask  | XConstants.ButtonPressMask | XConstants.ButtonReleaseMask
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
    85
                   | XConstants.EnterWindowMask  | XConstants.LeaveWindowMask | XConstants.PointerMotionMask
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
    86
                   | XConstants.ButtonMotionMask | XConstants.ExposureMask    | XConstants.StructureNotifyMask | XConstants.SubstructureNotifyMask);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    void installModalityListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        ((SunToolkit)Toolkit.getDefaultToolkit()).addModalityListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    void deinstallModalityListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        ((SunToolkit)Toolkit.getDefaultToolkit()).removeModalityListener(this);
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 installAcceleratorListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventPostProcessor(this);
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 deinstallAcceleratorListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventPostProcessor(this);
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 installActivateListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        // FIXME: should watch for hierarchy changes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        Window toplevel = getTopLevel(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        if (toplevel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            toplevel.addWindowFocusListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            applicationActive = toplevel.isFocused();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    void deinstallActivateListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        Window toplevel = getTopLevel(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        if (toplevel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            toplevel.removeWindowFocusListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    boolean isXEmbedActive() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        return xembed.handle != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    boolean isApplicationActive() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        return applicationActive;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    void initDispatching() {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   131
        if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Init embedding for " + Long.toHexString(xembed.handle));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            XToolkit.addEventDispatcher(xembed.handle, xembed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            XlibWrapper.XSelectInput(XToolkit.getDisplay(), xembed.handle,
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   136
                                     XConstants.StructureNotifyMask | XConstants.PropertyChangeMask);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            XDropTargetRegistry.getRegistry().registerXEmbedClient(getWindow(), xembed.handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        xembed.processXEmbedInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        notifyChildEmbedded();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    void endDispatching() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        xembedLog.fine("End dispatching for " + Long.toHexString(xembed.handle));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            XDropTargetRegistry.getRegistry().unregisterXEmbedClient(getWindow(), xembed.handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            // We can't deselect input since someone else might be interested in it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            XToolkit.removeEventDispatcher(xembed.handle, xembed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            XToolkit.awtUnlock();
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
    void embedChild(long child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (xembed.handle != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            detachChild();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        xembed.handle = child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        initDispatching();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    void childDestroyed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        xembedLog.fine("Child " + Long.toHexString(xembed.handle) + " has self-destroyed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        endDispatching();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        xembed.handle = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public void handleEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        super.handleEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            switch (e.getID()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
              case FocusEvent.FOCUS_GAINED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                  canvasFocusGained((FocusEvent)e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
              case FocusEvent.FOCUS_LOST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                  canvasFocusLost((FocusEvent)e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
              case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
              case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                  if (!((InputEvent)e).isConsumed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                      forwardKeyEvent((KeyEvent)e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public void dispatchEvent(XEvent ev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        super.dispatchEvent(ev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        switch (ev.get_type()) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   196
          case XConstants.CreateNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
              XCreateWindowEvent cr = ev.get_xcreatewindow();
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   198
              if (xembedLog.isLoggable(PlatformLogger.FINEST)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                  xembedLog.finest("Message on embedder: " + cr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
              }
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   201
              if (xembedLog.isLoggable(PlatformLogger.FINER)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                  xembedLog.finer("Create notify for parent " + Long.toHexString(cr.get_parent()) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                                  ", window " + Long.toHexString(cr.get_window()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
              embedChild(cr.get_window());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   207
          case XConstants.DestroyNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
              XDestroyWindowEvent dn = ev.get_xdestroywindow();
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   209
              if (xembedLog.isLoggable(PlatformLogger.FINEST)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                  xembedLog.finest("Message on embedder: " + dn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
              }
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   212
              if (xembedLog.isLoggable(PlatformLogger.FINER)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                  xembedLog.finer("Destroy notify for parent: " + dn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
              childDestroyed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   217
          case XConstants.ReparentNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
              XReparentEvent rep = ev.get_xreparent();
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   219
              if (xembedLog.isLoggable(PlatformLogger.FINEST)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                  xembedLog.finest("Message on embedder: " + rep);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
              }
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   222
              if (xembedLog.isLoggable(PlatformLogger.FINER)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                  xembedLog.finer("Reparent notify for parent " + Long.toHexString(rep.get_parent()) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                                  ", window " + Long.toHexString(rep.get_window()) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                  ", event " + Long.toHexString(rep.get_event()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
              if (rep.get_parent() == getWindow()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                  // Reparented into us - embed it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                  embedChild(rep.get_window());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
              } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                  // Reparented out of us - detach it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                  childDestroyed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
              break;
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
    public Dimension getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                long p_hints = XlibWrapper.XAllocSizeHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                XSizeHints hints = new XSizeHints(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), xembed.handle, p_hints, XlibWrapper.larg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                Dimension res = new Dimension(hints.get_width(), hints.get_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                XlibWrapper.XFree(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            return super.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    public Dimension getMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                long p_hints = XlibWrapper.XAllocSizeHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                XSizeHints hints = new XSizeHints(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), xembed.handle, p_hints, XlibWrapper.larg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                Dimension res = new Dimension(hints.get_min_width(), hints.get_min_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                XlibWrapper.XFree(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            return super.getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            detachChild();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        deinstallActivateListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        deinstallModalityListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        deinstallAcceleratorListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        // BUG: Focus traversal doesn't become enabled after the one round of embedding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        //target.setFocusTraversalKeysEnabled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        super.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    // Focusable is true in order to enable focus traversal through this Canvas
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    public boolean isFocusable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    Window getTopLevel(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        while (comp != null && !(comp instanceof Window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            comp = comp.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        return (Window)comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    Rectangle getClientBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            XWindowAttributes wattr = new XWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            try {
2802
d05a9dcc8296 6678385: Random java.lang.StackOverflowError from various JDKs
art
parents: 439
diff changeset
   303
                XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                                                              xembed.handle, wattr.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                XToolkit.RESTORE_XERROR_HANDLER();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                if (status == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                    (XToolkit.saved_error != null &&
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   311
                     XToolkit.saved_error.get_error_code() != XConstants.Success)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                return new Rectangle(wattr.get_x(), wattr.get_y(), wattr.get_width(), wattr.get_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                wattr.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    void childResized() {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   325
        if (xembedLog.isLoggable(PlatformLogger.FINER)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            Rectangle bounds = getClientBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            xembedLog.finer("Child resized: " + bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            // It is not required to update embedder's size when client size changes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            // However, since there is no any means to get client size it seems to be the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            // only way to provide it. However, it contradicts with Java layout concept -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            // so it is disabled for now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
//             Rectangle my_bounds = getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
//             setBounds(my_bounds.x, my_bounds.y, bounds.width, bounds.height, SET_BOUNDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        XToolkit.postEvent(XToolkit.targetToAppContext(target), new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    void focusNext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            xembedLog.fine("Requesting focus for the next component after embedder");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            postEvent(new InvocationEvent(target, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                        KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            xembedLog.fine("XEmbed is not active - denying focus next");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    void focusPrev() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            xembedLog.fine("Requesting focus for the next component after embedder");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            postEvent(new InvocationEvent(target, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                        KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            xembedLog.fine("XEmbed is not active - denying focus prev");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    void requestXEmbedFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            xembedLog.fine("Requesting focus for client");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            postEvent(new InvocationEvent(target, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                        target.requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            xembedLog.fine("XEmbed is not active - denying request focus");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    void notifyChildEmbedded() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        xembed.sendMessage(xembed.handle, XEMBED_EMBEDDED_NOTIFY, getWindow(), Math.min(xembed.version, XEMBED_VERSION), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        if (isApplicationActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            xembedLog.fine("Sending WINDOW_ACTIVATE during initialization");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            xembed.sendMessage(xembed.handle, XEMBED_WINDOW_ACTIVATE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            if (hasFocus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                xembedLog.fine("Sending FOCUS_GAINED during initialization");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                xembed.sendMessage(xembed.handle, XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    void detachChild() {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   390
        if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Detaching child " + Long.toHexString(xembed.handle));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
         *  XEmbed specification:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
         *  "The embedder can unmap the client and reparent the client window to the root window. If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
         *  client receives an ReparentNotify event, it should check the parent field of the XReparentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
         *  structure. If this is the root window of the window's screen, then the protocol is finished and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
         *  there is no further interaction. If it is a window other than the root window, then the protocol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
         *  continues with the new parent acting as the embedder window."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), xembed.handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            XlibWrapper.XReparentWindow(XToolkit.getDisplay(), xembed.handle, XToolkit.getDefaultRootWindow(), 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        endDispatching();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        xembed.handle = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    public void windowGainedFocus(WindowEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        applicationActive = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            xembedLog.fine("Sending WINDOW_ACTIVATE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            xembed.sendMessage(xembed.handle, XEMBED_WINDOW_ACTIVATE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    public void windowLostFocus(WindowEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        applicationActive = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            xembedLog.fine("Sending WINDOW_DEACTIVATE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            xembed.sendMessage(xembed.handle, XEMBED_WINDOW_DEACTIVATE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    void canvasFocusGained(FocusEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            xembedLog.fine("Forwarding FOCUS_GAINED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            int flavor = XEMBED_FOCUS_CURRENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            if (e instanceof CausedFocusEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                CausedFocusEvent ce = (CausedFocusEvent)e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_FORWARD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                    flavor = XEMBED_FOCUS_FIRST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                } else if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_BACKWARD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                    flavor = XEMBED_FOCUS_LAST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            xembed.sendMessage(xembed.handle, XEMBED_FOCUS_IN, flavor, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    void canvasFocusLost(FocusEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        if (isXEmbedActive() && !e.isTemporary()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            xembedLog.fine("Forwarding FOCUS_LOST");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            int num = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.xembed.testing"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                Component opp = e.getOppositeComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                    num = Integer.parseInt(opp.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                } catch (NumberFormatException nfe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            xembed.sendMessage(xembed.handle, XEMBED_FOCUS_OUT, num, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    static Field bdataField;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    static byte[] getBData(KeyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            if (bdataField == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                bdataField = SunToolkit.getField(java.awt.AWTEvent.class, "bdata");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            return (byte[])bdataField.get(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        } catch (IllegalAccessException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    void forwardKeyEvent(KeyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        xembedLog.fine("Try to forward key event");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        byte[] bdata = getBData(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        long data = Native.toData(bdata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        if (data == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            XKeyEvent ke = new XKeyEvent(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            ke.set_window(xembed.handle);
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   479
            if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Forwarding native key event: " + ke);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            try {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   482
                XlibWrapper.XSendEvent(XToolkit.getDisplay(), xembed.handle, false, XConstants.NoEventMask, data);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            XlibWrapper.unsafe.freeMemory(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * Grab/ungrab key functionality is an unofficial API supported by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * GTK.  Unfortunately, it doesn't support accelerator API, so,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * since this is the ONLY shortcut-processing API available, we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * must support it.  See XEmbed.NON_STANDARD_XEMBED_GTK_*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * messages.  The format of these messages is as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * - request from client:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * data[1] = NON_STANDARD_XEMBED_GTK_GRAB_KEY or NON_STANDARD_XEMBED_GTK_UNGRAB_KEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * data[3] = X keysym
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * data[4] = X modifiers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * - response from server (in case the grabbed key has been pressed):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * forwarded XKeyEvent that matches keysym/modifiers pair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    void grabKey(final long keysym, final long modifiers) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        postEvent(new InvocationEvent(target, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                    GrabbedKey grab = new GrabbedKey(keysym, modifiers);
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   510
                    if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Grabbing key: " + grab);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                    synchronized(GRAB_LOCK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                        grabbed_keys.add(grab);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    void ungrabKey(final long keysym, final long modifiers) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        postEvent(new InvocationEvent(target, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                    GrabbedKey grab = new GrabbedKey(keysym, modifiers);
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   522
                    if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("UnGrabbing key: " + grab);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                    synchronized(GRAB_LOCK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                        grabbed_keys.remove(grab);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    void registerAccelerator(final long accel_id, final long keysym, final long modifiers) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        postEvent(new InvocationEvent(target, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                    AWTKeyStroke stroke = xembed.getKeyStrokeForKeySym(keysym, modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                    if (stroke != null) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   535
                        if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Registering accelerator " + accel_id + " for " + stroke);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                        synchronized(ACCEL_LOCK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                            accelerators.put(accel_id, stroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                            accel_lookup.put(stroke, accel_id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                    propogateRegisterAccelerator(stroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    void unregisterAccelerator(final long accel_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        postEvent(new InvocationEvent(target, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                    AWTKeyStroke stroke = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                    synchronized(ACCEL_LOCK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                        stroke = accelerators.get(accel_id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                        if (stroke != null) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   553
                            if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Unregistering accelerator: " + accel_id);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                            accelerators.remove(accel_id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                            accel_lookup.remove(stroke); // FIXME: How about several accelerators with the same stroke?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                    propogateUnRegisterAccelerator(stroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
            }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    void propogateRegisterAccelerator(AWTKeyStroke stroke) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        // Find the top-level and see if it is XEmbed client. If so, ask him to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        // register the accelerator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        XWindowPeer parent = getToplevelXWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        if (parent != null && parent instanceof XEmbeddedFramePeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            XEmbeddedFramePeer embedded = (XEmbeddedFramePeer)parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            embedded.registerAccelerator(stroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    void propogateUnRegisterAccelerator(AWTKeyStroke stroke) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        // Find the top-level and see if it is XEmbed client. If so, ask him to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        // register the accelerator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        XWindowPeer parent = getToplevelXWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        if (parent != null && parent instanceof XEmbeddedFramePeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            XEmbeddedFramePeer embedded = (XEmbeddedFramePeer)parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            embedded.unregisterAccelerator(stroke);
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
    public boolean postProcessKeyEvent(KeyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        // Processing events only if we are in the focused window but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        // we are not focus owner since otherwise we will get
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        // duplicate shortcut events in the client - one is from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        // activate_accelerator, another from forwarded event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        // FIXME: This is probably an incompatibility, protocol
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        // doesn't say anything about disable accelerators when client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        // is focused.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        XWindowPeer parent = getToplevelXWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        if (parent == null || !((Window)parent.getTarget()).isFocused() || target.isFocusOwner()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        boolean result = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   599
        if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Post-processing event " + e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        // Process ACCELERATORS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        long accel_id = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        boolean exists = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        synchronized(ACCEL_LOCK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
            exists = accel_lookup.containsKey(stroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            if (exists) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                accel_id = accel_lookup.get(stroke).longValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        if (exists) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   612
            if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Activating accelerator " + accel_id);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            xembed.sendMessage(xembed.handle, XEMBED_ACTIVATE_ACCELERATOR, accel_id, 0, 0); // FIXME: How about overloaded?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            result = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        // Process Grabs, unofficial GTK feature
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        exists = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        GrabbedKey key = new GrabbedKey(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        synchronized(GRAB_LOCK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            exists = grabbed_keys.contains(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        if (exists) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   624
            if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Forwarding grabbed key " + e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            forwardKeyEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            result = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    public void modalityPushed(ModalityEvent ev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        xembed.sendMessage(xembed.handle, XEMBED_MODALITY_ON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    public void modalityPopped(ModalityEvent ev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        xembed.sendMessage(xembed.handle, XEMBED_MODALITY_OFF);
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 void handleClientMessage(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        super.handleClientMessage(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        XClientMessageEvent msg = xev.get_xclient();
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   643
        if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Client message to embedder: " + msg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        if (msg.get_message_type() == xembed.XEmbed.getAtom()) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   645
            if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine(xembed.XEmbedMessageToString(msg));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            switch ((int)msg.get_data(1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
              case XEMBED_REQUEST_FOCUS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                  requestXEmbedFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
              case XEMBED_FOCUS_NEXT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                  focusNext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
              case XEMBED_FOCUS_PREV:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                  focusPrev();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
              case XEMBED_REGISTER_ACCELERATOR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                  registerAccelerator(msg.get_data(2), msg.get_data(3), msg.get_data(4));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
              case XEMBED_UNREGISTER_ACCELERATOR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                  unregisterAccelerator(msg.get_data(2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
              case NON_STANDARD_XEMBED_GTK_GRAB_KEY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                  grabKey(msg.get_data(3), msg.get_data(4));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
              case NON_STANDARD_XEMBED_GTK_UNGRAB_KEY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                  ungrabKey(msg.get_data(3), msg.get_data(4));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            xembedLog.finer("But XEmbed is not Active!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    private static class XEmbedDropTarget extends DropTarget {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        public void addDropTargetListener(DropTargetListener dtl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
          throws TooManyListenersException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            // Drop target listeners registered with this target will never be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            // notified, since all drag notifications are routed to the XEmbed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            // client. To avoid confusion we prohibit listeners registration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            // by throwing TooManyListenersException as if there is a listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            // registered with this target already.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            throw new TooManyListenersException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    public void setXEmbedDropTarget() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        // Register a drop site on the top level.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        Runnable r = new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                    target.setDropTarget(new XEmbedDropTarget());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        SunToolkit.executeOnEventHandlerThread(target, r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    public void removeXEmbedDropTarget() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        // Unregister a drop site on the top level.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        Runnable r = new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                    if (target.getDropTarget() instanceof XEmbedDropTarget) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                        target.setDropTarget(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        SunToolkit.executeOnEventHandlerThread(target, r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    public boolean processXEmbedDnDEvent(long ctxt, int eventID) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   711
        if (xembedLog.isLoggable(PlatformLogger.FINEST)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            xembedLog.finest("     Drop target=" + target.getDropTarget());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        if (target.getDropTarget() instanceof XEmbedDropTarget) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            AppContext appContext = XToolkit.targetToAppContext(getTarget());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
            XDropTargetContextPeer peer =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                XDropTargetContextPeer.getPeer(appContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            peer.forwardEventToEmbedded(xembed.handle, ctxt, eventID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    class XEmbedServer extends XEmbedHelper implements XEventDispatcher {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        long handle; // Handle to XEmbed client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        long version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        long flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        boolean processXEmbedInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
            long xembed_info_data = Native.allocateLongArray(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                if (!XEmbedInfo.getAtomData(handle, xembed_info_data, 2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                    // No more XEMBED_INFO? This is not XEmbed client!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                    // Unfortunately this is the initial state of the most clients
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                    // FIXME: add 5-state processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                    //childDestroyed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                    xembedLog.finer("Unable to get XEMBED_INFO atom data");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                version = Native.getCard32(xembed_info_data, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                flags = Native.getCard32(xembed_info_data, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                boolean new_mapped = (flags & XEMBED_MAPPED) != 0;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   744
                boolean currently_mapped = XlibUtil.getWindowMapState(handle) != XConstants.IsUnmapped;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                if (new_mapped != currently_mapped) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   746
                    if (xembedLog.isLoggable(PlatformLogger.FINER))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                        xembedLog.fine("Mapping state of the client has changed, old state: " + currently_mapped + ", new state: " + new_mapped);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                    if (new_mapped) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                            XlibWrapper.XMapWindow(XToolkit.getDisplay(), handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                            XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                    xembedLog.finer("Mapping state didn't change, mapped: " + currently_mapped);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                XlibWrapper.unsafe.freeMemory(xembed_info_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        public void handlePropertyNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
            if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                XPropertyEvent ev = xev.get_xproperty();
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   775
                if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Property change on client: " + ev);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                if (ev.get_atom() == XAtom.XA_WM_NORMAL_HINTS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                    childResized();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                } else if (ev.get_atom() == XEmbedInfo.getAtom()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                    processXEmbedInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                } else if (ev.get_atom() ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                           XDnDConstants.XA_XdndAware.getAtom()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                    XDropTargetRegistry.getRegistry().unregisterXEmbedClient(getWindow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                                                                             xembed.handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                    if (ev.get_state() == XConstants.PropertyNewValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                        XDropTargetRegistry.getRegistry().registerXEmbedClient(getWindow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                                                                                xembed.handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                xembedLog.finer("XEmbed is not active");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        void handleConfigureNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
            if (isXEmbedActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                XConfigureEvent ev = xev.get_xconfigure();
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   796
                if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Bounds change on client: " + ev);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                if (xev.get_xany().get_window() == handle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                    childResized();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        public void dispatchEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
            int type = xev.get_type();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            switch (type) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   805
              case XConstants.PropertyNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                  handlePropertyNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                  break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   808
              case XConstants.ConfigureNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                  handleConfigureNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                  break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   811
              case XConstants.ClientMessage:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                  handleClientMessage(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    static class GrabbedKey {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        long keysym;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        long modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        GrabbedKey(long keysym, long modifiers) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            this.keysym = keysym;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
            this.modifiers = modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        GrabbedKey(KeyEvent ev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            init(ev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        private void init(KeyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
            byte[] bdata = getBData(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            long data = Native.toData(bdata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            if (data == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            try {
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
                    keysym = XWindow.getKeySymForAWTKeyCode(e.getKeyCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                    XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                XKeyEvent ke = new XKeyEvent(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                // We recognize only these masks
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   846
                modifiers = ke.get_state() & (XConstants.ShiftMask | XConstants.ControlMask | XConstants.LockMask);
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2802
diff changeset
   847
                if (xembedLog.isLoggable(PlatformLogger.FINEST)) xembedLog.finest("Mapped " + e + " to " + this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                XlibWrapper.unsafe.freeMemory(data);
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
        public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            return (int)keysym & 0xFFFFFFFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            if (!(o instanceof GrabbedKey)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
            GrabbedKey key = (GrabbedKey)o;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
            return (keysym == key.keysym && modifiers == key.modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
            return "Key combination[keysym=" + keysym + ", mods=" + modifiers + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
}