jdk/src/solaris/classes/sun/awt/X11/XEmbedHelper.java
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 5506 202f599c92aa
child 16839 d0f2e97b7359
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
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: 4370
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: 4370
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: 4370
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: 4370
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4370
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4370
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 sun.misc.Unsafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 439
diff changeset
    30
import sun.util.logging.PlatformLogger;
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 439
diff changeset
    31
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.AWTKeyStroke;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.event.InputEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Common class for all XEmbed protocol participating classes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Contains constant definitions and helper routines.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
public class XEmbedHelper {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 439
diff changeset
    40
    private static final PlatformLogger xembedLog = PlatformLogger.getLogger("sun.awt.X11.xembed");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    final static Unsafe unsafe = Unsafe.getUnsafe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    final static int XEMBED_VERSION = 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        XEMBED_MAPPED = (1 << 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/* XEMBED messages */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    final static int XEMBED_EMBEDDED_NOTIFY     =       0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    final static int XEMBED_WINDOW_ACTIVATE  =  1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    final static int XEMBED_WINDOW_DEACTIVATE =         2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    final static int XEMBED_REQUEST_FOCUS               =3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    final static int XEMBED_FOCUS_IN    =       4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    final static int XEMBED_FOCUS_OUT   =       5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    final static int XEMBED_FOCUS_NEXT  =       6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    final static int XEMBED_FOCUS_PREV  =       7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
/* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    final static int XEMBED_GRAB_KEY = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    final static int XEMBED_UNGRAB_KEY = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    final static int XEMBED_MODALITY_ON         =       10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    final static int XEMBED_MODALITY_OFF        =       11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    final static int XEMBED_REGISTER_ACCELERATOR =    12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    final static int XEMBED_UNREGISTER_ACCELERATOR=   13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    final static int XEMBED_ACTIVATE_ACCELERATOR  =   14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    final static int NON_STANDARD_XEMBED_GTK_GRAB_KEY = 108;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    final static int NON_STANDARD_XEMBED_GTK_UNGRAB_KEY = 109;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
//     A detail code is required for XEMBED_FOCUS_IN. The following values are valid:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
/* Details for  XEMBED_FOCUS_IN: */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    final static int XEMBED_FOCUS_CURRENT       =       0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    final static int XEMBED_FOCUS_FIRST         =       1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    final static int XEMBED_FOCUS_LAST  =       2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
// Modifiers bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    final static int XEMBED_MODIFIER_SHIFT   = (1 << 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    final static int XEMBED_MODIFIER_CONTROL = (1 << 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    final static int XEMBED_MODIFIER_ALT     = (1 << 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    final static int XEMBED_MODIFIER_SUPER   = (1 << 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    final static int XEMBED_MODIFIER_HYPER   = (1 << 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    static XAtom XEmbedInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    static XAtom XEmbed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    XEmbedHelper() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        if (XEmbed == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            XEmbed = XAtom.get("_XEMBED");
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 439
diff changeset
    85
            if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Created atom " + XEmbed.toString());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        if (XEmbedInfo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            XEmbedInfo = XAtom.get("_XEMBED_INFO");
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 439
diff changeset
    89
            if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Created atom " + XEmbedInfo.toString());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    void sendMessage(long window, int message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        sendMessage(window, message, 0, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    void sendMessage(long window, int message, long detail, long data1, long data2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        XClientMessageEvent msg = new XClientMessageEvent();
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
    98
        msg.set_type((int)XConstants.ClientMessage);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        msg.set_window(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        msg.set_message_type(XEmbed.getAtom());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        msg.set_format(32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        msg.set_data(0, XToolkit.getCurrentServerTime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        msg.set_data(1, message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        msg.set_data(2, detail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        msg.set_data(3, data1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        msg.set_data(4, data2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        try {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 439
diff changeset
   109
            if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Sending " + XEmbedMessageToString(msg));
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 120
diff changeset
   110
            XlibWrapper.XSendEvent(XToolkit.getDisplay(), window, false, XConstants.NoEventMask, msg.pData);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        msg.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    static String msgidToString(int msg_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        switch (msg_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
          case XEMBED_EMBEDDED_NOTIFY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
              return "XEMBED_EMBEDDED_NOTIFY";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
          case XEMBED_WINDOW_ACTIVATE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
              return "XEMBED_WINDOW_ACTIVATE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
          case XEMBED_WINDOW_DEACTIVATE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
              return "XEMBED_WINDOW_DEACTIVATE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
          case XEMBED_FOCUS_IN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
              return "XEMBED_FOCUS_IN";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
          case XEMBED_FOCUS_OUT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
              return "XEMBED_FOCUS_OUT";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
          case XEMBED_REQUEST_FOCUS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
              return "XEMBED_REQUEST_FOCUS";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
          case XEMBED_FOCUS_NEXT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
              return "XEMBED_FOCUS_NEXT";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
          case XEMBED_FOCUS_PREV:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
              return "XEMBED_FOCUS_PREV";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
          case XEMBED_MODALITY_ON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
              return "XEMBED_MODALITY_ON";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
          case XEMBED_MODALITY_OFF:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
              return "XEMBED_MODALITY_OFF";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
          case XEMBED_REGISTER_ACCELERATOR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
              return "XEMBED_REGISTER_ACCELERATOR";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
          case XEMBED_UNREGISTER_ACCELERATOR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
              return "XEMBED_UNREGISTER_ACCELERATOR";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
          case XEMBED_ACTIVATE_ACCELERATOR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
              return "XEMBED_ACTIVATE_ACCELERATOR";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
          case XEMBED_GRAB_KEY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
              return "XEMBED_GRAB_KEY";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
          case XEMBED_UNGRAB_KEY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
              return "XEMBED_UNGRAB_KEY";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
          case NON_STANDARD_XEMBED_GTK_UNGRAB_KEY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
              return "NON_STANDARD_XEMBED_GTK_UNGRAB_KEY";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
          case NON_STANDARD_XEMBED_GTK_GRAB_KEY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
              return "NON_STANDARD_XEMBED_GTK_GRAB_KEY";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
          case XConstants.KeyPress | XEmbedServerTester.SYSTEM_EVENT_MASK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
              return "KeyPress";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
          case XConstants.MapNotify | XEmbedServerTester.SYSTEM_EVENT_MASK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
              return "MapNotify";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
          case XConstants.PropertyNotify | XEmbedServerTester.SYSTEM_EVENT_MASK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
              return "PropertyNotify";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
              return "unknown XEMBED id " + msg_id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    static String focusIdToString(int focus_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        switch(focus_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
          case XEMBED_FOCUS_CURRENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
              return "XEMBED_FOCUS_CURRENT";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
          case XEMBED_FOCUS_FIRST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
              return "XEMBED_FOCUS_FIRST";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
          case XEMBED_FOCUS_LAST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
              return "XEMBED_FOCUS_LAST";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
              return "unknown focus id " + focus_id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    static String XEmbedMessageToString(XClientMessageEvent msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        return ("XEmbed message to " + Long.toHexString(msg.get_window()) + ": " + msgidToString((int)msg.get_data(1)) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                ", detail: " + msg.get_data(2) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                ", data:[" + msg.get_data(3) + "," + msg.get_data(4) + "]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Converts XEMBED modifiers mask into AWT InputEvent mask
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    int getModifiers(int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        int mods = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        if ((state & XEMBED_MODIFIER_SHIFT) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            mods |= InputEvent.SHIFT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if ((state & XEMBED_MODIFIER_CONTROL) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            mods |= InputEvent.CTRL_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        if ((state & XEMBED_MODIFIER_ALT) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            mods |= InputEvent.ALT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        // FIXME: What is super/hyper?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        // FIXME: Experiments show that SUPER is ALT. So what is Alt then?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        if ((state & XEMBED_MODIFIER_SUPER) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            mods |= InputEvent.ALT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
//         if ((state & XEMBED_MODIFIER_HYPER) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
//             mods |= InputEvent.DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
//         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        return mods;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    // Shouldn't be called on Toolkit thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    AWTKeyStroke getKeyStrokeForKeySym(long keysym, long state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        XBaseWindow.checkSecurity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        int keycode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        try {
4370
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3938
diff changeset
   219
            XKeysym.Keysym2JavaKeycode kc = XKeysym.getJavaKeycode( keysym );
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3938
diff changeset
   220
            if(kc == null) {
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3938
diff changeset
   221
                keycode = java.awt.event.KeyEvent.VK_UNDEFINED;
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3938
diff changeset
   222
            }else{
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3938
diff changeset
   223
                keycode = kc.getJavaKeycode();
cc409c51b108 5099725: AWT doesn't seem to handle MappingNotify events under X11.
yan
parents: 3938
diff changeset
   224
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        int modifiers = getModifiers((int)state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return AWTKeyStroke.getAWTKeyStroke(keycode, modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
}