jdk/src/windows/native/sun/windows/awt_Window.cpp
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8515 f1c29dfb4f6a
child 10902 a76a2350fe7b
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8515
diff changeset
     2
 * Copyright (c) 1996, 2011, 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: 4375
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: 4375
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: 4375
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4375
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4375
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
    26
#include "awt.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
    28
#include <jlong.h>
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
    29
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "awt_Component.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "awt_Container.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "awt_Frame.h"
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
    33
#include "awt_Dialog.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "awt_Insets.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "awt_Panel.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "awt_Toolkit.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "awt_Window.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "awt_Win32GraphicsDevice.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "awt_BitmapUtil.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "awt_IconCursor.h"
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
    41
#include "ComCtl32Util.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include "java_awt_Insets.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include <java_awt_Container.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#include <java_awt_event_ComponentEvent.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#include "sun_awt_windows_WCanvasPeer.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
    48
#include <windowsx.h>
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
    49
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#if !defined(__int3264)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
typedef __int32 LONG_PTR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#endif // __int3264
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
// Used for Swing's Menu/Tooltip animation Support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
const int UNSPECIFIED = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
const int TOOLTIP = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
const int MENU = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
const int SUBMENU = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
const int POPUPMENU = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
const int COMBOBOX_POPUP = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
const int TYPES_COUNT = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
jint windowTYPES[TYPES_COUNT];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
/* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/***********************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
// struct for _SetAlwaysOnTop() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
struct SetAlwaysOnTopStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    jobject window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    jboolean value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
// struct for _SetTitle() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
struct SetTitleStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    jobject window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    jstring title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
// struct for _SetResizable() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
struct SetResizableStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    jobject window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    jboolean resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
// struct for _UpdateInsets() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
struct UpdateInsetsStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    jobject window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    jobject insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
// struct for _ReshapeFrame() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
struct ReshapeFrameStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    jobject frame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    jint x, y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    jint w, h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
// struct for _SetIconImagesData
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
struct SetIconImagesDataStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    jobject window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    jintArray iconRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    jint w, h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    jintArray smallIconRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    jint smw, smh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
// struct for _SetMinSize() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
// and other methods setting sizes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
struct SizeStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    jobject window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    jint w, h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
// struct for _SetFocusableWindow() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
struct SetFocusableWindowStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    jobject window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    jboolean isFocusableWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
// struct for _ModalDisable() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
struct ModalDisableStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    jobject window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    jlong blockerHWnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
};
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   119
// struct for _SetOpacity() method
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   120
struct OpacityStruct {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   121
    jobject window;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   122
    jint iOpacity;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   123
};
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   124
// struct for _SetOpaque() method
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   125
struct OpaqueStruct {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   126
    jobject window;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   127
    jboolean isOpaque;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   128
};
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   129
// struct for _UpdateWindow() method
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   130
struct UpdateWindowStruct {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   131
    jobject window;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   132
    jintArray data;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   133
    HBITMAP hBitmap;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   134
    jint width, height;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   135
};
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   136
// Struct for _RequestWindowFocus() method
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   137
struct RequestWindowFocusStruct {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   138
    jobject component;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   139
    jboolean isMouseEventCause;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   140
};
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   141
// struct for _RepositionSecurityWarning() method
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   142
struct RepositionSecurityWarningStruct {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   143
    jobject window;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   144
};
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   145
4256
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
   146
struct SetFullScreenExclusiveModeStateStruct {
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
   147
    jobject window;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
   148
    jboolean isFSEMState;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
   149
};
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
   150
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   151
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * AwtWindow fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
jfieldID AwtWindow::warningStringID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
jfieldID AwtWindow::locationByPlatformID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
jfieldID AwtWindow::autoRequestFocusID;
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   159
jfieldID AwtWindow::securityWarningWidthID;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   160
jfieldID AwtWindow::securityWarningHeightID;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
   162
jfieldID AwtWindow::sysXID;
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
   163
jfieldID AwtWindow::sysYID;
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
   164
jfieldID AwtWindow::sysWID;
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
   165
jfieldID AwtWindow::sysHID;
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
   166
jfieldID AwtWindow::windowTypeID;
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
   167
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   168
jmethodID AwtWindow::getWarningStringMID;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   169
jmethodID AwtWindow::calculateSecurityWarningPositionMID;
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
   170
jmethodID AwtWindow::windowTypeNameMID;
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   171
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
int AwtWindow::ms_instanceCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
HHOOK AwtWindow::ms_hCBTFilter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
AwtWindow * AwtWindow::m_grabbedWindow = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
BOOL AwtWindow::sm_resizing = FALSE;
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   176
UINT AwtWindow::untrustedWindowsCounter = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 * AwtWindow class methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
AwtWindow::AwtWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    m_sizePt.x = m_sizePt.y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    m_owningFrameDialog = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    m_isResizable = FALSE;//Default value is replaced after construction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    m_minSize.x = m_minSize.y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    m_hIcon = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    m_hIconSm = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    m_iconInherited = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    VERIFY(::SetRectEmpty(&m_insets));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    VERIFY(::SetRectEmpty(&m_old_insets));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    VERIFY(::SetRectEmpty(&m_warningRect));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    // what's the best initial value?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    m_screenNum = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    ms_instanceCounter++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    m_grabbed = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    m_isFocusableWindow = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    m_isRetainingHierarchyZOrder = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    m_filterFocusAndActivation = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    if (AwtWindow::ms_instanceCounter == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        AwtWindow::ms_hCBTFilter =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            ::SetWindowsHookEx(WH_CBT, (HOOKPROC)AwtWindow::CBTFilter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                               0, AwtToolkit::MainThread());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   207
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   208
    m_opaque = TRUE;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   209
    m_opacity = 0xff;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   210
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   211
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   212
    warningString = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   213
    warningWindow = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   214
    securityTooltipWindow = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   215
    securityWarningAnimationStage = 0;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   216
    currentWmSizeState = SIZE_RESTORED;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   217
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   218
    hContentBitmap = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   219
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
   220
    ::InitializeCriticalSection(&contentBitmapCS);
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
   221
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   222
    m_windowType = NORMAL;
4375
dc92e241ccea 6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents: 4367
diff changeset
   223
    m_alwaysOnTop = false;
8515
f1c29dfb4f6a 7022488: The security warning may disappear unexpectedly
anthony
parents: 7668
diff changeset
   224
f1c29dfb4f6a 7022488: The security warning may disappear unexpectedly
anthony
parents: 7668
diff changeset
   225
    fullScreenExclusiveModeState = FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
AwtWindow::~AwtWindow()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
{
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   230
    if (warningString != NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   231
        delete [] warningString;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   232
    }
3726
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
   233
    DeleteContentBitmap();
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   234
    ::DeleteCriticalSection(&contentBitmapCS);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
void AwtWindow::Dispose()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    // Fix 4745575 GDI Resource Leak
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    // MSDN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    // Before a window is destroyed (that is, before it returns from processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    // the WM_NCDESTROY message), an application must remove all entries it has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    // added to the property list. The application must use the RemoveProp function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    // to remove the entries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    if (--AwtWindow::ms_instanceCounter == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        ::UnhookWindowsHookEx(AwtWindow::ms_hCBTFilter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    ::RemoveProp(GetHWnd(), ModalBlockerProp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    if (m_grabbedWindow == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        Ungrab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    if ((m_hIcon != NULL) && !m_iconInherited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        ::DestroyIcon(m_hIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    if ((m_hIconSm != NULL) && !m_iconInherited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        ::DestroyIcon(m_hIconSm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    AwtCanvas::Dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
AwtWindow::Grab() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    if (m_grabbedWindow != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        m_grabbedWindow->Ungrab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    m_grabbed = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    m_grabbedWindow = this;
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   273
    if (AwtComponent::GetFocusedWindow() == NULL && IsFocusableWindow()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        // we shouldn't perform grab in this case (see 4841881 & 6539458)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        Ungrab();
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   276
    } else if (GetHWnd() != AwtComponent::GetFocusedWindow()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        _ToFront(env->NewGlobalRef(GetPeer(env)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        // Global ref was deleted in _ToFront
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
AwtWindow::Ungrab(BOOL doPost) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    if (m_grabbed && m_grabbedWindow == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        if (doPost) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            PostUngrabEvent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        m_grabbedWindow = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        m_grabbed = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
AwtWindow::Ungrab() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    Ungrab(TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
void AwtWindow::_Grab(void * param) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    if (env->EnsureLocalCapacity(1) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    AwtWindow *p = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    p = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    p->Grab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
  ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
void AwtWindow::_Ungrab(void * param) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    if (env->EnsureLocalCapacity(1) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    AwtWindow *p = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    p = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    p->Ungrab(FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
  ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
MsgRouting AwtWindow::WmNcMouseDown(WPARAM hitTest, int x, int y, int button) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    if (m_grabbedWindow != NULL && !m_grabbedWindow->IsOneOfOwnersOf(this)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        m_grabbedWindow->Ungrab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    return AwtCanvas::WmNcMouseDown(hitTest, x, y, button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
MsgRouting AwtWindow::WmWindowPosChanging(LPARAM windowPos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   353
void AwtWindow::RepositionSecurityWarning(JNIEnv *env)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   354
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   355
    RECT rect;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   356
    CalculateWarningWindowBounds(env, &rect);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   357
4375
dc92e241ccea 6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents: 4367
diff changeset
   358
    ::SetWindowPos(warningWindow, IsAlwaysOnTop() ? HWND_TOPMOST : GetHWnd(),
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   359
            rect.left, rect.top,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   360
            rect.right - rect.left, rect.bottom - rect.top,
4375
dc92e241ccea 6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents: 4367
diff changeset
   361
            SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE |
2640
643213b1a0a0 6825342: Security warning may change Z-order of top-level
anthony
parents: 2472
diff changeset
   362
            SWP_NOOWNERZORDER
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   363
            );
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   364
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   365
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
MsgRouting AwtWindow::WmWindowPosChanged(LPARAM windowPos) {
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   367
    WINDOWPOS * wp = (WINDOWPOS *)windowPos;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   368
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   369
    // Reposition the warning window
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   370
    if (IsUntrusted() && warningWindow != NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   371
        if (wp->flags & SWP_HIDEWINDOW) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   372
            UpdateSecurityWarningVisibility();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   373
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   374
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   375
        RepositionSecurityWarning((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2));
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   376
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   377
        if (wp->flags & SWP_SHOWWINDOW) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   378
            UpdateSecurityWarningVisibility();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   379
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   380
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   381
3726
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
   382
    if (wp->flags & SWP_HIDEWINDOW) {
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
   383
        EnableTranslucency(FALSE);
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
   384
    }
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
   385
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
LPCTSTR AwtWindow::GetClassName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
  return TEXT("SunAwtWindow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
void AwtWindow::FillClassInfo(WNDCLASSEX *lpwc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    AwtComponent::FillClassInfo(lpwc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * This line causes bug #4189244 (Swing Popup menu is not being refreshed (cleared) under a Dialog)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * so it's comment out (son@sparc.spb.su)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * lpwc->style     |= CS_SAVEBITS; // improve pull-down menu performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    lpwc->cbWndExtra = DLGWINDOWEXTRA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   405
bool AwtWindow::IsWarningWindow(HWND hWnd)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   406
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   407
    const UINT len = 128;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   408
    TCHAR windowClassName[len];
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   409
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   410
    ::RealGetWindowClass(hWnd, windowClassName, len);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   411
    return 0 == _tcsncmp(windowClassName,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   412
            AwtWindow::GetWarningWindowClassName(), len);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   413
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   414
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
LRESULT CALLBACK AwtWindow::CBTFilter(int nCode, WPARAM wParam, LPARAM lParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    if (nCode == HCBT_ACTIVATE || nCode == HCBT_SETFOCUS) {
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   418
        HWND hWnd = (HWND)wParam;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   419
        AwtComponent *comp = AwtComponent::GetComponent(hWnd);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   420
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   421
        if (comp == NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   422
            // Check if it's a security warning icon
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   423
            // See: 5091224, 6181725, 6732583
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   424
            if (AwtWindow::IsWarningWindow(hWnd)) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   425
                return 1;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   426
            }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   427
        } else {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   428
            if (comp->IsTopLevel()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   429
                AwtWindow* win = (AwtWindow*)comp;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   430
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   431
                if (!win->IsFocusableWindow() ||
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   432
                        win->m_filterFocusAndActivation)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   433
                {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   434
                    return 1; // Don't change focus/activation.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   435
                }
131
fe5ccd4774b4 6567410: PIT : java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusSetVisibleTest.java fails
ant
parents: 129
diff changeset
   436
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    return ::CallNextHookEx(AwtWindow::ms_hCBTFilter, nCode, wParam, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   442
void AwtWindow::InitSecurityWarningSize(JNIEnv *env)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   443
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   444
    warningWindowWidth = ::GetSystemMetrics(SM_CXSMICON);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   445
    warningWindowHeight = ::GetSystemMetrics(SM_CYSMICON);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   446
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   447
    jobject target = GetTarget(env);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   448
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   449
    env->SetIntField(target, AwtWindow::securityWarningWidthID,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   450
            warningWindowWidth);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   451
    env->SetIntField(target, AwtWindow::securityWarningHeightID,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   452
            warningWindowHeight);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   453
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   454
    env->DeleteLocalRef(target);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   455
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   456
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   457
void AwtWindow::CreateHWnd(JNIEnv *env, LPCWSTR title,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   458
        DWORD windowStyle,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   459
        DWORD windowExStyle,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   460
        int x, int y, int w, int h,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   461
        HWND hWndParent, HMENU hMenu,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   462
        COLORREF colorForeground,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   463
        COLORREF colorBackground,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   464
        jobject peer)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   465
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   466
    // Retrieve the warning string
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   467
    // Note: we need to get it before CreateHWnd() happens because
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   468
    // the isUntrusted() method may be invoked while the HWND
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   469
    // is being created in response to some window messages.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   470
    jobject target = env->GetObjectField(peer, AwtObject::targetID);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   471
    jstring javaWarningString =
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   472
        (jstring)env->CallObjectMethod(target, AwtWindow::getWarningStringMID);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   473
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   474
    if (javaWarningString != NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   475
        size_t length = env->GetStringLength(javaWarningString) + 1;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   476
        warningString = new WCHAR[length];
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   477
        env->GetStringRegion(javaWarningString, 0,
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
   478
                static_cast<jsize>(length - 1), reinterpret_cast<jchar*>(warningString));
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   479
        warningString[length-1] = L'\0';
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   480
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   481
        env->DeleteLocalRef(javaWarningString);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   482
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   483
    env->DeleteLocalRef(target);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   484
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
   485
    InitType(env, peer);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
   486
    TweakStyle(windowStyle, windowExStyle);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
   487
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   488
    AwtCanvas::CreateHWnd(env, title,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   489
            windowStyle,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   490
            windowExStyle,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   491
            x, y, w, h,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   492
            hWndParent, hMenu,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   493
            colorForeground,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   494
            colorBackground,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   495
            peer);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   496
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   497
    // Now we need to create the warning window.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   498
    CreateWarningWindow(env);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   499
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   500
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   501
void AwtWindow::CreateWarningWindow(JNIEnv *env)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   502
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   503
    if (!IsUntrusted()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   504
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   505
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   506
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   507
    if (++AwtWindow::untrustedWindowsCounter == 1) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   508
        AwtToolkit::GetInstance().InstallMouseLowLevelHook();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   509
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   510
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   511
    InitSecurityWarningSize(env);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   512
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   513
    RECT rect;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   514
    CalculateWarningWindowBounds(env, &rect);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   515
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   516
    RegisterWarningWindowClass();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   517
    warningWindow = ::CreateWindowEx(
3443
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   518
            WS_EX_NOACTIVATE,
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   519
            GetWarningWindowClassName(),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   520
            warningString,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   521
            WS_POPUP,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   522
            rect.left, rect.top,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   523
            rect.right - rect.left, rect.bottom - rect.top,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   524
            GetHWnd(), // owner
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   525
            NULL, // menu
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   526
            AwtToolkit::GetInstance().GetModuleHandle(),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   527
            NULL // lParam
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   528
            );
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   529
    if (warningWindow == NULL) {
3443
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   530
        //XXX: actually this is bad... We didn't manage to create the window.
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   531
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   532
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   533
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   534
    HICON hIcon = GetSecurityWarningIcon();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   535
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   536
    ICONINFO ii;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   537
    ::GetIconInfo(hIcon, &ii);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   538
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   539
    //Note: we assume that every security icon has exactly the same shape.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   540
    HRGN rgn = BitmapUtil::BitmapToRgn(ii.hbmColor);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   541
    if (rgn) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   542
        ::SetWindowRgn(warningWindow, rgn, TRUE);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   543
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   544
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   545
    // Now we need to create the tooltip control for this window.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   546
    if (!ComCtl32Util::GetInstance().IsToolTipControlInitialized()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   547
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   548
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   549
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   550
    securityTooltipWindow = ::CreateWindowEx(
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   551
            WS_EX_TOPMOST,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   552
            TOOLTIPS_CLASS,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   553
            NULL,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   554
            WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   555
            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   556
            warningWindow,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   557
            NULL,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   558
            AwtToolkit::GetInstance().GetModuleHandle(),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   559
            NULL
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   560
            );
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   561
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   562
    ::SetWindowPos(securityTooltipWindow,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   563
            HWND_TOPMOST, 0, 0, 0, 0,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   564
            SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   565
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   566
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   567
    // We currently don't expect changing the size of the window,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   568
    // hence we may not care of updating the TOOL position/size.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   569
    ::GetClientRect(warningWindow, &rect);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   570
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   571
    TOOLINFO ti;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   572
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   573
    ti.cbSize = sizeof(ti);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   574
    ti.uFlags = TTF_SUBCLASS;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   575
    ti.hwnd = warningWindow;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   576
    ti.hinst = AwtToolkit::GetInstance().GetModuleHandle();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   577
    ti.uId = 0;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   578
    ti.lpszText = warningString;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   579
    ti.rect.left = rect.left;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   580
    ti.rect.top = rect.top;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   581
    ti.rect.right = rect.right;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   582
    ti.rect.bottom = rect.bottom;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   583
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   584
    ::SendMessage(securityTooltipWindow, TTM_ADDTOOL,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   585
            0, (LPARAM) (LPTOOLINFO) &ti);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   586
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   587
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   588
void AwtWindow::DestroyWarningWindow()
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   589
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   590
    if (!IsUntrusted()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   591
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   592
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   593
    if (--AwtWindow::untrustedWindowsCounter == 0) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   594
        AwtToolkit::GetInstance().UninstallMouseLowLevelHook();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   595
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   596
    if (warningWindow != NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   597
        // Note that the warningWindow is an owned window, and hence
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   598
        // it would be destroyed automatically. However, the window
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   599
        // class may only be unregistered if there's no any single
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   600
        // window left using this class. Thus, we're destroying the
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   601
        // warning window manually. Note that the tooltip window
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   602
        // will be destroyed automatically because it's an owned
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   603
        // window as well.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   604
        ::DestroyWindow(warningWindow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   605
        warningWindow = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   606
        securityTooltipWindow = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   607
        UnregisterWarningWindowClass();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   608
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   609
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   610
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   611
void AwtWindow::DestroyHWnd()
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   612
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   613
    DestroyWarningWindow();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   614
    AwtCanvas::DestroyHWnd();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   615
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   616
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   617
LPCTSTR AwtWindow::GetWarningWindowClassName()
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   618
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   619
    return TEXT("SunAwtWarningWindow");
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   620
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   621
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   622
void AwtWindow::FillWarningWindowClassInfo(WNDCLASS *lpwc)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   623
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   624
    lpwc->style         = 0L;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   625
    lpwc->lpfnWndProc   = (WNDPROC)WarningWindowProc;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   626
    lpwc->cbClsExtra    = 0;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   627
    lpwc->cbWndExtra    = 0;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   628
    lpwc->hInstance     = AwtToolkit::GetInstance().GetModuleHandle(),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   629
    lpwc->hIcon         = AwtToolkit::GetInstance().GetAwtIcon();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   630
    lpwc->hCursor       = ::LoadCursor(NULL, IDC_ARROW);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   631
    lpwc->hbrBackground = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   632
    lpwc->lpszMenuName  = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   633
    lpwc->lpszClassName = AwtWindow::GetWarningWindowClassName();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   634
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   635
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   636
void AwtWindow::RegisterWarningWindowClass()
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   637
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   638
    WNDCLASS  wc;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   639
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   640
    ::ZeroMemory(&wc, sizeof(wc));
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   641
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   642
    if (!::GetClassInfo(AwtToolkit::GetInstance().GetModuleHandle(),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   643
                        AwtWindow::GetWarningWindowClassName(), &wc))
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   644
    {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   645
        AwtWindow::FillWarningWindowClassInfo(&wc);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   646
        ATOM atom = ::RegisterClass(&wc);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   647
        DASSERT(atom != 0);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   648
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   649
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   650
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   651
void AwtWindow::UnregisterWarningWindowClass()
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   652
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   653
    ::UnregisterClass(AwtWindow::GetWarningWindowClassName(), AwtToolkit::GetInstance().GetModuleHandle());
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   654
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   655
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   656
HICON AwtWindow::GetSecurityWarningIcon()
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   657
{
4367
e60cfd711532 6901021: Security Warning Icon not getting displayed properly when frame loses focus
anthony
parents: 4366
diff changeset
   658
    // It is assumed that the icon at index 0 is gray
e60cfd711532 6901021: Security Warning Icon not getting displayed properly when frame loses focus
anthony
parents: 4366
diff changeset
   659
    const UINT index = securityAnimationKind == akShow ?
e60cfd711532 6901021: Security Warning Icon not getting displayed properly when frame loses focus
anthony
parents: 4366
diff changeset
   660
        securityWarningAnimationStage : 0;
e60cfd711532 6901021: Security Warning Icon not getting displayed properly when frame loses focus
anthony
parents: 4366
diff changeset
   661
    HICON ico = AwtToolkit::GetInstance().GetSecurityWarningIcon(index,
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   662
            warningWindowWidth, warningWindowHeight);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   663
    return ico;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   664
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   665
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   666
// This function calculates the bounds of the warning window and stores them
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   667
// into the RECT structure pointed by the argument rect.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   668
void AwtWindow::CalculateWarningWindowBounds(JNIEnv *env, LPRECT rect)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   669
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   670
    RECT windowBounds;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   671
    AwtToolkit::GetWindowRect(GetHWnd(), &windowBounds);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   672
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   673
    jobject target = GetTarget(env);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   674
    jobject point2D = env->CallObjectMethod(target,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   675
            calculateSecurityWarningPositionMID,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   676
            (jdouble)windowBounds.left, (jdouble)windowBounds.top,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   677
            (jdouble)(windowBounds.right - windowBounds.left),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   678
            (jdouble)(windowBounds.bottom - windowBounds.top));
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   679
    env->DeleteLocalRef(target);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   680
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   681
    static jclass point2DClassID = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   682
    static jmethodID point2DGetXMID = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   683
    static jmethodID point2DGetYMID = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   684
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   685
    if (point2DClassID == NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   686
        jclass point2DClassIDLocal = env->FindClass("java/awt/geom/Point2D");
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   687
        point2DClassID = (jclass)env->NewGlobalRef(point2DClassIDLocal);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   688
        env->DeleteLocalRef(point2DClassIDLocal);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   689
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   690
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   691
    if (point2DGetXMID == NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   692
        point2DGetXMID = env->GetMethodID(point2DClassID, "getX", "()D");
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   693
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   694
    if (point2DGetYMID == NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   695
        point2DGetYMID = env->GetMethodID(point2DClassID, "getY", "()D");
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   696
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   697
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   698
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   699
    int x = (int)env->CallDoubleMethod(point2D, point2DGetXMID);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   700
    int y = (int)env->CallDoubleMethod(point2D, point2DGetYMID);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   701
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   702
    env->DeleteLocalRef(point2D);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   703
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   704
    rect->left = x;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   705
    rect->top = y;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   706
    rect->right = rect->left + warningWindowWidth;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   707
    rect->bottom = rect->top + warningWindowHeight;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   708
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   709
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   710
LRESULT CALLBACK AwtWindow::WarningWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   711
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   712
    switch (uMsg) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   713
        case WM_PAINT:
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   714
            PaintWarningWindow(hwnd);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   715
            return 0;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   716
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   717
        case WM_MOUSEACTIVATE:
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   718
            {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   719
                // Retrive the owner of the warning window.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   720
                HWND javaWindow = ::GetParent(hwnd);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   721
                if (javaWindow) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   722
                    // If the window is blocked by a modal dialog, substitute
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   723
                    // its handle with the topmost blocker.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   724
                    HWND topmostBlocker = GetTopmostModalBlocker(javaWindow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   725
                    if (::IsWindow(topmostBlocker)) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   726
                        javaWindow = topmostBlocker;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   727
                    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   728
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   729
                    ::BringWindowToTop(javaWindow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   730
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   731
                    AwtWindow * window =
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   732
                        (AwtWindow*)AwtComponent::GetComponent(javaWindow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   733
                    if (window == NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   734
                        // Quite unlikely to go into here, but it's way better
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   735
                        // than getting a crash.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   736
                        ::SetForegroundWindow(javaWindow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   737
                    } else {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   738
                        // Activate the window if it is focusable and inactive
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   739
                        if (window->IsFocusableWindow() &&
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   740
                                javaWindow != ::GetActiveWindow()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   741
                            ::SetForegroundWindow(javaWindow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   742
                        } else {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   743
                            // ...otherwise just start the animation.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   744
                            window->StartSecurityAnimation(akShow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   745
                        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   746
                    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   747
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   748
                    // In every case if there's a top-most blocker, we need to
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   749
                    // enable modal animation.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   750
                    if (::IsWindow(topmostBlocker)) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   751
                        AwtDialog::AnimateModalBlocker(topmostBlocker);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   752
                    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   753
                }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   754
                return MA_NOACTIVATEANDEAT;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   755
            }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   756
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   757
    return ::DefWindowProc(hwnd, uMsg, wParam, lParam);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   758
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   759
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   760
void AwtWindow::PaintWarningWindow(HWND warningWindow)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   761
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   762
    RECT updateRect;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   763
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   764
    if (!::GetUpdateRect(warningWindow, &updateRect, FALSE)) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   765
        // got nothing to update
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   766
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   767
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   768
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   769
    PAINTSTRUCT ps;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   770
    HDC hdc = ::BeginPaint(warningWindow, &ps);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   771
    if (hdc == NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   772
        // indicates an error
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   773
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   774
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   775
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   776
    PaintWarningWindow(warningWindow, hdc);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   777
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   778
    ::EndPaint(warningWindow, &ps);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   779
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   780
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   781
void AwtWindow::PaintWarningWindow(HWND warningWindow, HDC hdc)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   782
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   783
    HWND javaWindow = ::GetParent(warningWindow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   784
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   785
    AwtWindow * window = (AwtWindow*)AwtComponent::GetComponent(javaWindow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   786
    if (window == NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   787
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   788
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   789
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   790
    ::DrawIconEx(hdc, 0, 0, window->GetSecurityWarningIcon(),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   791
            window->warningWindowWidth, window->warningWindowHeight,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   792
            0, NULL, DI_NORMAL);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   793
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   794
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   795
static const UINT_PTR IDT_AWT_SECURITYANIMATION = 0x102;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   796
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   797
// Approximately 6 times a second. 0.75 seconds total.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   798
static const UINT securityAnimationTimerElapse = 150;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   799
static const UINT securityAnimationMaxIterations = 5;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   800
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   801
void AwtWindow::RepaintWarningWindow()
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   802
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   803
    HDC hdc = ::GetDC(warningWindow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   804
    PaintWarningWindow(warningWindow, hdc);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   805
    ::ReleaseDC(warningWindow, hdc);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   806
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   807
3443
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   808
void AwtWindow::SetLayered(HWND window, bool layered)
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   809
{
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   810
    const LONG ex_style = ::GetWindowLong(window, GWL_EXSTYLE);
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   811
    ::SetWindowLong(window, GWL_EXSTYLE, layered ?
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   812
            ex_style | WS_EX_LAYERED : ex_style & ~WS_EX_LAYERED);
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   813
}
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   814
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   815
bool AwtWindow::IsLayered(HWND window)
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   816
{
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   817
    const LONG ex_style = ::GetWindowLong(window, GWL_EXSTYLE);
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   818
    return ex_style & WS_EX_LAYERED;
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   819
}
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   820
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   821
void AwtWindow::StartSecurityAnimation(AnimationKind kind)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   822
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   823
    if (!IsUntrusted()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   824
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   825
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   826
    if (warningWindow == NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   827
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   828
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   829
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   830
    securityAnimationKind = kind;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   831
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   832
    securityWarningAnimationStage = 1;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   833
    ::SetTimer(GetHWnd(), IDT_AWT_SECURITYANIMATION,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   834
            securityAnimationTimerElapse, NULL);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   835
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   836
    if (securityAnimationKind == akShow) {
4375
dc92e241ccea 6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents: 4367
diff changeset
   837
        ::SetWindowPos(warningWindow,
dc92e241ccea 6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents: 4367
diff changeset
   838
                IsAlwaysOnTop() ? HWND_TOPMOST : GetHWnd(),
dc92e241ccea 6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents: 4367
diff changeset
   839
                0, 0, 0, 0,
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   840
                SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE |
2640
643213b1a0a0 6825342: Security warning may change Z-order of top-level
anthony
parents: 2472
diff changeset
   841
                SWP_SHOWWINDOW | SWP_NOOWNERZORDER);
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   842
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   843
        ::SetLayeredWindowAttributes(warningWindow, RGB(0, 0, 0),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   844
                0xFF, LWA_ALPHA);
3443
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   845
        AwtWindow::SetLayered(warningWindow, false);
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   846
        ::RedrawWindow(warningWindow, NULL, NULL,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   847
                RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
3443
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   848
    } else if (securityAnimationKind == akPreHide) {
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   849
        // Pre-hiding means fading-out. We have to make the window layered.
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   850
        // Note: Some VNC clients do not support layered windows, hence
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   851
        // we dynamically turn it on and off. See 6805231.
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
   852
        AwtWindow::SetLayered(warningWindow, true);
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   853
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   854
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   855
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   856
void AwtWindow::StopSecurityAnimation()
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   857
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   858
    if (!IsUntrusted()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   859
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   860
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   861
    if (warningWindow == NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   862
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   863
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   864
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   865
    securityWarningAnimationStage = 0;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   866
    ::KillTimer(GetHWnd(), IDT_AWT_SECURITYANIMATION);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   867
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   868
    switch (securityAnimationKind) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   869
        case akHide:
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   870
        case akPreHide:
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   871
            ::SetWindowPos(warningWindow, HWND_NOTOPMOST, 0, 0, 0, 0,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   872
                    SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE |
2640
643213b1a0a0 6825342: Security warning may change Z-order of top-level
anthony
parents: 2472
diff changeset
   873
                    SWP_HIDEWINDOW | SWP_NOOWNERZORDER);
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   874
            break;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   875
        case akShow:
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   876
            RepaintWarningWindow();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   877
            break;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   878
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   879
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   880
    securityAnimationKind = akNone;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   881
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   882
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   883
MsgRouting AwtWindow::WmTimer(UINT_PTR timerID)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   884
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   885
    if (timerID != IDT_AWT_SECURITYANIMATION) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   886
        return mrPassAlong;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   887
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   888
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   889
    if (securityWarningAnimationStage == 0) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   890
        return mrConsume;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   891
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   892
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   893
    securityWarningAnimationStage++;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   894
    if (securityWarningAnimationStage >= securityAnimationMaxIterations) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   895
        if (securityAnimationKind == akPreHide) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   896
            // chain real hiding
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   897
            StartSecurityAnimation(akHide);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   898
        } else {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   899
            StopSecurityAnimation();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   900
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   901
    } else {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   902
        switch (securityAnimationKind) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   903
            case akHide:
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   904
                {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   905
                    BYTE opacity = ((int)0xFF *
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   906
                            (securityAnimationMaxIterations -
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   907
                             securityWarningAnimationStage)) /
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   908
                        securityAnimationMaxIterations;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   909
                    ::SetLayeredWindowAttributes(warningWindow,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   910
                            RGB(0, 0, 0), opacity, LWA_ALPHA);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   911
                }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   912
                break;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   913
            case akShow:
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   914
            case akNone: // quite unlikely, but quite safe
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   915
                RepaintWarningWindow();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   916
                break;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   917
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   918
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   919
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   920
    return mrConsume;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   921
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   922
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   923
// The security warning is visible if:
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   924
//    1. The window has the keyboard window focus, OR
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   925
//    2. The mouse pointer is located within the window bounds,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   926
//       or within the security warning icon.
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   927
void AwtWindow::UpdateSecurityWarningVisibility()
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   928
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   929
    if (!IsUntrusted()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   930
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   931
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   932
    if (warningWindow == NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   933
        return;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   934
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   935
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   936
    bool show = false;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   937
4256
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
   938
    if (IsVisible() && currentWmSizeState != SIZE_MINIMIZED &&
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
   939
            !isFullScreenExclusiveMode())
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
   940
    {
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   941
        if (AwtComponent::GetFocusedWindow() == GetHWnd()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   942
            show = true;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   943
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   944
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   945
        HWND hwnd = AwtToolkit::GetInstance().GetWindowUnderMouse();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   946
        if (hwnd == GetHWnd()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   947
            show = true;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   948
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   949
        if (hwnd == warningWindow) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   950
            show = true;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   951
        }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   952
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   953
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   954
    if (show && (!::IsWindowVisible(warningWindow) ||
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   955
                securityAnimationKind == akHide ||
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   956
                securityAnimationKind == akPreHide)) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   957
        StartSecurityAnimation(akShow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   958
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   959
    if (!show && ::IsWindowVisible(warningWindow)) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   960
        StartSecurityAnimation(akPreHide);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   961
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   962
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   963
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   964
void AwtWindow::FocusedWindowChanged(HWND from, HWND to)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   965
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   966
    AwtWindow * fw = (AwtWindow *)AwtComponent::GetComponent(from);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   967
    AwtWindow * tw = (AwtWindow *)AwtComponent::GetComponent(to);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   968
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   969
    if (fw != NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   970
        fw->UpdateSecurityWarningVisibility();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   971
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   972
    if (tw != NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   973
        tw->UpdateSecurityWarningVisibility();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   974
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   975
        // Flash on receiving the keyboard focus even if the warning
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   976
        // has already been shown (e.g. by hovering with the mouse)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   977
        tw->StartSecurityAnimation(akShow);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   978
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   979
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   980
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   981
void AwtWindow::_RepositionSecurityWarning(void* param)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   982
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   983
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   984
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   985
    RepositionSecurityWarningStruct *rsws =
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   986
        (RepositionSecurityWarningStruct *)param;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   987
    jobject self = rsws->window;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   988
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   989
    PDATA pData;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   990
    JNI_CHECK_PEER_GOTO(self, ret);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   991
    AwtWindow *window = (AwtWindow *)pData;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   992
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   993
    window->RepositionSecurityWarning(env);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   994
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   995
  ret:
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   996
    env->DeleteGlobalRef(self);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   997
    delete rsws;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   998
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
   999
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1000
void AwtWindow::InitType(JNIEnv *env, jobject peer)
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1001
{
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1002
    jobject type = env->GetObjectField(peer, windowTypeID);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1003
    if (type == NULL) {
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1004
        return;
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1005
    }
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1006
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1007
    jstring value = (jstring)env->CallObjectMethod(type, windowTypeNameMID);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1008
    if (value == NULL) {
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1009
        env->DeleteLocalRef(type);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1010
        return;
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1011
    }
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1012
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1013
    const char* valueNative = env->GetStringUTFChars(value, 0);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1014
    if (valueNative == NULL) {
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1015
        env->DeleteLocalRef(value);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1016
        env->DeleteLocalRef(type);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1017
        return;
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1018
    }
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1019
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1020
    if (strcmp(valueNative, "UTILITY") == 0) {
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1021
        m_windowType = UTILITY;
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1022
    } else if (strcmp(valueNative, "POPUP") == 0) {
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1023
        m_windowType = POPUP;
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1024
    }
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1025
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1026
    env->ReleaseStringUTFChars(value, valueNative);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1027
    env->DeleteLocalRef(value);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1028
    env->DeleteLocalRef(type);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1029
}
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1030
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1031
void AwtWindow::TweakStyle(DWORD & style, DWORD & exStyle)
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1032
{
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1033
    switch (GetType()) {
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1034
        case UTILITY:
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1035
            exStyle |= WS_EX_TOOLWINDOW;
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1036
            break;
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
  1037
        case POPUP:
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1038
            style &= ~WS_OVERLAPPED;
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1039
            style |= WS_POPUP;
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1040
            break;
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1041
    }
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1042
}
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  1043
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
/* Create a new AwtWindow object and window.   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
AwtWindow* AwtWindow::Create(jobject self, jobject parent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    jobject target = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    AwtWindow* window = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        if (env->EnsureLocalCapacity(1) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        AwtWindow* awtParent = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
        if (parent != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
            JNI_CHECK_PEER_GOTO(parent, done);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
            awtParent = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
        target = env->GetObjectField(self, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        JNI_CHECK_NULL_GOTO(target, "null target", done);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
        window = new AwtWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
            if (JNU_IsInstanceOfByName(env, target, "javax/swing/Popup$HeavyWeightWindow") > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                window->m_isRetainingHierarchyZOrder = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
            DWORD style = WS_CLIPCHILDREN | WS_POPUP;
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1075
            DWORD exStyle = WS_EX_NOACTIVATE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
            if (GetRTL()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                if (GetRTLReadingOrder())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                    exStyle |= WS_EX_RTLREADING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
            if (awtParent != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                window->InitOwner(awtParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                // specify WS_EX_TOOLWINDOW to remove parentless windows from taskbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
                exStyle |= WS_EX_TOOLWINDOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
            window->CreateHWnd(env, L"",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
                               style, exStyle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
                               0, 0, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                               (awtParent != NULL) ? awtParent->GetHWnd() : NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
                               NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
                               ::GetSysColor(COLOR_WINDOWTEXT),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                               ::GetSysColor(COLOR_WINDOW),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
                               self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
            jint x = env->GetIntField(target, AwtComponent::xID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
            jint y = env->GetIntField(target, AwtComponent::yID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
            jint width = env->GetIntField(target, AwtComponent::widthID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
            jint height = env->GetIntField(target, AwtComponent::heightID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
             * Initialize icon as inherited from parent if it exists
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
            if (parent != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
                window->m_hIcon = awtParent->GetHIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
                window->m_hIconSm = awtParent->GetHIconSm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
                window->m_iconInherited = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            window->DoUpdateIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
             * Reshape here instead of during create, so that a WM_NCCALCSIZE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
             * is sent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
            window->Reshape(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
    } catch (...) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
        env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
        throw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
done:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
    return window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
BOOL AwtWindow::IsOneOfOwnersOf(AwtWindow * wnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    while (wnd != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
        if (wnd == this || wnd->GetOwningFrameOrDialog() == this) return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
        wnd = (AwtWindow*)GetComponent(::GetWindow(wnd->GetHWnd(), GW_OWNER));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
void AwtWindow::InitOwner(AwtWindow *owner)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    DASSERT(owner != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
    while (owner != NULL && owner->IsSimpleWindow()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        HWND ownerOwnerHWND = ::GetWindow(owner->GetHWnd(), GW_OWNER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        if (ownerOwnerHWND == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
            owner = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        owner = (AwtWindow *)AwtComponent::GetComponent(ownerOwnerHWND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
    m_owningFrameDialog = (AwtFrame *)owner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
void AwtWindow::moveToDefaultLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
    HWND boggy = ::CreateWindow(GetClassName(), L"BOGGY", WS_OVERLAPPED, CW_USEDEFAULT, 0 ,0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
        NULL, NULL, NULL, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
    RECT defLoc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
    // Fixed 6477497: Windows drawn off-screen on Win98, even when java.awt.Window.locationByPlatform is set
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
    //    Win9x does not position a window until the window is shown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
    //    The behavior is slightly opposite to the WinNT (and up), where
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
    //    Windows will position the window upon creation of the window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
    //    That's why we have to manually set the left & top values of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
    //    the defLoc to 0 if the GetWindowRect function returns FALSE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
    BOOL result = ::GetWindowRect(boggy, &defLoc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
    if (!result) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
        defLoc.left = defLoc.top = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
    VERIFY(::DestroyWindow(boggy));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
    VERIFY(::SetWindowPos(GetHWnd(), NULL, defLoc.left, defLoc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
void AwtWindow::Show()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    m_visible = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
    BOOL  done = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
    HWND hWnd = GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
    if (env->EnsureLocalCapacity(2) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
    jobject target = GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
    INT nCmdShow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
    AwtFrame* owningFrame = GetOwningFrameOrDialog();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
    if (IsFocusableWindow() && IsAutoRequestFocus() && owningFrame != NULL &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        ::GetForegroundWindow() == owningFrame->GetHWnd())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        nCmdShow = SW_SHOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        nCmdShow = SW_SHOWNA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
    BOOL locationByPlatform = env->GetBooleanField(GetTarget(env), AwtWindow::locationByPlatformID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
    if (locationByPlatform) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
         moveToDefaultLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
3726
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  1198
    EnableTranslucency(TRUE);
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  1199
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
    // The following block exists to support Menu/Tooltip animation for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
    // Swing programs in a way which avoids introducing any new public api into
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
    // AWT or Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
    // This code should eventually be replaced by a better longterm solution
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
    // which might involve tagging java.awt.Window instances with a semantic
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
    // property so platforms can animate/decorate/etc accordingly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
    //
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1207
    if (JNU_IsInstanceOfByName(env, target, "com/sun/java/swing/plaf/windows/WindowsPopupWindow") > 0)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
        // need this global ref to make the class unloadable (see 6500204)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
        static jclass windowsPopupWindowCls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
        static jfieldID windowTypeFID = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
        jint windowType = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
        BOOL  animateflag = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
        BOOL  fadeflag = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
        DWORD animateStyle = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
        if (windowTypeFID == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
            // Initialize Window type constants ONCE...
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
            jfieldID windowTYPESFID[TYPES_COUNT];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
            jclass cls = env->GetObjectClass(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
            windowTypeFID = env->GetFieldID(cls, "windowType", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
            windowTYPESFID[UNSPECIFIED] = env->GetStaticFieldID(cls, "UNDEFINED_WINDOW_TYPE", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            windowTYPESFID[TOOLTIP] = env->GetStaticFieldID(cls, "TOOLTIP_WINDOW_TYPE", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
            windowTYPESFID[MENU] = env->GetStaticFieldID(cls, "MENU_WINDOW_TYPE", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
            windowTYPESFID[SUBMENU] = env->GetStaticFieldID(cls, "SUBMENU_WINDOW_TYPE", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
            windowTYPESFID[POPUPMENU] = env->GetStaticFieldID(cls, "POPUPMENU_WINDOW_TYPE", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
            windowTYPESFID[COMBOBOX_POPUP] = env->GetStaticFieldID(cls, "COMBOBOX_POPUP_WINDOW_TYPE", "I");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
            for (int i=0; i < 6; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                windowTYPES[i] = env->GetStaticIntField(cls, windowTYPESFID[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
            windowsPopupWindowCls = (jclass) env->NewGlobalRef(cls);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
            env->DeleteLocalRef(cls);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
        windowType = env->GetIntField(target, windowTypeFID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
        if (windowType == windowTYPES[TOOLTIP]) {
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1240
            SystemParametersInfo(SPI_GETTOOLTIPANIMATION, 0, &animateflag, 0);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1241
            SystemParametersInfo(SPI_GETTOOLTIPFADE, 0, &fadeflag, 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
            if (animateflag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
              // AW_BLEND currently produces runtime parameter error
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
              // animateStyle = fadeflag? AW_BLEND : AW_SLIDE | AW_VER_POSITIVE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
                 animateStyle = fadeflag? 0 : AW_SLIDE | AW_VER_POSITIVE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        } else if (windowType == windowTYPES[MENU] || windowType == windowTYPES[SUBMENU] ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
                   windowType == windowTYPES[POPUPMENU]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
            SystemParametersInfo(SPI_GETMENUANIMATION, 0, &animateflag, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
            if (animateflag) {
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1251
                SystemParametersInfo(SPI_GETMENUFADE, 0, &fadeflag, 0);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1252
                if (fadeflag) {
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1253
                    // AW_BLEND currently produces runtime parameter error
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1254
                    //animateStyle = AW_BLEND;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
                if (animateStyle == 0 && !fadeflag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
                    animateStyle = AW_SLIDE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
                    if (windowType == windowTYPES[MENU]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
                      animateStyle |= AW_VER_POSITIVE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
                    } else if (windowType == windowTYPES[SUBMENU]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
                      animateStyle |= AW_HOR_POSITIVE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
                    } else { /* POPUPMENU */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
                      animateStyle |= (AW_VER_POSITIVE | AW_HOR_POSITIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
        } else if (windowType == windowTYPES[COMBOBOX_POPUP]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
            SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &animateflag, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
            if (animateflag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
                 animateStyle = AW_SLIDE | AW_VER_POSITIVE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
        if (animateStyle != 0) {
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1275
            BOOL result = ::AnimateWindow(hWnd, (DWORD)200, animateStyle);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1276
            if (!result) {
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1277
                // TODO: log message
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1278
            } else {
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1279
                // WM_PAINT is not automatically sent when invoking AnimateWindow,
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1280
                // so force an expose event
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1281
                RECT rect;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1282
                ::GetWindowRect(hWnd,&rect);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1283
                ::ScreenToClient(hWnd, (LPPOINT)&rect);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1284
                ::InvalidateRect(hWnd, &rect, TRUE);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1285
                ::UpdateWindow(hWnd);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1286
                done = TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
    if (!done) {
2646
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2640
diff changeset
  1291
        // transient windows shouldn't change the owner window's position in the z-order
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2640
diff changeset
  1292
        if (IsRetainingHierarchyZOrder()){
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2640
diff changeset
  1293
            UINT flags = SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOOWNERZORDER;
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2640
diff changeset
  1294
            if (nCmdShow == SW_SHOWNA) {
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2640
diff changeset
  1295
                flags |= SWP_NOACTIVATE;
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2640
diff changeset
  1296
            }
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2640
diff changeset
  1297
            ::SetWindowPos(GetHWnd(), HWND_TOPMOST, 0, 0, 0, 0, flags);
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2640
diff changeset
  1298
        } else {
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2640
diff changeset
  1299
            ::ShowWindow(GetHWnd(), nCmdShow);
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2640
diff changeset
  1300
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
 * Get and return the insets for this window (container, really).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
 * Calculate & cache them while we're at it, for use by AwtGraphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
BOOL AwtWindow::UpdateInsets(jobject insets)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
    DASSERT(GetPeer(env) != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
    if (env->EnsureLocalCapacity(2) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
    // fix 4167248 : don't update insets when frame is iconified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
    // to avoid bizarre window/client rectangles
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
    if (::IsIconic(GetHWnd())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
     * Code to calculate insets. Stores results in frame's data
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
     * members, and in the peer's Inset object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
    RECT outside;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
    RECT inside;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
    int extraBottomInsets = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
    ::GetClientRect(GetHWnd(), &inside);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
    ::GetWindowRect(GetHWnd(), &outside);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
    /* Update our inset member */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
    if (outside.right - outside.left > 0 && outside.bottom - outside.top > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
        ::MapWindowPoints(GetHWnd(), 0, (LPPOINT)&inside, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
        m_insets.top = inside.top - outside.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
        m_insets.bottom = outside.bottom - inside.bottom + extraBottomInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
        m_insets.left = inside.left - outside.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
        m_insets.right = outside.right - inside.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
        m_insets.top = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
    if (m_insets.left < 0 || m_insets.top < 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
        m_insets.right < 0 || m_insets.bottom < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
        /* This window hasn't been sized yet -- use system metrics. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
        jobject target = GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
        if (IsUndecorated() == FALSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
            /* Get outer frame sizes. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
            LONG style = GetStyle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
            if (style & WS_THICKFRAME) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
                m_insets.left = m_insets.right =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
                    ::GetSystemMetrics(SM_CXSIZEFRAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
                m_insets.top = m_insets.bottom =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
                    ::GetSystemMetrics(SM_CYSIZEFRAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
                m_insets.left = m_insets.right =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
                    ::GetSystemMetrics(SM_CXDLGFRAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
                m_insets.top = m_insets.bottom =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
                    ::GetSystemMetrics(SM_CYDLGFRAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
            /* Add in title. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
            m_insets.top += ::GetSystemMetrics(SM_CYCAPTION);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
            /* fix for 4418125: Undecorated frames are off by one */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
            /* undo the -1 set above */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
            /* Additional fix for 5059656 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
                /* Also, 5089312: Window insets should be 0. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
            ::memset(&m_insets, 0, sizeof(m_insets));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
        /* Add in menuBar, if any. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
        if (JNU_IsInstanceOfByName(env, target, "java/awt/Frame") > 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
            ((AwtFrame*)this)->GetMenuBar()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
            m_insets.top += ::GetSystemMetrics(SM_CYMENU);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
        m_insets.bottom += extraBottomInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
        env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
    BOOL insetsChanged = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
    jobject peer = GetPeer(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
    /* Get insets into our peer directly */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
    jobject peerInsets = (env)->GetObjectField(peer, AwtPanel::insets_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
    if (peerInsets != NULL) { // may have been called during creation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
        (env)->SetIntField(peerInsets, AwtInsets::topID, m_insets.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
        (env)->SetIntField(peerInsets, AwtInsets::bottomID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
                           m_insets.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
        (env)->SetIntField(peerInsets, AwtInsets::leftID, m_insets.left);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
        (env)->SetIntField(peerInsets, AwtInsets::rightID, m_insets.right);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
    /* Get insets into the Inset object (if any) that was passed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
    if (insets != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
        (env)->SetIntField(insets, AwtInsets::topID, m_insets.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
        (env)->SetIntField(insets, AwtInsets::bottomID, m_insets.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
        (env)->SetIntField(insets, AwtInsets::leftID, m_insets.left);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
        (env)->SetIntField(insets, AwtInsets::rightID, m_insets.right);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
    env->DeleteLocalRef(peerInsets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
    insetsChanged = !::EqualRect( &m_old_insets, &m_insets );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
    ::CopyRect( &m_old_insets, &m_insets );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 418
diff changeset
  1410
    if (insetsChanged) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
        // Since insets are changed we need to update the surfaceData object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
        // to reflect that change
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
        env->CallVoidMethod(peer, AwtComponent::replaceSurfaceDataLaterMID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
    return insetsChanged;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
 * Sometimes we need the hWnd that actually owns this Window's hWnd (if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
 * there is an owner).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
HWND AwtWindow::GetTopLevelHWnd()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
    return m_owningFrameDialog ? m_owningFrameDialog->GetHWnd() :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
                                 GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
 * Although this function sends ComponentEvents, it needs to be defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
 * here because only top-level windows need to have move and resize
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
 * events fired from native code.  All contained windows have these events
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
 * fired from common Java code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
void AwtWindow::SendComponentEvent(jint eventId)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
    static jclass classEvent = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
    if (classEvent == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
        if (env->PushLocalFrame(1) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
        classEvent = env->FindClass("java/awt/event/ComponentEvent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
        if (classEvent != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
            classEvent = (jclass)env->NewGlobalRef(classEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
        env->PopLocalFrame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
    static jmethodID eventInitMID = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
    if (eventInitMID == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
        eventInitMID = env->GetMethodID(classEvent, "<init>",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
                                        "(Ljava/awt/Component;I)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
        if (eventInitMID == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
    if (env->EnsureLocalCapacity(2) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
    jobject target = GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
    jobject event = env->NewObject(classEvent, eventInitMID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
                                   target, eventId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
    DASSERT(event != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
    SendEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
    env->DeleteLocalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
void AwtWindow::SendWindowEvent(jint id, HWND opposite,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
                                jint oldState, jint newState)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
    static jclass wClassEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
    if (wClassEvent == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
        if (env->PushLocalFrame(1) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
        wClassEvent = env->FindClass("java/awt/event/WindowEvent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
        if (wClassEvent != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
            wClassEvent = (jclass)env->NewGlobalRef(wClassEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
        env->PopLocalFrame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
        if (wClassEvent == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
    static jmethodID wEventInitMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
    if (wEventInitMID == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
        wEventInitMID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
            env->GetMethodID(wClassEvent, "<init>",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
                             "(Ljava/awt/Window;ILjava/awt/Window;II)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
        DASSERT(wEventInitMID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
        if (wEventInitMID == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
    static jclass sequencedEventCls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
    if (sequencedEventCls == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
        jclass sequencedEventClsLocal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
            = env->FindClass("java/awt/SequencedEvent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
        DASSERT(sequencedEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
        if (sequencedEventClsLocal == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
            /* exception already thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
        sequencedEventCls =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
            (jclass)env->NewGlobalRef(sequencedEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
        env->DeleteLocalRef(sequencedEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
    static jmethodID sequencedEventConst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
    if (sequencedEventConst == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
        sequencedEventConst =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
            env->GetMethodID(sequencedEventCls, "<init>",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
                             "(Ljava/awt/AWTEvent;)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
    if (env->EnsureLocalCapacity(3) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
    jobject target = GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
    jobject jOpposite = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
    if (opposite != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
        AwtComponent *awtOpposite = AwtComponent::GetComponent(opposite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
        if (awtOpposite != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
            jOpposite = awtOpposite->GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
    jobject event = env->NewObject(wClassEvent, wEventInitMID, target, id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
                                   jOpposite, oldState, newState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
    DASSERT(event != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
    if (jOpposite != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
        env->DeleteLocalRef(jOpposite); jOpposite = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
    env->DeleteLocalRef(target); target = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
    if (id == java_awt_event_WindowEvent_WINDOW_GAINED_FOCUS ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
        id == java_awt_event_WindowEvent_WINDOW_LOST_FOCUS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
        jobject sequencedEvent = env->NewObject(sequencedEventCls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
                                                sequencedEventConst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
                                                event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
        DASSERT(sequencedEvent != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
        env->DeleteLocalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
        event = sequencedEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
    SendEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
    env->DeleteLocalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1560
BOOL AwtWindow::AwtSetActiveWindow(BOOL isMouseEventCause, UINT hittest)
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1561
{
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1562
    // Fix for 6458497.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1563
    // Retreat if current foreground window is out of both our and embedder process.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1564
    // The exception is when activation is requested due to a mouse event.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1565
    if (!isMouseEventCause) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1566
        HWND fgWindow = ::GetForegroundWindow();
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1567
        if (NULL != fgWindow) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1568
            DWORD fgProcessID;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1569
            ::GetWindowThreadProcessId(fgWindow, &fgProcessID);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1570
            if (fgProcessID != ::GetCurrentProcessId()
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1571
                && !AwtToolkit::GetInstance().IsEmbedderProcessId(fgProcessID))
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1572
            {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1573
                return FALSE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1574
            }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1575
        }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1576
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1577
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1578
    HWND proxyContainerHWnd = GetProxyToplevelContainer();
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1579
    HWND proxyHWnd = GetProxyFocusOwner();
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1580
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1581
    if (proxyContainerHWnd == NULL || proxyHWnd == NULL) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1582
        return FALSE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1583
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1584
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1585
    // Activate the proxy toplevel container
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1586
    if (::GetActiveWindow() != proxyContainerHWnd) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1587
        sm_suppressFocusAndActivation = TRUE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1588
        ::BringWindowToTop(proxyContainerHWnd);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1589
        ::SetForegroundWindow(proxyContainerHWnd);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1590
        sm_suppressFocusAndActivation = FALSE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1591
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1592
        if (::GetActiveWindow() != proxyContainerHWnd) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1593
            return FALSE; // activation has been rejected
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1594
        }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1595
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1596
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1597
    // Focus the proxy itself
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1598
    if (::GetFocus() != proxyHWnd) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1599
        sm_suppressFocusAndActivation = TRUE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1600
        ::SetFocus(proxyHWnd);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1601
        sm_suppressFocusAndActivation = FALSE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1602
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1603
        if (::GetFocus() != proxyHWnd) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1604
            return FALSE; // focus has been rejected (that is unlikely)
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1605
        }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1606
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1607
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1608
    const HWND focusedWindow = AwtComponent::GetFocusedWindow();
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1609
    if (focusedWindow != GetHWnd()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1610
        if (focusedWindow != NULL) {
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1611
            // Deactivate the old focused window
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1612
            AwtWindow::SynthesizeWmActivate(FALSE, focusedWindow, GetHWnd());
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1613
        }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1614
        // Activate the new focused window.
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1615
        AwtWindow::SynthesizeWmActivate(TRUE, GetHWnd(), focusedWindow);
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1616
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1617
    return TRUE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1618
}
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1619
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
MsgRouting AwtWindow::WmActivate(UINT nState, BOOL fMinimized, HWND opposite)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
    jint type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
    if (nState != WA_INACTIVE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
        type = java_awt_event_WindowEvent_WINDOW_GAINED_FOCUS;
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1626
        AwtComponent::SetFocusedWindow(GetHWnd());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
    } else {
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1628
        // The owner is not necassarily getting WM_ACTIVATE(WA_INACTIVE).
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1629
        // So, initiate retaining the actualFocusedWindow.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1630
        AwtFrame *owner = GetOwningFrameOrDialog();
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1631
        if (owner) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1632
            owner->CheckRetainActualFocusedWindow(opposite);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1633
        }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1634
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
        if (m_grabbedWindow != NULL && !m_grabbedWindow->IsOneOfOwnersOf(this)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
            m_grabbedWindow->Ungrab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
        type = java_awt_event_WindowEvent_WINDOW_LOST_FOCUS;
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1639
        AwtComponent::SetFocusedWindow(NULL);
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1640
        sm_focusOwner = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
    SendWindowEvent(type, opposite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
MsgRouting AwtWindow::WmCreate()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
MsgRouting AwtWindow::WmClose()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
    SendWindowEvent(java_awt_event_WindowEvent_WINDOW_CLOSING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
    /* Rely on above notification to handle quitting as needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
MsgRouting AwtWindow::WmDestroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
    SendWindowEvent(java_awt_event_WindowEvent_WINDOW_CLOSED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
    return AwtComponent::WmDestroy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
MsgRouting AwtWindow::WmShowWindow(BOOL show, UINT status)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
     * Original fix for 4810575. Modified for 6386592.
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1670
     * If a simple window gets disposed we should synthesize
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
     * WM_ACTIVATE for its nearest owner. This is not performed by default because
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
     * the owner frame/dialog is natively active.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
    HWND hwndSelf = GetHWnd();
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1675
    HWND hwndOwner = ::GetParent(hwndSelf);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1677
    if (!show && IsSimpleWindow() && hwndSelf == AwtComponent::GetFocusedWindow() &&
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1678
        hwndOwner != NULL && ::IsWindowVisible(hwndOwner))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
    {
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1680
        AwtFrame *owner = (AwtFrame*)AwtComponent::GetComponent(hwndOwner);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1681
        if (owner != NULL) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1682
            owner->AwtSetActiveWindow();
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  1683
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
    //Fixed 4842599: REGRESSION: JPopupMenu not Hidden Properly After Iconified and Deiconified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
    if (show && (status == SW_PARENTOPENING)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
        if (!IsVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
            return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
    return AwtCanvas::WmShowWindow(show, status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
 * Override AwtComponent's move handling to first update the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
 * java AWT target's position fields directly, since Windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
 * and below can be resized from outside of java (by user)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
MsgRouting AwtWindow::WmMove(int x, int y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
    if ( ::IsIconic(GetHWnd()) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
    // fixes 4065534 (robi.khan@eng)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
    // if a window is iconified we don't want to update
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
    // it's target's position since minimized Win32 windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
    // move to -32000, -32000 for whatever reason
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
    // NOTE: See also AwtWindow::Reshape
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
    if (m_screenNum == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
    // Set initial value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
        m_screenNum = GetScreenImOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
        CheckIfOnNewScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
    /* Update the java AWT target component's fields directly */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
    if (env->EnsureLocalCapacity(1) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
        return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
    jobject peer = GetPeer(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
    jobject target = env->GetObjectField(peer, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
    RECT rect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
    ::GetWindowRect(GetHWnd(), &rect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
    (env)->SetIntField(target, AwtComponent::xID, rect.left);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
    (env)->SetIntField(target, AwtComponent::yID, rect.top);
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  1732
    (env)->SetIntField(peer, AwtWindow::sysXID, rect.left);
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  1733
    (env)->SetIntField(peer, AwtWindow::sysYID, rect.top);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
    SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_MOVED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
    return AwtComponent::WmMove(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
MsgRouting AwtWindow::WmGetMinMaxInfo(LPMINMAXINFO lpmmi)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
    MsgRouting r = AwtCanvas::WmGetMinMaxInfo(lpmmi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
    if ((m_minSize.x == 0) && (m_minSize.y == 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
        return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
    lpmmi->ptMinTrackSize.x = m_minSize.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
    lpmmi->ptMinTrackSize.y = m_minSize.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
MsgRouting AwtWindow::WmSizing()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
    if (!AwtToolkit::GetInstance().IsDynamicLayoutActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
    DTRACE_PRINTLN("AwtWindow::WmSizing  fullWindowDragEnabled");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
    SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_RESIZED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
    HWND thisHwnd = GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
    if (thisHwnd == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
    // Call WComponentPeer::dynamicallyLayoutContainer()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
    jobject peer = GetPeer(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
    JNU_CallMethodByName(env, NULL, peer, "dynamicallyLayoutContainer", "()V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
 * Override AwtComponent's size handling to first update the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
 * java AWT target's dimension fields directly, since Windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
 * and below can be resized from outside of java (by user)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
MsgRouting AwtWindow::WmSize(UINT type, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
{
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1782
    currentWmSizeState = type;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1783
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
    if (type == SIZE_MINIMIZED) {
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1785
        UpdateSecurityWarningVisibility();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
    if (env->EnsureLocalCapacity(1) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
    jobject target = GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
    // fix 4167248 : ensure the insets are up-to-date before using
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
    BOOL insetsChanged = UpdateInsets(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
    int newWidth = w + m_insets.left + m_insets.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
    int newHeight = h + m_insets.top + m_insets.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
    (env)->SetIntField(target, AwtComponent::widthID, newWidth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
    (env)->SetIntField(target, AwtComponent::heightID, newHeight);
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  1800
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  1801
    jobject peer = GetPeer(env);
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  1802
    (env)->SetIntField(peer, AwtWindow::sysWID, newWidth);
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  1803
    (env)->SetIntField(peer, AwtWindow::sysHID, newHeight);
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  1804
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
    if (!AwtWindow::IsResizing()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
        WindowResized();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
    return AwtComponent::WmSize(type, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
MsgRouting AwtWindow::WmPaint(HDC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
    PaintUpdateRgn(&m_insets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
MsgRouting AwtWindow::WmSettingChange(UINT wFlag, LPCTSTR pszSection)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
    if (wFlag == SPI_SETNONCLIENTMETRICS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
    // user changed window metrics in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
    // Control Panel->Display->Appearance
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
    // which may cause window insets to change
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
        UpdateInsets(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
    // [rray] fix for 4407329 - Changing Active Window Border width in display
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
    //  settings causes problems
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
        WindowResized();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
        Invalidate(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
        return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
MsgRouting AwtWindow::WmNcCalcSize(BOOL fCalcValidRects,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
                                   LPNCCALCSIZE_PARAMS lpncsp, LRESULT& retVal)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
    MsgRouting mrRetVal = mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
    if (fCalcValidRects == FALSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
    if (env->EnsureLocalCapacity(2) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
        return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
    }
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1849
    // WM_NCCALCSIZE is usually in response to a resize, but
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1850
    // also can be triggered by SetWindowPos(SWP_FRAMECHANGED),
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1851
    // which means the insets will have changed - rnk 4/7/1998
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1852
    retVal = static_cast<UINT>(DefWindowProc(
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1853
                WM_NCCALCSIZE, fCalcValidRects, reinterpret_cast<LPARAM>(lpncsp)));
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1854
    if (HasValidRect()) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1855
        UpdateInsets(NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
    }
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  1857
    mrRetVal = mrConsume;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
    return mrRetVal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
MsgRouting AwtWindow::WmNcHitTest(UINT x, UINT y, LRESULT& retVal)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
    // If this window is blocked by modal dialog, return HTCLIENT for any point of it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
    // That prevents it to be moved or resized using the mouse. Disabling these
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
    // actions to be launched from sysmenu is implemented by ignoring WM_SYSCOMMAND
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
    if (::IsWindow(GetModalBlocker(GetHWnd()))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
        retVal = HTCLIENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
        retVal = DefWindowProc(WM_NCHITTEST, 0, MAKELPARAM(x, y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
MsgRouting AwtWindow::WmGetIcon(WPARAM iconType, LRESULT& retValue)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
LRESULT AwtWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
    MsgRouting mr = mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
    LRESULT retValue = 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
    switch(message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
        case WM_GETICON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
            mr = WmGetIcon(wParam, retValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
        case WM_SYSCOMMAND:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
            //Fixed 6355340: Contents of frame are not layed out properly on maximize
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
            if ((wParam & 0xFFF0) == SC_SIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
                AwtWindow::sm_resizing = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
                mr = WmSysCommand(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
                if (mr != mrConsume) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
                    AwtWindow::DefWindowProc(message, wParam, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
                AwtWindow::sm_resizing = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
                if (!AwtToolkit::GetInstance().IsDynamicLayoutActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
                    WindowResized();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
                mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
    if (mr != mrConsume) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
        retValue = AwtCanvas::WindowProc(message, wParam, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
    return retValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
 * Fix for BugTraq ID 4041703: keyDown not being invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
 * This method overrides AwtCanvas::HandleEvent() since
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
 * an empty Window always receives the focus on the activation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
 * so we don't have to modify the behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
MsgRouting AwtWindow::HandleEvent(MSG *msg, BOOL synthetic)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
    return AwtComponent::HandleEvent(msg, synthetic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
void AwtWindow::WindowResized()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
    SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_RESIZED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
    // Need to replace surfaceData on resize to catch changes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
    // various component-related values, such as insets
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 418
diff changeset
  1927
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 418
diff changeset
  1928
    env->CallVoidMethod(m_peerObject, AwtComponent::replaceSurfaceDataLaterMID);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
BOOL CALLBACK InvalidateChildRect(HWND hWnd, LPARAM)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
    ::InvalidateRect(hWnd, NULL, TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
    return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
    CATCH_BAD_ALLOC_RET(FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
void AwtWindow::Invalidate(RECT* r)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
    ::InvalidateRect(GetHWnd(), NULL, TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
    ::EnumChildWindows(GetHWnd(), (WNDENUMPROC)InvalidateChildRect, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
BOOL AwtWindow::IsResizable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
    return m_isResizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
void AwtWindow::SetResizable(BOOL isResizable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
    m_isResizable = isResizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
    if (IsEmbeddedFrame()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
    LONG style = GetStyle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
    LONG resizeStyle = WS_MAXIMIZEBOX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
    if (IsUndecorated() == FALSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
        resizeStyle |= WS_THICKFRAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
    if (isResizable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
        style |= resizeStyle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
        style &= ~resizeStyle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
    SetStyle(style);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
    RedrawNonClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
// SetWindowPos flags to cause frame edge to be recalculated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
static const UINT SwpFrameChangeFlags =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
    SWP_FRAMECHANGED | /* causes WM_NCCALCSIZE to be called */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
    SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
    SWP_NOACTIVATE | SWP_NOCOPYBITS |
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
    SWP_NOREPOSITION | SWP_NOSENDCHANGING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
// Forces WM_NCCALCSIZE to be called to recalculate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
// window border (updates insets) without redrawing it
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
void AwtWindow::RecalcNonClient()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
    ::SetWindowPos(GetHWnd(), (HWND) NULL, 0, 0, 0, 0, SwpFrameChangeFlags|SWP_NOREDRAW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
// Forces WM_NCCALCSIZE to be called to recalculate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
// window border (updates insets) and redraws border to match
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
void AwtWindow::RedrawNonClient()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
    ::SetWindowPos(GetHWnd(), (HWND) NULL, 0, 0, 0, 0, SwpFrameChangeFlags|SWP_ASYNCWINDOWPOS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
int AwtWindow::GetScreenImOn() {
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  1999
    HMONITOR hmon;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
    int scrnNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  2002
    hmon = ::MonitorFromWindow(GetHWnd(), MONITOR_DEFAULTTOPRIMARY);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
    DASSERT(hmon != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  2005
    scrnNum = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(hmon);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
    DASSERT(scrnNum > -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
    return scrnNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
/* Check to see if we've been moved onto another screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
 * If so, update internal data, surfaces, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
void AwtWindow::CheckIfOnNewScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
    int curScrn = GetScreenImOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
    if (curScrn != m_screenNum) {  // we've been moved
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
        jclass peerCls = env->GetObjectClass(m_peerObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
        DASSERT(peerCls);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
        jmethodID draggedID = env->GetMethodID(peerCls, "draggedToNewScreen",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
                                               "()V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
        DASSERT(draggedID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
        env->CallVoidMethod(m_peerObject, draggedID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
        m_screenNum = curScrn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
        env->DeleteLocalRef(peerCls);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
BOOL AwtWindow::IsFocusableWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
     * For Window/Frame/Dialog to accept focus it should:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
     * - be focusable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
     * - be not blocked by any modal blocker.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2040
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
    BOOL focusable = m_isFocusableWindow && !::IsWindow(AwtWindow::GetModalBlocker(GetHWnd()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
    AwtFrame *owner = GetOwningFrameOrDialog(); // NULL for Frame and Dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
    if (owner != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
         * Also for Window (not Frame/Dialog) to accept focus:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
         * - its decorated parent should accept focus;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
        focusable = focusable && owner->IsFocusableWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
    return focusable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
void AwtWindow::SetModalBlocker(HWND window, HWND blocker) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
    if (!::IsWindow(window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
    }
122
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 2
diff changeset
  2058
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
    if (::IsWindow(blocker)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
        ::SetProp(window, ModalBlockerProp, reinterpret_cast<HANDLE>(blocker));
122
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 2
diff changeset
  2061
        ::EnableWindow(window, FALSE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
        ::RemoveProp(window, ModalBlockerProp);
122
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 2
diff changeset
  2064
         AwtComponent *comp = AwtComponent::GetComponent(window);
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 2
diff changeset
  2065
         // we don't expect to be called with non-java HWNDs
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 2
diff changeset
  2066
         DASSERT(comp && comp->IsTopLevel());
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 2
diff changeset
  2067
         // we should not unblock disabled toplevels
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 2
diff changeset
  2068
         ::EnableWindow(window, comp->isEnabled());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
void AwtWindow::SetAndActivateModalBlocker(HWND window, HWND blocker) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
    if (!::IsWindow(window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
    AwtWindow::SetModalBlocker(window, blocker);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
    if (::IsWindow(blocker)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
        // We must check for visibility. Otherwise invisible dialog will receive WM_ACTIVATE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
        if (::IsWindowVisible(blocker)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
            ::BringWindowToTop(blocker);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
            ::SetForegroundWindow(blocker);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2086
HWND AwtWindow::GetTopmostModalBlocker(HWND window)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2087
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2088
    HWND ret, blocker = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2089
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2090
    do {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2091
        ret = blocker;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2092
        blocker = AwtWindow::GetModalBlocker(window);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2093
        window = blocker;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2094
    } while (::IsWindow(blocker));
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2095
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2096
    return ret;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2097
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  2098
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
void AwtWindow::FlashWindowEx(HWND hWnd, UINT count, DWORD timeout, DWORD flags) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
    FLASHWINFO fi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
    fi.cbSize = sizeof(fi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
    fi.hwnd = hWnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
    fi.dwFlags = flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
    fi.uCount = count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
    fi.dwTimeout = timeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
    ::FlashWindowEx(&fi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2109
jboolean
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2110
AwtWindow::_RequestWindowFocus(void *param)
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2111
{
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2112
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2113
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2114
    RequestWindowFocusStruct *rfs = (RequestWindowFocusStruct *)param;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2115
    jobject self = rfs->component;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2116
    jboolean isMouseEventCause = rfs->isMouseEventCause;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2117
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2118
    jboolean result = JNI_FALSE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2119
    AwtWindow *window = NULL;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2120
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2121
    PDATA pData;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2122
    JNI_CHECK_NULL_GOTO(self, "peer", ret);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2123
    pData = JNI_GET_PDATA(self);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2124
    if (pData == NULL) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2125
        // do nothing just return false
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2126
        goto ret;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2127
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2128
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2129
    window = (AwtWindow *)pData;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2130
    if (::IsWindow(window->GetHWnd())) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2131
        result = (jboolean)window->SendMessage(WM_AWT_WINDOW_SETACTIVE, (WPARAM)isMouseEventCause, 0);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2132
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2133
ret:
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2134
    env->DeleteGlobalRef(self);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2135
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2136
    delete rfs;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2137
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2138
    return result;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2139
}
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2140
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
void AwtWindow::_ToFront(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
    AwtWindow *w = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
    w = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
    if (::IsWindow(w->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
        UINT flags = SWP_NOMOVE|SWP_NOSIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
        BOOL focusable = w->IsFocusableWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
        BOOL autoRequestFocus = w->IsAutoRequestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
        if (!focusable || !autoRequestFocus)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2159
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2160
            flags = flags|SWP_NOACTIVATE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2162
        ::SetWindowPos(w->GetHWnd(), HWND_TOP, 0, 0, 0, 0, flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
        if (focusable && autoRequestFocus)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2165
            ::SetForegroundWindow(w->GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2168
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2169
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2170
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2172
void AwtWindow::_ToBack(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2176
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2177
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
    AwtWindow *w = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
    w = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
    if (::IsWindow(w->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
        HWND hwnd = w->GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
//        if (AwtComponent::GetComponent(hwnd) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2187
//            // Window was disposed. Don't bother.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2188
//            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2189
//        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2191
        ::SetWindowPos(hwnd, HWND_BOTTOM, 0, 0 ,0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
            SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2193
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2194
        // If hwnd is the foreground window or if *any* of its owners are, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2195
        // we have to reset the foreground window. The reason is that when we send
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
        // hwnd to back, all of its owners are sent to back as well. If any one of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
        // them is the foreground window, then it's possible that we could end up
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
        // with a foreground window behind a window of another application.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
        HWND foregroundWindow = ::GetForegroundWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
        BOOL adjustForegroundWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
        HWND toTest = hwnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
        do
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2203
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
            adjustForegroundWindow = (toTest == foregroundWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2205
            if (adjustForegroundWindow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
            toTest = ::GetWindow(toTest, GW_OWNER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2211
        while (toTest != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2212
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2213
        if (adjustForegroundWindow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
            HWND foregroundSearch = hwnd, newForegroundWindow = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
                while (1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2218
                foregroundSearch = ::GetNextWindow(foregroundSearch, GW_HWNDPREV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2219
                if (foregroundSearch == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
                LONG style = static_cast<LONG>(::GetWindowLongPtr(foregroundSearch, GWL_STYLE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
                if ((style & WS_CHILD) || !(style & WS_VISIBLE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2229
                AwtComponent *c = AwtComponent::GetComponent(foregroundSearch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2230
                if ((c != NULL) && !::IsWindow(AwtWindow::GetModalBlocker(c->GetHWnd())))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2231
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
                    newForegroundWindow = foregroundSearch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2233
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2234
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2235
            if (newForegroundWindow != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2236
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
                ::SetWindowPos(newForegroundWindow, HWND_TOP, 0, 0, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
                    SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2239
                if (((AwtWindow*)AwtComponent::GetComponent(newForegroundWindow))->IsFocusableWindow())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2240
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2241
                    ::SetForegroundWindow(newForegroundWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2242
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2243
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2244
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2245
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2246
                // We *have* to set the active HWND to something new. We simply
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2247
                // cannot risk having an active Java HWND which is behind an HWND
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2248
                // of a native application. This really violates the Windows user
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2249
                // experience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2250
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2251
                // Windows won't allow us to set the foreground window to NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2252
                // so we use the desktop window instead. To the user, it appears
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2253
                // that there is no foreground window system-wide.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2254
                ::SetForegroundWindow(::GetDesktopWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2255
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2256
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2258
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2259
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2260
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2261
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2262
void AwtWindow::_SetAlwaysOnTop(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2263
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2264
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2265
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2266
    SetAlwaysOnTopStruct *sas = (SetAlwaysOnTopStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2267
    jobject self = sas->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2268
    jboolean value = sas->value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2269
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2270
    AwtWindow *w = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2271
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2272
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2273
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2274
    w = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2275
    if (::IsWindow(w->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2276
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2277
        w->SendMessage(WM_AWT_SETALWAYSONTOP, (WPARAM)value, (LPARAM)w);
4375
dc92e241ccea 6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents: 4367
diff changeset
  2278
        w->m_alwaysOnTop = (bool)value;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2280
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2281
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2283
    delete sas;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2284
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2285
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2286
void AwtWindow::_SetTitle(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2287
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2288
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2289
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2290
    SetTitleStruct *sts = (SetTitleStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2291
    jobject self = sts->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2292
    jstring title = sts->title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2293
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2294
    AwtWindow *w = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2295
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2296
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2297
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2298
    JNI_CHECK_NULL_GOTO(title, "null title", ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2299
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2300
    w = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2301
    if (::IsWindow(w->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2302
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2303
        int length = env->GetStringLength(title);
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  2304
        TCHAR *buffer = new TCHAR[length + 1];
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  2305
        env->GetStringRegion(title, 0, length, reinterpret_cast<jchar*>(buffer));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2306
        buffer[length] = L'\0';
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 887
diff changeset
  2307
        VERIFY(::SetWindowText(w->GetHWnd(), buffer));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2308
        delete[] buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2310
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2311
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2312
    if (title != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2313
        env->DeleteGlobalRef(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2315
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2316
    delete sts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2317
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2318
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2319
void AwtWindow::_SetResizable(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2320
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2321
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2322
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2323
    SetResizableStruct *srs = (SetResizableStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2324
    jobject self = srs->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2325
    jboolean resizable = srs->resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2326
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2327
    AwtWindow *w = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2329
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2330
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2331
    w = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2332
    if (::IsWindow(w->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2333
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2334
        DASSERT(!IsBadReadPtr(w, sizeof(AwtWindow)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2335
        w->SetResizable(resizable != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2337
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2338
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2339
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2340
    delete srs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2341
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2342
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2343
void AwtWindow::_UpdateInsets(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2344
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2345
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2346
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2347
    UpdateInsetsStruct *uis = (UpdateInsetsStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2348
    jobject self = uis->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2349
    jobject insets = uis->insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2350
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2351
    AwtWindow *w = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2352
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2353
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2354
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2355
    JNI_CHECK_NULL_GOTO(insets, "null insets", ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2356
    w = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2357
    if (::IsWindow(w->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2358
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2359
        w->UpdateInsets(insets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2361
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2362
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2363
    env->DeleteGlobalRef(insets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2364
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2365
    delete uis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2366
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2367
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2368
void AwtWindow::_ReshapeFrame(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2369
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2370
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2371
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2372
    ReshapeFrameStruct *rfs = (ReshapeFrameStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2373
    jobject self = rfs->frame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2374
    jint x = rfs->x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2375
    jint y = rfs->y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2376
    jint w = rfs->w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2377
    jint h = rfs->h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2378
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2379
    if (env->EnsureLocalCapacity(1) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2380
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2381
        env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2382
        delete rfs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2383
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2385
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2386
    AwtFrame *p = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2387
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2388
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2389
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2390
    p = (AwtFrame *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2391
    if (::IsWindow(p->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2392
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2393
        jobject target = env->GetObjectField(self, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2394
        if (target != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2395
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2396
            // enforce tresholds before sending the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2397
            // Fix for 4459064 : do not enforce thresholds for embedded frames
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2398
            if (!p->IsEmbeddedFrame())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2399
            {
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  2400
                jobject peer = p->GetPeer(env);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2401
                int minWidth = ::GetSystemMetrics(SM_CXMIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2402
                int minHeight = ::GetSystemMetrics(SM_CYMIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2403
                if (w < minWidth)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2404
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2405
                    env->SetIntField(target, AwtComponent::widthID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2406
                        w = minWidth);
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  2407
                    env->SetIntField(peer, AwtWindow::sysWID,
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  2408
                        w);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2409
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2410
                if (h < minHeight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2411
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2412
                    env->SetIntField(target, AwtComponent::heightID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2413
                        h = minHeight);
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  2414
                    env->SetIntField(peer, AwtWindow::sysHID,
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  2415
                        h);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2416
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2417
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2418
            env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2419
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2420
            RECT *r = new RECT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2421
            ::SetRect(r, x, y, x + w, y + h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2422
            p->SendMessage(WM_AWT_RESHAPE_COMPONENT, 0, (LPARAM)r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2423
            // r is deleted in message handler
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2424
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2425
            // After the input method window shown, the dimension & position may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2426
            // be valid until this method is called. So we need to adjust the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2427
            // IME candidate window position for the same reason as commented on
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2428
            // awt_Frame.cpp Show() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2429
            if (p->isInputMethodWindow() && ::IsWindowVisible(p->GetHWnd())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2430
              p->AdjustCandidateWindowPos();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2431
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2432
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2433
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2434
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2435
            JNU_ThrowNullPointerException(env, "null target");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2436
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2438
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2439
   env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2440
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2441
   delete rfs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2442
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2443
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2444
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2445
 * This is AwtWindow-specific function that is not intended for reusing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2446
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2447
HICON CreateIconFromRaster(JNIEnv* env, jintArray iconRaster, jint w, jint h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2448
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2449
    HBITMAP mask = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2450
    HBITMAP image = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2451
    HICON icon = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2452
    if (iconRaster != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2453
        int* iconRasterBuffer = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2454
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2455
            iconRasterBuffer = (int *)env->GetPrimitiveArrayCritical(iconRaster, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2456
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2457
            JNI_CHECK_NULL_GOTO(iconRasterBuffer, "iconRaster data", done);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2458
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2459
            mask = BitmapUtil::CreateTransparencyMaskFromARGB(w, h, iconRasterBuffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2460
            image = BitmapUtil::CreateV4BitmapFromARGB(w, h, iconRasterBuffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2461
        } catch (...) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2462
            if (iconRasterBuffer != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2463
                env->ReleasePrimitiveArrayCritical(iconRaster, iconRasterBuffer, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2464
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2465
            throw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2466
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2467
        if (iconRasterBuffer != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2468
            env->ReleasePrimitiveArrayCritical(iconRaster, iconRasterBuffer, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2469
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2470
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2471
    if (mask && image) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2472
        ICONINFO icnInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2473
        memset(&icnInfo, 0, sizeof(ICONINFO));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2474
        icnInfo.hbmMask = mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2475
        icnInfo.hbmColor = image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2476
        icnInfo.fIcon = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2477
        icon = ::CreateIconIndirect(&icnInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2479
    if (image) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2480
        destroy_BMP(image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2482
    if (mask) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2483
        destroy_BMP(mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2484
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2485
done:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2486
    return icon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2487
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2488
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2489
void AwtWindow::SetIconData(JNIEnv* env, jintArray iconRaster, jint w, jint h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2490
                             jintArray smallIconRaster, jint smw, jint smh)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2491
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2492
    HICON hOldIcon = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2493
    HICON hOldIconSm = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2494
    //Destroy previous icon if it isn't inherited
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2495
    if ((m_hIcon != NULL) && !m_iconInherited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2496
        hOldIcon = m_hIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2498
    m_hIcon = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2499
    if ((m_hIconSm != NULL) && !m_iconInherited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2500
        hOldIconSm = m_hIconSm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2501
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2502
    m_hIconSm = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2503
    m_hIcon = CreateIconFromRaster(env, iconRaster, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2504
    m_hIconSm = CreateIconFromRaster(env, smallIconRaster, smw, smh);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2505
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2506
    m_iconInherited = (m_hIcon == NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2507
    if (m_iconInherited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2508
        HWND hOwner = ::GetWindow(GetHWnd(), GW_OWNER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2509
        AwtWindow* owner = (AwtWindow *)AwtComponent::GetComponent(hOwner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2510
        if (owner != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2511
            m_hIcon = owner->GetHIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2512
            m_hIconSm = owner->GetHIconSm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2513
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2514
            m_iconInherited = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2515
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2516
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2517
    DoUpdateIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2518
    EnumThreadWindows(AwtToolkit::MainThread(), UpdateOwnedIconCallback, (LPARAM)this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2519
    if (hOldIcon != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2520
        DestroyIcon(hOldIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2521
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2522
    if (hOldIconSm != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2523
        DestroyIcon(hOldIconSm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2524
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2525
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2526
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2527
BOOL AwtWindow::UpdateOwnedIconCallback(HWND hWndOwned, LPARAM lParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2528
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2529
    HWND hWndOwner = ::GetWindow(hWndOwned, GW_OWNER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2530
    AwtWindow* owner = (AwtWindow*)lParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2531
    if (hWndOwner == owner->GetHWnd()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2532
        AwtComponent* comp = AwtComponent::GetComponent(hWndOwned);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2533
        if (comp != NULL && comp->IsTopLevel()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2534
            AwtWindow* owned = (AwtWindow *)comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2535
            if (owned->m_iconInherited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2536
                owned->m_hIcon = owner->m_hIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2537
                owned->m_hIconSm = owner->m_hIconSm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2538
                owned->DoUpdateIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2539
                EnumThreadWindows(AwtToolkit::MainThread(), UpdateOwnedIconCallback, (LPARAM)owned);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2540
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2541
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2542
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2543
    return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2544
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2545
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2546
void AwtWindow::DoUpdateIcon()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2547
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2548
    //Does nothing for windows, is overriden for frames and dialogs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2549
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2550
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2551
void AwtWindow::RedrawWindow()
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2552
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2553
    if (isOpaque()) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2554
        ::RedrawWindow(GetHWnd(), NULL, NULL,
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2555
                RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2556
    } else {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2557
        ::EnterCriticalSection(&contentBitmapCS);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2558
        if (hContentBitmap != NULL) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2559
            UpdateWindowImpl(contentWidth, contentHeight, hContentBitmap);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2560
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2561
        ::LeaveCriticalSection(&contentBitmapCS);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2562
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2563
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2564
3726
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2565
// Deletes the hContentBitmap if it is non-null
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2566
void AwtWindow::DeleteContentBitmap()
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2567
{
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2568
    ::EnterCriticalSection(&contentBitmapCS);
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2569
    if (hContentBitmap != NULL) {
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2570
        ::DeleteObject(hContentBitmap);
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2571
        hContentBitmap = NULL;
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2572
    }
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2573
    ::LeaveCriticalSection(&contentBitmapCS);
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2574
}
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2575
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2576
// The effects are enabled only upon showing the window.
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2577
// See 6780496 for details.
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2578
void AwtWindow::EnableTranslucency(BOOL enable)
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2579
{
3726
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2580
    if (enable) {
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2581
        SetTranslucency(getOpacity(), isOpaque(), FALSE, TRUE);
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2582
    } else {
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2583
        SetTranslucency(0xFF, TRUE, FALSE);
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2584
    }
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2585
}
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2586
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2587
/**
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2588
 * Sets the translucency effects.
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2589
 *
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2590
 * This method is used to:
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2591
 *
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2592
 * 1. Apply the translucency effects upon showing the window
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2593
 *    (setValues == FALSE, useDefaultForOldValues == TRUE);
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2594
 * 2. Turn off the effects upon hiding the window
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2595
 *    (setValues == FALSE, useDefaultForOldValues == FALSE);
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2596
 * 3. Set the effects per user's request
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2597
 *    (setValues == TRUE, useDefaultForOldValues == FALSE);
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2598
 *
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2599
 * In case #3 the effects may or may not be applied immediately depending on
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2600
 * the current visibility status of the window.
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2601
 *
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2602
 * The setValues argument indicates if we need to preserve the passed values
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2603
 * in local fields for further use.
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2604
 * The useDefaultForOldValues argument indicates whether we should consider
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2605
 * the window as if it has not any effects applied at the moment.
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2606
 */
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2607
void AwtWindow::SetTranslucency(BYTE opacity, BOOL opaque, BOOL setValues,
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2608
        BOOL useDefaultForOldValues)
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2609
{
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2610
    BYTE old_opacity = useDefaultForOldValues ? 0xFF : getOpacity();
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2611
    BOOL old_opaque = useDefaultForOldValues ? TRUE : isOpaque();
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2612
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2613
    if (opacity == old_opacity && opaque == old_opaque) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2614
        return;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2615
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2616
3726
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2617
    if (setValues) {
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2618
       m_opacity = opacity;
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2619
       m_opaque = opaque;
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2620
    }
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2621
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2622
    // If we're invisible and are storing the values, return
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2623
    // Otherwise, apply the effects immediately
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2624
    if (!IsVisible() && setValues) {
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2625
        return;
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2626
    }
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2627
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2628
    HWND hwnd = GetHWnd();
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2629
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2630
    if (opaque != old_opaque) {
3726
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2631
        DeleteContentBitmap();
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2632
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2633
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2634
    if (opaque && opacity == 0xff) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2635
        // Turn off all the effects
3443
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
  2636
        AwtWindow::SetLayered(hwnd, false);
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
  2637
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2638
        // Ask the window to repaint itself and all the children
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2639
        RedrawWindow();
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2640
    } else {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2641
        // We're going to enable some effects
3443
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
  2642
        if (!AwtWindow::IsLayered(hwnd)) {
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
  2643
            AwtWindow::SetLayered(hwnd, true);
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2644
        } else {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2645
            if ((opaque && opacity < 0xff) ^ (old_opaque && old_opacity < 0xff)) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2646
                // _One_ of the modes uses the SetLayeredWindowAttributes.
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2647
                // Need to reset the style in this case.
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2648
                // If both modes are simple (i.e. just changing the opacity level),
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2649
                // no need to reset the style.
3443
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
  2650
                AwtWindow::SetLayered(hwnd, false);
72f1e3846339 6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents: 2472
diff changeset
  2651
                AwtWindow::SetLayered(hwnd, true);
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2652
            }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2653
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2654
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2655
        if (opaque) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2656
            // Simple opacity mode
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2657
            ::SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), opacity, LWA_ALPHA);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2658
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2659
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2660
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2661
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2662
static HBITMAP CreateBitmapFromRaster(JNIEnv* env, jintArray raster, jint w, jint h)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2663
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2664
    HBITMAP image = NULL;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2665
    if (raster != NULL) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2666
        int* rasterBuffer = NULL;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2667
        try {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2668
            rasterBuffer = (int *)env->GetPrimitiveArrayCritical(raster, 0);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2669
            JNI_CHECK_NULL_GOTO(rasterBuffer, "raster data", done);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2670
            image = BitmapUtil::CreateBitmapFromARGBPre(w, h, w*4, rasterBuffer);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2671
        } catch (...) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2672
            if (rasterBuffer != NULL) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2673
                env->ReleasePrimitiveArrayCritical(raster, rasterBuffer, 0);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2674
            }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2675
            throw;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2676
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2677
        if (rasterBuffer != NULL) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2678
            env->ReleasePrimitiveArrayCritical(raster, rasterBuffer, 0);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2679
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2680
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2681
done:
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2682
    return image;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2683
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2684
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2685
void AwtWindow::UpdateWindowImpl(int width, int height, HBITMAP hBitmap)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2686
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2687
    if (isOpaque()) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2688
        return;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2689
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2690
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2691
    HWND hWnd = GetHWnd();
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2692
    HDC hdcDst = ::GetDC(NULL);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2693
    HDC hdcSrc = ::CreateCompatibleDC(NULL);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2694
    HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hdcSrc, hBitmap);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2695
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2696
    //XXX: this code doesn't paint the children (say, the java.awt.Button)!
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2697
    //So, if we ever want to support HWs here, we need to repaint them
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2698
    //in some other way...
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2699
    //::SendMessage(hWnd, WM_PRINT, (WPARAM)hdcSrc, /*PRF_CHECKVISIBLE |*/
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2700
    //      PRF_CHILDREN /*| PRF_CLIENT | PRF_NONCLIENT*/);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2701
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2702
    POINT ptSrc;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2703
    ptSrc.x = ptSrc.y = 0;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2704
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2705
    RECT rect;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2706
    POINT ptDst;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2707
    SIZE size;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2708
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2709
    ::GetWindowRect(hWnd, &rect);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2710
    ptDst.x = rect.left;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2711
    ptDst.y = rect.top;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2712
    size.cx = width;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2713
    size.cy = height;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2714
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2715
    BLENDFUNCTION bf;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2716
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2717
    bf.SourceConstantAlpha = getOpacity();
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2718
    bf.AlphaFormat = AC_SRC_ALPHA;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2719
    bf.BlendOp = AC_SRC_OVER;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2720
    bf.BlendFlags = 0;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2721
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2722
    ::UpdateLayeredWindow(hWnd, hdcDst, &ptDst, &size, hdcSrc, &ptSrc,
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2723
            RGB(0, 0, 0), &bf, ULW_ALPHA);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2724
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2725
    ::ReleaseDC(NULL, hdcDst);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2726
    ::SelectObject(hdcSrc, hOldBitmap);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2727
    ::DeleteDC(hdcSrc);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2728
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2729
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2730
void AwtWindow::UpdateWindow(JNIEnv* env, jintArray data, int width, int height,
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2731
                             HBITMAP hNewBitmap)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2732
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2733
    if (isOpaque()) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2734
        return;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2735
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2736
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2737
    HBITMAP hBitmap;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2738
    if (hNewBitmap == NULL) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2739
        if (data == NULL) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2740
            return;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2741
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2742
        hBitmap = CreateBitmapFromRaster(env, data, width, height);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2743
        if (hBitmap == NULL) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2744
            return;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2745
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2746
    } else {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2747
        hBitmap = hNewBitmap;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2748
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2749
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2750
    ::EnterCriticalSection(&contentBitmapCS);
3726
d97f7f568e97 6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents: 3456
diff changeset
  2751
    DeleteContentBitmap();
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2752
    hContentBitmap = hBitmap;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2753
    contentWidth = width;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2754
    contentHeight = height;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2755
    UpdateWindowImpl(width, height, hBitmap);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2756
    ::LeaveCriticalSection(&contentBitmapCS);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2757
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2758
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2759
/*
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2760
 * Fixed 6353381: it's improved fix for 4792958
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2761
 * which was backed-out to avoid 5059656
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2762
 */
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2763
BOOL AwtWindow::HasValidRect()
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2764
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2765
    RECT inside;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2766
    RECT outside;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2767
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2768
    if (::IsIconic(GetHWnd())) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2769
        return FALSE;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2770
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2771
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2772
    ::GetClientRect(GetHWnd(), &inside);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2773
    ::GetWindowRect(GetHWnd(), &outside);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2774
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2775
    BOOL isZeroClientArea = (inside.right == 0 && inside.bottom == 0);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2776
    BOOL isInvalidLocation = ((outside.left == -32000 && outside.top == -32000) || // Win2k && WinXP
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2777
                              (outside.left == 32000 && outside.top == 32000) || // Win95 && Win98
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2778
                              (outside.left == 3000 && outside.top == 3000)); // Win95 && Win98
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2779
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2780
    // the bounds correspond to iconic state
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2781
    if (isZeroClientArea && isInvalidLocation)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2782
    {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2783
        return FALSE;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2784
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2785
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2786
    return TRUE;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2787
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2788
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2789
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2790
void AwtWindow::_SetIconImagesData(void * param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2791
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2792
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2793
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2794
    SetIconImagesDataStruct* s = (SetIconImagesDataStruct*)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2795
    jobject self = s->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2796
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2797
    jintArray iconRaster = s->iconRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2798
    jintArray smallIconRaster = s->smallIconRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2799
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2800
    AwtWindow *window = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2801
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2802
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2803
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2804
    // ok to pass null raster: default AWT icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2805
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2806
    window = (AwtWindow*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2807
    if (::IsWindow(window->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2808
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2809
        window->SetIconData(env, iconRaster, s->w, s->h, smallIconRaster, s->smw, s->smh);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2810
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2811
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2812
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2813
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2814
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2815
    env->DeleteGlobalRef(iconRaster);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2816
    env->DeleteGlobalRef(smallIconRaster);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2817
    delete s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2818
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2819
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2820
void AwtWindow::_SetMinSize(void* param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2821
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2822
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2823
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2824
    SizeStruct *ss = (SizeStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2825
    jobject self = ss->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2826
    jint w = ss->w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2827
    jint h = ss->h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2828
    //Perform size setting
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2829
    AwtWindow *window = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2830
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2831
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2832
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2833
    window = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2834
    window->m_minSize.x = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2835
    window->m_minSize.y = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2836
  ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2837
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2838
    delete ss;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2839
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2840
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2841
jint AwtWindow::_GetScreenImOn(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2842
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2843
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2844
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2845
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2846
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2847
    // It's entirely possible that our native resources have been destroyed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2848
    // before our java peer - if we're dispose()d, for instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2849
    // Alert caller w/ IllegalComponentStateException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2850
    if (self == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2851
        JNU_ThrowByName(env, "java/awt/IllegalComponentStateException",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2852
                        "Peer null in JNI");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2853
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2854
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2855
    PDATA pData = JNI_GET_PDATA(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2856
    if (pData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2857
        JNU_ThrowByName(env, "java/awt/IllegalComponentStateException",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2858
                        "Native resources unavailable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2859
        env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2860
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2861
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2862
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2863
    jint result = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2864
    AwtWindow *w = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2865
    if (::IsWindow(w->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2866
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2867
        result = (jint)w->GetScreenImOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2868
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2869
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2870
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2871
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2872
    return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2873
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2874
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2875
void AwtWindow::_SetFocusableWindow(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2876
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2877
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2878
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2879
    SetFocusableWindowStruct *sfws = (SetFocusableWindowStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2880
    jobject self = sfws->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2881
    jboolean isFocusableWindow = sfws->isFocusableWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2882
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2883
    AwtWindow *window = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2884
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2885
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2886
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2887
    window = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2888
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2889
    window->m_isFocusableWindow = isFocusableWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2890
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2891
    // A simple window is permanently set to WS_EX_NOACTIVATE
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2892
    if (!window->IsSimpleWindow()) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2893
        if (!window->m_isFocusableWindow) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2894
            LONG isPopup = window->GetStyle() & WS_POPUP;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2895
            window->SetStyleEx(window->GetStyleEx() | (isPopup ? 0 : WS_EX_APPWINDOW) | WS_EX_NOACTIVATE);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2896
        } else {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2897
            window->SetStyleEx(window->GetStyleEx() & ~WS_EX_APPWINDOW & ~WS_EX_NOACTIVATE);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  2898
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2899
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2900
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2901
  ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2902
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2903
    delete sfws;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2904
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2905
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2906
void AwtWindow::_ModalDisable(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2907
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2908
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2909
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2910
    ModalDisableStruct *mds = (ModalDisableStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2911
    jobject self = mds->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2912
    HWND blockerHWnd = (HWND)mds->blockerHWnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2913
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2914
    AwtWindow *window = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2915
    HWND windowHWnd = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2916
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2917
    JNI_CHECK_NULL_GOTO(self, "peer", ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2918
    PDATA pData = JNI_GET_PDATA(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2919
    if (pData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2920
        env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2921
        delete mds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2922
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2923
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2924
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2925
    window = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2926
    windowHWnd = window->GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2927
    if (::IsWindow(windowHWnd)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2928
        AwtWindow::SetAndActivateModalBlocker(windowHWnd, blockerHWnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2929
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2930
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2931
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2932
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2933
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2934
    delete mds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2935
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2936
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2937
void AwtWindow::_ModalEnable(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2938
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2939
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2940
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2941
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2942
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2943
    AwtWindow *window = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2944
    HWND windowHWnd = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2945
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2946
    JNI_CHECK_NULL_GOTO(self, "peer", ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2947
    PDATA pData = JNI_GET_PDATA(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2948
    if (pData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2949
        env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2950
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2951
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2952
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2953
    window = (AwtWindow *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2954
    windowHWnd = window->GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2955
    if (::IsWindow(windowHWnd)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2956
        AwtWindow::SetModalBlocker(windowHWnd, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2957
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2958
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2959
  ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2960
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2961
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2962
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2963
void AwtWindow::_SetOpacity(void* param)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2964
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2965
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2966
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2967
    OpacityStruct *os = (OpacityStruct *)param;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2968
    jobject self = os->window;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2969
    BYTE iOpacity = (BYTE)os->iOpacity;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2970
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2971
    PDATA pData;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2972
    JNI_CHECK_PEER_GOTO(self, ret);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2973
    AwtWindow *window = (AwtWindow *)pData;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2974
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2975
    window->SetTranslucency(iOpacity, window->isOpaque());
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2976
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2977
  ret:
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2978
    env->DeleteGlobalRef(self);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2979
    delete os;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2980
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2981
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2982
void AwtWindow::_SetOpaque(void* param)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2983
{
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2984
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2985
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2986
    OpaqueStruct *os = (OpaqueStruct *)param;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2987
    jobject self = os->window;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2988
    BOOL isOpaque = (BOOL)os->isOpaque;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2989
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2990
    PDATA pData;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2991
    JNI_CHECK_PEER_GOTO(self, ret);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2992
    AwtWindow *window = (AwtWindow *)pData;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2993
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2994
    window->SetTranslucency(window->getOpacity(), isOpaque);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2995
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2996
  ret:
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2997
    env->DeleteGlobalRef(self);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2998
    delete os;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  2999
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3000
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3001
void AwtWindow::_UpdateWindow(void* param)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3002
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3003
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3004
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3005
    UpdateWindowStruct *uws = (UpdateWindowStruct *)param;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3006
    jobject self = uws->window;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3007
    jintArray data = uws->data;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3008
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3009
    PDATA pData;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3010
    JNI_CHECK_PEER_GOTO(self, ret);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3011
    AwtWindow *window = (AwtWindow *)pData;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3012
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3013
    window->UpdateWindow(env, data, (int)uws->width, (int)uws->height,
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3014
                         uws->hBitmap);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3015
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3016
  ret:
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3017
    env->DeleteGlobalRef(self);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3018
    if (data != NULL) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3019
        env->DeleteGlobalRef(data);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3020
    }
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3021
    delete uws;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3022
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3023
4256
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3024
void AwtWindow::_SetFullScreenExclusiveModeState(void *param)
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3025
{
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3026
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3027
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3028
    SetFullScreenExclusiveModeStateStruct * data =
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3029
        (SetFullScreenExclusiveModeStateStruct*)param;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3030
    jobject self = data->window;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3031
    jboolean state = data->isFSEMState;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3032
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3033
    PDATA pData;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3034
    JNI_CHECK_PEER_GOTO(self, ret);
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3035
    AwtWindow *window = (AwtWindow *)pData;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3036
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3037
    window->setFullScreenExclusiveModeState(state != 0);
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3038
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3039
  ret:
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3040
    env->DeleteGlobalRef(self);
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3041
    delete data;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3042
}
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3043
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3044
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3045
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3046
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3047
 * Class:     java_awt_Window
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3048
 * Method:    initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3049
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3050
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3051
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3052
Java_java_awt_Window_initIDs(JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3053
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3054
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3056
    AwtWindow::warningStringID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3057
        env->GetFieldID(cls, "warningString", "Ljava/lang/String;");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3058
    AwtWindow::locationByPlatformID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3059
        env->GetFieldID(cls, "locationByPlatform", "Z");
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3060
    AwtWindow::securityWarningWidthID =
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3061
        env->GetFieldID(cls, "securityWarningWidth", "I");
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3062
    AwtWindow::securityWarningHeightID =
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3063
        env->GetFieldID(cls, "securityWarningHeight", "I");
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3064
    AwtWindow::getWarningStringMID =
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3065
        env->GetMethodID(cls, "getWarningString", "()Ljava/lang/String;");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3066
    AwtWindow::autoRequestFocusID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3067
        env->GetFieldID(cls, "autoRequestFocus", "Z");
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3068
    AwtWindow::calculateSecurityWarningPositionMID =
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3069
        env->GetMethodID(cls, "calculateSecurityWarningPosition", "(DDDD)Ljava/awt/geom/Point2D;");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3070
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  3071
    jclass windowTypeClass = env->FindClass("java/awt/Window$Type");
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  3072
    AwtWindow::windowTypeNameMID =
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  3073
        env->GetMethodID(windowTypeClass, "name", "()Ljava/lang/String;");
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  3074
    env->DeleteLocalRef(windowTypeClass);
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  3075
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3076
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3077
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3078
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3079
} /* extern "C" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3080
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3082
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3083
 * WindowPeer native methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3084
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3085
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3086
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3087
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3088
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3089
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3090
 * Method:    initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3091
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3092
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3093
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3094
Java_sun_awt_windows_WWindowPeer_initIDs(JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3095
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3096
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3097
129
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  3098
    AwtWindow::sysXID = env->GetFieldID(cls, "sysX", "I");
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  3099
    AwtWindow::sysYID = env->GetFieldID(cls, "sysY", "I");
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  3100
    AwtWindow::sysWID = env->GetFieldID(cls, "sysW", "I");
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  3101
    AwtWindow::sysHID = env->GetFieldID(cls, "sysH", "I");
f995b9c9c5fa 6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents: 122
diff changeset
  3102
4366
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  3103
    AwtWindow::windowTypeID = env->GetFieldID(cls, "windowType",
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  3104
            "Ljava/awt/Window$Type;");
4446f3b8a9b4 6402325: Swing toolbars vs native toolbars on Windows
anthony
parents: 4256
diff changeset
  3105
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3106
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3107
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3108
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3109
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3110
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3111
 * Method:    toFront
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3112
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3113
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3114
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3115
Java_sun_awt_windows_WWindowPeer__1toFront(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3116
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3117
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3118
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3119
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_ToFront,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3120
        env->NewGlobalRef(self));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3121
    // global ref is deleted in _ToFront()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3123
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3124
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3125
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3126
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3127
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3128
 * Method:    toBack
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3129
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3130
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3131
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3132
Java_sun_awt_windows_WWindowPeer_toBack(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3133
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3134
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3135
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3136
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_ToBack,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3137
        env->NewGlobalRef(self));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3138
    // global ref is deleted in _ToBack()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3139
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3140
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3141
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3142
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3143
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3144
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3145
 * Method:    setAlwaysOnTop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3146
 * Signature: (Z)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3147
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3148
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3149
Java_sun_awt_windows_WWindowPeer_setAlwaysOnTopNative(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3150
                                                jboolean value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3151
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3152
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3153
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3154
    SetAlwaysOnTopStruct *sas = new SetAlwaysOnTopStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3155
    sas->window = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3156
    sas->value = value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3157
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3158
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetAlwaysOnTop, sas);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3159
    // global ref and sas are deleted in _SetAlwaysOnTop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3160
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3161
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3162
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3163
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3164
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3165
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3166
 * Method:    _setTitle
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3167
 * Signature: (Ljava/lang/String;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3168
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3169
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3170
Java_sun_awt_windows_WWindowPeer__1setTitle(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3171
                                            jstring title)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3172
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3173
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3174
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3175
    SetTitleStruct *sts = new SetTitleStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3176
    sts->window = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3177
    sts->title = (jstring)env->NewGlobalRef(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3178
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3179
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetTitle, sts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3180
    /// global refs and sts are deleted in _SetTitle()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3181
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3182
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3183
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3184
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3185
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3186
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3187
 * Method:    _setResizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3188
 * Signature: (Z)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3189
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3190
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3191
Java_sun_awt_windows_WWindowPeer__1setResizable(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3192
                                                jboolean resizable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3193
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3194
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3195
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3196
    SetResizableStruct *srs = new SetResizableStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3197
    srs->window = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3198
    srs->resizable = resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3199
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3200
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetResizable, srs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3201
    // global ref and srs are deleted in _SetResizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3202
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3203
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3204
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3205
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3206
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3207
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3208
 * Method:    create
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3209
 * Signature: (Lsun/awt/windows/WComponentPeer;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3210
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3211
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3212
Java_sun_awt_windows_WWindowPeer_createAwtWindow(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3213
                                                 jobject parent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3214
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3215
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3217
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3218
//    JNI_CHECK_PEER_RETURN(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3219
    AwtToolkit::CreateComponent(self, parent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3220
                                (AwtToolkit::ComponentFactory)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3221
                                AwtWindow::Create);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3222
    JNI_CHECK_PEER_CREATION_RETURN(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3223
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3224
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3225
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3226
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3227
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3228
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3229
 * Method:    updateInsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3230
 * Signature: (Ljava/awt/Insets;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3231
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3232
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3233
Java_sun_awt_windows_WWindowPeer_updateInsets(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3234
                                              jobject insets)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3235
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3236
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3237
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3238
    UpdateInsetsStruct *uis = new UpdateInsetsStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3239
    uis->window = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3240
    uis->insets = env->NewGlobalRef(insets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3241
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3242
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_UpdateInsets, uis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3243
    // global refs and uis are deleted in _UpdateInsets()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3244
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3245
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3246
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3247
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3248
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3249
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3250
 * Method:    reshapeFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3251
 * Signature: (IIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3252
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3253
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3254
Java_sun_awt_windows_WWindowPeer_reshapeFrame(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3255
                                        jint x, jint y, jint w, jint h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3256
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3257
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3258
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3259
    ReshapeFrameStruct *rfs = new ReshapeFrameStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3260
    rfs->frame = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3261
    rfs->x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3262
    rfs->y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3263
    rfs->w = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3264
    rfs->h = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3265
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3266
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_ReshapeFrame, rfs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3267
    // global ref and rfs are deleted in _ReshapeFrame()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3268
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3269
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3270
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3271
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3272
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3273
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3274
 * Method:    getSysMinWidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3275
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3276
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3277
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3278
Java_sun_awt_windows_WWindowPeer_getSysMinWidth(JNIEnv *env, jclass self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3279
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3280
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3281
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3282
    return ::GetSystemMetrics(SM_CXMIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3283
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3284
    CATCH_BAD_ALLOC_RET(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3285
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3286
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3287
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3288
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3289
 * Method:    getSysMinHeight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3290
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3291
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3292
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3293
Java_sun_awt_windows_WWindowPeer_getSysMinHeight(JNIEnv *env, jclass self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3294
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3295
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3296
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3297
    return ::GetSystemMetrics(SM_CYMIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3298
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3299
    CATCH_BAD_ALLOC_RET(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3300
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3301
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3302
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3303
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3304
 * Method:    getSysIconHeight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3305
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3306
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3307
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3308
Java_sun_awt_windows_WWindowPeer_getSysIconHeight(JNIEnv *env, jclass self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3309
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3310
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3311
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3312
    return ::GetSystemMetrics(SM_CYICON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3313
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3314
    CATCH_BAD_ALLOC_RET(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3315
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3316
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3317
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3318
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3319
 * Method:    getSysIconWidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3320
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3321
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3322
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3323
Java_sun_awt_windows_WWindowPeer_getSysIconWidth(JNIEnv *env, jclass self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3324
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3325
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3326
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3327
    return ::GetSystemMetrics(SM_CXICON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3329
    CATCH_BAD_ALLOC_RET(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3330
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3331
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3332
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3333
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3334
 * Method:    getSysSmIconHeight
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3335
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3336
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3337
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3338
Java_sun_awt_windows_WWindowPeer_getSysSmIconHeight(JNIEnv *env, jclass self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3339
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3340
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3341
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3342
    return ::GetSystemMetrics(SM_CYSMICON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3343
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3344
    CATCH_BAD_ALLOC_RET(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3345
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3346
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3347
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3348
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3349
 * Method:    getSysSmIconWidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3350
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3351
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3352
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3353
Java_sun_awt_windows_WWindowPeer_getSysSmIconWidth(JNIEnv *env, jclass self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3354
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3355
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3356
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3357
    return ::GetSystemMetrics(SM_CXSMICON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3358
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3359
    CATCH_BAD_ALLOC_RET(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3360
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3361
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3362
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3363
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3364
 * Method:    setIconImagesData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3365
 * Signature: ([I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3366
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3367
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3368
Java_sun_awt_windows_WWindowPeer_setIconImagesData(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3369
    jintArray iconRaster, jint w, jint h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3370
    jintArray smallIconRaster, jint smw, jint smh)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3371
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3372
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3373
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3374
    SetIconImagesDataStruct *sims = new SetIconImagesDataStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3375
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3376
    sims->window = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3377
    sims->iconRaster = (jintArray)env->NewGlobalRef(iconRaster);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3378
    sims->w = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3379
    sims->h = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3380
    sims->smallIconRaster = (jintArray)env->NewGlobalRef(smallIconRaster);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3381
    sims->smw = smw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3382
    sims->smh = smh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3383
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3384
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetIconImagesData, sims);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3385
    // global refs and sims are deleted in _SetIconImagesData()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3386
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3387
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3388
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3389
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3390
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3391
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3392
 * Method:    setMinSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3393
 * Signature: (Lsun/awt/windows/WWindowPeer;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3394
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3395
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3396
Java_sun_awt_windows_WWindowPeer_setMinSize(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3397
                                              jint w, jint h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3398
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3399
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3400
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3401
    SizeStruct *ss = new SizeStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3402
    ss->window = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3403
    ss->w = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3404
    ss->h = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3405
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3406
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetMinSize, ss);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3407
    // global refs and mds are deleted in _SetMinSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3408
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3409
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3410
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3411
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3412
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3413
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3414
 * Method:    getScreenImOn
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3415
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3416
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3417
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3418
Java_sun_awt_windows_WWindowPeer_getScreenImOn(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3419
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3420
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3421
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3422
    return static_cast<jint>(reinterpret_cast<INT_PTR>(AwtToolkit::GetInstance().SyncCall(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3423
        (void *(*)(void *))AwtWindow::_GetScreenImOn,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3424
        env->NewGlobalRef(self))));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3425
    // global ref is deleted in _GetScreenImOn()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3426
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3427
    CATCH_BAD_ALLOC_RET(-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3428
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3429
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3430
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3431
 * Class:     sun_awt_windows_WWindowPeer
4256
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3432
 * Method:    setFullScreenExclusiveModeState
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3433
 * Signature: (Z)V
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3434
 */
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3435
JNIEXPORT void JNICALL
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3436
Java_sun_awt_windows_WWindowPeer_setFullScreenExclusiveModeState(JNIEnv *env,
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3437
        jobject self, jboolean state)
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3438
{
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3439
    TRY;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3440
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3441
    SetFullScreenExclusiveModeStateStruct *data =
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3442
        new SetFullScreenExclusiveModeStateStruct;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3443
    data->window = env->NewGlobalRef(self);
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3444
    data->isFSEMState = state;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3445
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3446
    AwtToolkit::GetInstance().SyncCall(
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3447
            AwtWindow::_SetFullScreenExclusiveModeState, data);
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3448
    // global ref and data are deleted in the invoked method
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3449
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3450
    CATCH_BAD_ALLOC;
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3451
}
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3452
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3453
/*
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 3726
diff changeset
  3454
 * Class:     sun_awt_windows_WWindowPeer
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3455
 * Method:    modalDisable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3456
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3457
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3458
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3459
Java_sun_awt_windows_WWindowPeer_modalDisable(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3460
                                              jobject blocker, jlong blockerHWnd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3461
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3462
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3463
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3464
    ModalDisableStruct *mds = new ModalDisableStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3465
    mds->window = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3466
    mds->blockerHWnd = blockerHWnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3467
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3468
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_ModalDisable, mds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3469
    // global ref and mds are deleted in _ModalDisable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3470
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3471
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3472
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3473
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3474
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3475
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3476
 * Method:    modalEnable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3477
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3478
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3479
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3480
Java_sun_awt_windows_WWindowPeer_modalEnable(JNIEnv *env, jobject self, jobject blocker)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3481
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3482
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3483
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3484
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_ModalEnable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3485
        env->NewGlobalRef(self));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3486
    // global ref is deleted in _ModalEnable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3487
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3488
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3489
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3490
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3491
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3492
 * Class:     sun_awt_windows_WWindowPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3493
 * Method:    setFocusableWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3494
 * Signature: (Z)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3495
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3496
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3497
Java_sun_awt_windows_WWindowPeer_setFocusableWindow(JNIEnv *env, jobject self, jboolean isFocusableWindow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3498
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3499
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3500
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3501
    SetFocusableWindowStruct *sfws = new SetFocusableWindowStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3502
    sfws->window = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3503
    sfws->isFocusableWindow = isFocusableWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3504
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3505
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetFocusableWindow, sfws);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3506
    // global ref and sfws are deleted in _SetFocusableWindow()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3507
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3508
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3509
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3510
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3511
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3512
Java_sun_awt_windows_WWindowPeer_nativeGrab(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3513
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3514
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3515
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3516
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_Grab, env->NewGlobalRef(self));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3517
    // global ref is deleted in _Grab()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3518
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3519
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3520
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3521
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3522
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3523
Java_sun_awt_windows_WWindowPeer_nativeUngrab(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3524
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3525
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3526
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3527
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_Ungrab, env->NewGlobalRef(self));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3528
    // global ref is deleted in _Ungrab()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3529
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3530
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3531
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3532
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3533
/*
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3534
 * Class:     sun_awt_windows_WWindowPeer
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3535
 * Method:    setOpacity
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3536
 * Signature: (I)V
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3537
 */
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3538
JNIEXPORT void JNICALL
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3539
Java_sun_awt_windows_WWindowPeer_setOpacity(JNIEnv *env, jobject self,
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3540
                                              jint iOpacity)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3541
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3542
    TRY;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3543
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3544
    OpacityStruct *os = new OpacityStruct;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3545
    os->window = env->NewGlobalRef(self);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3546
    os->iOpacity = iOpacity;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3547
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3548
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetOpacity, os);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3549
    // global refs and mds are deleted in _SetMinSize
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3550
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3551
    CATCH_BAD_ALLOC;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3552
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3553
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3554
/*
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3555
 * Class:     sun_awt_windows_WWindowPeer
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3556
 * Method:    setOpaqueImpl
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3557
 * Signature: (Z)V
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3558
 */
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3559
JNIEXPORT void JNICALL
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3560
Java_sun_awt_windows_WWindowPeer_setOpaqueImpl(JNIEnv *env, jobject self,
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3561
                                              jboolean isOpaque)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3562
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3563
    TRY;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3564
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3565
    OpaqueStruct *os = new OpaqueStruct;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3566
    os->window = env->NewGlobalRef(self);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3567
    os->isOpaque = isOpaque;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3568
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3569
    AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetOpaque, os);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3570
    // global refs and mds are deleted in _SetMinSize
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3571
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3572
    CATCH_BAD_ALLOC;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3573
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3574
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3575
/*
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3576
 * Class:     sun_awt_windows_WWindowPeer
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3577
 * Method:    updateWindowImpl
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3578
 * Signature: ([III)V
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3579
 */
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3580
JNIEXPORT void JNICALL
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3581
Java_sun_awt_windows_WWindowPeer_updateWindowImpl(JNIEnv *env, jobject self,
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3582
                                                  jintArray data,
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3583
                                                  jint width, jint height)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3584
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3585
    TRY;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3586
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3587
    UpdateWindowStruct *uws = new UpdateWindowStruct;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3588
    uws->window = env->NewGlobalRef(self);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3589
    uws->data = (jintArray)env->NewGlobalRef(data);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3590
    uws->hBitmap = NULL;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3591
    uws->width = width;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3592
    uws->height = height;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3593
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3594
    AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_UpdateWindow, uws);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3595
    // global refs and mds are deleted in _UpdateWindow
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3596
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3597
    CATCH_BAD_ALLOC;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3598
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3599
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3600
/**
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3601
 * This method is called from the WGL pipeline when it needs to update
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3602
 * the layered window WindowPeer's C++ level object.
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3603
 */
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3604
void AwtWindow_UpdateWindow(JNIEnv *env, jobject peer,
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3605
                            jint width, jint height, HBITMAP hBitmap)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3606
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3607
    TRY;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3608
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3609
    UpdateWindowStruct *uws = new UpdateWindowStruct;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3610
    uws->window = env->NewGlobalRef(peer);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3611
    uws->data = NULL;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3612
    uws->hBitmap = hBitmap;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3613
    uws->width = width;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3614
    uws->height = height;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3615
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3616
    AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_UpdateWindow, uws);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3617
    // global refs and mds are deleted in _UpdateWindow
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3618
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3619
    CATCH_BAD_ALLOC;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3620
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1954
diff changeset
  3621
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3622
/*
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3623
 * Class:     sun_awt_windows_WComponentPeer
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3624
 * Method:    requestFocus
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3625
 * Signature: (Z)Z
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3626
 */
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3627
JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WWindowPeer_requestWindowFocus
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3628
    (JNIEnv *env, jobject self, jboolean isMouseEventCause)
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3629
{
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3630
    TRY;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3631
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3632
    jobject selfGlobalRef = env->NewGlobalRef(self);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3633
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3634
    RequestWindowFocusStruct *rfs = new RequestWindowFocusStruct;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3635
    rfs->component = selfGlobalRef;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3636
    rfs->isMouseEventCause = isMouseEventCause;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3637
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3638
    return (jboolean)AwtToolkit::GetInstance().SyncCall(
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3639
        (void*(*)(void*))AwtWindow::_RequestWindowFocus, rfs);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3640
    // global refs and rfs are deleted in _RequestWindowFocus
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3641
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3642
    CATCH_BAD_ALLOC_RET(JNI_FALSE);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3643
}
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
  3644
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3645
/*
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3646
 * Class:     sun_awt_windows_WWindowPeer
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3647
 * Method:    repositionSecurityWarning
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3648
 * Signature: ()V
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3649
 */
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3650
JNIEXPORT void JNICALL
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3651
Java_sun_awt_windows_WWindowPeer_repositionSecurityWarning(JNIEnv *env,
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3652
        jobject self)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3653
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3654
    TRY;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3655
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3656
    RepositionSecurityWarningStruct *rsws =
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3657
        new RepositionSecurityWarningStruct;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3658
    rsws->window = env->NewGlobalRef(self);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3659
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3660
    AwtToolkit::GetInstance().InvokeFunction(
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3661
            AwtWindow::_RepositionSecurityWarning, rsws);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3662
    // global refs and mds are deleted in _RepositionSecurityWarning
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3663
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3664
    CATCH_BAD_ALLOC;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3665
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2464
diff changeset
  3666
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3667
} /* extern "C" */