src/java.desktop/unix/classes/sun/awt/X11/XEmbedChildProxyPeer.java
author serb
Wed, 18 Apr 2018 14:07:41 -0700
changeset 49998 9070717a16a1
parent 47216 71c04702a3d5
permissions -rw-r--r--
8187392: Deprecated methods in the peers can be removed Reviewed-by: prr, kaddepalli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
49998
9070717a16a1 8187392: Deprecated methods in the peers can be removed
serb
parents: 47216
diff changeset
     2
 * Copyright (c) 2003, 2018, 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 print(Graphics g) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public void setBounds(int x, int y, int width, int height, int op) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        // Unimplemeneted: Check for min/max hints for non-resizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), handle, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public void handleEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        switch (e.getID()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
          case FocusEvent.FOCUS_GAINED:
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 11093
diff changeset
    98
              XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(proxy);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
              container.focusGained(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
          case FocusEvent.FOCUS_LOST:
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 11093
diff changeset
   102
              XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
              container.focusLost(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
          case KeyEvent.KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
          case KeyEvent.KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
              if (!((InputEvent)e).isConsumed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                  container.forwardKeyEvent(handle, (KeyEvent)e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public void                coalescePaintEvent(PaintEvent e) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public Point                getLocationOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        XWindowAttributes attr = new XWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        try{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), handle, attr.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            return new Point(attr.get_x(), attr.get_y());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            attr.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public Dimension            getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        long p_hints = XlibWrapper.XAllocSizeHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            XSizeHints hints = new XSizeHints(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), handle, p_hints, XlibWrapper.larg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            Dimension res = new Dimension(hints.get_width(), hints.get_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            XlibWrapper.XFree(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public Dimension            getMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        long p_hints = XlibWrapper.XAllocSizeHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            XSizeHints hints = new XSizeHints(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), handle, p_hints, XlibWrapper.larg1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            Dimension res = new Dimension(hints.get_min_width(), hints.get_min_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            XlibWrapper.XFree(p_hints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public ColorModel           getColorModel() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public Toolkit              getToolkit() { return Toolkit.getDefaultToolkit(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public Graphics             getGraphics() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public FontMetrics          getFontMetrics(Font font) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public void         dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        container.detachChild(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public void         setForeground(Color c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public void         setBackground(Color c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public void         setFont(Font f) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    public void                 updateCursorImmediately() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    void postEvent(AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        XToolkit.postEvent(XToolkit.targetToAppContext(proxy), event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    boolean simulateMotifRequestFocus(Component lightweightChild, boolean temporary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                      boolean focusedWindowChangeAllowed, long time)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        if (lightweightChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            lightweightChild = (Component)proxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 11093
diff changeset
   174
        Component currentOwner = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 28231
diff changeset
   175
        if (currentOwner != null && !currentOwner.isDisplayable()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            currentOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        FocusEvent  fg = new FocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, false, currentOwner );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        FocusEvent fl = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        if (currentOwner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            fl = new FocusEvent(currentOwner, FocusEvent.FOCUS_LOST, false, lightweightChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   184
        // TODO: do we need to wrap in sequenced?
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        if (fl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            postEvent(XComponentPeer.wrapInSequenced(fl));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        postEvent(XComponentPeer.wrapInSequenced(fg));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        // End of Motif compatibility code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public boolean requestFocus(Component lightweightChild,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                                boolean temporary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                                boolean focusedWindowChangeAllowed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                                long time,
37694
c064aefc5a2f 8080395: consider making sun.awt.CausedFocusEvent functionality public
ssadetsky
parents: 30469
diff changeset
   197
                                FocusEvent.Cause cause)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        int result = XKeyboardFocusManagerPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            .shouldNativelyFocusHeavyweight(proxy, lightweightChild,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                                            temporary, false, time, cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        switch (result) {
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   204
          case XKeyboardFocusManagerPeer.SNFH_FAILURE:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
              return false;
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   206
          case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
              // Currently we just generate focus events like we deal with lightweight instead of calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
              // XSetInputFocus on native window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
              /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
               * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
               * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
               * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
               * 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
   215
               * owner which had focus before WLF. So, we should not add request record for such requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
               * but store this component in mostRecent - and return true as before for compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
               */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
              Container parent = proxy.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
              // Search for parent window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
              while (parent != null && !(parent instanceof Window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                  parent = parent.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
              if (parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                  Window parentWindow = (Window)parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                  // and check that it is focused
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 11093
diff changeset
   226
                  if (!parentWindow.isFocused() &&
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 11093
diff changeset
   227
                      XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() == parentWindow) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                      // if it is not - skip requesting focus on Solaris
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                      // but return true for compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                      return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
              // NOTE: We simulate heavyweight behavior of Motif - component receives focus right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
              // after request, not after event. Normally, we should better listen for event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
              // by listeners.
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   237
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   238
              // TODO: consider replacing with XKeyboardFocusManagerPeer.deliverFocus
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
              return simulateMotifRequestFocus(lightweightChild, temporary, focusedWindowChangeAllowed, time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
              // Motif compatibility code
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   241
          case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
              // Either lightweight or excessive requiest - all events are generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
              return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    public boolean              isFocusable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public Image                createImage(ImageProducer producer) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public Image                createImage(int width, int height) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public VolatileImage        createVolatileImage(int width, int height) { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    public boolean              prepareImage(Image img, int w, int h, ImageObserver o) { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    public int                  checkImage(Image img, int w, int h, ImageObserver o) { return 0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    public GraphicsConfiguration getGraphicsConfiguration() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public boolean     handlesWheelScrolling() { return true; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    public void createBuffers(int numBuffers, BufferCapabilities caps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
      throws AWTException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public Image getBackBuffer() { return null; }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 439
diff changeset
   261
    public void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) {  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public void destroyBuffers() { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Used by lightweight implementations to tell a ComponentPeer to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * its sub-elements.  For instance, a lightweight Checkbox needs to layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * the box, as well as the text label.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    public void        layout() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    Window getTopLevel(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        while (comp != null && !(comp instanceof Window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            comp = comp.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        return (Window)comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    void childResized() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        XToolkit.postEvent(XToolkit.targetToAppContext(proxy), new ComponentEvent(proxy, ComponentEvent.COMPONENT_RESIZED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        container.childResized(proxy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
//         XToolkit.postEvent(XToolkit.targetToAppContext(proxy), new InvocationEvent(proxy, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
//                 public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
//                     getTopLevel(proxy).invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
//                     getTopLevel(proxy).pack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
//                 }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
//             }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    void handlePropertyNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        XPropertyEvent ev = xev.get_xproperty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        if (ev.get_atom() == XAtom.XA_WM_NORMAL_HINTS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            childResized();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    void handleConfigureNotify(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        childResized();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    public void dispatchEvent(XEvent xev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        int type = xev.get_type();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        switch (type) {
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   300
          case XConstants.PropertyNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
              handlePropertyNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
              break;
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   303
          case XConstants.ConfigureNotify:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
              handleConfigureNotify(xev);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    void requestXEmbedFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        postEvent(new InvocationEvent(proxy, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                    proxy.requestFocusInWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            }));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    public void reparent(ContainerPeer newNativeParent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    public boolean isReparentSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        XWindowAttributes attrs = new XWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), handle, attrs.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            return new Rectangle(attrs.get_x(), attrs.get_y(), attrs.get_width(), attrs.get_height());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            attrs.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    public void setBoundsOperation(int operation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    public void applyShape(Region shape) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    }
2459
08f3416ff334 6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents: 887
diff changeset
   338
2462
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
   339
    public void setZOrder(ComponentPeer above) {
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
   340
    }
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
   341
2805
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2464
diff changeset
   342
    public boolean updateGraphicsData(GraphicsConfiguration gc) {
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2464
diff changeset
   343
        return false;
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2464
diff changeset
   344
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
}