jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java
author leonidr
Wed, 29 Aug 2012 19:53:35 +0400
changeset 13648 90effcfc064f
parent 11093 e753252dc8a9
child 23010 6dadb192ad81
permissions -rw-r--r--
7124375: [macosx] Focus isn't transfered as expected between components Reviewed-by: art, ant, serb
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: 2805
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: 2805
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: 2805
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: 2805
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2805
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2805
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.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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    XEmbeddingContainer container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    XEmbedChildProxy proxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    long handle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    XEmbedChildProxyPeer(XEmbedChildProxy proxy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        this.container = proxy.getEmbeddingContainer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        this.handle = proxy.getHandle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        this.proxy = proxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        initDispatching();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    void initDispatching() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            XToolkit.addEventDispatcher(handle, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            XlibWrapper.XSelectInput(XToolkit.getDisplay(), handle,
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
    54
                    XConstants.StructureNotifyMask | XConstants.PropertyChangeMask);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        container.notifyChildEmbedded(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    public boolean isObscured() { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public boolean canDetermineObscurity() { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public void                 setVisible(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        if (!b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                XlibWrapper.XMapWindow(XToolkit.getDisplay(), handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public void setEnabled(boolean b) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public void paint(Graphics g) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public void repaint(long tm, int x, int y, int width, int height) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public void print(Graphics g) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public void setBounds(int x, int y, int width, int height, int op) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        // Unimplemeneted: Check for min/max hints for non-resizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), handle, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public void handleEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        switch (e.getID()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
          case FocusEvent.FOCUS_GAINED:
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 11093
diff changeset
    99
              XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(proxy);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
              container.focusGained(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
          case FocusEvent.FOCUS_LOST:
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 11093
diff changeset
   103
              XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
              container.focusLost(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
          case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
          case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
              if (!((InputEvent)e).isConsumed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                  container.forwardKeyEvent(handle, (KeyEvent)e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public void                coalescePaintEvent(PaintEvent e) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public Point                getLocationOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        XWindowAttributes attr = new XWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        try{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), handle, attr.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            return new Point(attr.get_x(), attr.get_y());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            attr.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public Dimension            getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        long p_hints = XlibWrapper.XAllocSizeHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            XSizeHints hints = new XSizeHints(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), handle, p_hints, XlibWrapper.larg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            Dimension res = new Dimension(hints.get_width(), hints.get_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            XlibWrapper.XFree(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public Dimension            getMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        long p_hints = XlibWrapper.XAllocSizeHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            XSizeHints hints = new XSizeHints(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), handle, p_hints, XlibWrapper.larg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            Dimension res = new Dimension(hints.get_min_width(), hints.get_min_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            XlibWrapper.XFree(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public ColorModel           getColorModel() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public Toolkit              getToolkit() { return Toolkit.getDefaultToolkit(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public Graphics             getGraphics() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public FontMetrics          getFontMetrics(Font font) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public void         dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        container.detachChild(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public void         setForeground(Color c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public void         setBackground(Color c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    public void         setFont(Font f) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public void                 updateCursorImmediately() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    void postEvent(AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        XToolkit.postEvent(XToolkit.targetToAppContext(proxy), event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    boolean simulateMotifRequestFocus(Component lightweightChild, boolean temporary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                                      boolean focusedWindowChangeAllowed, long time)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if (lightweightChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            lightweightChild = (Component)proxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 11093
diff changeset
   175
        Component currentOwner = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        if (currentOwner != null && currentOwner.getPeer() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            currentOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        FocusEvent  fg = new FocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, false, currentOwner );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        FocusEvent fl = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        if (currentOwner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            fl = new FocusEvent(currentOwner, FocusEvent.FOCUS_LOST, false, lightweightChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   185
        // TODO: do we need to wrap in sequenced?
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        if (fl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            postEvent(XComponentPeer.wrapInSequenced(fl));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        postEvent(XComponentPeer.wrapInSequenced(fg));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        // End of Motif compatibility code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public boolean requestFocus(Component lightweightChild,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                                boolean temporary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                                boolean focusedWindowChangeAllowed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                                long time,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                                CausedFocusEvent.Cause cause)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        int result = XKeyboardFocusManagerPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            .shouldNativelyFocusHeavyweight(proxy, lightweightChild,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                                            temporary, false, time, cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        switch (result) {
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   205
          case XKeyboardFocusManagerPeer.SNFH_FAILURE:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
              return false;
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   207
          case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
              // Currently we just generate focus events like we deal with lightweight instead of calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
              // XSetInputFocus on native window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
              /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
               * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
               * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
               * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
               * 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
   216
               * owner which had focus before WLF. So, we should not add request record for such requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
               * but store this component in mostRecent - and return true as before for compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
               */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
              Container parent = proxy.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
              // Search for parent window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
              while (parent != null && !(parent instanceof Window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                  parent = parent.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
              if (parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                  Window parentWindow = (Window)parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                  // and check that it is focused
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 11093
diff changeset
   227
                  if (!parentWindow.isFocused() &&
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 11093
diff changeset
   228
                      XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() == parentWindow) {
2
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.
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   238
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   239
              // TODO: consider replacing with XKeyboardFocusManagerPeer.deliverFocus
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
              return simulateMotifRequestFocus(lightweightChild, temporary, focusedWindowChangeAllowed, time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
              // Motif compatibility code
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   242
          case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
              // Either lightweight or excessive requiest - all events are generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
              return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    public boolean              isFocusable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public Image                createImage(ImageProducer producer) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public Image                createImage(int width, int height) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    public VolatileImage        createVolatileImage(int width, int height) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    public boolean              prepareImage(Image img, int w, int h, ImageObserver o) { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    public int                  checkImage(Image img, int w, int h, ImageObserver o) { return 0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public GraphicsConfiguration getGraphicsConfiguration() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    public boolean     handlesWheelScrolling() { return true; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    public void createBuffers(int numBuffers, BufferCapabilities caps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
      throws AWTException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public Image getBackBuffer() { return null; }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 439
diff changeset
   262
    public void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) {  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public void destroyBuffers() { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * Used by lightweight implementations to tell a ComponentPeer to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * its sub-elements.  For instance, a lightweight Checkbox needs to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * the box, as well as the text label.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    public void        layout() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * DEPRECATED:  Replaced by getPreferredSize().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public Dimension            preferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * DEPRECATED:  Replaced by getMinimumSize().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    public Dimension            minimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        return getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * DEPRECATED:  Replaced by setVisible(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    public void         show() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * DEPRECATED:  Replaced by setVisible(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    public void         hide() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * DEPRECATED:  Replaced by setEnabled(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    public void         enable() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * DEPRECATED:  Replaced by setEnabled(boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    public void         disable() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * DEPRECATED:  Replaced by setBounds(int, int, int, int).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    public void reshape(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        setBounds(x, y, width, height, SET_BOUNDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    Window getTopLevel(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        while (comp != null && !(comp instanceof Window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            comp = comp.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        return (Window)comp;
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() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        XToolkit.postEvent(XToolkit.targetToAppContext(proxy), new ComponentEvent(proxy, ComponentEvent.COMPONENT_RESIZED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        container.childResized(proxy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
//         XToolkit.postEvent(XToolkit.targetToAppContext(proxy), new InvocationEvent(proxy, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
//                 public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
//                     getTopLevel(proxy).invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
//                     getTopLevel(proxy).pack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
//                 }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
//             }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    void handlePropertyNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        XPropertyEvent ev = xev.get_xproperty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        if (ev.get_atom() == XAtom.XA_WM_NORMAL_HINTS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            childResized();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    void handleConfigureNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        childResized();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    public void dispatchEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        int type = xev.get_type();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        switch (type) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   346
          case XConstants.PropertyNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
              handlePropertyNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   349
          case XConstants.ConfigureNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
              handleConfigureNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    void requestXEmbedFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        postEvent(new InvocationEvent(proxy, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                    proxy.requestFocusInWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    public void reparent(ContainerPeer newNativeParent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public boolean isReparentSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        XWindowAttributes attrs = new XWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), handle, attrs.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            return new Rectangle(attrs.get_x(), attrs.get_y(), attrs.get_width(), attrs.get_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            attrs.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    public void setBoundsOperation(int operation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public void applyShape(Region shape) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    }
2459
08f3416ff334 6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents: 887
diff changeset
   384
2462
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
   385
    public void setZOrder(ComponentPeer above) {
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
   386
    }
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
   387
2805
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2464
diff changeset
   388
    public boolean updateGraphicsData(GraphicsConfiguration gc) {
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2464
diff changeset
   389
        return false;
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2464
diff changeset
   390
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
}