jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java
author anthony
Tue, 18 Mar 2008 16:19:03 +0300
changeset 129 f995b9c9c5fa
parent 2 90ce3da70b43
child 439 3488710b02f8
permissions -rw-r--r--
6589527: Window and Frame instances can hide their "Applet Warning" Summary: Additional constraints have been added for the setBounds() operation. Reviewed-by: son, art
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.image.ImageObserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.image.ImageProducer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.image.VolatileImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.java2d.pipe.Region;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.awt.motif.MToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.awt.motif.X11FontMetrics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    XEmbeddingContainer container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    XEmbedChildProxy proxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    long handle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    XEmbedChildProxyPeer(XEmbedChildProxy proxy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        this.container = proxy.getEmbeddingContainer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        this.handle = proxy.getHandle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        this.proxy = proxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        initDispatching();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    void initDispatching() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            XToolkit.addEventDispatcher(handle, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            XlibWrapper.XSelectInput(XToolkit.getDisplay(), handle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                    XlibWrapper.StructureNotifyMask | XlibWrapper.PropertyChangeMask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        container.notifyChildEmbedded(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public boolean isObscured() { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public boolean canDetermineObscurity() { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public void                 setVisible(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        if (!b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                XlibWrapper.XMapWindow(XToolkit.getDisplay(), handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public void setEnabled(boolean b) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public void paint(Graphics g) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public void repaint(long tm, int x, int y, int width, int height) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public void print(Graphics g) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public void setBounds(int x, int y, int width, int height, int op) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        // Unimplemeneted: Check for min/max hints for non-resizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), handle, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public void handleEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        switch (e.getID()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
          case FocusEvent.FOCUS_GAINED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
              XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(proxy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
              container.focusGained(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
          case FocusEvent.FOCUS_LOST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
              XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
              container.focusLost(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
          case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
          case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
              if (!((InputEvent)e).isConsumed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                  container.forwardKeyEvent(handle, (KeyEvent)e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public void                coalescePaintEvent(PaintEvent e) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public Point                getLocationOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        XWindowAttributes attr = new XWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        try{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), handle, attr.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            return new Point(attr.get_x(), attr.get_y());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            attr.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public Dimension            getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        long p_hints = XlibWrapper.XAllocSizeHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            XSizeHints hints = new XSizeHints(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), handle, p_hints, XlibWrapper.larg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            Dimension res = new Dimension(hints.get_width(), hints.get_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            XlibWrapper.XFree(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public Dimension            getMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        long p_hints = XlibWrapper.XAllocSizeHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            XSizeHints hints = new XSizeHints(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), handle, p_hints, XlibWrapper.larg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            Dimension res = new Dimension(hints.get_min_width(), hints.get_min_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            XlibWrapper.XFree(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public ColorModel           getColorModel() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public Toolkit              getToolkit() { return Toolkit.getDefaultToolkit(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public Graphics             getGraphics() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public FontMetrics          getFontMetrics(Font font) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public void         dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        container.detachChild(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    public void         setForeground(Color c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public void         setBackground(Color c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public void         setFont(Font f) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public void                 updateCursorImmediately() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    void postEvent(AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        XToolkit.postEvent(XToolkit.targetToAppContext(proxy), event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    boolean simulateMotifRequestFocus(Component lightweightChild, boolean temporary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                                      boolean focusedWindowChangeAllowed, long time)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        if (lightweightChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            lightweightChild = (Component)proxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        Component currentOwner = XKeyboardFocusManagerPeer.getCurrentNativeFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if (currentOwner != null && currentOwner.getPeer() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            currentOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        FocusEvent  fg = new FocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, false, currentOwner );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        FocusEvent fl = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        if (currentOwner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            fl = new FocusEvent(currentOwner, FocusEvent.FOCUS_LOST, false, lightweightChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        if (fl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            postEvent(XComponentPeer.wrapInSequenced(fl));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        postEvent(XComponentPeer.wrapInSequenced(fg));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        // End of Motif compatibility code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public boolean requestFocus(Component lightweightChild,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                                boolean temporary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                                boolean focusedWindowChangeAllowed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                                long time,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                                CausedFocusEvent.Cause cause)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        int result = XKeyboardFocusManagerPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            .shouldNativelyFocusHeavyweight(proxy, lightweightChild,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                                            temporary, false, time, cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        switch (result) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
          case XComponentPeer.SNFH_FAILURE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
              return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
          case XComponentPeer.SNFH_SUCCESS_PROCEED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
              // Currently we just generate focus events like we deal with lightweight instead of calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
              // XSetInputFocus on native window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
              /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
               * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
               * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
               * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
               * in requests list - and it breaks our requests sequence as first record on WGF should be the last focus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
               * owner which had focus before WLF. So, we should not add request record for such requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
               * but store this component in mostRecent - and return true as before for compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
               */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
              Container parent = proxy.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
              // Search for parent window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
              while (parent != null && !(parent instanceof Window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                  parent = parent.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
              if (parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                  Window parentWindow = (Window)parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                  // and check that it is focused
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                  if (!parentWindow.isFocused() && XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() == parentWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                      // if it is not - skip requesting focus on Solaris
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                      // but return true for compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                      return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
              // NOTE: We simulate heavyweight behavior of Motif - component receives focus right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
              // after request, not after event. Normally, we should better listen for event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
              // by listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
              return simulateMotifRequestFocus(lightweightChild, temporary, focusedWindowChangeAllowed, time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
              // Motif compatibility code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
          case XComponentPeer.SNFH_SUCCESS_HANDLED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
              // Either lightweight or excessive requiest - all events are generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
              return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public boolean              isFocusable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public Image                createImage(ImageProducer producer) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public Image                createImage(int width, int height) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public VolatileImage        createVolatileImage(int width, int height) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public boolean              prepareImage(Image img, int w, int h, ImageObserver o) { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    public int                  checkImage(Image img, int w, int h, ImageObserver o) { return 0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    public GraphicsConfiguration getGraphicsConfiguration() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    public boolean     handlesWheelScrolling() { return true; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public void createBuffers(int numBuffers, BufferCapabilities caps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
      throws AWTException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    public Image getBackBuffer() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public void flip(BufferCapabilities.FlipContents flipAction) {  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public void destroyBuffers() { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * Used by lightweight implementations to tell a ComponentPeer to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * its sub-elements.  For instance, a lightweight Checkbox needs to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * the box, as well as the text label.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public void        layout() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * DEPRECATED:  Replaced by getPreferredSize().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    public Dimension            preferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        return getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * DEPRECATED:  Replaced by getMinimumSize().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    public Dimension            minimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        return getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * DEPRECATED:  Replaced by setVisible(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    public void         show() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        setVisible(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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * DEPRECATED:  Replaced by setVisible(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    public void         hide() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * DEPRECATED:  Replaced by setEnabled(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    public void         enable() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * DEPRECATED:  Replaced by setEnabled(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    public void         disable() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * DEPRECATED:  Replaced by setBounds(int, int, int, int).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public void reshape(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        setBounds(x, y, width, height, SET_BOUNDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    Window getTopLevel(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        while (comp != null && !(comp instanceof Window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            comp = comp.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        return (Window)comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    void childResized() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        XToolkit.postEvent(XToolkit.targetToAppContext(proxy), new ComponentEvent(proxy, ComponentEvent.COMPONENT_RESIZED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        container.childResized(proxy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
//         XToolkit.postEvent(XToolkit.targetToAppContext(proxy), new InvocationEvent(proxy, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
//                 public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
//                     getTopLevel(proxy).invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
//                     getTopLevel(proxy).pack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
//                 }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
//             }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    void handlePropertyNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        XPropertyEvent ev = xev.get_xproperty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        if (ev.get_atom() == XAtom.XA_WM_NORMAL_HINTS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            childResized();
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 handleConfigureNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        childResized();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    public void dispatchEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        int type = xev.get_type();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
          case XlibWrapper.PropertyNotify:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
              handlePropertyNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
          case XlibWrapper.ConfigureNotify:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
              handleConfigureNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    void requestXEmbedFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        postEvent(new InvocationEvent(proxy, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                    proxy.requestFocusInWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    public void reparent(ContainerPeer newNativeParent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    public boolean isReparentSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        XWindowAttributes attrs = new XWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), handle, attrs.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            return new Rectangle(attrs.get_x(), attrs.get_y(), attrs.get_width(), attrs.get_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            attrs.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    public void setBoundsOperation(int operation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    public void applyShape(Region shape) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
}