src/java.desktop/windows/native/libawt/windows/awt_Component.cpp
author dmarkov
Wed, 13 Jun 2018 12:54:41 +0100
changeset 50655 1427a66f7714
parent 50005 48637783b4f6
child 50837 86897f8a6598
permissions -rw-r--r--
8200353: Shift or Capslock not working in Textfield after accented keystrokes Reviewed-by: serb, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
45348
383dbc53e342 8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents: 44754
diff changeset
     2
 * Copyright (c) 1996, 2017, 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: 5138
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: 5138
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: 5138
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5138
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5138
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: 889
diff changeset
    26
#include "awt.h"
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
    27
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <windowsx.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <zmouse.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "jlong.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "awt_AWTEvent.h"
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
    33
#include "awt_BitmapUtil.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "awt_Component.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "awt_Cursor.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "awt_Dimension.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "awt_Frame.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "awt_InputEvent.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "awt_InputTextInfor.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "awt_Insets.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include "awt_KeyEvent.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#include "awt_MenuItem.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include "awt_MouseEvent.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include "awt_Palette.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#include "awt_Toolkit.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#include "awt_Window.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#include "awt_Win32GraphicsDevice.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#include "Hashtable.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#include "ComCtl32Util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#include <Region.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#include <jawt.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#include <java_awt_Toolkit.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#include <java_awt_FontMetrics.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#include <java_awt_Color.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#include <java_awt_Event.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#include <java_awt_event_KeyEvent.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#include <java_awt_Insets.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#include <sun_awt_windows_WPanelPeer.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#include <java_awt_event_InputEvent.h>
37572
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
    63
#include <java_awt_event_ActionEvent.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#include <java_awt_event_InputMethodEvent.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#include <sun_awt_windows_WInputMethod.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#include <java_awt_event_MouseEvent.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#include <java_awt_event_MouseWheelEvent.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
// Begin -- Win32 SDK include files
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#include <imm.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#include <ime.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
// End -- Win32 SDK include files
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#include <awt_DnDDT.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
LPCTSTR szAwtComponentClassName = TEXT("SunAwtComponent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
// register a message that no other window in the process (even in a plugin
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
// scenario) will be using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
const UINT AwtComponent::WmAwtIsComponent =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    ::RegisterWindowMessage(szAwtComponentClassName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
static HWND g_hwndDown = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
static DCList activeDCList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
static DCList passiveDCList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
extern void CheckFontSmoothingSettings(HWND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    // Remember the input language has changed by some user's action
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    // (Alt+Shift or through the language icon on the Taskbar) to control the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    // race condition between the toolkit thread and the AWT event thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    // This flag remains TRUE until the next WInputMethod.getNativeLocale() is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    // issued.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    BOOL g_bUserHasChangedInputLang = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
    97
BOOL AwtComponent::sm_suppressFocusAndActivation = FALSE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
    98
BOOL AwtComponent::sm_restoreFocusAndActivation = FALSE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
    99
HWND AwtComponent::sm_focusOwner = NULL;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   100
HWND AwtComponent::sm_focusedWindow = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
BOOL AwtComponent::sm_bMenuLoop = FALSE;
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   102
BOOL AwtComponent::sm_inSynthesizeFocus = FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
/************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
// Struct for _Reshape() and ReshapeNoCheck() methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
struct ReshapeStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    jobject component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    jint x, y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    jint w, h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
// Struct for _NativeHandleEvent() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
struct NativeHandleEventStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    jobject component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    jobject event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
// Struct for _SetForeground() and _SetBackground() methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
struct SetColorStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    jobject component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    jint rgb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
// Struct for _SetFont() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
struct SetFontStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    jobject component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    jobject font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
// Struct for _CreatePrintedPixels() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
struct CreatePrintedPixelsStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    jobject component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    int srcx, srcy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    int srcw, srch;
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
   131
    jint alpha;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
// Struct for _SetRectangularShape() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
struct SetRectangularShapeStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    jobject component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    jint x1, x2, y1, y2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    jobject region;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
};
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   139
// Struct for _GetInsets function
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   140
struct GetInsetsStruct {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   141
    jobject window;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   142
    RECT *insets;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   143
};
2462
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
   144
// Struct for _SetZOrder function
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
   145
struct SetZOrderStruct {
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
   146
    jobject component;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
   147
    jlong above;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
   148
};
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   149
// Struct for _SetFocus function
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   150
struct SetFocusStruct {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   151
    jobject component;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   152
    jboolean doSetFocus;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   153
};
47404
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   154
// Struct for _SetParent function
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   155
struct SetParentStruct {
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   156
    jobject component;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   157
    jobject parentComp;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   158
};
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
/************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
//////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
/*************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 * AwtComponent fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
jfieldID AwtComponent::peerID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
jfieldID AwtComponent::xID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
jfieldID AwtComponent::yID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
jfieldID AwtComponent::widthID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
jfieldID AwtComponent::heightID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
jfieldID AwtComponent::visibleID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
jfieldID AwtComponent::backgroundID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
jfieldID AwtComponent::foregroundID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
jfieldID AwtComponent::enabledID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
jfieldID AwtComponent::parentID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
jfieldID AwtComponent::graphicsConfigID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
jfieldID AwtComponent::peerGCID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
jfieldID AwtComponent::focusableID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
jfieldID AwtComponent::appContextID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
jfieldID AwtComponent::cursorID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
jfieldID AwtComponent::hwndID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
jmethodID AwtComponent::getFontMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
jmethodID AwtComponent::getToolkitMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
jmethodID AwtComponent::isEnabledMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
jmethodID AwtComponent::getLocationOnScreenMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
jmethodID AwtComponent::replaceSurfaceDataMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
jmethodID AwtComponent::replaceSurfaceDataLaterMID;
10689
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
   191
jmethodID AwtComponent::disposeLaterMID;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
HKL    AwtComponent::m_hkl = ::GetKeyboardLayout(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
LANGID AwtComponent::m_idLang = LOWORD(::GetKeyboardLayout(0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
UINT   AwtComponent::m_CodePage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                       = AwtComponent::LangToCodePage(m_idLang);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
   198
jint *AwtComponent::masks;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
   199
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
static BOOL bLeftShiftIsDown = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
static BOOL bRightShiftIsDown = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
static UINT lastShiftKeyPressed = 0; // init to safe value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
// Added by waleed to initialize the RTL Flags
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
BOOL AwtComponent::sm_rtl = PRIMARYLANGID(GetInputLanguage()) == LANG_ARABIC ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                            PRIMARYLANGID(GetInputLanguage()) == LANG_HEBREW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
BOOL AwtComponent::sm_rtlReadingOrder =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    PRIMARYLANGID(GetInputLanguage()) == LANG_ARABIC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   210
BOOL AwtComponent::sm_PrimaryDynamicTableBuilt = FALSE;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   211
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
HWND AwtComponent::sm_cursorOn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
BOOL AwtComponent::m_QueryNewPaletteCalled = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
CriticalSection windowMoveLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
BOOL windowMoveLockHeld = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
 * AwtComponent methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
AwtComponent::AwtComponent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
{
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
   224
    m_mouseButtonClickAllowed = 0;
47384
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
   225
    m_touchDownOccurred = FALSE;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
   226
    m_touchUpOccurred = FALSE;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
   227
    m_touchDownPoint.x = m_touchDownPoint.y = 0;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
   228
    m_touchUpPoint.x = m_touchUpPoint.y = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    m_callbacksEnabled = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    m_hwnd = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    m_colorForeground = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    m_colorBackground = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    m_backgroundColorSet = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    m_penForeground = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    m_brushBackground = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    m_DefWindowProc = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    m_nextControlID = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    m_childList = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    m_myControlID = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    m_hdwp = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    m_validationNestCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    m_dropTarget = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    m_InputMethod = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    m_useNativeCompWindow = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    m_PendingLeadByte = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    m_bitsCandType = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    windowMoveLockPosX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    windowMoveLockPosY = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    windowMoveLockPosCX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    windowMoveLockPosCY = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    m_hCursorCache = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    m_bSubclassed = FALSE;
10689
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
   259
    m_bPauseDestroy = FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    m_MessagesProcessing = 0;
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
   262
    m_wheelRotationAmountX = 0;
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
   263
    m_wheelRotationAmountY = 0;
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   264
    if (!sm_PrimaryDynamicTableBuilt) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   265
        // do it once.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   266
        AwtComponent::BuildPrimaryDynamicTable();
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   267
        sm_PrimaryDynamicTableBuilt = TRUE;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
   268
    }
39525
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
   269
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
   270
    deadKeyActive = FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
AwtComponent::~AwtComponent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    DASSERT(AwtToolkit::IsMainThread());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * All the messages for this component are processed, native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * resources are freed, and Java object is not connected to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * the native one anymore. So we can safely destroy component's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * handle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     */
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   283
    DestroyHWnd();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
void AwtComponent::Dispose()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
{
47404
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   288
    DASSERT(AwtToolkit::IsMainThread());
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   289
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   290
    // NOTE: in case the component/toplevel was focused, Java should
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 19178
diff changeset
   291
    // have already taken care of proper transferring it or clearing.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    if (m_hdwp != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    // end any deferred window positioning, regardless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    // of m_validationNestCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        ::EndDeferWindowPos(m_hdwp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    // Send final message to release all DCs associated with this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    SendMessage(WM_AWT_RELEASE_ALL_DCS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    /* Stop message filtering. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    UnsubclassHWND();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    /* Release global ref to input method */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    SetInputMethod(NULL, TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
47404
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   308
    if (m_childList != NULL) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        delete m_childList;
47404
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   310
        m_childList = NULL;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   311
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    DestroyDropTarget();
12175
e832f6ea56e5 7128738: dragged dialog freezes system on dispose
bagiras
parents: 10689
diff changeset
   314
    ReleaseDragCapture(0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    if (m_myControlID != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        AwtComponent* parent = GetParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        if (parent != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            parent->RemoveChild(m_myControlID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    ::RemoveProp(GetHWnd(), DrawingStateProp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /* Release any allocated resources. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    if (m_penForeground != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        m_penForeground->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        m_penForeground = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    if (m_brushBackground != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        m_brushBackground->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        m_brushBackground = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
47404
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   334
    /* Disconnect all links. */
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   335
    UnlinkObjects();
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
   336
10689
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
   337
    if (m_bPauseDestroy) {
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
   338
        // AwtComponent::WmNcDestroy could be released now
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
   339
        m_bPauseDestroy = FALSE;
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
   340
        m_hwnd = NULL;
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
   341
    }
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
   342
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    // The component instance is deleted using AwtObject::Dispose() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    AwtObject::Dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
/* store component pointer in window extra bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
void AwtComponent::SetComponentInHWND() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    DASSERT(::GetWindowLongPtr(GetHWnd(), GWLP_USERDATA) == NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    ::SetWindowLongPtr(GetHWnd(), GWLP_USERDATA, (LONG_PTR)this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
 * static function to get AwtComponent pointer from hWnd --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
 * you don't want to call this from inside a wndproc to avoid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
 * infinite recursion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
AwtComponent* AwtComponent::GetComponent(HWND hWnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    // Requests for Toolkit hwnd resolution happen pretty often. Check first.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    if (hWnd == AwtToolkit::GetInstance().GetHWnd()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    // check that it's an AWT component from the same toolkit as the caller
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    if (::IsWindow(hWnd) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        AwtToolkit::MainThread() == ::GetWindowThreadProcessId(hWnd, NULL))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        DASSERT(WmAwtIsComponent != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        if (::SendMessage(hWnd, WmAwtIsComponent, 0, 0L)) {
43205
df23cecb03ae 8162973: Better component components
serb
parents: 42736
diff changeset
   370
            return GetComponentImpl(hWnd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
 * static function to get AwtComponent pointer from hWnd--
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
 * different from GetComponent because caller knows the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
 * hwnd is an AWT component hwnd
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
AwtComponent* AwtComponent::GetComponentImpl(HWND hWnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    AwtComponent *component =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        (AwtComponent *)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
   384
    DASSERT(!component || !IsBadReadPtr(component, sizeof(AwtComponent)) );
10088
6f41dfc57ce6 7050935: closed/java/awt/Choice/WheelEventsConsumed/WheelEventsConsumed.html fails on win32
bagiras
parents: 9765
diff changeset
   385
    DASSERT(!component || component->GetHWnd() == hWnd );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    return component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
 * Single window proc for all the components. Delegates real work to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
 * the component's WindowProc() member function.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
LRESULT CALLBACK AwtComponent::WndProc(HWND hWnd, UINT message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                                       WPARAM wParam, LPARAM lParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    AwtComponent * self = AwtComponent::GetComponentImpl(hWnd);
4834
2571be1e8f1d 6660258: Java application stops Windows logout/shutdown (regression in 1.5.0_14)
dcherepanov
parents: 3348
diff changeset
   399
    if (self == NULL || self->GetHWnd() != hWnd ||
2571be1e8f1d 6660258: Java application stops Windows logout/shutdown (regression in 1.5.0_14)
dcherepanov
parents: 3348
diff changeset
   400
        message == WM_UNDOCUMENTED_CLIENTSHUTDOWN) // handle log-off gracefully
2571be1e8f1d 6660258: Java application stops Windows logout/shutdown (regression in 1.5.0_14)
dcherepanov
parents: 3348
diff changeset
   401
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        return ComCtl32Util::GetInstance().DefWindowProc(NULL, hWnd, message, wParam, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        return self->WindowProc(message, wParam, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    CATCH_BAD_ALLOC_RET(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
BOOL AwtComponent::IsFocusable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    jobject peer = GetPeer(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    jobject target = env->GetObjectField(peer, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    BOOL res = env->GetBooleanField(target, focusableID);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   415
    AwtWindow *pCont = GetContainer();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   416
    if (pCont) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   417
        res &= pCont->IsFocusableWindow();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   418
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
 * AwtComponent dynamic methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
 * Window class registration routines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
 * Fix for 4964237: Win XP: Changing theme changes java dialogs title icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
void AwtComponent::FillClassInfo(WNDCLASSEX *lpwc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    lpwc->cbSize        = sizeof(WNDCLASSEX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    lpwc->style         = 0L;//CS_OWNDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    lpwc->lpfnWndProc   = (WNDPROC)::DefWindowProc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    lpwc->cbClsExtra    = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    lpwc->cbWndExtra    = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    lpwc->hInstance     = AwtToolkit::GetInstance().GetModuleHandle(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    lpwc->hIcon         = AwtToolkit::GetInstance().GetAwtIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    lpwc->hCursor       = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    lpwc->hbrBackground = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    lpwc->lpszMenuName  = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    lpwc->lpszClassName = GetClassName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    //Fixed 6233560: PIT: Java Cup Logo on the title bar of top-level windows look blurred, Win32
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    lpwc->hIconSm       = AwtToolkit::GetInstance().GetAwtIconSm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
void AwtComponent::RegisterClass()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    WNDCLASSEX wc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    if (!::GetClassInfoEx(AwtToolkit::GetInstance().GetModuleHandle(), GetClassName(), &wc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        FillClassInfo(&wc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        ATOM ret = ::RegisterClassEx(&wc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        DASSERT(ret != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
void AwtComponent::UnregisterClass()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    ::UnregisterClass(GetClassName(), AwtToolkit::GetInstance().GetModuleHandle());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
 * Copy the graphicsConfig reference from Component into WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
void AwtComponent::InitPeerGraphicsConfig(JNIEnv *env, jobject peer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    jobject target = env->GetObjectField(peer, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    //Get graphicsConfig object ref from Component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    jobject compGC = env->GetObjectField(target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                      AwtComponent::graphicsConfigID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    //Set peer's graphicsConfig to Component's graphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    if (compGC != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        jclass win32GCCls = env->FindClass("sun/awt/Win32GraphicsConfig");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        DASSERT(win32GCCls != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        DASSERT(env->IsInstanceOf(compGC, win32GCCls));
26006
da0572ecab20 8049057: JNI exception pending in jdk/src/windows/native/sun/windows/
serb
parents: 26005
diff changeset
   479
        if (win32GCCls == NULL) {
da0572ecab20 8049057: JNI exception pending in jdk/src/windows/native/sun/windows/
serb
parents: 26005
diff changeset
   480
            throw std::bad_alloc();
da0572ecab20 8049057: JNI exception pending in jdk/src/windows/native/sun/windows/
serb
parents: 26005
diff changeset
   481
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        env->SetObjectField(peer, AwtComponent::peerGCID, compGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
AwtComponent::CreateHWnd(JNIEnv *env, LPCWSTR title,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                         DWORD windowStyle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                         DWORD windowExStyle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                         int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                         HWND hWndParent, HMENU hMenu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                         COLORREF colorForeground,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                         COLORREF colorBackground,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                         jobject peer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    if (env->EnsureLocalCapacity(2) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * The window class of multifont label must be "BUTTON" because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * "STATIC" class can't get WM_DRAWITEM message, and m_peerObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * member is referred in the GetClassName method of AwtLabel class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * So m_peerObject member must be set here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     */
25562
af98568d21e9 8040076: Memory leak. java.awt.List objects allowing multiple selections are not GC-ed.
mcherkas
parents: 24155
diff changeset
   506
    if (m_peerObject == NULL) {
af98568d21e9 8040076: Memory leak. java.awt.List objects allowing multiple selections are not GC-ed.
mcherkas
parents: 24155
diff changeset
   507
        m_peerObject = env->NewGlobalRef(peer);
af98568d21e9 8040076: Memory leak. java.awt.List objects allowing multiple selections are not GC-ed.
mcherkas
parents: 24155
diff changeset
   508
    } else {
af98568d21e9 8040076: Memory leak. java.awt.List objects allowing multiple selections are not GC-ed.
mcherkas
parents: 24155
diff changeset
   509
        assert(env->IsSameObject(m_peerObject, peer));
af98568d21e9 8040076: Memory leak. java.awt.List objects allowing multiple selections are not GC-ed.
mcherkas
parents: 24155
diff changeset
   510
    }
af98568d21e9 8040076: Memory leak. java.awt.List objects allowing multiple selections are not GC-ed.
mcherkas
parents: 24155
diff changeset
   511
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    RegisterClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    jobject target = env->GetObjectField(peer, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    jboolean visible = env->GetBooleanField(target, AwtComponent::visibleID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    m_visible = visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    if (visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        windowStyle |= WS_VISIBLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        windowStyle &= ~WS_VISIBLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    InitPeerGraphicsConfig(env, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    SetLastError(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    HWND hwnd = ::CreateWindowEx(windowExStyle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                                 GetClassName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                                 title,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                                 windowStyle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                                 x, y, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                                 hWndParent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                                 hMenu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                                 AwtToolkit::GetInstance().GetModuleHandle(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                                 NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    // fix for 5088782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    // check if CreateWindowsEx() returns not null value and if it does -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    //   create an InternalError or OutOfMemoryError based on GetLastError().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    //   This error is set to createError field of WObjectPeer and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    //   checked and thrown in WComponentPeer constructor. We can't throw an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    //   error here because this code is invoked on Toolkit thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    if (hwnd == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        DWORD dw = ::GetLastError();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        jobject createError = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        if (dw == ERROR_OUTOFMEMORY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        {
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
   549
            jstring errorMsg = JNU_NewStringPlatform(env, L"too many window handles");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   550
            if (errorMsg == NULL || env->ExceptionCheck()) {
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   551
                env->ExceptionClear();
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   552
                createError = JNU_NewObjectByName(env, "java/lang/OutOfMemoryError", "()V");
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   553
            } else {
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   554
                createError = JNU_NewObjectByName(env, "java/lang/OutOfMemoryError",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                                                      "(Ljava/lang/String;)V",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                                                      errorMsg);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   557
                env->DeleteLocalRef(errorMsg);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   558
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            TCHAR *buf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                (LPTSTR)&buf, 0, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            jstring s = JNU_NewStringPlatform(env, buf);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   567
            if (s == NULL || env->ExceptionCheck()) {
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   568
                env->ExceptionClear();
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   569
                createError = JNU_NewObjectByName(env, "java/lang/InternalError", "()V");
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   570
            } else {
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   571
                createError = JNU_NewObjectByName(env, "java/lang/InternalError",
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   572
                                                                  "(Ljava/lang/String;)V", s);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   573
                env->DeleteLocalRef(s);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   574
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            LocalFree(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        }
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   577
        if (createError != NULL) {
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
   578
            env->SetObjectField(peer, AwtObject::createErrorID, createError);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            env->DeleteLocalRef(createError);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    m_hwnd = hwnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
12817
5b0f3d1b8cfe 7170996: IME composition window does not disappear when file dialog is closed : Japanese WinXP
zhouyx
parents: 12175
diff changeset
   587
    ::ImmAssociateContext(m_hwnd, NULL);
5b0f3d1b8cfe 7170996: IME composition window does not disappear when file dialog is closed : Japanese WinXP
zhouyx
parents: 12175
diff changeset
   588
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    SetDrawState((jint)JAWT_LOCK_SURFACE_CHANGED |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        (jint)JAWT_LOCK_BOUNDS_CHANGED |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        (jint)JAWT_LOCK_CLIP_CHANGED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    LinkObjects(env, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    /* Subclass the window now so that we can snoop on its messages */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    SubclassHWND();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
47384
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
   598
    AwtToolkit& tk = AwtToolkit::GetInstance();
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
   599
    if (tk.IsWin8OrLater() && tk.IsTouchKeyboardAutoShowEnabled()) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
   600
        tk.TIRegisterTouchWindow(GetHWnd(), TWF_WANTPALM);
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
   601
    }
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
   602
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
      * Fix for 4046446.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    SetWindowPos(GetHWnd(), 0, x, y, w, h, SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOACTIVATE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    /* Set default colors. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    m_colorForeground = colorForeground;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    m_colorBackground = colorBackground;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * Only set background color if the color is actually set on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * target -- this avoids inheriting a parent's color unnecessarily,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * and has to be done here because there isn't an API to get the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * real background color from outside the AWT package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    jobject bkgrd = env->GetObjectField(target, AwtComponent::backgroundID) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    if (bkgrd != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        JNU_CallMethodByName(env, NULL, peer, "setBackground",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                             "(Ljava/awt/Color;)V", bkgrd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    env->DeleteLocalRef(bkgrd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
/*
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   629
 * Destroy this window's HWND
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   630
 */
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   631
void AwtComponent::DestroyHWnd() {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   632
    if (m_hwnd != NULL) {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   633
        AwtToolkit::DestroyComponentHWND(m_hwnd);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   634
        //AwtToolkit::DestroyComponent(this);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   635
        m_hwnd = NULL;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   636
    }
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   637
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   638
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
   639
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
 * Returns hwnd for target on non Toolkit thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
HWND
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
AwtComponent::GetHWnd(JNIEnv* env, jobject target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    if (JNU_IsNull(env, target)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    jobject peer = env->GetObjectField(target, AwtComponent::peerID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    if (JNU_IsNull(env, peer)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    HWND hwnd = reinterpret_cast<HWND>(static_cast<LONG_PTR> (
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        env->GetLongField(peer, AwtComponent::hwndID)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    env->DeleteLocalRef(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    return hwnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
// Propagate the background color to synchronize Java field and peer's field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
// This is needed to fix 4148334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
void AwtComponent::UpdateBackground(JNIEnv *env, jobject target)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    if (env->EnsureLocalCapacity(1) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    jobject bkgrnd = env->GetObjectField(target, AwtComponent::backgroundID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    if (bkgrnd == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        bkgrnd = JNU_NewObjectByName(env, "java/awt/Color", "(III)V",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                                     GetRValue(m_colorBackground),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                                     GetGValue(m_colorBackground),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                                     GetBValue(m_colorBackground));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        if (bkgrnd != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            env->SetObjectField(target, AwtComponent::backgroundID, bkgrnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    env->DeleteLocalRef(bkgrnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
 * Install our window proc as the proc for our HWND, and save off the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
 * previous proc as the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
void AwtComponent::SubclassHWND()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    if (m_bSubclassed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    const WNDPROC wndproc = WndProc; // let compiler type check WndProc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    m_DefWindowProc = ComCtl32Util::GetInstance().SubclassHWND(GetHWnd(), wndproc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    m_bSubclassed = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
 * Reinstall the original window proc as the proc for our HWND
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
void AwtComponent::UnsubclassHWND()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    if (!m_bSubclassed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    ComCtl32Util::GetInstance().UnsubclassHWND(GetHWnd(), WndProc, m_DefWindowProc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    m_bSubclassed = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
/////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
// (static method)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
// Determines the top-level ancestor for a given window. If the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
// window is a top-level window, return itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
// 'Top-level' includes dialogs as well.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
HWND AwtComponent::GetTopLevelParentForWindow(HWND hwndDescendant) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    if (hwndDescendant == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    DASSERT(IsWindow(hwndDescendant));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    HWND hwnd = hwndDescendant;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    for(;;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        // a) found a non-child window so terminate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        // b) found real toplevel window (e.g. EmbeddedFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        //    that is child though)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        if ( (style & WS_CHILD) == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
             AwtComponent::IsTopLevelHWnd(hwnd) )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        hwnd = ::GetParent(hwnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    return hwnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
jobject AwtComponent::FindHeavyweightUnderCursor(BOOL useCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    if (env->EnsureLocalCapacity(1) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    HWND hit = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    POINT p = { 0, 0 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    AwtComponent *comp = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    if (useCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        if (sm_cursorOn == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        DASSERT(::IsWindow(sm_cursorOn));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        VERIFY(::GetCursorPos(&p));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
         * Fix for BugTraq ID 4304024.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
         * Allow a non-default cursor only for the client area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        comp = AwtComponent::GetComponent(sm_cursorOn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        if (comp != NULL &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
            ::SendMessage(sm_cursorOn, WM_NCHITTEST, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                          MAKELPARAM(p.x, p.y)) == HTCLIENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            goto found;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    ::GetCursorPos(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    hit = ::WindowFromPoint(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    while (hit != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        comp = AwtComponent::GetComponent(hit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        if (comp != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
            INT nHittest = (INT)::SendMessage(hit, WM_NCHITTEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                                          0, MAKELPARAM(p.x, p.y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
             * Fix for BugTraq ID 4304024.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
             * Allow a non-default cursor only for the client area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            if (nHittest != HTCLIENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                 * When over the non-client area, send WM_SETCURSOR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                 * to revert the cursor to an arrow.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                ::SendMessage(hit, WM_SETCURSOR, (WPARAM)hit,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                              MAKELPARAM(nHittest, WM_MOUSEMOVE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
              sm_cursorOn = hit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
              goto found;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        if ((::GetWindowLong(hit, GWL_STYLE) & WS_CHILD) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        hit = ::GetParent(hit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
found:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    jobject localRef = comp->GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
    jobject globalRef = env->NewGlobalRef(localRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    env->DeleteLocalRef(localRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    return globalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
void AwtComponent::SetColor(COLORREF c)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    int grayscale = AwtWin32GraphicsDevice::GetGrayness(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    if (grayscale != GS_NOTGRAY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        int g;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        g = (int) (.299 * (c & 0xFF) + .587 * ((c >> 8) & 0xFF) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            .114 * ((c >> 16) & 0xFF) + 0.5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        // c = g | (g << 8) | (g << 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        c = PALETTERGB(g, g, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    if (m_colorForeground == c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    m_colorForeground = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    if (m_penForeground != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        m_penForeground->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        m_penForeground = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    VERIFY(::InvalidateRect(GetHWnd(), NULL, FALSE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
void AwtComponent::SetBackgroundColor(COLORREF c)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    int grayscale = AwtWin32GraphicsDevice::GetGrayness(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    if (grayscale != GS_NOTGRAY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        int g;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        g = (int) (.299 * (c & 0xFF) + .587 * ((c >> 8) & 0xFF) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            .114 * ((c >> 16) & 0xFF) + 0.5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        // c = g | (g << 8) | (g << 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        c = PALETTERGB(g, g, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    if (m_colorBackground == c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    m_colorBackground = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    m_backgroundColorSet = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    if (m_brushBackground != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        m_brushBackground->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        m_brushBackground = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    VERIFY(::InvalidateRect(GetHWnd(), NULL, TRUE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
HPEN AwtComponent::GetForegroundPen()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    if (m_penForeground == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        m_penForeground = AwtPen::Get(m_colorForeground);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    return (HPEN)m_penForeground->GetHandle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
COLORREF AwtComponent::GetBackgroundColor()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
    if (m_backgroundColorSet == FALSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        AwtComponent* c = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        while ((c = c->GetParent()) != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            if (c->IsBackgroundColorSet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                return c->GetBackgroundColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    return m_colorBackground;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
HBRUSH AwtComponent::GetBackgroundBrush()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
    if (m_backgroundColorSet == FALSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        if (m_brushBackground != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            m_brushBackground->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            m_brushBackground = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
          AwtComponent* c = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
          while ((c = c->GetParent()) != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
              if (c->IsBackgroundColorSet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
                  m_brushBackground =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                      AwtBrush::Get(c->GetBackgroundColor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
    if (m_brushBackground == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        m_brushBackground = AwtBrush::Get(m_colorBackground);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    return (HBRUSH)m_brushBackground->GetHandle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
void AwtComponent::SetFont(AwtFont* font)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
    DASSERT(font != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    if (font->GetAscent() < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        AwtFont::SetupAscent(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    SendMessage(WM_SETFONT, (WPARAM)font->GetHFont(), MAKELPARAM(FALSE, 0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    VERIFY(::InvalidateRect(GetHWnd(), NULL, TRUE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
AwtComponent* AwtComponent::GetParent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    HWND hwnd = ::GetParent(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    if (hwnd == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    return GetComponent(hwnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
AwtWindow* AwtComponent::GetContainer()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    AwtComponent* comp = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    while (comp != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        if (comp->IsContainer()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
            return (AwtWindow*)comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        comp = comp->GetParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
void AwtComponent::Show()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
    m_visible = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
    ::ShowWindow(GetHWnd(), SW_SHOWNA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
void AwtComponent::Hide()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
    m_visible = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
    ::ShowWindow(GetHWnd(), SW_HIDE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
BOOL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
AwtComponent::SetWindowPos(HWND wnd, HWND after,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                           int x, int y, int w, int h, UINT flags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
    // Conditions we shouldn't handle:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
    // z-order changes, correct window dimensions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
    if (after != NULL || (w < 32767 && h < 32767)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
        || ((::GetWindowLong(wnd, GWL_STYLE) & WS_CHILD) == 0))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        return ::SetWindowPos(wnd, after, x, y, w, h, flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
    WINDOWPLACEMENT wp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
    ::ZeroMemory(&wp, sizeof(wp));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
    wp.length = sizeof(wp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
    ::GetWindowPlacement(wnd, &wp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    wp.rcNormalPosition.left = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
    wp.rcNormalPosition.top = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
    wp.rcNormalPosition.right = x + w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
    wp.rcNormalPosition.bottom = y + h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    if ( flags & SWP_NOACTIVATE ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        wp.showCmd = SW_SHOWNOACTIVATE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
    ::SetWindowPlacement(wnd, &wp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
43822
d8b083d63bbd 8147440: HiDPI (Windows) Swing components have incorrect sizes after changing display resolution
alexsch
parents: 43205
diff changeset
   971
void AwtComponent::Reshape(int x, int y, int w, int h) {
d8b083d63bbd 8147440: HiDPI (Windows) Swing components have incorrect sizes after changing display resolution
alexsch
parents: 43205
diff changeset
   972
    ReshapeNoScale(ScaleUpX(x), ScaleUpY(y), ScaleUpX(w), ScaleUpY(h));
d8b083d63bbd 8147440: HiDPI (Windows) Swing components have incorrect sizes after changing display resolution
alexsch
parents: 43205
diff changeset
   973
}
d8b083d63bbd 8147440: HiDPI (Windows) Swing components have incorrect sizes after changing display resolution
alexsch
parents: 43205
diff changeset
   974
d8b083d63bbd 8147440: HiDPI (Windows) Swing components have incorrect sizes after changing display resolution
alexsch
parents: 43205
diff changeset
   975
void AwtComponent::ReshapeNoScale(int x, int y, int w, int h)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
#if defined(DEBUG)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
    RECT        rc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
    ::GetWindowRect(GetHWnd(), &rc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
    ::MapWindowPoints(HWND_DESKTOP, ::GetParent(GetHWnd()), (LPPOINT)&rc, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
    DTRACE_PRINTLN4("AwtComponent::Reshape from %d, %d, %d, %d", rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
#endif
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
   983
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
    AwtWindow* container = GetContainer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    AwtComponent* parent = GetParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
    if (container != NULL && container == parent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        container->SubtractInsetPoint(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
    DTRACE_PRINTLN4("AwtComponent::Reshape to %d, %d, %d, %d", x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
    UINT flags = SWP_NOACTIVATE | SWP_NOZORDER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    RECT        r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
    ::GetWindowRect(GetHWnd(), &r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    // if the component size is changing , don't copy window bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    if (r.right - r.left != w || r.bottom - r.top != h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
        flags |= SWP_NOCOPYBITS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    if (parent && _tcscmp(parent->GetClassName(), TEXT("SunAwtScrollPane")) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
        if (x > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
            x = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        if (y > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
            y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    if (m_hdwp != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        m_hdwp = ::DeferWindowPos(m_hdwp, GetHWnd(), 0, x, y, w, h, flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        DASSERT(m_hdwp != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
         * Fox for 4046446
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
         * If window has dimensions above the short int limit, ::SetWindowPos doesn't work.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
         * We should use SetWindowPlacement instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
        SetWindowPos(GetHWnd(), 0, x, y, w, h, flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
void AwtComponent::SetScrollValues(UINT bar, int min, int value, int max)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
    int minTmp, maxTmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    ::GetScrollRange(GetHWnd(), bar, &minTmp, &maxTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
    if (min == INT_MAX) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
        min = minTmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    if (value == INT_MAX) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
        value = ::GetScrollPos(GetHWnd(), bar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
    if (max == INT_MAX) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
        max = maxTmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
    if (min == max) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        max++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
    ::SetScrollRange(GetHWnd(), bar, min, max, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
    ::SetScrollPos(GetHWnd(), bar, value, TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
 * Save Global Reference of sun.awt.windows.WInputMethod object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
void AwtComponent::SetInputMethod(jobject im, BOOL useNativeCompWindow)
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
    if (m_InputMethod!=NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
        env->DeleteGlobalRef(m_InputMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    if (im!=NULL){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        m_InputMethod = env->NewGlobalRef(im);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        m_useNativeCompWindow = useNativeCompWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        m_InputMethod = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        m_useNativeCompWindow = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
 * Opportunity to process and/or eat a message before it is dispatched
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
MsgRouting AwtComponent::PreProcessMsg(MSG& msg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
    return mrPassAlong;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
static UINT lastMessage = WM_NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
#ifndef SPY_MESSAGES
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
#define SpyWinMessage(hwin,msg,str)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
#define FMT_MSG(x,y) case x: _stprintf(szBuf, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
    "0x%8.8x(%s):%s\n", hwnd, szComment, y); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
#define WIN_MSG(x) FMT_MSG(x,#x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
void SpyWinMessage(HWND hwnd, UINT message, LPCTSTR szComment) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
    TCHAR szBuf[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
    switch (message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
        WIN_MSG(WM_NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
        WIN_MSG(WM_CREATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
        WIN_MSG(WM_DESTROY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        WIN_MSG(WM_MOVE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
        WIN_MSG(WM_SIZE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
        WIN_MSG(WM_ACTIVATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        WIN_MSG(WM_SETFOCUS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
        WIN_MSG(WM_KILLFOCUS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
        WIN_MSG(WM_ENABLE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
        WIN_MSG(WM_SETREDRAW)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
        WIN_MSG(WM_SETTEXT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
        WIN_MSG(WM_GETTEXT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
        WIN_MSG(WM_GETTEXTLENGTH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
        WIN_MSG(WM_PAINT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
        WIN_MSG(WM_CLOSE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        WIN_MSG(WM_QUERYENDSESSION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
        WIN_MSG(WM_QUIT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
        WIN_MSG(WM_QUERYOPEN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        WIN_MSG(WM_ERASEBKGND)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
        WIN_MSG(WM_SYSCOLORCHANGE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
        WIN_MSG(WM_ENDSESSION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
        WIN_MSG(WM_SHOWWINDOW)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        FMT_MSG(WM_WININICHANGE,"WM_WININICHANGE/WM_SETTINGCHANGE")
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        WIN_MSG(WM_DEVMODECHANGE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        WIN_MSG(WM_ACTIVATEAPP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
        WIN_MSG(WM_FONTCHANGE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
        WIN_MSG(WM_TIMECHANGE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
        WIN_MSG(WM_CANCELMODE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
        WIN_MSG(WM_SETCURSOR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        WIN_MSG(WM_MOUSEACTIVATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
        WIN_MSG(WM_CHILDACTIVATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
        WIN_MSG(WM_QUEUESYNC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
        WIN_MSG(WM_GETMINMAXINFO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
        WIN_MSG(WM_PAINTICON)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
        WIN_MSG(WM_ICONERASEBKGND)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
        WIN_MSG(WM_NEXTDLGCTL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
        WIN_MSG(WM_SPOOLERSTATUS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
        WIN_MSG(WM_DRAWITEM)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
        WIN_MSG(WM_MEASUREITEM)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
        WIN_MSG(WM_DELETEITEM)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
        WIN_MSG(WM_VKEYTOITEM)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
        WIN_MSG(WM_CHARTOITEM)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
        WIN_MSG(WM_SETFONT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        WIN_MSG(WM_GETFONT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
        WIN_MSG(WM_SETHOTKEY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
        WIN_MSG(WM_GETHOTKEY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
        WIN_MSG(WM_QUERYDRAGICON)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
        WIN_MSG(WM_COMPAREITEM)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
        FMT_MSG(0x003D, "WM_GETOBJECT")
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
        WIN_MSG(WM_COMPACTING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        WIN_MSG(WM_COMMNOTIFY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
        WIN_MSG(WM_WINDOWPOSCHANGING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
        WIN_MSG(WM_WINDOWPOSCHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
        WIN_MSG(WM_POWER)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
        WIN_MSG(WM_COPYDATA)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
        WIN_MSG(WM_CANCELJOURNAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        WIN_MSG(WM_NOTIFY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        WIN_MSG(WM_INPUTLANGCHANGEREQUEST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
        WIN_MSG(WM_INPUTLANGCHANGE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        WIN_MSG(WM_TCARD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
        WIN_MSG(WM_HELP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        WIN_MSG(WM_USERCHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
        WIN_MSG(WM_NOTIFYFORMAT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        WIN_MSG(WM_CONTEXTMENU)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
        WIN_MSG(WM_STYLECHANGING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
        WIN_MSG(WM_STYLECHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
        WIN_MSG(WM_DISPLAYCHANGE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
        WIN_MSG(WM_GETICON)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
        WIN_MSG(WM_SETICON)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
        WIN_MSG(WM_NCCREATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
        WIN_MSG(WM_NCDESTROY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        WIN_MSG(WM_NCCALCSIZE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
        WIN_MSG(WM_NCHITTEST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
        WIN_MSG(WM_NCPAINT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
        WIN_MSG(WM_NCACTIVATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
        WIN_MSG(WM_GETDLGCODE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
        WIN_MSG(WM_SYNCPAINT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
        WIN_MSG(WM_NCMOUSEMOVE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
        WIN_MSG(WM_NCLBUTTONDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
        WIN_MSG(WM_NCLBUTTONUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
        WIN_MSG(WM_NCLBUTTONDBLCLK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
        WIN_MSG(WM_NCRBUTTONDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
        WIN_MSG(WM_NCRBUTTONUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
        WIN_MSG(WM_NCRBUTTONDBLCLK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
        WIN_MSG(WM_NCMBUTTONDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
        WIN_MSG(WM_NCMBUTTONUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
        WIN_MSG(WM_NCMBUTTONDBLCLK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
        WIN_MSG(WM_KEYDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
        WIN_MSG(WM_KEYUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
        WIN_MSG(WM_CHAR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
        WIN_MSG(WM_DEADCHAR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
        WIN_MSG(WM_SYSKEYDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
        WIN_MSG(WM_SYSKEYUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
        WIN_MSG(WM_SYSCHAR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
        WIN_MSG(WM_SYSDEADCHAR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
        WIN_MSG(WM_IME_STARTCOMPOSITION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
        WIN_MSG(WM_IME_ENDCOMPOSITION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
        WIN_MSG(WM_IME_COMPOSITION)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
        WIN_MSG(WM_INITDIALOG)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
        WIN_MSG(WM_COMMAND)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        WIN_MSG(WM_SYSCOMMAND)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
        WIN_MSG(WM_TIMER)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        WIN_MSG(WM_HSCROLL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
        WIN_MSG(WM_VSCROLL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        WIN_MSG(WM_INITMENU)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
        WIN_MSG(WM_INITMENUPOPUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
        WIN_MSG(WM_MENUSELECT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
        WIN_MSG(WM_MENUCHAR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
        WIN_MSG(WM_ENTERIDLE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
        FMT_MSG(0x0122, "WM_MENURBUTTONUP")
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
        FMT_MSG(0x0123, "WM_MENUDRAG")
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
        FMT_MSG(0x0124, "WM_MENUGETOBJECT")
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        FMT_MSG(0x0125, "WM_UNINITMENUPOPUP")
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        FMT_MSG(0x0126, "WM_MENUCOMMAND")
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        WIN_MSG(WM_CTLCOLORMSGBOX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        WIN_MSG(WM_CTLCOLOREDIT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
        WIN_MSG(WM_CTLCOLORLISTBOX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        WIN_MSG(WM_CTLCOLORBTN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        WIN_MSG(WM_CTLCOLORDLG)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
        WIN_MSG(WM_CTLCOLORSCROLLBAR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
        WIN_MSG(WM_CTLCOLORSTATIC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
        WIN_MSG(WM_MOUSEMOVE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
        WIN_MSG(WM_LBUTTONDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
        WIN_MSG(WM_LBUTTONUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
        WIN_MSG(WM_LBUTTONDBLCLK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
        WIN_MSG(WM_RBUTTONDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
        WIN_MSG(WM_RBUTTONUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
        WIN_MSG(WM_RBUTTONDBLCLK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
        WIN_MSG(WM_MBUTTONDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
        WIN_MSG(WM_MBUTTONUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
        WIN_MSG(WM_MBUTTONDBLCLK)
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1216
        WIN_MSG(WM_XBUTTONDBLCLK)
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1217
        WIN_MSG(WM_XBUTTONDOWN)
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1218
        WIN_MSG(WM_XBUTTONUP)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
        WIN_MSG(WM_MOUSEWHEEL)
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  1220
        WIN_MSG(WM_MOUSEHWHEEL)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
        WIN_MSG(WM_PARENTNOTIFY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
        WIN_MSG(WM_ENTERMENULOOP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
        WIN_MSG(WM_EXITMENULOOP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
        WIN_MSG(WM_NEXTMENU)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
        WIN_MSG(WM_SIZING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
        WIN_MSG(WM_CAPTURECHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
        WIN_MSG(WM_MOVING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
        WIN_MSG(WM_POWERBROADCAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
        WIN_MSG(WM_DEVICECHANGE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
        WIN_MSG(WM_MDICREATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
        WIN_MSG(WM_MDIDESTROY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
        WIN_MSG(WM_MDIACTIVATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
        WIN_MSG(WM_MDIRESTORE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
        WIN_MSG(WM_MDINEXT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
        WIN_MSG(WM_MDIMAXIMIZE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
        WIN_MSG(WM_MDITILE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
        WIN_MSG(WM_MDICASCADE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        WIN_MSG(WM_MDIICONARRANGE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
        WIN_MSG(WM_MDIGETACTIVE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
        WIN_MSG(WM_MDISETMENU)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
        WIN_MSG(WM_ENTERSIZEMOVE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
        WIN_MSG(WM_EXITSIZEMOVE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
        WIN_MSG(WM_DROPFILES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
        WIN_MSG(WM_MDIREFRESHMENU)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
        WIN_MSG(WM_IME_SETCONTEXT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        WIN_MSG(WM_IME_NOTIFY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        WIN_MSG(WM_IME_CONTROL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
        WIN_MSG(WM_IME_COMPOSITIONFULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
        WIN_MSG(WM_IME_SELECT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        WIN_MSG(WM_IME_CHAR)
9481
fd8eab58a220 7034291: Regression : Preedit String on active client is committed into unexpected component
dcherepanov
parents: 9476
diff changeset
  1251
        FMT_MSG(WM_IME_REQUEST)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        WIN_MSG(WM_IME_KEYDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
        WIN_MSG(WM_IME_KEYUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        FMT_MSG(0x02A1, "WM_MOUSEHOVER")
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
        FMT_MSG(0x02A3, "WM_MOUSELEAVE")
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
        WIN_MSG(WM_CUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
        WIN_MSG(WM_COPY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
        WIN_MSG(WM_PASTE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
        WIN_MSG(WM_CLEAR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
        WIN_MSG(WM_UNDO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
        WIN_MSG(WM_RENDERFORMAT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
        WIN_MSG(WM_RENDERALLFORMATS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
        WIN_MSG(WM_DESTROYCLIPBOARD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
        WIN_MSG(WM_DRAWCLIPBOARD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
        WIN_MSG(WM_PAINTCLIPBOARD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
        WIN_MSG(WM_VSCROLLCLIPBOARD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
        WIN_MSG(WM_SIZECLIPBOARD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
        WIN_MSG(WM_ASKCBFORMATNAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
        WIN_MSG(WM_CHANGECBCHAIN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
        WIN_MSG(WM_HSCROLLCLIPBOARD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
        WIN_MSG(WM_QUERYNEWPALETTE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
        WIN_MSG(WM_PALETTEISCHANGING)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
        WIN_MSG(WM_PALETTECHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
        WIN_MSG(WM_HOTKEY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
        WIN_MSG(WM_PRINT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
        WIN_MSG(WM_PRINTCLIENT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
        WIN_MSG(WM_HANDHELDFIRST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
        WIN_MSG(WM_HANDHELDLAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
        WIN_MSG(WM_AFXFIRST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
        WIN_MSG(WM_AFXLAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
        WIN_MSG(WM_PENWINFIRST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
        WIN_MSG(WM_PENWINLAST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
        WIN_MSG(WM_AWT_COMPONENT_CREATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
        WIN_MSG(WM_AWT_DESTROY_WINDOW)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
        WIN_MSG(WM_AWT_MOUSEENTER)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
        WIN_MSG(WM_AWT_MOUSEEXIT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
        WIN_MSG(WM_AWT_COMPONENT_SHOW)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
        WIN_MSG(WM_AWT_COMPONENT_HIDE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
        WIN_MSG(WM_AWT_COMPONENT_SETFOCUS)
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1290
        WIN_MSG(WM_AWT_WINDOW_SETACTIVE)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
        WIN_MSG(WM_AWT_LIST_SETMULTISELECT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
        WIN_MSG(WM_AWT_HANDLE_EVENT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
        WIN_MSG(WM_AWT_PRINT_COMPONENT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
        WIN_MSG(WM_AWT_RESHAPE_COMPONENT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
        WIN_MSG(WM_AWT_SETALWAYSONTOP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
        WIN_MSG(WM_AWT_BEGIN_VALIDATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
        WIN_MSG(WM_AWT_END_VALIDATE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
        WIN_MSG(WM_AWT_FORWARD_CHAR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
        WIN_MSG(WM_AWT_FORWARD_BYTE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
        WIN_MSG(WM_AWT_SET_SCROLL_INFO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
        WIN_MSG(WM_AWT_CREATECONTEXT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
        WIN_MSG(WM_AWT_DESTROYCONTEXT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
        WIN_MSG(WM_AWT_ASSOCIATECONTEXT)
2952
0679c7600523 6829180: Removing focused component from a window causes a JVM crash for JDK7b50+ on WinXP/Vista
dcherepanov
parents: 2950
diff changeset
  1304
        WIN_MSG(WM_AWT_GET_DEFAULT_IME_HANDLER)
0679c7600523 6829180: Removing focused component from a window causes a JVM crash for JDK7b50+ on WinXP/Vista
dcherepanov
parents: 2950
diff changeset
  1305
        WIN_MSG(WM_AWT_HANDLE_NATIVE_IME_EVENT)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
        WIN_MSG(WM_AWT_PRE_KEYDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
        WIN_MSG(WM_AWT_PRE_KEYUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
        WIN_MSG(WM_AWT_PRE_SYSKEYDOWN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        WIN_MSG(WM_AWT_PRE_SYSKEYUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
        WIN_MSG(WM_AWT_ENDCOMPOSITION,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
        WIN_MSG(WM_AWT_DISPOSE,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
        WIN_MSG(WM_AWT_DELETEOBJECT,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
        WIN_MSG(WM_AWT_SETCONVERSIONSTATUS,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
        WIN_MSG(WM_AWT_GETCONVERSIONSTATUS,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
        WIN_MSG(WM_AWT_SETOPENSTATUS,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
        WIN_MSG(WM_AWT_GETOPENSTATUS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
        WIN_MSG(WM_AWT_ACTIVATEKEYBOARDLAYOUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
        WIN_MSG(WM_AWT_OPENCANDIDATEWINDOW)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
        WIN_MSG(WM_AWT_DLG_SHOWMODAL,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
        WIN_MSG(WM_AWT_DLG_ENDMODAL,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
        WIN_MSG(WM_AWT_SETCURSOR,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
        WIN_MSG(WM_AWT_WAIT_FOR_SINGLE_OBJECT,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
        WIN_MSG(WM_AWT_INVOKE_METHOD,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
        WIN_MSG(WM_AWT_INVOKE_VOID_METHOD,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
        WIN_MSG(WM_AWT_EXECUTE_SYNC,)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
        WIN_MSG(WM_AWT_CURSOR_SYNC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
        WIN_MSG(WM_AWT_GETDC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
        WIN_MSG(WM_AWT_RELEASEDC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
        WIN_MSG(WM_AWT_RELEASE_ALL_DCS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
        WIN_MSG(WM_AWT_SHOWCURSOR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
        WIN_MSG(WM_AWT_HIDECURSOR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
        WIN_MSG(WM_AWT_CREATE_PRINTED_PIXELS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
        WIN_MSG(WM_AWT_OBJECTLISTCLEANUP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
            sprintf(szBuf, "0x%8.8x(%s):Unknown message 0x%8.8x\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
                hwnd, szComment, message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
    printf(szBuf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
#endif /* SPY_MESSAGES */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
 * Dispatch messages for this window class--general component
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
    CounterHelper ch(&m_MessagesProcessing);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
    JNILocalFrame lframe(AwtToolkit::GetEnv(), 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
    SpyWinMessage(GetHWnd(), message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
        (message == WM_AWT_RELEASE_ALL_DCS) ? TEXT("Disposed Component") : GetClassName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
    LRESULT retValue = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
    MsgRouting mr = mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
    AwtToolkit::GetInstance().eventNumber++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
    static BOOL ignoreNextLBTNUP = FALSE; //Ignore next LBUTTONUP msg?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
    lastMessage = message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
    if (message == WmAwtIsComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
    // special message to identify AWT HWND's without using
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
    // resource hogging ::SetProp
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
        return (LRESULT)TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1369
    DWORD curPos = 0;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1370
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1371
    UINT switchMessage = message;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
    switch (switchMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
      case WM_AWT_GETDC:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
            HDC hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
            // First, release the DCs scheduled for deletion
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
            ReleaseDCList(GetHWnd(), passiveDCList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
            GetDCReturnStruct *returnStruct = new GetDCReturnStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
            returnStruct->gdiLimitReached = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
            if (AwtGDIObject::IncrementIfAvailable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
                hDC = ::GetDCEx(GetHWnd(), NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
                                DCX_CACHE | DCX_CLIPCHILDREN |
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
                                DCX_CLIPSIBLINGS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
                if (hDC != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
                    // Add new DC to list of DC's associated with this Component
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
                    activeDCList.AddDC(hDC, GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
                    // Creation failed; decrement counter in AwtGDIObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
                    AwtGDIObject::Decrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
                hDC = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
                returnStruct->gdiLimitReached = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
            returnStruct->hDC = hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
            retValue = (LRESULT)returnStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
            mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
      case WM_AWT_RELEASEDC:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
            HDC hDC = (HDC)wParam;
33508
75a3d3923c24 8130136: Swing window sometimes fails to repaint partially when it becomes exposed
aivanov
parents: 33249
diff changeset
  1404
            MoveDCToPassiveList(hDC, GetHWnd());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
            ReleaseDCList(GetHWnd(), passiveDCList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
            mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
      case WM_AWT_RELEASE_ALL_DCS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
            // Called during Component destruction.  Gets current list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
            // DC's associated with Component and releases each DC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
            ReleaseDCList(GetHWnd(), activeDCList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
            ReleaseDCList(GetHWnd(), passiveDCList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
            mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
      case WM_AWT_SHOWCURSOR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
          ::ShowCursor(TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
      case WM_AWT_HIDECURSOR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
          ::ShowCursor(FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
      case WM_CREATE: mr = WmCreate(); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
      case WM_CLOSE:      mr = WmClose(); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
      case WM_DESTROY:    mr = WmDestroy(); break;
10689
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  1427
      case WM_NCDESTROY:  mr = WmNcDestroy(); break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
      case WM_ERASEBKGND:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
          mr = WmEraseBkgnd((HDC)wParam, *(BOOL*)&retValue); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
      case WM_PAINT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
          CheckFontSmoothingSettings(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
          /* Set draw state */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
          SetDrawState(GetDrawState() | JAWT_LOCK_CLIP_CHANGED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
          mr = WmPaint((HDC)wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
      case WM_GETMINMAXINFO:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
          mr = WmGetMinMaxInfo((LPMINMAXINFO)lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
      case WM_WINDOWPOSCHANGING:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
          // We process this message so that we can synchronize access to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
          // a moving window.  The Scale/Blt functions in Win32BlitLoops
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
          // take the same windowMoveLock to ensure that a window is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
          // moving while we are trying to copy pixels into it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
          WINDOWPOS *lpPosInfo = (WINDOWPOS *)lParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
          if ((lpPosInfo->flags & (SWP_NOMOVE | SWP_NOSIZE)) !=
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
              (SWP_NOMOVE | SWP_NOSIZE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
          {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
              // Move or Size command.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
              // Windows tends to send erroneous events that the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
              // is about to move when the coordinates are exactly the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
              // same as the last time.  This can cause problems with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
              // our windowMoveLock CriticalSection because we enter it
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
              // here and never get to WM_WINDOWPOSCHANGED to release it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
              // So make sure this is a real move/size event before bothering
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
              // to grab the critical section.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
              BOOL takeLock = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
              if (!(lpPosInfo->flags & SWP_NOMOVE) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
                  ((windowMoveLockPosX != lpPosInfo->x) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
                   (windowMoveLockPosY != lpPosInfo->y)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
              {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
                  // Real move event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
                  takeLock = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
                  windowMoveLockPosX = lpPosInfo->x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
                  windowMoveLockPosY = lpPosInfo->y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
              if (!(lpPosInfo->flags & SWP_NOSIZE) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
                  ((windowMoveLockPosCX != lpPosInfo->cx) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
                   (windowMoveLockPosCY != lpPosInfo->cy)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
              {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
                  // Real size event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
                  takeLock = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
                  windowMoveLockPosCX = lpPosInfo->cx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
                  windowMoveLockPosCY = lpPosInfo->cy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
              if (takeLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
                  if (!windowMoveLockHeld) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
                      windowMoveLock.Enter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
                      windowMoveLockHeld = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
          mr = WmWindowPosChanging(lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
      case WM_WINDOWPOSCHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
          // Release lock grabbed in the POSCHANGING message
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
          if (windowMoveLockHeld) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
              windowMoveLockHeld = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
              windowMoveLock.Leave();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
          mr = WmWindowPosChanged(lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
      case WM_MOVE: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
          RECT r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
          ::GetWindowRect(GetHWnd(), &r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
          mr = WmMove(r.left, r.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
      case WM_SIZE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
          RECT r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
          // fix 4128317 : use GetClientRect for full 32-bit int precision and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
          // to avoid negative client area dimensions overflowing 16-bit params - robi
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
          ::GetClientRect( GetHWnd(), &r );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
          mr = WmSize(static_cast<UINT>(wParam), r.right - r.left, r.bottom - r.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
          //mr = WmSize(wParam, LOWORD(lParam), HIWORD(lParam));
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  1513
          SetCompositionWindow(r);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
      case WM_SIZING:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
          mr = WmSizing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
      case WM_SHOWWINDOW:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
          mr = WmShowWindow(static_cast<BOOL>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
                            static_cast<UINT>(lParam)); break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
      case WM_SYSCOMMAND:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
          mr = WmSysCommand(static_cast<UINT>(wParam & 0xFFF0),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
                            GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
          break;
44141
54188c6a042c 8175293: Window size is not updated after setting location to display with different DPI
alexsch
parents: 43822
diff changeset
  1526
      case WM_ENTERSIZEMOVE:
54188c6a042c 8175293: Window size is not updated after setting location to display with different DPI
alexsch
parents: 43822
diff changeset
  1527
          mr = WmEnterSizeMove();
54188c6a042c 8175293: Window size is not updated after setting location to display with different DPI
alexsch
parents: 43822
diff changeset
  1528
          break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
      case WM_EXITSIZEMOVE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
          mr = WmExitSizeMove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
      // Bug #4039858 (Selecting menu item causes bogus mouse click event)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
      case WM_ENTERMENULOOP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
          mr = WmEnterMenuLoop((BOOL)wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
          sm_bMenuLoop = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
          // we need to release grab if menu is shown
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
          if (AwtWindow::GetGrabbedWindow() != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
              AwtWindow::GetGrabbedWindow()->Ungrab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
      case WM_EXITMENULOOP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
          mr = WmExitMenuLoop((BOOL)wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
          sm_bMenuLoop = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1546
      // We don't expect any focus messages on non-proxy component,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1547
      // except those that came from Java.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
      case WM_SETFOCUS:
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1549
          if (sm_inSynthesizeFocus) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1550
              mr = WmSetFocus((HWND)wParam);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1551
          } else {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1552
              mr = mrConsume;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1553
          }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
      case WM_KILLFOCUS:
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1556
          if (sm_inSynthesizeFocus) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1557
              mr = WmKillFocus((HWND)wParam);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1558
          } else {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1559
              mr = mrConsume;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1560
          }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
          break;
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1562
      case WM_ACTIVATE: {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
          UINT nState = LOWORD(wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
          BOOL fMinimized = (BOOL)HIWORD(wParam);
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1565
          mr = mrConsume;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1566
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
          if (!sm_suppressFocusAndActivation &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
              (!fMinimized || (nState == WA_INACTIVE)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
          {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
              mr = WmActivate(nState, fMinimized, (HWND)lParam);
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1571
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
              // When the window is deactivated, send WM_IME_ENDCOMPOSITION
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
              // message to deactivate the composition window so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
              // it won't receive keyboard input focus.
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  1575
              HIMC hIMC;
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  1576
              HWND hwnd = ImmGetHWnd();
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  1577
              if ((hIMC = ImmGetContext(hwnd)) != NULL) {
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  1578
                  ImmReleaseContext(hwnd, hIMC);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
                  DefWindowProc(WM_IME_ENDCOMPOSITION, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
          }
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1582
          break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
      }
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1584
      case WM_MOUSEACTIVATE: {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1585
          AwtWindow *window = GetContainer();
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1586
          if (window && window->IsFocusableWindow()) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1587
              // AWT/Swing will later request focus to a proper component
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1588
              // on handling the Java mouse event. Anyway, we have to
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1589
              // activate the window here as it works both for AWT & Swing.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1590
              // Do it in our own fassion,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1591
              window->AwtSetActiveWindow(TRUE, LOWORD(lParam)/*hittest*/);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1592
          }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1593
          mr = mrConsume;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1594
          retValue = MA_NOACTIVATE;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1595
          break;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1596
      }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
      case WM_CTLCOLORMSGBOX:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
      case WM_CTLCOLOREDIT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
      case WM_CTLCOLORLISTBOX:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
      case WM_CTLCOLORBTN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
      case WM_CTLCOLORDLG:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
      case WM_CTLCOLORSCROLLBAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
      case WM_CTLCOLORSTATIC:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
          mr = WmCtlColor((HDC)wParam, (HWND)lParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
                          message-WM_CTLCOLORMSGBOX+CTLCOLOR_MSGBOX,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
                          *(HBRUSH*)&retValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
      case WM_HSCROLL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
          mr = WmHScroll(LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
      case WM_VSCROLL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
          mr = WmVScroll(LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
      // 4664415: We're seeing a WM_LBUTTONUP when the user releases the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
      // mouse button after a WM_NCLBUTTONDBLCLK.  We want to ignore this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
      // WM_LBUTTONUP, so we set a flag in WM_NCLBUTTONDBLCLK and look for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
      // flag on a WM_LBUTTONUP.  -bchristi
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
      case WM_NCLBUTTONDBLCLK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
          mr = WmNcMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), LEFT_BUTTON | DBL_CLICK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
          if (mr == mrDoDefault) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
              ignoreNextLBTNUP = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
      case WM_NCLBUTTONDOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
          mr = WmNcMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), LEFT_BUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
          ignoreNextLBTNUP = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
      case WM_NCLBUTTONUP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
          mr = WmNcMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), LEFT_BUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
      case WM_NCRBUTTONDOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
           mr = WmNcMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), RIGHT_BUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
           break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
      case WM_LBUTTONUP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
          if (ignoreNextLBTNUP) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
              ignoreNextLBTNUP = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
              return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
          //fall-through
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
      case WM_LBUTTONDOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
          ignoreNextLBTNUP = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
          //fall-through
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
      case WM_LBUTTONDBLCLK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
      case WM_RBUTTONDOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
      case WM_RBUTTONDBLCLK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
      case WM_RBUTTONUP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
      case WM_MBUTTONDOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
      case WM_MBUTTONDBLCLK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
      case WM_MBUTTONUP:
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1650
      case WM_XBUTTONDBLCLK:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1651
      case WM_XBUTTONDOWN:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1652
      case WM_XBUTTONUP:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
      case WM_MOUSEMOVE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
      case WM_MOUSEWHEEL:
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  1655
      case WM_MOUSEHWHEEL:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
      case WM_AWT_MOUSEENTER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
      case WM_AWT_MOUSEEXIT:
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1658
          curPos = ::GetMessagePos();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
          POINT myPos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
          myPos.x = GET_X_LPARAM(curPos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
          myPos.y = GET_Y_LPARAM(curPos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
          ::ScreenToClient(GetHWnd(), &myPos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
          switch(switchMessage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
          case WM_AWT_MOUSEENTER:
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1665
              mr = WmMouseEnter(static_cast<UINT>(wParam), myPos.x, myPos.y);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1666
              break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
          case WM_LBUTTONDOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
          case WM_LBUTTONDBLCLK:
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1669
              mr = WmMouseDown(static_cast<UINT>(wParam), myPos.x, myPos.y,
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1670
                               LEFT_BUTTON);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1671
              break;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1672
          case WM_LBUTTONUP:
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1673
              mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1674
                             LEFT_BUTTON);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1675
              break;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1676
          case WM_MOUSEMOVE:
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1677
              mr = WmMouseMove(static_cast<UINT>(wParam), myPos.x, myPos.y);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1678
              break;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1679
          case WM_MBUTTONDOWN:
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1680
          case WM_MBUTTONDBLCLK:
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1681
              mr = WmMouseDown(static_cast<UINT>(wParam), myPos.x, myPos.y,
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1682
                               MIDDLE_BUTTON);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1683
              break;
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1684
          case WM_XBUTTONDOWN:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1685
          case WM_XBUTTONDBLCLK:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1686
              if (AwtToolkit::GetInstance().areExtraMouseButtonsEnabled()) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1687
                  if (HIWORD(wParam) == 1) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1688
                      mr = WmMouseDown(static_cast<UINT>(wParam), myPos.x, myPos.y,
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1689
                                       X1_BUTTON);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1690
                  }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1691
                  if (HIWORD(wParam) == 2) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1692
                      mr = WmMouseDown(static_cast<UINT>(wParam), myPos.x, myPos.y,
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1693
                                       X2_BUTTON);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1694
                  }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1695
              }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1696
              break;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1697
          case WM_XBUTTONUP:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1698
              if (AwtToolkit::GetInstance().areExtraMouseButtonsEnabled()) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1699
                  if (HIWORD(wParam) == 1) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1700
                      mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1701
                                     X1_BUTTON);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1702
                  }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1703
                  if (HIWORD(wParam) == 2) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1704
                      mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1705
                                     X2_BUTTON);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1706
                  }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1707
              }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  1708
              break;
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1709
          case WM_RBUTTONDOWN:
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1710
          case WM_RBUTTONDBLCLK:
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1711
              mr = WmMouseDown(static_cast<UINT>(wParam), myPos.x, myPos.y,
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1712
                               RIGHT_BUTTON);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1713
              break;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1714
          case WM_RBUTTONUP:
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1715
              mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1716
                             RIGHT_BUTTON);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1717
              break;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1718
          case WM_MBUTTONUP:
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1719
              mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1720
                             MIDDLE_BUTTON);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1721
              break;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1722
          case WM_AWT_MOUSEEXIT:
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1723
              mr = WmMouseExit(static_cast<UINT>(wParam), myPos.x, myPos.y);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1724
              break;
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  1725
          case WM_MOUSEWHEEL:
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  1726
          case WM_MOUSEHWHEEL:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
              mr = WmMouseWheel(GET_KEYSTATE_WPARAM(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
                                GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  1729
                                GET_WHEEL_DELTA_WPARAM(wParam),
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  1730
                                switchMessage == WM_MOUSEHWHEEL);
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  1731
              break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
          break;
47384
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  1734
      case WM_TOUCH:
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  1735
          WmTouch(wParam, lParam);
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  1736
          break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
      case WM_SETCURSOR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
          mr = mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
          if (LOWORD(lParam) == HTCLIENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
              if (AwtComponent* comp =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
                                    AwtComponent::GetComponent((HWND)wParam)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
                  AwtCursor::UpdateCursor(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
                  mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
      case WM_KEYDOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
          mr = WmKeyDown(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
                         LOWORD(lParam), HIWORD(lParam), FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
      case WM_KEYUP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
          mr = WmKeyUp(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
                       LOWORD(lParam), HIWORD(lParam), FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
      case WM_SYSKEYDOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
          mr = WmKeyDown(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
                         LOWORD(lParam), HIWORD(lParam), TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
      case WM_SYSKEYUP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
          mr = WmKeyUp(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
                       LOWORD(lParam), HIWORD(lParam), TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
      case WM_IME_SETCONTEXT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
          // lParam is passed as pointer and it can be modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
          mr = WmImeSetContext(static_cast<BOOL>(wParam), &lParam);
24155
53e618ceb567 8019990: IM candidate window appears on the South-East corner of the display.
bae
parents: 24145
diff changeset
  1767
          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
      case WM_IME_NOTIFY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
          mr = WmImeNotify(wParam, lParam);
24155
53e618ceb567 8019990: IM candidate window appears on the South-East corner of the display.
bae
parents: 24145
diff changeset
  1771
          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
      case WM_IME_STARTCOMPOSITION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
          mr = WmImeStartComposition();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
      case WM_IME_ENDCOMPOSITION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
          mr = WmImeEndComposition();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
      case WM_IME_COMPOSITION: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
          WORD dbcschar = static_cast<WORD>(wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
          mr = WmImeComposition(dbcschar, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
      case WM_IME_CONTROL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
      case WM_IME_COMPOSITIONFULL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
      case WM_IME_SELECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
      case WM_IME_KEYUP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
      case WM_IME_KEYDOWN:
9481
fd8eab58a220 7034291: Regression : Preedit String on active client is committed into unexpected component
dcherepanov
parents: 9476
diff changeset
  1792
      case WM_IME_REQUEST:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
      case WM_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
          mr = WmChar(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
                      LOWORD(lParam), HIWORD(lParam), FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
      case WM_SYSCHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
          mr = WmChar(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
                      LOWORD(lParam), HIWORD(lParam), TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
      case WM_IME_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
          mr = WmIMEChar(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
                         LOWORD(lParam), HIWORD(lParam), FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
      case WM_INPUTLANGCHANGEREQUEST: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
          DTRACE_PRINTLN4("WM_INPUTLANGCHANGEREQUEST: hwnd = 0x%X (%s);"//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
                          "0x%08X -> 0x%08X",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
                          GetHWnd(), GetClassName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
                          (UINT_PTR)GetKeyboardLayout(), (UINT_PTR)lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
          // 4267428: make sure keyboard layout is turned undead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
          static BYTE keyboardState[AwtToolkit::KB_STATE_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
          AwtToolkit::GetKeyboardState(keyboardState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
          WORD ignored;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
          ::ToAsciiEx(VK_SPACE, ::MapVirtualKey(VK_SPACE, 0),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
                      keyboardState, &ignored, 0, GetKeyboardLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
          // Set this flag to block ActivateKeyboardLayout from
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
          // WInputMethod.activate()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
          g_bUserHasChangedInputLang = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
      case WM_INPUTLANGCHANGE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
          DTRACE_PRINTLN3("WM_INPUTLANGCHANGE: hwnd = 0x%X (%s);"//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
                          "new = 0x%08X",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
                          GetHWnd(), GetClassName(), (UINT)lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
          mr = WmInputLangChange(static_cast<UINT>(wParam), reinterpret_cast<HKL>(lParam));
49214
838c11e59a38 8187635: On Windows Swing changes keyboard layout on a window activation
dmarkov
parents: 47830
diff changeset
  1831
          g_bUserHasChangedInputLang = TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
          // should return non-zero if we process this message
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
          retValue = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
      case WM_AWT_FORWARD_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
          mr = WmForwardChar(LOWORD(wParam), lParam, HIWORD(wParam));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
      case WM_AWT_FORWARD_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
          mr = HandleEvent( (MSG *) lParam, (BOOL) wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
      case WM_PASTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
          mr = WmPaste();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
      case WM_TIMER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
          mr = WmTimer(wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
      case WM_COMMAND:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
          mr = WmCommand(LOWORD(wParam), (HWND)lParam, HIWORD(wParam));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
      case WM_COMPAREITEM:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
          mr = WmCompareItem(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
                             *(COMPAREITEMSTRUCT*)lParam, retValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
      case WM_DELETEITEM:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
          mr = WmDeleteItem(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
                            *(DELETEITEMSTRUCT*)lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
      case WM_DRAWITEM:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
          mr = WmDrawItem(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
                          *(DRAWITEMSTRUCT*)lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
      case WM_MEASUREITEM:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
          mr = WmMeasureItem(static_cast<UINT>(wParam),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
                             *(MEASUREITEMSTRUCT*)lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
      case WM_AWT_HANDLE_EVENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
          mr = HandleEvent( (MSG *) lParam, (BOOL) wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
      case WM_PRINT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
          mr = WmPrint((HDC)wParam, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
      case WM_PRINTCLIENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
          mr = WmPrintClient((HDC)wParam, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
      case WM_NCCALCSIZE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
          mr = WmNcCalcSize((BOOL)wParam, (LPNCCALCSIZE_PARAMS)lParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
                            retValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
      case WM_NCPAINT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
          mr = WmNcPaint((HRGN)wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
      case WM_NCHITTEST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
          mr = WmNcHitTest(LOWORD(lParam), HIWORD(lParam), retValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
      case WM_AWT_RESHAPE_COMPONENT: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
          RECT* r = (RECT*)lParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
          WPARAM checkEmbedded = wParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
          if (checkEmbedded == CHECK_EMBEDDED && IsEmbeddedFrame()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
              ::OffsetRect(r, -r->left, -r->top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
          Reshape(r->left, r->top, r->right - r->left, r->bottom - r->top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
          delete r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
          mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
      case WM_AWT_SETALWAYSONTOP: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
        AwtWindow* w = (AwtWindow*)lParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
        BOOL value = (BOOL)wParam;
2646
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2473
diff changeset
  1909
        UINT flags = SWP_NOMOVE | SWP_NOSIZE;
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2473
diff changeset
  1910
        // 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: 2473
diff changeset
  1911
        if (w->IsRetainingHierarchyZOrder()) {
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2473
diff changeset
  1912
            flags |= SWP_NOOWNERZORDER;
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2473
diff changeset
  1913
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
        ::SetWindowPos(w->GetHWnd(), (value != 0 ? HWND_TOPMOST : HWND_NOTOPMOST),
2646
ab13ed73d1f5 6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents: 2473
diff changeset
  1915
                       0,0,0,0, flags);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
      case WM_AWT_BEGIN_VALIDATE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
          BeginValidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
          mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
      case WM_AWT_END_VALIDATE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
          EndValidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
          mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
      case WM_PALETTEISCHANGING:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
          mr = WmPaletteIsChanging((HWND)wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
          mr = mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
      case WM_QUERYNEWPALETTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
          mr = WmQueryNewPalette(retValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
      case WM_PALETTECHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
          mr = WmPaletteChanged((HWND)wParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
      case WM_STYLECHANGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
          mr = WmStyleChanged(static_cast<int>(wParam), (LPSTYLESTRUCT)lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
      case WM_SETTINGCHANGE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
          CheckFontSmoothingSettings(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
          mr = WmSettingChange(static_cast<UINT>(wParam), (LPCTSTR)lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
      case WM_CONTEXTMENU:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
          mr = WmContextMenu((HWND)wParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
                             GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
          /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
           * These messages are used to route Win32 calls to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
           * creating thread, since these calls fail unless executed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
           * there.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
           */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
      case WM_AWT_COMPONENT_SHOW:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
          Show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
          mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
      case WM_AWT_COMPONENT_HIDE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
          Hide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
          mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
      case WM_AWT_COMPONENT_SETFOCUS:
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1965
          if ((BOOL)wParam) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1966
              retValue = SynthesizeWmSetFocus(GetHWnd(), NULL);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1967
          } else {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1968
              retValue = SynthesizeWmKillFocus(GetHWnd(), NULL);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1969
          }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1970
          mr = mrConsume;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1971
          break;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1972
      case WM_AWT_WINDOW_SETACTIVE:
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  1973
          retValue = (LRESULT)((AwtWindow*)this)->AwtSetActiveWindow((BOOL)wParam);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
          mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
      case WM_AWT_SET_SCROLL_INFO: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
          SCROLLINFO *si = (SCROLLINFO *) lParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
          ::SetScrollInfo(GetHWnd(), (int) wParam, si, TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
          delete si;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
          mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
      }
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  1984
      case WM_AWT_CREATE_PRINTED_PIXELS: {
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  1985
          CreatePrintedPixelsStruct* cpps = (CreatePrintedPixelsStruct*)wParam;
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  1986
          SIZE loc = { cpps->srcx, cpps->srcy };
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  1987
          SIZE size = { cpps->srcw, cpps->srch };
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  1988
          retValue = (LRESULT)CreatePrintedPixels(loc, size, cpps->alpha);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
          mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
          break;
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  1991
      }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
      case WM_UNDOCUMENTED_CLICKMENUBAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
          if (::IsWindow(AwtWindow::GetModalBlocker(GetHWnd()))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
              mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
     * If not a specific Consume, it was a specific DoDefault, or a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
     * PassAlong (since the default is the next in chain), then call the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
     * default proc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
    if (mr != mrConsume) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
        retValue = DefWindowProc(message, wParam, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
    return retValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
 * Call this instance's default window proc, or if none set, call the stock
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
 * Window's one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
LRESULT AwtComponent::DefWindowProc(UINT msg, WPARAM wParam, LPARAM lParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
    return ComCtl32Util::GetInstance().DefWindowProc(m_DefWindowProc, GetHWnd(), msg, wParam, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
 * This message should only be received when a window is destroyed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
 * Windows, and not Java.  Window termination has been reworked so
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
 * this method should never be called during termination.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
MsgRouting AwtComponent::WmDestroy()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
{
10689
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2027
    return mrConsume;
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2028
}
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2029
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2030
/*
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2031
 * This message should only be received when a window is destroyed by
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2032
 * Windows, and not Java. It is sent only after child windows were destroyed.
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2033
 */
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2034
MsgRouting AwtComponent::WmNcDestroy()
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2035
{
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2036
    if (m_peerObject != NULL) { // is not being terminating
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2037
        // Stay in this handler until AwtComponent::Dispose is called.
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2038
        m_bPauseDestroy = TRUE;
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2039
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2040
        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2041
        // Post invocation event for WObjectPeer.dispose to EDT
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2042
        env->CallVoidMethod(m_peerObject, AwtComponent::disposeLaterMID);
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2043
        // Wait until AwtComponent::Dispose is called
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  2044
        AwtToolkit::GetInstance().PumpToDestroy(this);
9476
148209fd1cf5 6998716: client vm crashes making browser fails to respond under some scenarios
denis
parents: 7149
diff changeset
  2045
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
MsgRouting AwtComponent::WmGetMinMaxInfo(LPMINMAXINFO lpmmi)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
MsgRouting AwtComponent::WmMove(int x, int y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
    SetDrawState(GetDrawState() | static_cast<jint>(JAWT_LOCK_BOUNDS_CHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
        | static_cast<jint>(JAWT_LOCK_CLIP_CHANGED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
MsgRouting AwtComponent::WmSize(UINT type, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
    SetDrawState(GetDrawState() | static_cast<jint>(JAWT_LOCK_BOUNDS_CHANGED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
        | static_cast<jint>(JAWT_LOCK_CLIP_CHANGED));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
MsgRouting AwtComponent::WmSizing()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
MsgRouting AwtComponent::WmSysCommand(UINT uCmdType, int xPos, int yPos)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
44141
54188c6a042c 8175293: Window size is not updated after setting location to display with different DPI
alexsch
parents: 43822
diff changeset
  2079
MsgRouting AwtComponent::WmEnterSizeMove()
54188c6a042c 8175293: Window size is not updated after setting location to display with different DPI
alexsch
parents: 43822
diff changeset
  2080
{
54188c6a042c 8175293: Window size is not updated after setting location to display with different DPI
alexsch
parents: 43822
diff changeset
  2081
    return mrDoDefault;
54188c6a042c 8175293: Window size is not updated after setting location to display with different DPI
alexsch
parents: 43822
diff changeset
  2082
}
54188c6a042c 8175293: Window size is not updated after setting location to display with different DPI
alexsch
parents: 43822
diff changeset
  2083
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
MsgRouting AwtComponent::WmExitSizeMove()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
MsgRouting AwtComponent::WmEnterMenuLoop(BOOL isTrackPopupMenu)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
MsgRouting AwtComponent::WmExitMenuLoop(BOOL isTrackPopupMenu)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
MsgRouting AwtComponent::WmShowWindow(BOOL show, UINT status)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
MsgRouting AwtComponent::WmSetFocus(HWND hWndLostFocus)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
{
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2106
    m_wheelRotationAmountX = 0;
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2107
    m_wheelRotationAmountY = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
MsgRouting AwtComponent::WmKillFocus(HWND hWndGotFocus)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
{
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2113
    m_wheelRotationAmountX = 0;
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2114
    m_wheelRotationAmountY = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
MsgRouting AwtComponent::WmCtlColor(HDC hDC, HWND hCtrl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
                                    UINT ctlColor, HBRUSH& retBrush)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
    AwtComponent* child = AwtComponent::GetComponent(hCtrl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
    if (child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
        ::SetBkColor(hDC, child->GetBackgroundColor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
        ::SetTextColor(hDC, child->GetColor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
        retBrush = child->GetBackgroundBrush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
        return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
    switch (ctlColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
        case CTLCOLOR_MSGBOX:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
        case CTLCOLOR_EDIT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
        case CTLCOLOR_LISTBOX:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
        case CTLCOLOR_BTN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
        case CTLCOLOR_DLG:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
        case CTLCOLOR_SCROLLBAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
        case CTLCOLOR_STATIC:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
MsgRouting AwtComponent::WmHScroll(UINT scrollCode, UINT pos,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
                                   HWND hScrollbar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
    if (hScrollbar && hScrollbar != GetHWnd()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
        /* the last test should never happen */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
        AwtComponent* sb = GetComponent(hScrollbar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
        if (sb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
            sb->WmHScroll(scrollCode, pos, hScrollbar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
MsgRouting AwtComponent::WmVScroll(UINT scrollCode, UINT pos, HWND hScrollbar)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
    if (hScrollbar && hScrollbar != GetHWnd()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
        /* the last test should never happen */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
        AwtComponent* sb = GetComponent(hScrollbar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2159
        if (sb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2160
            sb->WmVScroll(scrollCode, pos, hScrollbar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2165
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2166
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
MsgRouting AwtComponent::WmPaint(HDC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2168
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2169
    /* Get the rectangle that covers all update regions, if any exist. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2170
    RECT r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
    if (::GetUpdateRect(GetHWnd(), &r, FALSE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2172
        if ((r.right-r.left) > 0 && (r.bottom-r.top) > 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
            m_peerObject != NULL && m_callbacksEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
             * Always call handlePaint, because the underlying control
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2176
             * will have painted itself (the "background") before any
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2177
             * paint method is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
            DoCallback("handlePaint", "(IIII)V",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
                       r.left, r.top, r.right-r.left, r.bottom-r.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
void AwtComponent::PaintUpdateRgn(const RECT *insets)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2187
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2188
    // Fix 4530093: Don't Validate if can't actually paint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2189
    if (m_peerObject == NULL || !m_callbacksEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2190
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 19178
diff changeset
  2191
        // Fix 4745222: If we don't ValidateRgn,  windows will keep sending
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
        // WM_PAINT messages until we do. This causes java to go into
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2193
        // a tight loop that increases CPU to 100% and starves main
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2194
        // thread which needs to complete initialization, but cant.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2195
        ::ValidateRgn(GetHWnd(), NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
    HRGN rgn = ::CreateRectRgn(0,0,1,1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
    int updated = ::GetUpdateRgn(GetHWnd(), rgn, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2203
     * Now remove all update regions from this window -- do it
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
     * here instead of after the Java upcall, in case any new
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2205
     * updating is requested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
    ::ValidateRgn(GetHWnd(), NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
    if (updated == COMPLEXREGION || updated == SIMPLEREGION) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
        if (insets != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2211
            ::OffsetRgn(rgn, insets->left, insets->top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2212
        }
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  2213
        DWORD size = ::GetRegionData(rgn, 0, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
        if (size == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
            ::DeleteObject((HGDIOBJ)rgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
        }
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  2218
        char* buffer = new char[size]; // safe because sizeof(char)==1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2219
        memset(buffer, 0, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
        LPRGNDATA rgndata = (LPRGNDATA)buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
        rgndata->rdh.dwSize = sizeof(RGNDATAHEADER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
        rgndata->rdh.iType = RDH_RECTANGLES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
        int retCode = ::GetRegionData(rgn, size, rgndata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
        VERIFY(retCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
        if (retCode == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
            delete [] buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
            ::DeleteObject((HGDIOBJ)rgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2230
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2231
         * Updating rects are divided into mostly vertical and mostly horizontal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
         * Each group is united together and if not empty painted separately
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2233
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2234
        RECT* r = (RECT*)(buffer + rgndata->rdh.dwSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2235
        RECT* un[2] = {0, 0};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2236
    DWORD i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
    for (i = 0; i < rgndata->rdh.nCount; i++, r++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
            int width = r->right-r->left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2239
            int height = r->bottom-r->top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2240
            if (width > 0 && height > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2241
                int toAdd = (width > height) ? 0: 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2242
                if (un[toAdd] != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2243
                    ::UnionRect(un[toAdd], un[toAdd], r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2244
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2245
                    un[toAdd] = r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2246
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2247
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2249
        for(i = 0; i < 2; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2250
            if (un[i] != 0) {
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  2251
                DoCallback("handleExpose", "(IIII)V",
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  2252
                           ScaleDownX(un[i]->left),
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  2253
                           ScaleDownY(un[i]->top),
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  2254
                           ScaleDownX(un[i]->right - un[i]->left),
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  2255
                           ScaleDownY(un[i]->bottom - un[i]->top));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2256
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2258
        delete [] buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2260
    ::DeleteObject((HGDIOBJ)rgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2261
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2262
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2263
MsgRouting AwtComponent::WmMouseEnter(UINT flags, int x, int y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2264
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2265
    SendMouseEvent(java_awt_event_MouseEvent_MOUSE_ENTERED,
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  2266
                   ::JVM_CurrentTimeMillis(NULL, 0), x, y, GetJavaModifiers(), 0, JNI_FALSE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2267
    if ((flags & ALL_MK_BUTTONS) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2268
        AwtCursor::UpdateCursor(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2270
    sm_cursorOn = GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2271
    return mrConsume;   /* Don't pass our synthetic event on! */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2272
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2273
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2274
MSG*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2275
AwtComponent::CreateMessage(UINT message, WPARAM wParam, LPARAM lParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2276
                            int x = 0, int y = 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2277
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2278
    MSG* pMsg = new MSG;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2279
    InitMessage(pMsg, message, wParam, lParam, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2280
    return pMsg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2281
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2283
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2284
jint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2285
AwtComponent::GetDrawState(HWND hwnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2286
    return (jint)(INT_PTR)(::GetProp(hwnd, DrawingStateProp));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2287
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2288
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2289
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2290
AwtComponent::SetDrawState(HWND hwnd, jint state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2291
    ::SetProp(hwnd, DrawingStateProp, (HANDLE)(INT_PTR)state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2292
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2293
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2294
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2295
AwtComponent::InitMessage(MSG* msg, UINT message, WPARAM wParam, LPARAM lParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2296
                            int x = 0, int y = 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2297
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2298
    msg->message = message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2299
    msg->wParam = wParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2300
    msg->lParam = lParam;
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  2301
    msg->time = ::GetMessageTime();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2302
    msg->pt.x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2303
    msg->pt.y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2304
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2305
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2306
MsgRouting AwtComponent::WmNcMouseDown(WPARAM hitTest, int x, int y, int button) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2307
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2308
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2309
MsgRouting AwtComponent::WmNcMouseUp(WPARAM hitTest, int x, int y, int button) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2310
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2311
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2312
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2313
MsgRouting AwtComponent::WmWindowPosChanging(LPARAM windowPos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2314
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2315
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2316
MsgRouting AwtComponent::WmWindowPosChanged(LPARAM windowPos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2317
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2318
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2319
47384
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2320
void AwtComponent::WmTouch(WPARAM wParam, LPARAM lParam) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2321
    AwtToolkit& tk = AwtToolkit::GetInstance();
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2322
    if (!tk.IsWin8OrLater() || !tk.IsTouchKeyboardAutoShowEnabled()) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2323
        return;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2324
    }
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2325
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2326
    UINT inputsCount = LOWORD(wParam);
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2327
    TOUCHINPUT* pInputs = new TOUCHINPUT[inputsCount];
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2328
    if (pInputs != NULL) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2329
        if (tk.TIGetTouchInputInfo((HTOUCHINPUT)lParam, inputsCount, pInputs,
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2330
                sizeof(TOUCHINPUT)) != 0) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2331
            for (UINT i = 0; i < inputsCount; i++) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2332
                TOUCHINPUT ti = pInputs[i];
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2333
                if (ti.dwFlags & TOUCHEVENTF_PRIMARY) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2334
                    if (ti.dwFlags & TOUCHEVENTF_DOWN) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2335
                        m_touchDownPoint.x = ti.x / 100;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2336
                        m_touchDownPoint.y = ti.y / 100;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2337
                        ::ScreenToClient(GetHWnd(), &m_touchDownPoint);
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2338
                        m_touchDownOccurred = TRUE;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2339
                    } else if (ti.dwFlags & TOUCHEVENTF_UP) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2340
                        m_touchUpPoint.x = ti.x / 100;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2341
                        m_touchUpPoint.y = ti.y / 100;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2342
                        ::ScreenToClient(GetHWnd(), &m_touchUpPoint);
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2343
                        m_touchUpOccurred = TRUE;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2344
                    }
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2345
                }
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2346
            }
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2347
        }
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2348
        delete[] pInputs;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2349
    }
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2350
}
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2351
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2352
/* Double-click variables. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2353
static jlong multiClickTime = ::GetDoubleClickTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2354
static int multiClickMaxX = ::GetSystemMetrics(SM_CXDOUBLECLK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2355
static int multiClickMaxY = ::GetSystemMetrics(SM_CYDOUBLECLK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2356
static AwtComponent* lastClickWnd = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2357
static jlong lastTime = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2358
static int lastClickX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2359
static int lastClickY = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2360
static int lastButton = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2361
static int clickCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2362
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2363
// A static method that makes the clickCount available in the derived classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2364
// overriding WmMouseDown().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2365
int AwtComponent::GetClickCount()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2366
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2367
    return clickCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2368
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2369
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2370
MsgRouting AwtComponent::WmMouseDown(UINT flags, int x, int y, int button)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2371
{
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  2372
    jlong now = ::JVM_CurrentTimeMillis(NULL, 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2373
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2374
    if (lastClickWnd == this &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2375
        lastButton == button &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2376
        (now - lastTime) <= multiClickTime &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2377
        abs(x - lastClickX) <= multiClickMaxX &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2378
        abs(y - lastClickY) <= multiClickMaxY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2379
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2380
        clickCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2381
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2382
        clickCount = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2383
        lastClickWnd = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2384
        lastButton = button;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2385
        lastClickX = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2386
        lastClickY = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2387
    }
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2388
    /*
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2389
     *Set appropriate bit of the mask on WM_MOUSE_DOWN message.
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2390
     */
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2391
    m_mouseButtonClickAllowed |= GetButtonMK(button);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2392
    lastTime = now;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2393
47384
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2394
    BOOL causedByTouchEvent = FALSE;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2395
    if (m_touchDownOccurred &&
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2396
        (abs(m_touchDownPoint.x - x) <= TOUCH_MOUSE_COORDS_DELTA) &&
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2397
        (abs(m_touchDownPoint.y - y) <= TOUCH_MOUSE_COORDS_DELTA)) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2398
        causedByTouchEvent = TRUE;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2399
        m_touchDownOccurred = FALSE;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2400
    }
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2401
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2402
    MSG msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2403
    InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2404
6635
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2405
    AwtWindow *toplevel = GetContainer();
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2406
    if (toplevel && !toplevel->IsSimpleWindow()) {
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2407
        /*
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2408
         * The frame should be focused by click in case it is
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2409
         * the active window but not the focused window. See 6886678.
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2410
         */
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2411
        if (toplevel->GetHWnd() == ::GetActiveWindow() &&
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2412
            toplevel->GetHWnd() != AwtComponent::GetFocusedWindow())
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2413
        {
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2414
            toplevel->AwtSetActiveWindow();
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2415
        }
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2416
    }
74a29718cc9e 6886678: Clicking on parent JFrame's client area does not switch focus from JWindow to JFrame on Windows
ant
parents: 5506
diff changeset
  2417
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2418
    SendMouseEvent(java_awt_event_MouseEvent_MOUSE_PRESSED, now, x, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2419
                   GetJavaModifiers(), clickCount, JNI_FALSE,
47384
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2420
                   GetButton(button), &msg, causedByTouchEvent);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2421
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2422
     * NOTE: this call is intentionally placed after all other code,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2423
     * since AwtComponent::WmMouseDown() assumes that the cached id of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2424
     * latest retrieved message (see lastMessage in awt_Component.cpp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2425
     * matches the mouse message being processed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2426
     * SetCapture() sends WM_CAPTURECHANGED and breaks that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2427
     * assumption.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2428
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2429
    SetDragCapture(flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2430
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2431
    AwtWindow * owner = (AwtWindow*)GetComponent(GetTopLevelParentForWindow(GetHWnd()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2432
    if (AwtWindow::GetGrabbedWindow() != NULL && owner != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2433
        if (!AwtWindow::GetGrabbedWindow()->IsOneOfOwnersOf(owner)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2434
            AwtWindow::GetGrabbedWindow()->Ungrab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2435
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2436
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2437
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2438
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2439
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2440
MsgRouting AwtComponent::WmMouseUp(UINT flags, int x, int y, int button)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2441
{
47384
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2442
    BOOL causedByTouchEvent = FALSE;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2443
    if (m_touchUpOccurred &&
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2444
        (abs(m_touchUpPoint.x - x) <= TOUCH_MOUSE_COORDS_DELTA) &&
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2445
        (abs(m_touchUpPoint.y - y) <= TOUCH_MOUSE_COORDS_DELTA)) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2446
        causedByTouchEvent = TRUE;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2447
        m_touchUpOccurred = FALSE;
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2448
    }
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2449
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2450
    MSG msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2451
    InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2452
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  2453
    SendMouseEvent(java_awt_event_MouseEvent_MOUSE_RELEASED, ::JVM_CurrentTimeMillis(NULL, 0),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2454
                   x, y, GetJavaModifiers(), clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2455
                   (GetButton(button) == java_awt_event_MouseEvent_BUTTON3 ?
47384
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  2456
                    TRUE : FALSE), GetButton(button), &msg, causedByTouchEvent);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2457
    /*
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2458
     * If no movement, then report a click following the button release.
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2459
     * When WM_MOUSEUP comes to a window without previous WM_MOUSEDOWN,
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2460
     * spurous MOUSE_CLICK is about to happen. See 6430553.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2461
     */
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2462
    if ((m_mouseButtonClickAllowed & GetButtonMK(button)) != 0) { //CLICK allowed
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2463
        SendMouseEvent(java_awt_event_MouseEvent_MOUSE_CLICKED,
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  2464
                       ::JVM_CurrentTimeMillis(NULL, 0), x, y, GetJavaModifiers(),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2465
                       clickCount, JNI_FALSE, GetButton(button));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2466
    }
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2467
    // Exclude button from allowed to generate CLICK messages
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2468
    m_mouseButtonClickAllowed &= ~GetButtonMK(button);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2469
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2470
    if ((flags & ALL_MK_BUTTONS) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2471
        // only update if all buttons have been released
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2472
        AwtCursor::UpdateCursor(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2473
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2474
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2475
     * NOTE: this call is intentionally placed after all other code,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2476
     * since AwtComponent::WmMouseUp() assumes that the cached id of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2477
     * latest retrieved message (see lastMessage in awt_Component.cpp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2478
     * matches the mouse message being processed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2479
     * ReleaseCapture() sends WM_CAPTURECHANGED and breaks that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2480
     * assumption.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2481
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2482
    ReleaseDragCapture(flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2483
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2484
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2485
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2486
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2487
MsgRouting AwtComponent::WmMouseMove(UINT flags, int x, int y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2488
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2489
    static AwtComponent* lastComp = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2490
    static int lastX = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2491
    static int lastY = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2492
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2493
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2494
     * Only report mouse move and drag events if a move or drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2495
     * actually happened -- Windows sends a WM_MOUSEMOVE in case the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2496
     * app wants to modify the cursor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2497
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2498
    if (lastComp != this || x != lastX || y != lastY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2499
        lastComp = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2500
        lastX = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2501
        lastY = y;
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2502
        BOOL extraButtonsEnabled = AwtToolkit::GetInstance().areExtraMouseButtonsEnabled();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2503
        if (((flags & (ALL_MK_BUTTONS)) != 0) ||
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2504
            (extraButtonsEnabled && (flags & (X_BUTTONS)) != 0))
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2505
//        if (( extraButtonsEnabled && ( (flags & (ALL_MK_BUTTONS | X_BUTTONS)) != 0 )) ||
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2506
//            ( !extraButtonsEnabled && (((flags & (ALL_MK_BUTTONS)) != 0 )) && ((flags & (X_BUTTONS)) == 0) ))
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2507
        {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2508
            // 6404008 : if Dragged event fired we shouldn't fire
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2509
            // Clicked event: m_firstDragSent set to TRUE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2510
            // This is a partial backout of 5039416 fix.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2511
            MSG msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2512
            InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  2513
            SendMouseEvent(java_awt_event_MouseEvent_MOUSE_DRAGGED, ::JVM_CurrentTimeMillis(NULL, 0), x, y,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2514
                           GetJavaModifiers(), 0, JNI_FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2515
                           java_awt_event_MouseEvent_NOBUTTON, &msg);
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2516
            //dragging means no more CLICKs until next WM_MOUSE_DOWN/WM_MOUSE_UP message sequence
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 441
diff changeset
  2517
            m_mouseButtonClickAllowed = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2518
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2519
            MSG msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2520
            InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  2521
            SendMouseEvent(java_awt_event_MouseEvent_MOUSE_MOVED, ::JVM_CurrentTimeMillis(NULL, 0), x, y,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2522
                           GetJavaModifiers(), 0, JNI_FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2523
                           java_awt_event_MouseEvent_NOBUTTON, &msg);
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
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2528
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2529
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2530
MsgRouting AwtComponent::WmMouseExit(UINT flags, int x, int y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2531
{
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  2532
    SendMouseEvent(java_awt_event_MouseEvent_MOUSE_EXITED, ::JVM_CurrentTimeMillis(NULL, 0), x,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2533
                   y, GetJavaModifiers(), 0, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2534
    sm_cursorOn = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2535
    return mrConsume;   /* Don't pass our synthetic event on! */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2536
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2537
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2538
MsgRouting AwtComponent::WmMouseWheel(UINT flags, int x, int y,
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2539
                                      int wheelRotation, BOOL isHorizontal)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2540
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2541
    // convert coordinates to be Component-relative, not screen relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2542
    // for wheeling when outside the window, this works similar to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2543
    // coordinates during a drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2544
    POINT eventPt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2545
    eventPt.x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2546
    eventPt.y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2547
    DTRACE_PRINT2("  original coords: %i,%i\n", x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2548
    ::ScreenToClient(GetHWnd(), &eventPt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2549
    DTRACE_PRINT2("  new coords: %i,%i\n\n", eventPt.x, eventPt.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2550
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2551
    // set some defaults
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2552
    jint scrollType = java_awt_event_MouseWheelEvent_WHEEL_UNIT_SCROLL;
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2553
    jint scrollUnits = 3;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2554
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2555
    BOOL result;
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2556
    UINT platformUnits;
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2557
    jint roundedWheelRotation;
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2558
    jdouble preciseWheelRotation;
121
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 108
diff changeset
  2559
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2560
    // AWT interprets wheel rotation differently than win32, so we need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2561
    // decode wheel amount.
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2562
    jint modifiers = GetJavaModifiers();
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2563
    if (isHorizontal) {
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2564
        modifiers |= java_awt_event_InputEvent_SHIFT_DOWN_MASK;
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2565
        m_wheelRotationAmountX += wheelRotation;
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2566
        roundedWheelRotation = m_wheelRotationAmountX / (WHEEL_DELTA);
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2567
        preciseWheelRotation = (jdouble) wheelRotation / (WHEEL_DELTA);
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2568
        result = ::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0,
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2569
                                        &platformUnits, 0);
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2570
    } else {
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2571
        m_wheelRotationAmountY += wheelRotation;
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2572
        roundedWheelRotation = m_wheelRotationAmountY / (-1 * WHEEL_DELTA);
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2573
        preciseWheelRotation = (jdouble) wheelRotation / (-1 * WHEEL_DELTA);
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2574
        result = ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2575
                                        &platformUnits, 0);
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2576
    }
121
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 108
diff changeset
  2577
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2578
    MSG msg;
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2579
    InitMessage(&msg, lastMessage, MAKEWPARAM(flags, wheelRotation),
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2580
                MAKELPARAM(x, y));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2581
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2582
    if (result) {
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2583
        if (platformUnits == WHEEL_PAGESCROLL) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2584
            scrollType = java_awt_event_MouseWheelEvent_WHEEL_BLOCK_SCROLL;
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2585
            scrollUnits = 1;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2586
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2587
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2588
            scrollType = java_awt_event_MouseWheelEvent_WHEEL_UNIT_SCROLL;
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2589
            scrollUnits = platformUnits;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2590
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2591
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2592
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2593
    DTRACE_PRINTLN("calling SendMouseWheelEvent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2594
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  2595
    SendMouseWheelEvent(java_awt_event_MouseEvent_MOUSE_WHEEL, ::JVM_CurrentTimeMillis(NULL, 0),
42736
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2596
                        eventPt.x, eventPt.y, modifiers, 0, 0, scrollType,
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2597
                        scrollUnits, roundedWheelRotation, preciseWheelRotation, &msg);
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2598
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2599
    m_wheelRotationAmountX %= WHEEL_DELTA;
860340360c32 4419271: Provide support for scrolling-mechanisms of non-mouse input-devices
serb
parents: 42205
diff changeset
  2600
    m_wheelRotationAmountY %= WHEEL_DELTA;
2469
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents: 2464
diff changeset
  2601
    // this message could be propagated up to the parent chain
c71d7365daf1 6730447: Support for high resolution mouse wheel is still incomplete. AWT panel needs to be supported
dcherepanov
parents: 2464
diff changeset
  2602
    // by the mouse message post processors
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2603
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2604
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2605
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2606
jint AwtComponent::GetKeyLocation(UINT wkey, UINT flags) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2607
    // Rector+Newcomer page 413
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2608
    // The extended keys are the Alt and Control on the right of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2609
    // the space bar, the non-Numpad arrow keys, the non-Numpad
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2610
    // Insert, PageUp, etc. keys, and the Numpad Divide and Enter keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2611
    // Note that neither Shift key is extended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2612
    // Although not listed in Rector+Newcomer, both Windows keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2613
    // (91 and 92) are extended keys, the Context Menu key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2614
    // (property key or application key - 93) is extended,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2615
    // and so is the NumLock key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2616
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2617
    // wkey is the wParam, flags is the HIWORD of the lParam
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2618
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2619
    // "Extended" bit is 24th in lParam, so it's 8th in flags = HIWORD(lParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2620
    BOOL extended = ((1<<8) & flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2621
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2622
    if (IsNumPadKey(wkey, extended)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2623
        return java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2624
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2625
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2626
    switch (wkey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2627
      case VK_SHIFT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2628
        return AwtComponent::GetShiftKeyLocation(wkey, flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2629
      case VK_CONTROL: // fall through
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2630
      case VK_MENU:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2631
        if (extended) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2632
            return java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2633
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2634
            return java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2635
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2636
      case VK_LWIN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2637
        return java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2638
      case VK_RWIN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2639
        return java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2640
      default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2641
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2642
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2643
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2644
    // REMIND: if we add keycodes for the windows keys, we'll have to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2645
    // include left/right discrimination code for them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2646
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2647
    return java_awt_event_KeyEvent_KEY_LOCATION_STANDARD;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2648
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2649
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2650
jint AwtComponent::GetShiftKeyLocation(UINT vkey, UINT flags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2651
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2652
    // init scancodes to safe values
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2653
    UINT leftShiftScancode = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2654
    UINT rightShiftScancode = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2655
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2656
    // First 8 bits of flags is the scancode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2657
    UINT keyScanCode = flags & 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2658
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2659
    DTRACE_PRINTLN3(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2660
      "AwtComponent::GetShiftKeyLocation  vkey = %d = 0x%x  scan = %d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2661
      vkey, vkey, keyScanCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2662
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2663
    leftShiftScancode = ::MapVirtualKey(VK_LSHIFT, 0);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2664
    rightShiftScancode = ::MapVirtualKey(VK_RSHIFT, 0);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2665
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2666
    if (keyScanCode == leftShiftScancode) {
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2667
        return java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2668
    }
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2669
    if (keyScanCode == rightShiftScancode) {
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2670
        return java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2671
    }
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2672
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2673
    DASSERT(false);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2674
    // Note: the above should not fail on NT (or 2000)
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2675
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2676
    // default value
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  2677
    return java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2678
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2679
37572
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2680
/* Returns Java ActionEvent modifieres.
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2681
 * When creating ActionEvent, modifiers provided by ActionEvent
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2682
 * class should be set.
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2683
 */
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2684
jint
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2685
AwtComponent::GetActionModifiers()
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2686
{
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2687
    jint modifiers = GetJavaModifiers();
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2688
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2689
    if (modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK) {
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2690
        modifiers |= java_awt_event_ActionEvent_CTRL_MASK;
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2691
    }
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2692
    if (modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK) {
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2693
        modifiers |= java_awt_event_ActionEvent_SHIFT_MASK;
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2694
    }
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2695
    if (modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK) {
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2696
        modifiers |= java_awt_event_ActionEvent_ALT_MASK;
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2697
    }
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2698
    return modifiers;
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2699
}
7b0c62fdb5d8 6191390: Action Event triggered by list does not reflect the modifiers properly on win32
arapte
parents: 35682
diff changeset
  2700
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2701
/* Returns Java extended InputEvent modifieres.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2702
 * Since ::GetKeyState returns current state and Java modifiers represent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2703
 * state before event, modifier on changed key are inverted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2704
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2705
jint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2706
AwtComponent::GetJavaModifiers()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2707
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2708
    jint modifiers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2709
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2710
    if (HIBYTE(::GetKeyState(VK_CONTROL)) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2711
        modifiers |= java_awt_event_InputEvent_CTRL_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2712
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2713
    if (HIBYTE(::GetKeyState(VK_SHIFT)) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2714
        modifiers |= java_awt_event_InputEvent_SHIFT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2715
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2716
    if (HIBYTE(::GetKeyState(VK_MENU)) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2717
        modifiers |= java_awt_event_InputEvent_ALT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2718
    }
35653
fb6bef1325f9 8041928: MouseEvent.getModifiersEx gives wrong result
ssadetsky
parents: 34394
diff changeset
  2719
    if (HIBYTE(::GetKeyState(VK_RMENU)) != 0) {
fb6bef1325f9 8041928: MouseEvent.getModifiersEx gives wrong result
ssadetsky
parents: 34394
diff changeset
  2720
        modifiers |= java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK;
fb6bef1325f9 8041928: MouseEvent.getModifiersEx gives wrong result
ssadetsky
parents: 34394
diff changeset
  2721
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2722
    if (HIBYTE(::GetKeyState(VK_MBUTTON)) != 0) {
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2723
       modifiers |= java_awt_event_InputEvent_BUTTON2_DOWN_MASK;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2724
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2725
    if (HIBYTE(::GetKeyState(VK_RBUTTON)) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2726
        modifiers |= java_awt_event_InputEvent_BUTTON3_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2727
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2728
    if (HIBYTE(::GetKeyState(VK_LBUTTON)) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2729
        modifiers |= java_awt_event_InputEvent_BUTTON1_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2730
    }
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2731
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2732
    if (HIBYTE(::GetKeyState(VK_XBUTTON1)) != 0) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2733
        modifiers |= masks[3];
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2734
    }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2735
    if (HIBYTE(::GetKeyState(VK_XBUTTON2)) != 0) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2736
        modifiers |= masks[4];
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2737
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2738
    return modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2739
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2740
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2741
jint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2742
AwtComponent::GetButton(int mouseButton)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2743
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2744
    /* Mouse buttons are already set correctly for left/right handedness */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2745
    switch(mouseButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2746
    case LEFT_BUTTON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2747
        return java_awt_event_MouseEvent_BUTTON1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2748
    case MIDDLE_BUTTON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2749
        return java_awt_event_MouseEvent_BUTTON2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2750
    case RIGHT_BUTTON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2751
        return java_awt_event_MouseEvent_BUTTON3;
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2752
    case X1_BUTTON: //16 :
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2753
        //just assign 4 and 5 numbers because MouseEvent class doesn't contain const identifier for them now
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2754
        return 4;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2755
    case X2_BUTTON: //32
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2756
        return 5;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2757
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2758
    return java_awt_event_MouseEvent_NOBUTTON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2759
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2760
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2761
UINT
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2762
AwtComponent::GetButtonMK(int mouseButton)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2763
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2764
    switch(mouseButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2765
    case LEFT_BUTTON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2766
        return MK_LBUTTON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2767
    case MIDDLE_BUTTON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2768
        return MK_MBUTTON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2769
    case RIGHT_BUTTON:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2770
        return MK_RBUTTON;
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2771
    case X1_BUTTON:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2772
        return MK_XBUTTON1;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2773
    case X2_BUTTON:
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2774
        return MK_XBUTTON2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2775
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2776
    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2777
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2778
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2779
// FIXME: Keyboard related stuff has grown so big and hairy that we
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2780
// really need to move it into a class of its own.  And, since
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2781
// keyboard is a shared resource, AwtComponent is a bad place for it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2782
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2783
// These constants are defined in the Japanese version of VC++5.0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2784
// but not the US version
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2785
#ifndef VK_CONVERT
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2786
#define VK_KANA           0x15
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2787
#define VK_KANJI          0x19
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2788
#define VK_CONVERT        0x1C
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2789
#define VK_NONCONVERT     0x1D
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2790
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2791
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2792
#ifndef VK_XBUTTON1
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2793
#define VK_XBUTTON1      0x05
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2794
#endif
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2795
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2796
#ifndef VK_XBUTTON2
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2797
#define VK_XBUTTON2      0x06
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2798
#endif
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  2799
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2800
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2801
    UINT javaKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2802
    UINT windowsKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2803
} KeyMapEntry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2804
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2805
// Static table, arranged more or less spatially.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2806
KeyMapEntry keyMapTable[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2807
    // Modifier keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2808
    {java_awt_event_KeyEvent_VK_CAPS_LOCK,        VK_CAPITAL},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2809
    {java_awt_event_KeyEvent_VK_SHIFT,            VK_SHIFT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2810
    {java_awt_event_KeyEvent_VK_CONTROL,          VK_CONTROL},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2811
    {java_awt_event_KeyEvent_VK_ALT,              VK_MENU},
38403
30fda0459799 8155742: [Windows] robot.keyPress(KeyEvent.VK_ALT_GRAPH) throws java.lang.IllegalArgumentException in windows
arapte
parents: 37572
diff changeset
  2812
    {java_awt_event_KeyEvent_VK_ALT_GRAPH,        VK_RMENU},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2813
    {java_awt_event_KeyEvent_VK_NUM_LOCK,         VK_NUMLOCK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2814
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2815
    // Miscellaneous Windows keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2816
    {java_awt_event_KeyEvent_VK_WINDOWS,          VK_LWIN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2817
    {java_awt_event_KeyEvent_VK_WINDOWS,          VK_RWIN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2818
    {java_awt_event_KeyEvent_VK_CONTEXT_MENU,     VK_APPS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2819
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2820
    // Alphabet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2821
    {java_awt_event_KeyEvent_VK_A,                'A'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2822
    {java_awt_event_KeyEvent_VK_B,                'B'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2823
    {java_awt_event_KeyEvent_VK_C,                'C'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2824
    {java_awt_event_KeyEvent_VK_D,                'D'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2825
    {java_awt_event_KeyEvent_VK_E,                'E'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2826
    {java_awt_event_KeyEvent_VK_F,                'F'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2827
    {java_awt_event_KeyEvent_VK_G,                'G'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2828
    {java_awt_event_KeyEvent_VK_H,                'H'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2829
    {java_awt_event_KeyEvent_VK_I,                'I'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2830
    {java_awt_event_KeyEvent_VK_J,                'J'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2831
    {java_awt_event_KeyEvent_VK_K,                'K'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2832
    {java_awt_event_KeyEvent_VK_L,                'L'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2833
    {java_awt_event_KeyEvent_VK_M,                'M'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2834
    {java_awt_event_KeyEvent_VK_N,                'N'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2835
    {java_awt_event_KeyEvent_VK_O,                'O'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2836
    {java_awt_event_KeyEvent_VK_P,                'P'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2837
    {java_awt_event_KeyEvent_VK_Q,                'Q'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2838
    {java_awt_event_KeyEvent_VK_R,                'R'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2839
    {java_awt_event_KeyEvent_VK_S,                'S'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2840
    {java_awt_event_KeyEvent_VK_T,                'T'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2841
    {java_awt_event_KeyEvent_VK_U,                'U'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2842
    {java_awt_event_KeyEvent_VK_V,                'V'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2843
    {java_awt_event_KeyEvent_VK_W,                'W'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2844
    {java_awt_event_KeyEvent_VK_X,                'X'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2845
    {java_awt_event_KeyEvent_VK_Y,                'Y'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2846
    {java_awt_event_KeyEvent_VK_Z,                'Z'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2847
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2848
    // Standard numeric row
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2849
    {java_awt_event_KeyEvent_VK_0,                '0'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2850
    {java_awt_event_KeyEvent_VK_1,                '1'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2851
    {java_awt_event_KeyEvent_VK_2,                '2'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2852
    {java_awt_event_KeyEvent_VK_3,                '3'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2853
    {java_awt_event_KeyEvent_VK_4,                '4'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2854
    {java_awt_event_KeyEvent_VK_5,                '5'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2855
    {java_awt_event_KeyEvent_VK_6,                '6'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2856
    {java_awt_event_KeyEvent_VK_7,                '7'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2857
    {java_awt_event_KeyEvent_VK_8,                '8'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2858
    {java_awt_event_KeyEvent_VK_9,                '9'},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2859
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2860
    // Misc key from main block
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2861
    {java_awt_event_KeyEvent_VK_ENTER,            VK_RETURN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2862
    {java_awt_event_KeyEvent_VK_SPACE,            VK_SPACE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2863
    {java_awt_event_KeyEvent_VK_BACK_SPACE,       VK_BACK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2864
    {java_awt_event_KeyEvent_VK_TAB,              VK_TAB},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2865
    {java_awt_event_KeyEvent_VK_ESCAPE,           VK_ESCAPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2866
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2867
    // NumPad with NumLock off & extended block (rectangular)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2868
    {java_awt_event_KeyEvent_VK_INSERT,           VK_INSERT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2869
    {java_awt_event_KeyEvent_VK_DELETE,           VK_DELETE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2870
    {java_awt_event_KeyEvent_VK_HOME,             VK_HOME},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2871
    {java_awt_event_KeyEvent_VK_END,              VK_END},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2872
    {java_awt_event_KeyEvent_VK_PAGE_UP,          VK_PRIOR},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2873
    {java_awt_event_KeyEvent_VK_PAGE_DOWN,        VK_NEXT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2874
    {java_awt_event_KeyEvent_VK_CLEAR,            VK_CLEAR}, // NumPad 5
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2875
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2876
    // NumPad with NumLock off & extended arrows block (triangular)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2877
    {java_awt_event_KeyEvent_VK_LEFT,             VK_LEFT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2878
    {java_awt_event_KeyEvent_VK_RIGHT,            VK_RIGHT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2879
    {java_awt_event_KeyEvent_VK_UP,               VK_UP},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2880
    {java_awt_event_KeyEvent_VK_DOWN,             VK_DOWN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2881
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2882
    // NumPad with NumLock on: numbers
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2883
    {java_awt_event_KeyEvent_VK_NUMPAD0,          VK_NUMPAD0},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2884
    {java_awt_event_KeyEvent_VK_NUMPAD1,          VK_NUMPAD1},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2885
    {java_awt_event_KeyEvent_VK_NUMPAD2,          VK_NUMPAD2},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2886
    {java_awt_event_KeyEvent_VK_NUMPAD3,          VK_NUMPAD3},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2887
    {java_awt_event_KeyEvent_VK_NUMPAD4,          VK_NUMPAD4},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2888
    {java_awt_event_KeyEvent_VK_NUMPAD5,          VK_NUMPAD5},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2889
    {java_awt_event_KeyEvent_VK_NUMPAD6,          VK_NUMPAD6},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2890
    {java_awt_event_KeyEvent_VK_NUMPAD7,          VK_NUMPAD7},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2891
    {java_awt_event_KeyEvent_VK_NUMPAD8,          VK_NUMPAD8},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2892
    {java_awt_event_KeyEvent_VK_NUMPAD9,          VK_NUMPAD9},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2893
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2894
    // NumPad with NumLock on
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2895
    {java_awt_event_KeyEvent_VK_MULTIPLY,         VK_MULTIPLY},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2896
    {java_awt_event_KeyEvent_VK_ADD,              VK_ADD},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2897
    {java_awt_event_KeyEvent_VK_SEPARATOR,        VK_SEPARATOR},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2898
    {java_awt_event_KeyEvent_VK_SUBTRACT,         VK_SUBTRACT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2899
    {java_awt_event_KeyEvent_VK_DECIMAL,          VK_DECIMAL},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2900
    {java_awt_event_KeyEvent_VK_DIVIDE,           VK_DIVIDE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2901
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2902
    // Functional keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2903
    {java_awt_event_KeyEvent_VK_F1,               VK_F1},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2904
    {java_awt_event_KeyEvent_VK_F2,               VK_F2},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2905
    {java_awt_event_KeyEvent_VK_F3,               VK_F3},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2906
    {java_awt_event_KeyEvent_VK_F4,               VK_F4},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2907
    {java_awt_event_KeyEvent_VK_F5,               VK_F5},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2908
    {java_awt_event_KeyEvent_VK_F6,               VK_F6},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2909
    {java_awt_event_KeyEvent_VK_F7,               VK_F7},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2910
    {java_awt_event_KeyEvent_VK_F8,               VK_F8},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2911
    {java_awt_event_KeyEvent_VK_F9,               VK_F9},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2912
    {java_awt_event_KeyEvent_VK_F10,              VK_F10},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2913
    {java_awt_event_KeyEvent_VK_F11,              VK_F11},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2914
    {java_awt_event_KeyEvent_VK_F12,              VK_F12},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2915
    {java_awt_event_KeyEvent_VK_F13,              VK_F13},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2916
    {java_awt_event_KeyEvent_VK_F14,              VK_F14},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2917
    {java_awt_event_KeyEvent_VK_F15,              VK_F15},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2918
    {java_awt_event_KeyEvent_VK_F16,              VK_F16},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2919
    {java_awt_event_KeyEvent_VK_F17,              VK_F17},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2920
    {java_awt_event_KeyEvent_VK_F18,              VK_F18},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2921
    {java_awt_event_KeyEvent_VK_F19,              VK_F19},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2922
    {java_awt_event_KeyEvent_VK_F20,              VK_F20},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2923
    {java_awt_event_KeyEvent_VK_F21,              VK_F21},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2924
    {java_awt_event_KeyEvent_VK_F22,              VK_F22},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2925
    {java_awt_event_KeyEvent_VK_F23,              VK_F23},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2926
    {java_awt_event_KeyEvent_VK_F24,              VK_F24},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2927
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2928
    {java_awt_event_KeyEvent_VK_PRINTSCREEN,      VK_SNAPSHOT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2929
    {java_awt_event_KeyEvent_VK_SCROLL_LOCK,      VK_SCROLL},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2930
    {java_awt_event_KeyEvent_VK_PAUSE,            VK_PAUSE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2931
    {java_awt_event_KeyEvent_VK_CANCEL,           VK_CANCEL},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2932
    {java_awt_event_KeyEvent_VK_HELP,             VK_HELP},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2933
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2934
    // Japanese
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2935
    {java_awt_event_KeyEvent_VK_CONVERT,          VK_CONVERT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2936
    {java_awt_event_KeyEvent_VK_NONCONVERT,       VK_NONCONVERT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2937
    {java_awt_event_KeyEvent_VK_INPUT_METHOD_ON_OFF, VK_KANJI},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2938
    {java_awt_event_KeyEvent_VK_ALPHANUMERIC,     VK_DBE_ALPHANUMERIC},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2939
    {java_awt_event_KeyEvent_VK_KATAKANA,         VK_DBE_KATAKANA},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2940
    {java_awt_event_KeyEvent_VK_HIRAGANA,         VK_DBE_HIRAGANA},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2941
    {java_awt_event_KeyEvent_VK_FULL_WIDTH,       VK_DBE_DBCSCHAR},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2942
    {java_awt_event_KeyEvent_VK_HALF_WIDTH,       VK_DBE_SBCSCHAR},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2943
    {java_awt_event_KeyEvent_VK_ROMAN_CHARACTERS, VK_DBE_ROMAN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2944
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2945
    {java_awt_event_KeyEvent_VK_UNDEFINED,        0}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2946
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2947
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2948
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2949
// Dynamic mapping table for OEM VK codes.  This table is refilled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2950
// by BuildDynamicKeyMapTable when keyboard layout is switched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2951
// (see NT4 DDK src/input/inc/vkoem.h for OEM VK_ values).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2952
struct DynamicKeyMapEntry {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2953
    UINT windowsKey;            // OEM VK codes known in advance
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2954
    UINT javaKey;               // depends on input langauge (kbd layout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2955
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2956
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2957
static DynamicKeyMapEntry dynamicKeyMapTable[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2958
    {0x00BA,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2959
    {0x00BB,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_PLUS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2960
    {0x00BC,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_COMMA
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2961
    {0x00BD,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_MINUS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2962
    {0x00BE,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_PERIOD
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2963
    {0x00BF,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2964
    {0x00C0,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2965
    {0x00DB,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2966
    {0x00DC,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_5
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2967
    {0x00DD,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2968
    {0x00DE,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_7
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2969
    {0x00DF,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_8
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2970
    {0x00E2,  java_awt_event_KeyEvent_VK_UNDEFINED}, // VK_OEM_102
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2971
    {0, 0}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2972
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2973
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2974
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2975
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2976
// Auxiliary tables used to fill the above dynamic table.  We first
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2977
// find the character for the OEM VK code using ::MapVirtualKey and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2978
// then go through these auxiliary tables to map it to Java VK code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2979
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2980
struct CharToVKEntry {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2981
    WCHAR c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2982
    UINT  javaKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2983
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2984
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2985
static const CharToVKEntry charToVKTable[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2986
    {L'!',   java_awt_event_KeyEvent_VK_EXCLAMATION_MARK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2987
    {L'"',   java_awt_event_KeyEvent_VK_QUOTEDBL},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2988
    {L'#',   java_awt_event_KeyEvent_VK_NUMBER_SIGN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2989
    {L'$',   java_awt_event_KeyEvent_VK_DOLLAR},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2990
    {L'&',   java_awt_event_KeyEvent_VK_AMPERSAND},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2991
    {L'\'',  java_awt_event_KeyEvent_VK_QUOTE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2992
    {L'(',   java_awt_event_KeyEvent_VK_LEFT_PARENTHESIS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2993
    {L')',   java_awt_event_KeyEvent_VK_RIGHT_PARENTHESIS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2994
    {L'*',   java_awt_event_KeyEvent_VK_ASTERISK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2995
    {L'+',   java_awt_event_KeyEvent_VK_PLUS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2996
    {L',',   java_awt_event_KeyEvent_VK_COMMA},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2997
    {L'-',   java_awt_event_KeyEvent_VK_MINUS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2998
    {L'.',   java_awt_event_KeyEvent_VK_PERIOD},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2999
    {L'/',   java_awt_event_KeyEvent_VK_SLASH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3000
    {L':',   java_awt_event_KeyEvent_VK_COLON},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3001
    {L';',   java_awt_event_KeyEvent_VK_SEMICOLON},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3002
    {L'<',   java_awt_event_KeyEvent_VK_LESS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3003
    {L'=',   java_awt_event_KeyEvent_VK_EQUALS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3004
    {L'>',   java_awt_event_KeyEvent_VK_GREATER},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3005
    {L'@',   java_awt_event_KeyEvent_VK_AT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3006
    {L'[',   java_awt_event_KeyEvent_VK_OPEN_BRACKET},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3007
    {L'\\',  java_awt_event_KeyEvent_VK_BACK_SLASH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3008
    {L']',   java_awt_event_KeyEvent_VK_CLOSE_BRACKET},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3009
    {L'^',   java_awt_event_KeyEvent_VK_CIRCUMFLEX},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3010
    {L'_',   java_awt_event_KeyEvent_VK_UNDERSCORE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3011
    {L'`',   java_awt_event_KeyEvent_VK_BACK_QUOTE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3012
    {L'{',   java_awt_event_KeyEvent_VK_BRACELEFT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3013
    {L'}',   java_awt_event_KeyEvent_VK_BRACERIGHT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3014
    {0x00A1, java_awt_event_KeyEvent_VK_INVERTED_EXCLAMATION_MARK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3015
    {0x20A0, java_awt_event_KeyEvent_VK_EURO_SIGN}, // ????
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3016
    {0,0}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3017
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3018
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3019
// For dead accents some layouts return ASCII punctuation, while some
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3020
// return spacing accent chars, so both should be listed.  NB: MS docs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3021
// say that conversion routings return spacing accent character, not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3022
// combining.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3023
static const CharToVKEntry charToDeadVKTable[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3024
    {L'`',   java_awt_event_KeyEvent_VK_DEAD_GRAVE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3025
    {L'\'',  java_awt_event_KeyEvent_VK_DEAD_ACUTE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3026
    {0x00B4, java_awt_event_KeyEvent_VK_DEAD_ACUTE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3027
    {L'^',   java_awt_event_KeyEvent_VK_DEAD_CIRCUMFLEX},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3028
    {L'~',   java_awt_event_KeyEvent_VK_DEAD_TILDE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3029
    {0x02DC, java_awt_event_KeyEvent_VK_DEAD_TILDE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3030
    {0x00AF, java_awt_event_KeyEvent_VK_DEAD_MACRON},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3031
    {0x02D8, java_awt_event_KeyEvent_VK_DEAD_BREVE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3032
    {0x02D9, java_awt_event_KeyEvent_VK_DEAD_ABOVEDOT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3033
    {L'"',   java_awt_event_KeyEvent_VK_DEAD_DIAERESIS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3034
    {0x00A8, java_awt_event_KeyEvent_VK_DEAD_DIAERESIS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3035
    {0x02DA, java_awt_event_KeyEvent_VK_DEAD_ABOVERING},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3036
    {0x02DD, java_awt_event_KeyEvent_VK_DEAD_DOUBLEACUTE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3037
    {0x02C7, java_awt_event_KeyEvent_VK_DEAD_CARON},            // aka hacek
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3038
    {L',',   java_awt_event_KeyEvent_VK_DEAD_CEDILLA},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3039
    {0x00B8, java_awt_event_KeyEvent_VK_DEAD_CEDILLA},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3040
    {0x02DB, java_awt_event_KeyEvent_VK_DEAD_OGONEK},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3041
    {0x037A, java_awt_event_KeyEvent_VK_DEAD_IOTA},             // ASCII ???
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3042
    {0x309B, java_awt_event_KeyEvent_VK_DEAD_VOICED_SOUND},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3043
    {0x309C, java_awt_event_KeyEvent_VK_DEAD_SEMIVOICED_SOUND},
39525
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3044
    {0x0004, java_awt_event_KeyEvent_VK_COMPOSE},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3045
    {0,0}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3046
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3047
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3048
// The full map of the current keyboard state including
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3049
// windows virtual key, scancode, java virtual key, and unicode
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3050
// for this key sans modifiers.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3051
// All but first element may be 0.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3052
// XXX in the update releases this is an addition to the unchanged existing code
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3053
struct DynPrimaryKeymapEntry {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3054
    UINT wkey;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3055
    UINT scancode;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3056
    UINT jkey;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3057
    WCHAR unicode;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3058
};
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3059
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3060
static DynPrimaryKeymapEntry dynPrimaryKeymap[256];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3062
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3063
AwtComponent::InitDynamicKeyMapTable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3064
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3065
    static BOOL kbdinited = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3066
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3067
    if (!kbdinited) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3068
        AwtComponent::BuildDynamicKeyMapTable();
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3069
        // We cannot build it here since JNI is not available yet:
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3070
        //AwtComponent::BuildPrimaryDynamicTable();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3071
        kbdinited = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3072
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3073
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3074
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3075
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3076
AwtComponent::BuildDynamicKeyMapTable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3077
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3078
    HKL hkl = GetKeyboardLayout();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3079
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3080
    DTRACE_PRINTLN2("Building dynamic VK mapping tables: HKL = %08X (CP%d)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3081
                    hkl, AwtComponent::GetCodePage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3082
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3083
    // Will need this to reset layout after dead keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3084
    UINT spaceScanCode = ::MapVirtualKeyEx(VK_SPACE, 0, hkl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3085
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3086
    // Entries in dynamic table that maps between Java VK and Windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3087
    // VK are built in three steps:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3088
    //   1. Map windows VK to ANSI character (cannot map to unicode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3089
    //      directly, since ::ToUnicode is not implemented on win9x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3090
    //   2. Convert ANSI char to Unicode char
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3091
    //   3. Map Unicode char to Java VK via two auxilary tables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3092
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3093
    for (DynamicKeyMapEntry *dynamic = dynamicKeyMapTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3094
         dynamic->windowsKey != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3095
         ++dynamic)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3096
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3097
        // Defaults to VK_UNDEFINED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3098
        dynamic->javaKey = java_awt_event_KeyEvent_VK_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3099
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3100
        BYTE kbdState[AwtToolkit::KB_STATE_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3101
        AwtToolkit::GetKeyboardState(kbdState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3102
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3103
        kbdState[dynamic->windowsKey] |=  0x80; // Press the key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3104
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3105
        // Unpress modifiers, since they are most likely pressed as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3106
        // part of the keyboard switching shortcut.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3107
        kbdState[VK_CONTROL] &= ~0x80;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3108
        kbdState[VK_SHIFT]   &= ~0x80;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3109
        kbdState[VK_MENU]    &= ~0x80;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3110
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3111
        char cbuf[2] = { '\0', '\0'};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3112
        UINT scancode = ::MapVirtualKeyEx(dynamic->windowsKey, 0, hkl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3113
        int nchars = ::ToAsciiEx(dynamic->windowsKey, scancode, kbdState,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3114
                                 (WORD*)cbuf, 0, hkl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3116
        // Auxiliary table used to map Unicode character to Java VK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3117
        // Will assign a different table for dead keys (below).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3118
        const CharToVKEntry *charMap = charToVKTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3119
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3120
        if (nchars < 0) { // Dead key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3121
            // Use a different table for dead chars since different layouts
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3122
            // return different characters for the same dead key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3123
            charMap = charToDeadVKTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3124
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3125
            // We also need to reset layout so that next translation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3126
            // is unaffected by the dead status.  We do this by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3127
            // translating <SPACE> key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3128
            kbdState[dynamic->windowsKey] &= ~0x80;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3129
            kbdState[VK_SPACE] |= 0x80;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3130
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3131
            char junkbuf[2] = { '\0', '\0'};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3132
            ::ToAsciiEx(VK_SPACE, spaceScanCode, kbdState,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3133
                        (WORD*)junkbuf, 0, hkl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3135
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3136
#ifdef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3137
        if (nchars == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3138
            DTRACE_PRINTLN1("VK 0x%02X -> cannot convert to ANSI char",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3139
                            dynamic->windowsKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3140
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3142
        else if (nchars > 1) {  // can't happen, see reset code below
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3143
            DTRACE_PRINTLN3("VK 0x%02X -> converted to <0x%02X,0x%02X>",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3144
                            dynamic->windowsKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3145
                            (UCHAR)cbuf[0], (UCHAR)cbuf[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3146
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3148
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3149
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3150
        WCHAR ucbuf[2] = { L'\0', L'\0' };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3151
        int nconverted = ::MultiByteToWideChar(AwtComponent::GetCodePage(), 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3152
                                               cbuf, 1, ucbuf, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3153
#ifdef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3154
        if (nconverted < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3155
            DTRACE_PRINTLN3("VK 0x%02X -> ANSI 0x%02X -> MultiByteToWideChar failed (0x%X)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3156
                            dynamic->windowsKey, (UCHAR)cbuf[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3157
                            ::GetLastError());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3158
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3160
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3161
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3162
        WCHAR uc = ucbuf[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3163
        for (const CharToVKEntry *map = charMap;  map->c != 0;  ++map) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3164
            if (uc == map->c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3165
                dynamic->javaKey = map->javaKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3166
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3167
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3169
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3170
        DTRACE_PRINTLN4("VK 0x%02X -> ANSI 0x%02X -> U+%04X -> Java VK 0x%X",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3171
                        dynamic->windowsKey, (UCHAR)cbuf[0], (UINT)ucbuf[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3172
                        dynamic->javaKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3173
    } // for each VK_OEM_*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3174
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3175
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3176
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3177
static BOOL isKanaLockAvailable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3178
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3179
    // This method is to determine whether the Kana Lock feature is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3180
    // available on the attached keyboard.  Kana Lock feature does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3181
    // necessarily require that the real KANA keytop is available on
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3182
    // keyboard, so using MapVirtualKey(VK_KANA) is not sufficient for testing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3183
    // Instead of that we regard it as Japanese keyboard (w/ Kana Lock) if :-
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3184
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3185
    // - the keyboard layout is Japanese (VK_KANA has the same value as VK_HANGUL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3186
    // - the keyboard is Japanese keyboard (keyboard type == 7).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3187
    return (LOWORD(GetKeyboardLayout(0)) == MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3188
        && (GetKeyboardType(0) == 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3189
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3191
void AwtComponent::JavaKeyToWindowsKey(UINT javaKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3192
                                       UINT *windowsKey, UINT *modifiers, UINT originalWindowsKey)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3193
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3194
    // Handle the few cases where a Java VK code corresponds to a Windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3195
    // key/modifier combination or applies only to specific keyboard layouts
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3196
    switch (javaKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3197
        case java_awt_event_KeyEvent_VK_ALL_CANDIDATES:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3198
            *windowsKey = VK_CONVERT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3199
            *modifiers = java_awt_event_InputEvent_ALT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3200
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3201
        case java_awt_event_KeyEvent_VK_PREVIOUS_CANDIDATE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3202
            *windowsKey = VK_CONVERT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3203
            *modifiers = java_awt_event_InputEvent_SHIFT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3204
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3205
        case java_awt_event_KeyEvent_VK_CODE_INPUT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3206
            *windowsKey = VK_DBE_ALPHANUMERIC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3207
            *modifiers = java_awt_event_InputEvent_ALT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3208
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3209
        case java_awt_event_KeyEvent_VK_KANA_LOCK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3210
            if (isKanaLockAvailable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3211
                *windowsKey = VK_KANA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3212
                *modifiers = java_awt_event_InputEvent_CTRL_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3213
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3214
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3217
    // for the general case, use a bi-directional table
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3218
    for (int i = 0; keyMapTable[i].windowsKey != 0; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3219
        if (keyMapTable[i].javaKey == javaKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3220
            *windowsKey = keyMapTable[i].windowsKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3221
            *modifiers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3222
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3225
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3226
    // Bug 4766655
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3227
    // Two Windows keys could map to the same Java key, so
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3228
    // give preference to the originalWindowsKey if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3229
    // specified (not IGNORE_KEY).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3230
    if (originalWindowsKey == IGNORE_KEY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3231
        for (int j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3232
            if (dynamicKeyMapTable[j].javaKey == javaKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3233
                *windowsKey = dynamicKeyMapTable[j].windowsKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3234
                *modifiers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3235
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3236
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3238
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3239
        BOOL found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3240
        for (int j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3241
            if (dynamicKeyMapTable[j].javaKey == javaKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3242
                *windowsKey = dynamicKeyMapTable[j].windowsKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3243
                *modifiers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3244
                found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3245
                if (*windowsKey == originalWindowsKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3246
                    return;   /* if ideal case found return, else keep looking */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3247
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3248
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3250
        if (found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3251
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3254
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3255
    *windowsKey = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3256
    *modifiers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3257
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3258
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3259
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3260
UINT AwtComponent::WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers, UINT character, BOOL isDeadKey)
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3261
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3262
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3263
    // Handle the few cases where we need to take the modifier into
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3264
    // consideration for the Java VK code or where we have to take the keyboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3265
    // layout into consideration so that function keys can get
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3266
    // recognized in a platform-independent way.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3267
    switch (windowsKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3268
        case VK_CONVERT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3269
            if ((modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3270
                return java_awt_event_KeyEvent_VK_ALL_CANDIDATES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3271
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3272
            if ((modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3273
                return java_awt_event_KeyEvent_VK_PREVIOUS_CANDIDATE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3274
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3275
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3276
        case VK_DBE_ALPHANUMERIC:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3277
            if ((modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3278
                return java_awt_event_KeyEvent_VK_CODE_INPUT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3279
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3280
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3281
        case VK_KANA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3282
            if (isKanaLockAvailable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3283
                return java_awt_event_KeyEvent_VK_KANA_LOCK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3284
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3285
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3286
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3287
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3288
    // check dead key
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3289
    if (isDeadKey) {
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3290
      for (int i = 0; charToDeadVKTable[i].c != 0; i++) {
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3291
        if (charToDeadVKTable[i].c == character) {
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3292
            return charToDeadVKTable[i].javaKey;
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3293
        }
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3294
      }
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3295
    }
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3296
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3297
    // for the general case, use a bi-directional table
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3298
    for (int i = 0; keyMapTable[i].windowsKey != 0; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3299
        if (keyMapTable[i].windowsKey == windowsKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3300
            return keyMapTable[i].javaKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3303
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3304
    for (int j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3305
        if (dynamicKeyMapTable[j].windowsKey == windowsKey) {
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3306
            if (dynamicKeyMapTable[j].javaKey != java_awt_event_KeyEvent_VK_UNDEFINED) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3307
                return dynamicKeyMapTable[j].javaKey;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3308
            }else{
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3309
                break;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3310
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3311
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3312
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3313
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3314
    return java_awt_event_KeyEvent_VK_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3315
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3316
636
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3317
BOOL AwtComponent::IsNavigationKey(UINT wkey) {
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3318
    switch (wkey) {
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3319
      case VK_END:
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3320
      case VK_PRIOR:  // PageUp
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3321
      case VK_NEXT:  // PageDown
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3322
      case VK_HOME:
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3323
      case VK_LEFT:
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3324
      case VK_UP:
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3325
      case VK_RIGHT:
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3326
      case VK_DOWN:
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3327
          return TRUE;
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3328
    }
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3329
    return FALSE;
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3330
}
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3331
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3332
// determine if a key is a numpad key (distinguishes the numpad
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3333
// arrow keys from the non-numpad arrow keys, for example).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3334
BOOL AwtComponent::IsNumPadKey(UINT vkey, BOOL extended)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3335
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3336
    // Note: scancodes are the same for the numpad arrow keys and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3337
    // the non-numpad arrow keys (also for PageUp, etc.).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3338
    // The scancodes for the numpad divide and the non-numpad slash
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3339
    // are the same, but the wparams are different
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3340
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3341
    DTRACE_PRINTLN3("AwtComponent::IsNumPadKey  vkey = %d = 0x%x  extended = %d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3342
      vkey, vkey, extended);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3343
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3344
    switch (vkey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3345
      case VK_CLEAR:  // numpad 5 with numlock off
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3346
      case VK_NUMPAD0:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3347
      case VK_NUMPAD1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3348
      case VK_NUMPAD2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3349
      case VK_NUMPAD3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3350
      case VK_NUMPAD4:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3351
      case VK_NUMPAD5:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3352
      case VK_NUMPAD6:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3353
      case VK_NUMPAD7:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3354
      case VK_NUMPAD8:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3355
      case VK_NUMPAD9:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3356
      case VK_MULTIPLY:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3357
      case VK_ADD:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3358
      case VK_SEPARATOR:  // numpad ,  not on US kbds
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3359
      case VK_SUBTRACT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3360
      case VK_DECIMAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3361
      case VK_DIVIDE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3362
      case VK_NUMLOCK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3363
        return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3364
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3365
      case VK_END:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3366
      case VK_PRIOR:  // PageUp
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3367
      case VK_NEXT:  // PageDown
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3368
      case VK_HOME:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3369
      case VK_LEFT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3370
      case VK_UP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3371
      case VK_RIGHT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3372
      case VK_DOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3373
      case VK_INSERT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3374
      case VK_DELETE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3375
        // extended if non-numpad
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3376
        return (!extended);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3377
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3378
      case VK_RETURN:  // extended if on numpad
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3379
        return (extended);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3380
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3381
      default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3382
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3383
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3384
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3385
    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3386
}
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3387
static void
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3388
resetKbdState( BYTE kstate[256]) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3389
    BYTE tmpState[256];
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3390
    WCHAR wc[2];
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3391
    memmove(tmpState, kstate, sizeof(kstate));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3392
    tmpState[VK_SHIFT] = 0;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3393
    tmpState[VK_CONTROL] = 0;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3394
    tmpState[VK_MENU] = 0;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3395
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3396
    ::ToUnicodeEx(VK_SPACE,::MapVirtualKey(VK_SPACE, 0), tmpState, wc, 2, 0,  GetKeyboardLayout(0));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3397
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3398
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3399
// XXX in the update releases this is an addition to the unchanged existing code
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3400
// After the call, a table will have a unicode associated with a windows virtual keycode
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3401
// sans modifiers. With some further simplification, one can
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3402
// derive java keycode from it, and anyway we will pass this unicode value
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3403
// all the way up in a comment to a KeyEvent.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3404
void
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3405
AwtComponent::BuildPrimaryDynamicTable() {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3406
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3407
    // XXX: how about that?
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3408
    //CriticalSection::Lock l(GetLock());
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3409
    //if (GetPeer(env) == NULL) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3410
    //    /* event received during termination. */
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3411
    //    return;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3412
    //}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3413
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3414
    HKL hkl = GetKeyboardLayout();
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3415
    UINT sc = 0;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3416
    BYTE kbdState[AwtToolkit::KB_STATE_SIZE];
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3417
    memset(kbdState, 0, sizeof (kbdState));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3418
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3419
    // Use JNI call to obtain java key code. We should keep a list
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3420
    // of currently available keycodes in a single place.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3421
    static jclass extKeyCodesCls;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3422
    if( extKeyCodesCls == NULL) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3423
        jclass extKeyCodesClsLocal = env->FindClass("sun/awt/ExtendedKeyCodes");
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3424
        DASSERT(extKeyCodesClsLocal);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  3425
        CHECK_NULL(extKeyCodesClsLocal);
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3426
        extKeyCodesCls = (jclass)env->NewGlobalRef(extKeyCodesClsLocal);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3427
        env->DeleteLocalRef(extKeyCodesClsLocal);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3428
    }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3429
    static jmethodID getExtendedKeyCodeForChar;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3430
    if (getExtendedKeyCodeForChar == NULL) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3431
        getExtendedKeyCodeForChar =
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3432
                  env->GetStaticMethodID(extKeyCodesCls, "getExtendedKeyCodeForChar", "(I)I");
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3433
        DASSERT(getExtendedKeyCodeForChar);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  3434
        CHECK_NULL(getExtendedKeyCodeForChar);
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3435
    }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3436
    jint extJKC; //extended Java key code
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3437
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3438
    for (UINT i = 0; i < 256; i++) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3439
        dynPrimaryKeymap[i].wkey = i;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3440
        dynPrimaryKeymap[i].jkey = java_awt_event_KeyEvent_VK_UNDEFINED;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3441
        dynPrimaryKeymap[i].unicode = 0;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3442
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3443
        if ((sc = MapVirtualKey (i, 0)) == 0) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3444
            dynPrimaryKeymap[i].scancode = 0;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3445
            continue;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3446
        }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3447
        dynPrimaryKeymap[i].scancode = sc;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3448
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3449
        // XXX process cases like VK_SHIFT etc.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3450
        kbdState[i] = 0x80; // "key pressed".
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3451
        WCHAR wc[16];
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3452
        int k = ::ToUnicodeEx(i, sc, kbdState, wc, 16, 0, hkl);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3453
        if (k == 1) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3454
            // unicode
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3455
            dynPrimaryKeymap[i].unicode = wc[0];
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3456
            if (dynPrimaryKeymap[i].jkey == java_awt_event_KeyEvent_VK_UNDEFINED) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3457
            // Convert unicode to java keycode.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3458
                //dynPrimaryKeymap[i].jkey = ((UINT)(wc[0]) + 0x01000000);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3459
                //
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3460
                //XXX If this key in on the keypad, we should force a special value equal to
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3461
                //XXX an old java keycode: but how to say if it is a keypad key?
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3462
                //XXX We'll do it in WmKeyUp/Down.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3463
                extJKC = env->CallStaticIntMethod(extKeyCodesCls,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3464
                                                  getExtendedKeyCodeForChar, (jint)(wc[0]));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3465
                dynPrimaryKeymap[i].jkey = extJKC;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3466
            }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3467
        }else if (k == -1) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3468
            // dead key: use charToDeadVKTable
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3469
            dynPrimaryKeymap[i].unicode = wc[0];
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3470
            resetKbdState( kbdState );
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3471
            for (const CharToVKEntry *map = charToDeadVKTable;  map->c != 0;  ++map) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3472
                if (wc[0] == map->c) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3473
                    dynPrimaryKeymap[i].jkey = map->javaKey;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3474
                    break;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3475
                }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3476
            }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3477
        } else if (k == 0) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3478
            // reset
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3479
            resetKbdState( kbdState );
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3480
        }else {
2950
5056d8edd83a 6839645: Swing application prints message in Control Panel if language is changed
yan
parents: 2808
diff changeset
  3481
            // k > 1: this key does generate multiple characters. Ignore it.
5056d8edd83a 6839645: Swing application prints message in Control Panel if language is changed
yan
parents: 2808
diff changeset
  3482
            // An example: Arabic Lam and Alef ligature.
5056d8edd83a 6839645: Swing application prints message in Control Panel if language is changed
yan
parents: 2808
diff changeset
  3483
            // There will be no extended keycode and thus shortcuts for this  key.
5056d8edd83a 6839645: Swing application prints message in Control Panel if language is changed
yan
parents: 2808
diff changeset
  3484
            // XXX shouldn't we reset the kbd state?
5056d8edd83a 6839645: Swing application prints message in Control Panel if language is changed
yan
parents: 2808
diff changeset
  3485
#ifdef DEBUG
5056d8edd83a 6839645: Swing application prints message in Control Panel if language is changed
yan
parents: 2808
diff changeset
  3486
            DTRACE_PRINTLN2("wkey 0x%02X (%d)", i,i);
5056d8edd83a 6839645: Swing application prints message in Control Panel if language is changed
yan
parents: 2808
diff changeset
  3487
#endif
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3488
        }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3489
        kbdState[i] = 0; // "key unpressed"
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3490
    }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3491
}
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3492
void
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3493
AwtComponent::UpdateDynPrimaryKeymap(UINT wkey, UINT jkeyLegacy, jint keyLocation, UINT modifiers)
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3494
{
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3495
    if( wkey && wkey < 256 ) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3496
        if(keyLocation == java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3497
            // At the creation time,
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3498
            // dynPrimaryKeymap cannot distinguish between e.g. "/" and "NumPad /"
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3499
            dynPrimaryKeymap[wkey].jkey = jkeyLegacy;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3500
        }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3501
        if(dynPrimaryKeymap[wkey].jkey ==  java_awt_event_KeyEvent_VK_UNDEFINED) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3502
            // E.g. it is non-unicode key
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3503
            dynPrimaryKeymap[wkey].jkey = jkeyLegacy;
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3504
        }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3505
    }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3506
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3507
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3508
UINT AwtComponent::WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops, BOOL &isDeadKey)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3509
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3510
    static Hashtable transTable("VKEY translations");
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3511
    static Hashtable deadKeyFlagTable("Dead Key Flags");
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3512
    isDeadKey = FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3513
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3514
    // Try to translate using last saved translation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3515
    if (ops == LOAD) {
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3516
       void* deadKeyFlag = deadKeyFlagTable.remove(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3517
       void* value = transTable.remove(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3518
       if (value != NULL) {
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3519
           isDeadKey = static_cast<BOOL>(reinterpret_cast<INT_PTR>(deadKeyFlag));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3520
           return static_cast<UINT>(reinterpret_cast<INT_PTR>(value));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3521
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3522
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3523
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3524
    // If the windows key is a return, wkey will equal 13 ('\r')
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3525
    // In this case, we want to return 10 ('\n')
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3526
    // Since ToAscii would convert VK_RETURN to '\r', we need
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3527
    // to have a special case here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3528
    if (wkey == VK_RETURN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3529
        return '\n';
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3530
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3531
    // high order bit in keyboardState indicates whether the key is down
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3532
    static const BYTE KEY_STATE_DOWN = 0x80;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3533
    BYTE    keyboardState[AwtToolkit::KB_STATE_SIZE];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3534
    AwtToolkit::GetKeyboardState(keyboardState);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3535
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3536
    // apply modifiers to keyboard state if necessary
39525
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3537
    BOOL shiftIsDown = FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3538
    if (modifiers) {
39525
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3539
        shiftIsDown = modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3540
        BOOL altIsDown = modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3541
        BOOL ctrlIsDown = modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3542
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3543
        // Windows treats AltGr as Ctrl+Alt
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3544
        if (modifiers & java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3545
            altIsDown = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3546
            ctrlIsDown = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3547
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3548
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3549
        if (shiftIsDown) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3550
            keyboardState[VK_SHIFT] |= KEY_STATE_DOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3551
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3552
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3553
        // fix for 4623376,4737679,4501485,4740906,4708221 (4173679/4122715)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3554
        // Here we try to resolve a conflict with ::ToAsciiEx's translating
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3555
        // ALT+number key combinations. kdm@sarc.spb.su
636
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3556
        // yan: Do it for navigation keys only, otherwise some AltGr deadkeys fail.
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3557
        if( IsNavigationKey(wkey) ) {
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3558
            keyboardState[VK_MENU] &= ~KEY_STATE_DOWN;
33bcd22c57ff 6253172: Some key characters on none US keyboard cannot be typed since JDK 1.4
yan
parents: 447
diff changeset
  3559
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3560
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3561
        if (ctrlIsDown)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3562
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3563
            if (altIsDown) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3564
                // bugid 4215009: don't mess with AltGr == Ctrl + Alt
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3565
                keyboardState[VK_CONTROL] |= KEY_STATE_DOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3566
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3567
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3568
                // bugid 4098210: old event model doesn't have KEY_TYPED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3569
                // events, so try to provide a meaningful character for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3570
                // Ctrl+<key>.  Take Ctrl into account only when we know
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3571
                // that Ctrl+<key> will be an ASCII control.  Ignore by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3572
                // default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3573
                keyboardState[VK_CONTROL] &= ~KEY_STATE_DOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3574
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3575
                // Letters have Ctrl+<letter> counterparts.  According to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3576
                // <winuser.h> VK_A through VK_Z are the same as ASCII
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3577
                // 'A' through 'Z'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3578
                if (wkey >= 'A' && wkey <= 'Z') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3579
                    keyboardState[VK_CONTROL] |= KEY_STATE_DOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3580
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3581
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3582
                    // Non-letter controls 033 to 037 are:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3583
                    // ^[ (ESC), ^\ (FS), ^] (GS), ^^ (RS), and ^_ (US)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3584
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3585
                    // Shift state bits returned by ::VkKeyScan in HIBYTE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3586
                    static const UINT _VKS_SHIFT_MASK = 0x01;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3587
                    static const UINT _VKS_CTRL_MASK = 0x02;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3588
                    static const UINT _VKS_ALT_MASK = 0x04;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3589
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3590
                    // Check to see whether there is a meaningful translation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3591
                    TCHAR ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3592
                    short vk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3593
                    for (ch = _T('\033'); ch < _T('\040'); ch++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3594
                        vk = ::VkKeyScan(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3595
                        if (wkey == LOBYTE(vk)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3596
                            UINT shiftState = HIBYTE(vk);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3597
                            if ((shiftState & _VKS_CTRL_MASK) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3598
                                (!(shiftState & _VKS_SHIFT_MASK)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3599
                                == !shiftIsDown))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3600
                            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3601
                                keyboardState[VK_CONTROL] |= KEY_STATE_DOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3602
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3603
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3604
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3605
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3606
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3607
            } // ctrlIsDown && altIsDown
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3608
        } // ctrlIsDown
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3609
    } // modifiers
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3610
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3611
    WORD wChar[2];
39525
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3612
    int converted = 1;
42205
9c0dd0361d9d 8169355: Diacritics input works incorrectly on Windows if Spanish (Latin American) keyboard layout is used
dmarkov
parents: 40164
diff changeset
  3613
    UINT ch = ::MapVirtualKeyEx(wkey, 2, GetKeyboardLayout());
39525
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3614
    if (ch & 0x80000000) {
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3615
        // Dead key which is handled as a normal key
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3616
        isDeadKey = deadKeyActive = TRUE;
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3617
    } else if (deadKeyActive) {
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3618
        // We cannot use ::ToUnicodeEx if dead key is active because this will
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3619
        // break dead key function
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3620
        wChar[0] = shiftIsDown ? ch : tolower(ch);
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3621
    } else {
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3622
        UINT scancode = ::MapVirtualKey(wkey, 0);
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3623
        converted = ::ToUnicodeEx(wkey, scancode, keyboardState,
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3624
                                              wChar, 2, 0, GetKeyboardLayout());
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3625
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3626
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3627
    UINT translation;
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3628
    BOOL deadKeyFlag = (converted == 2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3629
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3630
    // Dead Key
39540
c428ada91272 8160623: [PIT] Exception running java/awt/event/KeyEvent/KeyChar/KeyCharTest.java
ssadetsky
parents: 39525
diff changeset
  3631
    if (converted < 0 || isDeadKey) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3632
        translation = java_awt_event_KeyEvent_CHAR_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3633
    } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3634
    // No translation available -- try known conversions or else punt.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3635
    if (converted == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3636
        if (wkey == VK_DELETE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3637
            translation = '\177';
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3638
        } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3639
        if (wkey >= VK_NUMPAD0 && wkey <= VK_NUMPAD9) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3640
            translation = '0' + wkey - VK_NUMPAD0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3641
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3642
            translation = java_awt_event_KeyEvent_CHAR_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3643
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3644
    } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3645
    // the caller expects a Unicode character.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3646
    if (converted > 0) {
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3647
        translation = wChar[0];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3649
    if (ops == SAVE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3650
        transTable.put(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3651
                       reinterpret_cast<void*>(static_cast<INT_PTR>(translation)));
19178
81fa1a77bf7b 8013849: Awt assert on Hashtable.cpp:124
alexsch
parents: 18239
diff changeset
  3652
        if (deadKeyFlag) {
81fa1a77bf7b 8013849: Awt assert on Hashtable.cpp:124
alexsch
parents: 18239
diff changeset
  3653
            deadKeyFlagTable.put(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)),
81fa1a77bf7b 8013849: Awt assert on Hashtable.cpp:124
alexsch
parents: 18239
diff changeset
  3654
                         reinterpret_cast<void*>(static_cast<INT_PTR>(deadKeyFlag)));
81fa1a77bf7b 8013849: Awt assert on Hashtable.cpp:124
alexsch
parents: 18239
diff changeset
  3655
        } else {
81fa1a77bf7b 8013849: Awt assert on Hashtable.cpp:124
alexsch
parents: 18239
diff changeset
  3656
            deadKeyFlagTable.remove(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)));
81fa1a77bf7b 8013849: Awt assert on Hashtable.cpp:124
alexsch
parents: 18239
diff changeset
  3657
        }
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3658
    }
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3659
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3660
    isDeadKey = deadKeyFlag;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3661
    return translation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3662
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3663
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3664
MsgRouting AwtComponent::WmKeyDown(UINT wkey, UINT repCnt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3665
                                   UINT flags, BOOL system)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3666
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3667
    // VK_PROCESSKEY is a special value which means
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3668
    //          "Current IME wants to consume this KeyEvent"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3669
    // Real key code is saved by IMM32.DLL and can be retrieved by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3670
    // calling ImmGetVirtualKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3671
    if (wkey == VK_PROCESSKEY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3672
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3673
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3674
    MSG msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3675
    InitMessage(&msg, (system ? WM_SYSKEYDOWN : WM_KEYDOWN),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3676
                             wkey, MAKELPARAM(repCnt, flags));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3677
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3678
    UINT modifiers = GetJavaModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3679
    jint keyLocation = GetKeyLocation(wkey, flags);
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3680
    BOOL isDeadKey = FALSE;
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3681
    UINT character = WindowsKeyToJavaChar(wkey, modifiers, SAVE, isDeadKey);
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3682
    UINT jkey = WindowsKeyToJavaKey(wkey, modifiers, character, isDeadKey);
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3683
    UpdateDynPrimaryKeymap(wkey, jkey, keyLocation, modifiers);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3684
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3685
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3686
    SendKeyEventToFocusOwner(java_awt_event_KeyEvent_KEY_PRESSED,
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  3687
                             ::JVM_CurrentTimeMillis(NULL, 0), jkey, character,
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3688
                             modifiers, keyLocation, (jlong)wkey, &msg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3689
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3690
    // bugid 4724007: Windows does not create a WM_CHAR for the Del key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3691
    // for some reason, so we need to create the KEY_TYPED event on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3692
    // WM_KEYDOWN.  Use null msg so the character doesn't get sent back
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3693
    // to the native window for processing (this event is synthesized
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3694
    // for Java - we don't want Windows trying to process it).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3695
    if (jkey == java_awt_event_KeyEvent_VK_DELETE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3696
        SendKeyEventToFocusOwner(java_awt_event_KeyEvent_KEY_TYPED,
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  3697
                                 ::JVM_CurrentTimeMillis(NULL, 0),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3698
                                 java_awt_event_KeyEvent_VK_UNDEFINED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3699
                                 character, modifiers,
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3700
                                 java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN, (jlong)0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3701
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3702
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3703
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3704
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3705
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3706
MsgRouting AwtComponent::WmKeyUp(UINT wkey, UINT repCnt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3707
                                 UINT flags, BOOL system)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3708
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3709
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3710
    // VK_PROCESSKEY is a special value which means
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3711
    //          "Current IME wants to consume this KeyEvent"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3712
    // Real key code is saved by IMM32.DLL and can be retrieved by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3713
    // calling ImmGetVirtualKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3714
    if (wkey == VK_PROCESSKEY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3715
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3716
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3717
    MSG msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3718
    InitMessage(&msg, (system ? WM_SYSKEYUP : WM_KEYUP),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3719
                             wkey, MAKELPARAM(repCnt, flags));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3720
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3721
    UINT modifiers = GetJavaModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3722
    jint keyLocation = GetKeyLocation(wkey, flags);
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3723
    BOOL isDeadKey = FALSE;
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3724
    UINT character = WindowsKeyToJavaChar(wkey, modifiers, LOAD, isDeadKey);
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  3725
    UINT jkey = WindowsKeyToJavaKey(wkey, modifiers, character, isDeadKey);
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3726
    UpdateDynPrimaryKeymap(wkey, jkey, keyLocation, modifiers);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3727
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3728
    SendKeyEventToFocusOwner(java_awt_event_KeyEvent_KEY_RELEASED,
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  3729
                             ::JVM_CurrentTimeMillis(NULL, 0), jkey, character,
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3730
                             modifiers, keyLocation, (jlong)wkey, &msg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3731
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3732
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3733
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3734
MsgRouting AwtComponent::WmInputLangChange(UINT charset, HKL hKeyboardLayout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3735
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3736
    // Normally we would be able to use charset and TranslateCharSetInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3737
    // to get a code page that should be associated with this keyboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3738
    // layout change. However, there seems to be an NT 4.0 bug associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3739
    // with the WM_INPUTLANGCHANGE message, which makes the charset parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3740
    // unreliable, especially on Asian systems. Our workaround uses the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3741
    // keyboard layout handle instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3742
    m_hkl = hKeyboardLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3743
    m_idLang = LOWORD(hKeyboardLayout); // lower word of HKL is LANGID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3744
    m_CodePage = LangToCodePage(m_idLang);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3745
    BuildDynamicKeyMapTable();  // compute new mappings for VK_OEM
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3746
    BuildPrimaryDynamicTable();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3747
    return mrConsume;           // do not propagate to children
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3748
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3749
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3750
// Convert Language ID to CodePage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3751
UINT AwtComponent::LangToCodePage(LANGID idLang)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3752
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3753
    TCHAR strCodePage[MAX_ACP_STR_LEN];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3754
    // use the LANGID to create a LCID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3755
    LCID idLocale = MAKELCID(idLang, SORT_DEFAULT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3756
    // get the ANSI code page associated with this locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3757
    if (GetLocaleInfo(idLocale, LOCALE_IDEFAULTANSICODEPAGE, strCodePage, sizeof(strCodePage)/sizeof(TCHAR)) > 0 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3758
        return _ttoi(strCodePage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3759
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3760
        return GetACP();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3761
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3762
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3763
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3764
MsgRouting AwtComponent::WmIMEChar(UINT character, UINT repCnt, UINT flags, BOOL system)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3765
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3766
    // We will simply create Java events here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3767
    WCHAR unicodeChar = character;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3768
    MSG msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3769
    InitMessage(&msg, WM_IME_CHAR, character,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3770
                              MAKELPARAM(repCnt, flags));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3771
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3772
    jint modifiers = GetJavaModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3773
    SendKeyEventToFocusOwner(java_awt_event_KeyEvent_KEY_TYPED,
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  3774
                             ::JVM_CurrentTimeMillis(NULL, 0),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3775
                             java_awt_event_KeyEvent_VK_UNDEFINED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3776
                             unicodeChar, modifiers,
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3777
                             java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN, (jlong)0,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3778
                             &msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3779
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3780
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3781
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3782
MsgRouting AwtComponent::WmChar(UINT character, UINT repCnt, UINT flags,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3783
                                BOOL system)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3784
{
39525
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3785
    deadKeyActive = FALSE;
bc04e7b75111 8139189: Review request for 8139189: VK_OEM_102 dead key detected as VK_UNDEFINED
ssadetsky
parents: 39009
diff changeset
  3786
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3787
    // Will only get WmChar messages with DBCS if we create them for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3788
    // an Edit class in the WmForwardChar method. These synthesized
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3789
    // DBCS chars are ok to pass on directly to the default window
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3790
    // procedure. They've already been filtered through the Java key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3791
    // event queue. We will never get the trail byte since the edit
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3792
    // class will PeekMessage(&msg, hwnd, WM_CHAR, WM_CHAR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3793
    // PM_REMOVE).  I would like to be able to pass this character off
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3794
    // via WM_AWT_FORWARD_BYTE, but the Edit classes don't seem to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3795
    // like that.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3796
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3797
    // We will simply create Java events here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3798
    UINT message = system ? WM_SYSCHAR : WM_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3799
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3800
    // The Alt modifier is reported in the 29th bit of the lParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3801
    // i.e., it is the 13th bit of `flags' (which is HIWORD(lParam)).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3802
    bool alt_is_down = (flags & (1<<13)) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3803
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3804
    // Fix for bug 4141621, corrected by fix for bug 6223726: Alt+space doesn't invoke system menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3805
    // We should not pass this particular combination to Java.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3806
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3807
    if (system && alt_is_down) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3808
        if (character == VK_SPACE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3809
            return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3810
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3811
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3812
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3813
    // If this is a WM_CHAR (non-system) message, then the Alt flag
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3814
    // indicates that the character was typed using an AltGr key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3815
    // (which Windows treats as Ctrl+Alt), so in this case we do NOT
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3816
    // pass the Ctrl and Alt modifiers to Java, but instead we
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3817
    // replace them with Java's AltGraph modifier.  Note: the AltGraph
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3818
    // modifier does not exist in 1.1.x releases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3819
    jint modifiers = GetJavaModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3820
    if (!system && alt_is_down) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3821
        // character typed with AltGraph
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3822
        modifiers &= ~(java_awt_event_InputEvent_ALT_DOWN_MASK
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3823
                       | java_awt_event_InputEvent_CTRL_DOWN_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3824
        modifiers |= java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3825
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3826
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3827
    WCHAR unicodeChar = character;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3828
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3829
    // Kludge: Combine pending single byte with this char for some Chinese IMEs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3830
    if (m_PendingLeadByte != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3831
        character = (m_PendingLeadByte & 0x00ff) | (character << 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3832
        m_PendingLeadByte = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3833
        ::MultiByteToWideChar(GetCodePage(), 0, (CHAR*)&character, 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3834
                          &unicodeChar, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3835
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3836
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3837
    if (unicodeChar == VK_RETURN) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3838
        // Enter key generates \r in windows, but \n is required in java
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3839
        unicodeChar = java_awt_event_KeyEvent_VK_ENTER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3840
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3841
    MSG msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3842
    InitMessage(&msg, message, character,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3843
                              MAKELPARAM(repCnt, flags));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3844
    SendKeyEventToFocusOwner(java_awt_event_KeyEvent_KEY_TYPED,
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  3845
                             ::JVM_CurrentTimeMillis(NULL, 0),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3846
                             java_awt_event_KeyEvent_VK_UNDEFINED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3847
                             unicodeChar, modifiers,
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  3848
                             java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN, (jlong)0,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3849
                             &msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3850
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3851
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3852
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3853
MsgRouting AwtComponent::WmForwardChar(WCHAR character, LPARAM lParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3854
                                       BOOL synthetic)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3855
{
50655
1427a66f7714 8200353: Shift or Capslock not working in Textfield after accented keystrokes
dmarkov
parents: 50005
diff changeset
  3856
    deadKeyActive = FALSE;
1427a66f7714 8200353: Shift or Capslock not working in Textfield after accented keystrokes
dmarkov
parents: 50005
diff changeset
  3857
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  3858
    // just post WM_CHAR with unicode key value
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  3859
    DefWindowProc(WM_CHAR, (WPARAM)character, lParam);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3860
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3861
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3862
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3863
MsgRouting AwtComponent::WmPaste()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3864
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3865
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3866
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3867
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3868
// support IME Composition messages
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3869
void AwtComponent::SetCompositionWindow(RECT& r)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3870
{
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  3871
    HWND hwnd = ImmGetHWnd();
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  3872
    HIMC hIMC = ImmGetContext(hwnd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3873
    if (hIMC == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3874
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3875
    }
5138
29949600bb1f 6907881: Different undesired behavior for entering Asian characters in Windows IME starting with Java 6.0
peytoia
parents: 4834
diff changeset
  3876
    COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}};
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3877
    ImmSetCompositionWindow(hIMC, &cf);
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  3878
    ImmReleaseContext(hwnd, hIMC);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3879
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3880
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3881
void AwtComponent::OpenCandidateWindow(int x, int y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3882
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3883
    UINT bits = 1;
30480
f177387fbfc1 8076455: IME Composition Window is displayed on incorrect position
bae
parents: 30448
diff changeset
  3884
    POINT p = {0, 0}; // upper left corner of the client area
50005
48637783b4f6 8189687: Swing: Invalid position of candidate pop-up of InputMethod in Hi-DPI on Windows
ant
parents: 49303
diff changeset
  3885
    HWND hWnd = ImmGetHWnd();
45348
383dbc53e342 8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents: 44754
diff changeset
  3886
    if (!::IsWindowVisible(hWnd)) {
383dbc53e342 8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents: 44754
diff changeset
  3887
        return;
383dbc53e342 8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents: 44754
diff changeset
  3888
    }
30480
f177387fbfc1 8076455: IME Composition Window is displayed on incorrect position
bae
parents: 30448
diff changeset
  3889
    HWND hTop = GetTopLevelParentForWindow(hWnd);
f177387fbfc1 8076455: IME Composition Window is displayed on incorrect position
bae
parents: 30448
diff changeset
  3890
    ::ClientToScreen(hTop, &p);
50005
48637783b4f6 8189687: Swing: Invalid position of candidate pop-up of InputMethod in Hi-DPI on Windows
ant
parents: 49303
diff changeset
  3891
    int sx = ScaleUpX(x) - p.x;
48637783b4f6 8189687: Swing: Invalid position of candidate pop-up of InputMethod in Hi-DPI on Windows
ant
parents: 49303
diff changeset
  3892
    int sy = ScaleUpY(y) - p.y;
39009
5ca8adb8492c 8147842: IME Composition Window is displayed at incorrect location
ssadetsky
parents: 38403
diff changeset
  3893
    if (!m_bitsCandType) {
50005
48637783b4f6 8189687: Swing: Invalid position of candidate pop-up of InputMethod in Hi-DPI on Windows
ant
parents: 49303
diff changeset
  3894
        SetCandidateWindow(m_bitsCandType, sx, sy);
39009
5ca8adb8492c 8147842: IME Composition Window is displayed at incorrect location
ssadetsky
parents: 38403
diff changeset
  3895
        return;
5ca8adb8492c 8147842: IME Composition Window is displayed at incorrect location
ssadetsky
parents: 38403
diff changeset
  3896
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3897
    for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3898
        if ( m_bitsCandType & bits )
50005
48637783b4f6 8189687: Swing: Invalid position of candidate pop-up of InputMethod in Hi-DPI on Windows
ant
parents: 49303
diff changeset
  3899
            SetCandidateWindow(iCandType, sx, sy);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3900
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3901
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3902
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3903
void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3904
{
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  3905
    HWND hwnd = ImmGetHWnd();
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  3906
    HIMC hIMC = ImmGetContext(hwnd);
47830
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3907
    if (hIMC) {
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3908
        CANDIDATEFORM cf;
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3909
        cf.dwStyle = CFS_POINT;
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3910
        ImmGetCandidateWindow(hIMC, 0, &cf);
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3911
        if (x != cf.ptCurrentPos.x || y != cf.ptCurrentPos.y) {
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3912
            cf.dwIndex = iCandType;
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3913
            cf.dwStyle = CFS_POINT;
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3914
            cf.ptCurrentPos = {x, y};
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3915
            cf.rcArea = {0, 0, 0, 0};
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3916
            ImmSetCandidateWindow(hIMC, &cf);
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3917
        }
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3918
        COMPOSITIONFORM cfr;
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3919
        cfr.dwStyle = CFS_POINT;
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3920
        ImmGetCompositionWindow(hIMC, &cfr);
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3921
        if (x != cfr.ptCurrentPos.x || y != cfr.ptCurrentPos.y) {
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3922
            cfr.dwStyle = CFS_POINT;
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3923
            cfr.ptCurrentPos = {x, y};
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3924
            cfr.rcArea = {0, 0, 0, 0};
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3925
            ImmSetCompositionWindow(hIMC, &cfr);
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3926
        }
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3927
        ImmReleaseContext(hwnd, hIMC);
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3928
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3929
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3930
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3931
MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3932
{
3347
e817b4bb075e 6852429: IME should call ImmIsUIMessage() or DefWindowProc() when it receives WM_IME_SETCONTEX
naoto
parents: 2952
diff changeset
  3933
    // If the Windows input context is disabled, do not let Windows
e817b4bb075e 6852429: IME should call ImmIsUIMessage() or DefWindowProc() when it receives WM_IME_SETCONTEX
naoto
parents: 2952
diff changeset
  3934
    // display any UIs.
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  3935
    HWND hwnd = ImmGetHWnd();
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  3936
    HIMC hIMC = ImmGetContext(hwnd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3937
    if (hIMC == NULL) {
3347
e817b4bb075e 6852429: IME should call ImmIsUIMessage() or DefWindowProc() when it receives WM_IME_SETCONTEX
naoto
parents: 2952
diff changeset
  3938
        *lplParam = 0;
e817b4bb075e 6852429: IME should call ImmIsUIMessage() or DefWindowProc() when it receives WM_IME_SETCONTEX
naoto
parents: 2952
diff changeset
  3939
        return mrDoDefault;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3940
    }
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  3941
    ImmReleaseContext(hwnd, hIMC);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3942
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3943
    if (fSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3944
        LPARAM lParam = *lplParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3945
        if (!m_useNativeCompWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3946
            // stop to draw native composing window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3947
            *lplParam &= ~ISC_SHOWUICOMPOSITIONWINDOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3948
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3949
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3950
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3951
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3952
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3953
MsgRouting AwtComponent::WmImeNotify(WPARAM subMsg, LPARAM bitsCandType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3954
{
39009
5ca8adb8492c 8147842: IME Composition Window is displayed at incorrect location
ssadetsky
parents: 38403
diff changeset
  3955
    if (!m_useNativeCompWindow) {
47830
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3956
        if (subMsg == IMN_OPENCANDIDATE || subMsg == IMN_CHANGECANDIDATE) {
47153
9292a24eb113 8184016: Text in native popup is not always updated with Sogou IME
psadhukhan
parents: 45348
diff changeset
  3957
            m_bitsCandType = bitsCandType;
40164
15ea98f2a6fa 8161195: Regression: closed/javax/swing/text/FlowView/LayoutTest.java
ssadetsky
parents: 39540
diff changeset
  3958
            InquireCandidatePosition();
15ea98f2a6fa 8161195: Regression: closed/javax/swing/text/FlowView/LayoutTest.java
ssadetsky
parents: 39540
diff changeset
  3959
        } else if (subMsg == IMN_OPENSTATUSWINDOW ||
47830
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3960
                   subMsg == WM_IME_STARTCOMPOSITION ||
fd3c961a89ec 8183504: 8u131 Win 10, issue with wrong position of Sogou IME popup
ssadetsky
parents: 47404
diff changeset
  3961
                   subMsg == IMN_SETCANDIDATEPOS) {
47153
9292a24eb113 8184016: Text in native popup is not always updated with Sogou IME
psadhukhan
parents: 45348
diff changeset
  3962
            InquireCandidatePosition();
39009
5ca8adb8492c 8147842: IME Composition Window is displayed at incorrect location
ssadetsky
parents: 38403
diff changeset
  3963
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3964
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3965
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3966
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3967
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3968
MsgRouting AwtComponent::WmImeStartComposition()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3969
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3970
    if (m_useNativeCompWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3971
        RECT rc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3972
        ::GetClientRect(GetHWnd(), &rc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3973
        SetCompositionWindow(rc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3974
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3975
    } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3976
        return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3977
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3978
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3979
MsgRouting AwtComponent::WmImeEndComposition()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3980
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3981
    if (m_useNativeCompWindow)   return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3982
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3983
    SendInputMethodEvent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3984
        java_awt_event_InputMethodEvent_INPUT_METHOD_TEXT_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3985
        NULL, 0, NULL, NULL, 0, NULL, NULL, 0, 0, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3986
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3987
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3988
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3989
MsgRouting AwtComponent::WmImeComposition(WORD wChar, LPARAM flags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3990
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3991
    if (m_useNativeCompWindow)   return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3992
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3993
    int*      bndClauseW = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3994
    jstring*  readingClauseW = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3995
    int*      bndAttrW = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3996
    BYTE*     valAttrW = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3997
    int       cClauseW = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3998
    AwtInputTextInfor* textInfor = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  3999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4000
    try {
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  4001
        HWND hwnd = ImmGetHWnd();
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  4002
        HIMC hIMC = ImmGetContext(hwnd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4003
        DASSERT(hIMC!=0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4004
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4005
        textInfor = new AwtInputTextInfor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4006
        textInfor->GetContextData(hIMC, flags);
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  4007
        ImmReleaseContext(hwnd, hIMC);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4008
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4009
        jstring jtextString = textInfor->GetText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4010
        /* The conditions to send the input method event to AWT EDT are:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4011
           1. Whenever there is a composition message sent regarding whether
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4012
           the composition text is NULL or not. See details at bug 6222692.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4013
           2. When there is a committed message sent, in which case, we have to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4014
           check whether the committed string is NULL or not. If the committed string
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4015
           is NULL, there is no need to send any input method event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4016
           (Minor note: 'jtextString' returned is the merged string in the case of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4017
           partial commit.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4018
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4019
        if ((flags & GCS_RESULTSTR && jtextString != NULL) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4020
            (flags & GCS_COMPSTR)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4021
            int       cursorPosW = textInfor->GetCursorPosition();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4022
            // In order not to delete the readingClauseW in the catch clause,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4023
            // calling GetAttributeInfor before GetClauseInfor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4024
            int       cAttrW = textInfor->GetAttributeInfor(bndAttrW, valAttrW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4025
            cClauseW = textInfor->GetClauseInfor(bndClauseW, readingClauseW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4027
            /* Send INPUT_METHOD_TEXT_CHANGED event to the WInputMethod which in turn sends
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4028
               the event to AWT EDT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4029
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4030
               The last two paremeters are set to equal since we don't have recommendations for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4031
               the visible position within the current composed text. See details at
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4032
               java.awt.event.InputMethodEvent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4033
            */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4034
            SendInputMethodEvent(java_awt_event_InputMethodEvent_INPUT_METHOD_TEXT_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4035
                                 jtextString,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4036
                                 cClauseW, bndClauseW, readingClauseW,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4037
                                 cAttrW, bndAttrW, valAttrW,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4038
                                 textInfor->GetCommittedTextLength(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4039
                                 cursorPosW, cursorPosW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4040
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4041
    } catch (...) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4042
        // since GetClauseInfor and GetAttributeInfor could throw exception, we have to release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4043
        // the pointer here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4044
        delete [] bndClauseW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4045
        delete [] readingClauseW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4046
        delete [] bndAttrW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4047
        delete [] valAttrW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4048
        throw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4049
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4050
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4051
    /* Free the storage allocated. Since jtextString won't be passed from threads
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4052
     *  to threads, we just use the local ref and it will be deleted within the destructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4053
     *  of AwtInputTextInfor object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4054
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4055
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4056
    if (cClauseW && readingClauseW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4057
        for (int i = 0; i < cClauseW; i ++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4058
            if (readingClauseW[i]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4059
                env->DeleteLocalRef(readingClauseW[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4060
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4061
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4062
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4063
    delete [] bndClauseW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4064
    delete [] readingClauseW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4065
    delete [] bndAttrW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4066
    delete [] valAttrW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4067
    delete textInfor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4068
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4069
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4070
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4071
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4072
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4073
// generate and post InputMethodEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4074
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4075
void AwtComponent::SendInputMethodEvent(jint id, jstring text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4076
                                        int cClause, int* rgClauseBoundary, jstring* rgClauseReading,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4077
                                        int cAttrBlock, int* rgAttrBoundary, BYTE *rgAttrValue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4078
                                        int commitedTextLength, int caretPos, int visiblePos)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4079
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4080
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4082
    // assumption for array type casting
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4083
    DASSERT(sizeof(int)==sizeof(jint));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4084
    DASSERT(sizeof(BYTE)==sizeof(jbyte));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4085
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4086
    // caluse information
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4087
    jintArray clauseBoundary = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4088
    jobjectArray clauseReading = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4089
    if (cClause && rgClauseBoundary && rgClauseReading) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4090
        // convert clause boundary offset array to java array
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4091
        clauseBoundary = env->NewIntArray(cClause+1);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4092
        DASSERT(clauseBoundary);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4093
        CHECK_NULL(clauseBoundary);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4094
        env->SetIntArrayRegion(clauseBoundary, 0, cClause+1, (jint *)rgClauseBoundary);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4095
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4096
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4097
        // convert clause reading string array to java array
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4098
        jclass stringCls = JNU_ClassString(env);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4099
        DASSERT(stringCls);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4100
        CHECK_NULL(stringCls);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4101
        clauseReading = env->NewObjectArray(cClause, stringCls, NULL);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4102
        DASSERT(clauseReading);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4103
        CHECK_NULL(clauseReading);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4104
        for (int i=0; i<cClause; i++)   env->SetObjectArrayElement(clauseReading, i, rgClauseReading[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4105
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4107
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4108
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4109
    // attrubute value definition in WInputMethod.java must be equal to that in IMM.H
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4110
    DASSERT(ATTR_INPUT==sun_awt_windows_WInputMethod_ATTR_INPUT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4111
    DASSERT(ATTR_TARGET_CONVERTED==sun_awt_windows_WInputMethod_ATTR_TARGET_CONVERTED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4112
    DASSERT(ATTR_CONVERTED==sun_awt_windows_WInputMethod_ATTR_CONVERTED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4113
    DASSERT(ATTR_TARGET_NOTCONVERTED==sun_awt_windows_WInputMethod_ATTR_TARGET_NOTCONVERTED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4114
    DASSERT(ATTR_INPUT_ERROR==sun_awt_windows_WInputMethod_ATTR_INPUT_ERROR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4116
    // attribute information
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4117
    jintArray attrBoundary = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4118
    jbyteArray attrValue = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4119
    if (cAttrBlock && rgAttrBoundary && rgAttrValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4120
        // convert attribute boundary offset array to java array
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4121
        attrBoundary = env->NewIntArray(cAttrBlock+1);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4122
        DASSERT(attrBoundary);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4123
        CHECK_NULL(attrBoundary);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4124
        env->SetIntArrayRegion(attrBoundary, 0, cAttrBlock+1, (jint *)rgAttrBoundary);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4125
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4126
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4127
        // convert attribute value byte array to java array
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4128
        attrValue = env->NewByteArray(cAttrBlock);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4129
        DASSERT(attrValue);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4130
        CHECK_NULL(attrValue);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4131
        env->SetByteArrayRegion(attrValue, 0, cAttrBlock, (jbyte *)rgAttrValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4132
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4134
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4135
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4136
    // get global reference of WInputMethod class (run only once)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4137
    static jclass wInputMethodCls = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4138
    if (wInputMethodCls == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4139
        jclass wInputMethodClsLocal = env->FindClass("sun/awt/windows/WInputMethod");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4140
        DASSERT(wInputMethodClsLocal);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4141
        CHECK_NULL(wInputMethodClsLocal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4142
        wInputMethodCls = (jclass)env->NewGlobalRef(wInputMethodClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4143
        env->DeleteLocalRef(wInputMethodClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4145
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4146
    // get method ID of sendInputMethodEvent() (run only once)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4147
    static jmethodID sendIMEventMid = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4148
    if (sendIMEventMid == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4149
        sendIMEventMid =  env->GetMethodID(wInputMethodCls, "sendInputMethodEvent",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4150
                                           "(IJLjava/lang/String;[I[Ljava/lang/String;[I[BIII)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4151
        DASSERT(sendIMEventMid);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4152
        CHECK_NULL(sendIMEventMid);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4154
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4155
    // call m_InputMethod.sendInputMethod()
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
  4156
    env->CallVoidMethod(m_InputMethod, sendIMEventMid, id, ::JVM_CurrentTimeMillis(NULL, 0),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4157
                        text, clauseBoundary, clauseReading, attrBoundary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4158
                        attrValue, commitedTextLength, caretPos, visiblePos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4159
    if (safe_ExceptionOccurred(env))   env->ExceptionDescribe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4160
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4161
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4162
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4163
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4164
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4165
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4166
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4167
// Inquires candidate position according to the composed text
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4168
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4169
void AwtComponent::InquireCandidatePosition()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4170
{
45348
383dbc53e342 8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents: 44754
diff changeset
  4171
    if (!::IsWindowVisible(GetHWnd())) {
383dbc53e342 8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents: 44754
diff changeset
  4172
        return;
383dbc53e342 8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents: 44754
diff changeset
  4173
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4174
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4175
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4176
    // get global reference of WInputMethod class (run only once)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4177
    static jclass wInputMethodCls = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4178
    if (wInputMethodCls == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4179
        jclass wInputMethodClsLocal = env->FindClass("sun/awt/windows/WInputMethod");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4180
        DASSERT(wInputMethodClsLocal);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4181
        CHECK_NULL(wInputMethodClsLocal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4182
        wInputMethodCls = (jclass)env->NewGlobalRef(wInputMethodClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4183
        env->DeleteLocalRef(wInputMethodClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4185
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4186
    // get method ID of sendInputMethodEvent() (run only once)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4187
    static jmethodID inqCandPosMid = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4188
    if (inqCandPosMid == 0) {
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4189
        inqCandPosMid =  env->GetMethodID(wInputMethodCls, "inquireCandidatePosition", "()V");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4190
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4191
        DASSERT(inqCandPosMid);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4192
        CHECK_NULL(inqCandPosMid);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4194
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4195
    // call m_InputMethod.sendInputMethod()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4196
    jobject candPos = env->CallObjectMethod(m_InputMethod, inqCandPosMid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4197
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4198
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4199
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  4200
HWND AwtComponent::ImmGetHWnd()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4201
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4202
    HWND proxy = GetProxyFocusOwner();
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  4203
    return (proxy != NULL) ? proxy : GetHWnd();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4204
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4205
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4206
HIMC AwtComponent::ImmAssociateContext(HIMC himc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4207
{
13144
af0989bd5a41 7024749: JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
bagiras
parents: 12817
diff changeset
  4208
    return ::ImmAssociateContext(ImmGetHWnd(), himc);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4209
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4210
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4211
HWND AwtComponent::GetProxyFocusOwner()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4212
{
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4213
    AwtWindow *window = GetContainer();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4214
    if (window != 0) {
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4215
        AwtFrame *owner = window->GetOwningFrameOrDialog();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4216
        if (owner != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4217
            return owner->GetProxyFocusOwner();
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4218
        } else if (!window->IsSimpleWindow()) { // isn't an owned simple window
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4219
            return ((AwtFrame*)window)->GetProxyFocusOwner();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4222
    return (HWND)NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4223
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4224
33249
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents: 32295
diff changeset
  4225
/* Redirects message to the focus proxy, if any */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4226
void AwtComponent::CallProxyDefWindowProc(UINT message, WPARAM wParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4227
    LPARAM lParam, LRESULT &retVal, MsgRouting &mr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4228
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4229
    if (mr != mrConsume)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4230
        HWND proxy = GetProxyFocusOwner();
24155
53e618ceb567 8019990: IM candidate window appears on the South-East corner of the display.
bae
parents: 24145
diff changeset
  4231
        if (proxy != NULL && ::IsWindowEnabled(proxy)) {
39009
5ca8adb8492c 8147842: IME Composition Window is displayed at incorrect location
ssadetsky
parents: 38403
diff changeset
  4232
            retVal = ::DefWindowProc(proxy, message, wParam, lParam);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4233
            mr = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4236
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4237
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4238
MsgRouting AwtComponent::WmCommand(UINT id, HWND hWndChild, UINT notifyCode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4239
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4240
    /* Menu/Accelerator */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4241
    if (hWndChild == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4242
        AwtObject* obj = AwtToolkit::GetInstance().LookupCmdID(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4243
        if (obj == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4244
            return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4246
        DASSERT(((AwtMenuItem*)obj)->GetID() == id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4247
        obj->DoCommand();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4248
        return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4250
    /* Child id notification */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4251
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4252
        AwtComponent* child = AwtComponent::GetComponent(hWndChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4253
        if (child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4254
            child->WmNotify(notifyCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4257
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4258
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4259
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4260
MsgRouting AwtComponent::WmNotify(UINT notifyCode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4261
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4262
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4263
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4264
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4265
MsgRouting AwtComponent::WmCompareItem(UINT ctrlId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4266
                                       COMPAREITEMSTRUCT &compareInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4267
                                       LRESULT &result)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4268
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4269
    AwtComponent* child = AwtComponent::GetComponent(compareInfo.hwndItem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4270
    if (child == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4271
        /* DoCallback("handleItemDelete", */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4273
    else if (child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4274
        return child->WmCompareItem(ctrlId, compareInfo, result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4276
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4277
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4278
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4279
MsgRouting AwtComponent::WmDeleteItem(UINT ctrlId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4280
                                      DELETEITEMSTRUCT &deleteInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4281
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4282
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4283
     * Workaround for NT 4.0 bug -- if SetWindowPos is called on a AwtList
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4284
     * window, a WM_DELETEITEM message is sent to its parent with a window
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4285
     * handle of one of the list's child windows.  The property lookup
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4286
     * succeeds, but the HWNDs don't match.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4287
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4288
    if (deleteInfo.hwndItem == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4289
        return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4291
    AwtComponent* child = (AwtComponent *)AwtComponent::GetComponent(deleteInfo.hwndItem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4292
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4293
    if (child && child->GetHWnd() != deleteInfo.hwndItem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4294
        return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4296
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4297
    if (child == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4298
        /*DoCallback("handleItemDelete", */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4300
    else if (child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4301
        return child->WmDeleteItem(ctrlId, deleteInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4303
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4304
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4305
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4306
MsgRouting AwtComponent::WmDrawItem(UINT ctrlId, DRAWITEMSTRUCT &drawInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4307
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4308
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4309
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4310
    if (drawInfo.CtlType == ODT_MENU) {
44754
cc5c1fb080a3 8167110: Windows peering issue
serb
parents: 44141
diff changeset
  4311
        if (IsMenu((HMENU)drawInfo.hwndItem) && drawInfo.itemData != 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4312
            AwtMenu* menu = (AwtMenu*)(drawInfo.itemData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4313
            menu->DrawItem(drawInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4314
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4315
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4316
        return OwnerDrawItem(ctrlId, drawInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4318
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4319
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4320
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4321
MsgRouting AwtComponent::WmMeasureItem(UINT ctrlId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4322
                                       MEASUREITEMSTRUCT &measureInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4323
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4324
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4325
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4326
    if (measureInfo.CtlType == ODT_MENU) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4327
        if (measureInfo.itemData != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4328
            AwtMenu* menu = (AwtMenu*)(measureInfo.itemData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4329
            HDC hDC = ::GetDC(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4330
            /* menu->MeasureItem(env, hDC, measureInfo); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4331
            menu->MeasureItem(hDC, measureInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4332
            ::ReleaseDC(GetHWnd(), hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4333
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4334
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4335
        return OwnerMeasureItem(ctrlId, measureInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4337
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4338
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4339
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4340
MsgRouting AwtComponent::OwnerDrawItem(UINT ctrlId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4341
    DRAWITEMSTRUCT &drawInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4342
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4343
    AwtComponent* child = AwtComponent::GetComponent(drawInfo.hwndItem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4344
    if (child == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4345
        /* DoCallback("handleItemDelete", */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4346
    } else if (child != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4347
        return child->WmDrawItem(ctrlId, drawInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4349
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4350
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4351
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4352
MsgRouting AwtComponent::OwnerMeasureItem(UINT ctrlId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4353
    MEASUREITEMSTRUCT &measureInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4354
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4355
    HWND  hChild = ::GetDlgItem(GetHWnd(), measureInfo.CtlID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4356
    AwtComponent* child = AwtComponent::GetComponent(hChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4357
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4358
     * If the parent cannot find the child's instance from its handle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4359
     * maybe the child is in its creation.  So the child must be searched
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4360
     * from the list linked before the child's creation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4361
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4362
    if (child == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4363
        child = SearchChild((UINT)ctrlId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4364
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4365
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4366
    if (child == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4367
    /* DoCallback("handleItemDelete",  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4369
    else if (child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4370
        return child->WmMeasureItem(ctrlId, measureInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4372
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4373
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4374
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4375
/* for WmDrawItem method of Label, Button and Checkbox */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4376
void AwtComponent::DrawWindowText(HDC hDC, jobject font, jstring text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4377
                                  int x, int y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4378
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4379
    int nOldBkMode = ::SetBkMode(hDC,TRANSPARENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4380
    DASSERT(nOldBkMode != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4381
    AwtFont::drawMFString(hDC, font, text, x, y, GetCodePage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4382
    VERIFY(::SetBkMode(hDC,nOldBkMode));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4383
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4384
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4385
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4386
 * Draw text in gray (the color being set to COLOR_GRAYTEXT) when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4387
 * component is disabled.  Used only for label, checkbox and button in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4388
 * OWNER_DRAW.  It draws the text in emboss.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4389
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4390
void AwtComponent::DrawGrayText(HDC hDC, jobject font, jstring text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4391
                                int x, int y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4392
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4393
    ::SetTextColor(hDC, ::GetSysColor(COLOR_BTNHILIGHT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4394
    AwtComponent::DrawWindowText(hDC, font, text, x+1, y+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4395
    ::SetTextColor(hDC, ::GetSysColor(COLOR_BTNSHADOW));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4396
    AwtComponent::DrawWindowText(hDC, font, text, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4397
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4398
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4399
/* for WmMeasureItem method of List and Choice */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4400
jstring AwtComponent::GetItemString(JNIEnv *env, jobject target, jint index)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4401
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4402
    jstring str = (jstring)JNU_CallMethodByName(env, NULL, target, "getItemImpl",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4403
                                                "(I)Ljava/lang/String;",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4404
                                                index).l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4405
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4406
    return str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4407
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4408
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4409
/* for WmMeasureItem method of List and Choice */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4410
void AwtComponent::MeasureListItem(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4411
                                   MEASUREITEMSTRUCT &measureInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4412
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4413
    if (env->EnsureLocalCapacity(1) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4414
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4415
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4416
    jobject dimension = PreferredItemSize(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4417
    DASSERT(dimension);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4418
    measureInfo.itemWidth =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4419
      env->GetIntField(dimension, AwtDimension::widthID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4420
    measureInfo.itemHeight =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4421
      env->GetIntField(dimension, AwtDimension::heightID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4422
    env->DeleteLocalRef(dimension);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4423
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4424
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4425
/* for WmDrawItem method of List and Choice */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4426
void AwtComponent::DrawListItem(JNIEnv *env, DRAWITEMSTRUCT &drawInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4427
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4428
    if (env->EnsureLocalCapacity(3) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4429
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4430
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4431
    jobject peer = GetPeer(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4432
    jobject target = env->GetObjectField(peer, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4433
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4434
    HDC hDC = drawInfo.hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4435
    RECT rect = drawInfo.rcItem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4436
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4437
    BOOL bEnabled = isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4438
    BOOL unfocusableChoice = (drawInfo.itemState & ODS_COMBOBOXEDIT) && !IsFocusable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4439
    DWORD crBack, crText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4440
    if (drawInfo.itemState & ODS_SELECTED){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4441
        /* Set background and text colors for selected item */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4442
        crBack = ::GetSysColor (COLOR_HIGHLIGHT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4443
        crText = ::GetSysColor (COLOR_HIGHLIGHTTEXT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4444
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4445
        /* Set background and text colors for unselected item */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4446
        crBack = GetBackgroundColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4447
        crText = bEnabled ? GetColor() : ::GetSysColor(COLOR_GRAYTEXT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4449
    if (unfocusableChoice) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4450
        //6190728. Shouldn't draw selection field (edit control) of an owner-drawn combo box.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4451
        crBack = GetBackgroundColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4452
        crText = bEnabled ? GetColor() : ::GetSysColor(COLOR_GRAYTEXT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4453
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4454
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4455
    /* Fill item rectangle with background color */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4456
    HBRUSH hbrBack = ::CreateSolidBrush (crBack);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4457
    DASSERT(hbrBack);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4458
    /* 6190728. Shouldn't draw any kind of rectangle around selection field
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4459
     * (edit control) of an owner-drawn combo box while unfocusable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4460
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4461
    if (!unfocusableChoice){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4462
        VERIFY(::FillRect (hDC, &rect, hbrBack));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4463
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4464
    VERIFY(::DeleteObject (hbrBack));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4465
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4466
    /* Set current background and text colors */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4467
    ::SetBkColor (hDC, crBack);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4468
    ::SetTextColor (hDC, crText);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4469
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4470
    /*draw string (with left margin of 1 point) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4471
    if ((int) (drawInfo.itemID) >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4472
            jobject font = GET_FONT(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4473
            jstring text = GetItemString(env, target, drawInfo.itemID);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4474
            if (env->ExceptionCheck()) {
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4475
                env->DeleteLocalRef(font);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4476
                env->DeleteLocalRef(target);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4477
                return;
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4478
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4479
            SIZE size = AwtFont::getMFStringSize(hDC, font, text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4480
            AwtFont::drawMFString(hDC, font, text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4481
                                  (GetRTL()) ? rect.right - size.cx - 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4482
                                             : rect.left + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4483
                                  (rect.top + rect.bottom - size.cy) / 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4484
                                  GetCodePage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4485
            env->DeleteLocalRef(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4486
            env->DeleteLocalRef(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4487
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4488
    if ((drawInfo.itemState & ODS_FOCUS)  &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4489
        (drawInfo.itemAction & (ODA_FOCUS | ODA_DRAWENTIRE))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4490
      if (!unfocusableChoice){
30448
b963f710497d 7042645: Numerous api/java_awt jck tests fail - AWT Assertion Failure on fastdebug ri bundles b138 win7 x86
ssadetsky
parents: 27050
diff changeset
  4491
          if(::DrawFocusRect(hDC, &rect) == 0)
b963f710497d 7042645: Numerous api/java_awt jck tests fail - AWT Assertion Failure on fastdebug ri bundles b138 win7 x86
ssadetsky
parents: 27050
diff changeset
  4492
              VERIFY(::GetLastError() == 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4493
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4494
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4495
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4496
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4497
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4498
/* for MeasureListItem method and WmDrawItem method of Checkbox */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4499
jint AwtComponent::GetFontHeight(JNIEnv *env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4500
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4501
    if (env->EnsureLocalCapacity(4) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4502
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4503
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4504
    jobject self = GetPeer(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4505
    jobject target = env->GetObjectField(self, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4506
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4507
    jobject font = GET_FONT(target, self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4508
    jobject toolkit = env->CallObjectMethod(target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4509
                                            AwtComponent::getToolkitMID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4510
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4511
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4512
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4513
    jobject fontMetrics =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4514
        env->CallObjectMethod(toolkit, AwtToolkit::getFontMetricsMID, font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4515
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4516
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4517
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4518
    jint height = env->CallIntMethod(fontMetrics, AwtFont::getHeightMID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4519
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4520
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4521
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4522
    env->DeleteLocalRef(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4523
    env->DeleteLocalRef(toolkit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4524
    env->DeleteLocalRef(fontMetrics);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4525
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4526
    return height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4527
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4528
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4529
// If you override WmPrint, make sure to save a copy of the DC on the GDI
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4530
// stack to be restored in WmPrintClient. Windows mangles the DC in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4531
// ::DefWindowProc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4532
MsgRouting AwtComponent::WmPrint(HDC hDC, LPARAM flags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4533
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4534
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4535
     * DefWindowProc for WM_PRINT changes DC parameters, so we have
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4536
     * to restore it ourselves. Otherwise it will cause problems
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4537
     * when several components are printed to the same DC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4538
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4539
    int nOriginalDC = ::SaveDC(hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4540
    DASSERT(nOriginalDC != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4541
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4542
    if (flags & PRF_NONCLIENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4543
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4544
        VERIFY(::SaveDC(hDC));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4545
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4546
        DefWindowProc(WM_PRINT, (WPARAM)hDC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4547
                      (flags & (PRF_NONCLIENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4548
                                | PRF_CHECKVISIBLE | PRF_ERASEBKGND)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4549
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4550
        VERIFY(::RestoreDC(hDC, -1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4551
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4552
        // Special case for components with a sunken border. Windows does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4553
        // print the border correctly on PCL printers, so we have to do it ourselves.
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  4554
        if (GetStyleEx() & WS_EX_CLIENTEDGE) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4555
            RECT r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4556
            VERIFY(::GetWindowRect(GetHWnd(), &r));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4557
            VERIFY(::OffsetRect(&r, -r.left, -r.top));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4558
            VERIFY(::DrawEdge(hDC, &r, EDGE_SUNKEN, BF_RECT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4560
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4561
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4562
    if (flags & PRF_CLIENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4563
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4564
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4565
         * Special case for components with a sunken border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4566
         * Windows prints a client area without offset to a border width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4567
         * We will first print the non-client area with the original offset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4568
         * then the client area with a corrected offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4569
         */
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  4570
        if (GetStyleEx() & WS_EX_CLIENTEDGE) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4571
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4572
            int nEdgeWidth = ::GetSystemMetrics(SM_CXEDGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4573
            int nEdgeHeight = ::GetSystemMetrics(SM_CYEDGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4574
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4575
            VERIFY(::OffsetWindowOrgEx(hDC, -nEdgeWidth, -nEdgeHeight, NULL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4576
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4577
            // Save a copy of the DC for WmPrintClient
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4578
            VERIFY(::SaveDC(hDC));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4579
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4580
            DefWindowProc(WM_PRINT, (WPARAM) hDC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4581
                          (flags & (PRF_CLIENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4582
                                    | PRF_CHECKVISIBLE | PRF_ERASEBKGND)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4583
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4584
            VERIFY(::OffsetWindowOrgEx(hDC, nEdgeWidth, nEdgeHeight, NULL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4585
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4586
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4587
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4588
            // Save a copy of the DC for WmPrintClient
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4589
            VERIFY(::SaveDC(hDC));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4590
            DefWindowProc(WM_PRINT, (WPARAM) hDC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4591
                          (flags & (PRF_CLIENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4592
                                    | PRF_CHECKVISIBLE | PRF_ERASEBKGND)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4593
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4594
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4595
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4596
    if (flags & (PRF_CHILDREN | PRF_OWNED)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4597
        DefWindowProc(WM_PRINT, (WPARAM) hDC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4598
                      (flags & ~PRF_CLIENT & ~PRF_NONCLIENT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4599
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4600
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4601
    VERIFY(::RestoreDC(hDC, nOriginalDC));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4602
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4603
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4604
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4605
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4606
// If you override WmPrintClient, make sure to obtain a valid copy of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4607
// the DC from the GDI stack. The copy of the DC should have been placed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4608
// there by WmPrint. Windows mangles the DC in ::DefWindowProc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4609
MsgRouting AwtComponent::WmPrintClient(HDC hDC, LPARAM)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4610
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4611
    // obtain valid DC from GDI stack
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4612
    ::RestoreDC(hDC, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4613
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4614
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4615
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4616
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4617
MsgRouting AwtComponent::WmNcCalcSize(BOOL fCalcValidRects,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4618
                                      LPNCCALCSIZE_PARAMS lpncsp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4619
                                      LRESULT &retVal)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4620
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4621
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4622
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4623
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4624
MsgRouting AwtComponent::WmNcPaint(HRGN hrgn)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4625
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4626
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4627
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4628
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4629
MsgRouting AwtComponent::WmNcHitTest(UINT x, UINT y, LRESULT &retVal)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4630
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4631
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4632
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4633
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4634
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4635
 * WmQueryNewPalette is called whenever our component is coming to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4636
 * the foreground; this gives us an opportunity to install our
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4637
 * custom palette.  If this install actually changes entries in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4638
 * the system palette, then we get a further call to WmPaletteChanged
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4639
 * (but note that we only need to realize our palette once).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4640
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4641
MsgRouting AwtComponent::WmQueryNewPalette(LRESULT &retVal)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4642
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4643
    int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4644
    m_QueryNewPaletteCalled = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4645
    HDC hDC = ::GetDC(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4646
    DASSERT(hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4647
    AwtWin32GraphicsDevice::SelectPalette(hDC, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4648
    AwtWin32GraphicsDevice::RealizePalette(hDC, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4649
    ::ReleaseDC(GetHWnd(), hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4650
    // We must realize the palettes of all of our DC's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4651
    // There is sometimes a problem where the realization of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4652
    // our temporary hDC here does not actually do what
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4653
    // we want.  Not clear why, but presumably fallout from
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4654
    // our use of several simultaneous hDC's.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4655
    activeDCList.RealizePalettes(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4656
    // Do not invalidate here; if the palette
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4657
    // has not changed we will get an extra repaint
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4658
    retVal = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4659
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4660
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4661
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4662
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4663
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4664
 * We should not need to track this event since we handle our
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4665
 * palette management effectively in the WmQueryNewPalette and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4666
 * WmPaletteChanged methods.  However, there seems to be a bug
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4667
 * on some win32 systems (e.g., NT4) whereby the palette
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4668
 * immediately after a displayChange is not yet updated to its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4669
 * final post-display-change values (hence we adjust our palette
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4670
 * using the wrong system palette entries), then the palette is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4671
 * updated, but a WM_PALETTECHANGED message is never sent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4672
 * By tracking the ISCHANGING message as well (and by tracking
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4673
 * displayChange events in the AwtToolkit object), we can account
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4674
 * for this error by forcing our WmPaletteChanged method to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4675
 * called and thereby realizing our logical palette and updating
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4676
 * our dynamic colorModel object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4677
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4678
MsgRouting AwtComponent::WmPaletteIsChanging(HWND hwndPalChg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4679
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4680
    if (AwtToolkit::GetInstance().HasDisplayChanged()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4681
        WmPaletteChanged(hwndPalChg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4682
        AwtToolkit::GetInstance().ResetDisplayChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4683
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4684
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4685
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4686
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4687
MsgRouting AwtComponent::WmPaletteChanged(HWND hwndPalChg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4688
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4689
    // We need to re-realize our palette here (unless we're the one
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4690
    // that was realizing it in the first place).  That will let us match the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4691
    // remaining colors in the system palette as best we can.  We always
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4692
    // invalidate because the palette will have changed when we receive this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4693
    // message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4694
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4695
    int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4696
    if (hwndPalChg != GetHWnd()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4697
        HDC hDC = ::GetDC(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4698
        DASSERT(hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4699
        AwtWin32GraphicsDevice::SelectPalette(hDC, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4700
        AwtWin32GraphicsDevice::RealizePalette(hDC, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4701
        ::ReleaseDC(GetHWnd(), hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4702
        // We must realize the palettes of all of our DC's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4703
        activeDCList.RealizePalettes(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4704
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4705
    if (AwtWin32GraphicsDevice::UpdateSystemPalette(screen)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4706
        AwtWin32GraphicsDevice::UpdateDynamicColorModel(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4707
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4708
    Invalidate(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4709
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4710
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4711
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4712
MsgRouting AwtComponent::WmStyleChanged(int wStyleType, LPSTYLESTRUCT lpss)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4713
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4714
    DASSERT(!IsBadReadPtr(lpss, sizeof(STYLESTRUCT)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4715
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4716
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4717
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4718
MsgRouting AwtComponent::WmSettingChange(UINT wFlag, LPCTSTR pszSection)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4719
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4720
    DASSERT(!IsBadStringPtr(pszSection, 20));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4721
    DTRACE_PRINTLN2("WM_SETTINGCHANGE: wFlag=%d pszSection=%s", (int)wFlag, pszSection);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4722
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4723
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4724
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4725
HDC AwtComponent::GetDCFromComponent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4726
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4727
    GetDCReturnStruct *hdcStruct =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4728
        (GetDCReturnStruct*)SendMessage(WM_AWT_GETDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4729
    HDC hdc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4730
    if (hdcStruct) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4731
        if (hdcStruct->gdiLimitReached) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4732
            if (jvm != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4733
                JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4734
                if (env != NULL && !safe_ExceptionOccurred(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4735
                    JNU_ThrowByName(env, "java/awt/AWTError",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4736
                        "HDC creation failure - " \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4737
                        "exceeded maximum GDI resources");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4738
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4739
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4740
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4741
        hdc = hdcStruct->hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4742
        delete hdcStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4743
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4744
        hdc = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4745
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4746
    return hdc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4747
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4748
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4749
void AwtComponent::FillBackground(HDC hMemoryDC, SIZE &size)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4750
{
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4751
    RECT eraseR = { 0, 0, size.cx, size.cy };
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4752
    VERIFY(::FillRect(hMemoryDC, &eraseR, GetBackgroundBrush()));
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4753
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4754
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4755
void AwtComponent::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4756
{
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4757
    if (!bitmapBits) {
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4758
        return;
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4759
    }
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4760
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4761
    DWORD* dest = (DWORD*)bitmapBits;
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4762
    //XXX: might be optimized to use one loop (cy*cx -> 0)
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4763
    for (int i = 0; i < size.cy; i++ ) {
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4764
        for (int j = 0; j < size.cx; j++ ) {
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4765
            ((BYTE*)(dest++))[3] = alpha;
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4766
        }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4767
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4768
}
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  4769
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4770
int AwtComponent::ScaleUpX(int x) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4771
    int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4772
    Devices::InstanceAccess devices;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4773
    AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4774
    return device == NULL ? x : device->ScaleUpX(x);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4775
}
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4776
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4777
int AwtComponent::ScaleUpY(int y) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4778
    int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4779
    Devices::InstanceAccess devices;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4780
    AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4781
    return device == NULL ? y : device->ScaleUpY(y);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4782
}
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4783
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4784
int AwtComponent::ScaleDownX(int x) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4785
    int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4786
    Devices::InstanceAccess devices;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4787
    AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4788
    return device == NULL ? x : device->ScaleDownX(x);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4789
}
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4790
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4791
int AwtComponent::ScaleDownY(int y) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4792
    int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4793
    Devices::InstanceAccess devices;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4794
    AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4795
    return device == NULL ? y : device->ScaleDownY(y);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4796
}
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  4797
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4798
jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4799
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4800
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4801
    if (!::IsWindowVisible(GetHWnd())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4802
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4803
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4804
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4805
    HDC hdc = GetDCFromComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4806
    if (!hdc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4807
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4808
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4809
    HDC hMemoryDC = ::CreateCompatibleDC(hdc);
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4810
    void *bitmapBits = NULL;
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4811
    HBITMAP hBitmap = BitmapUtil::CreateARGBBitmap(size.cx, size.cy, &bitmapBits);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4812
    HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemoryDC, hBitmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4813
    SendMessage(WM_AWT_RELEASEDC, (WPARAM)hdc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4814
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4815
    FillBackground(hMemoryDC, size);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4816
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4817
    VERIFY(::SetWindowOrgEx(hMemoryDC, loc.cx, loc.cy, NULL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4818
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4819
    // Don't bother with PRF_CHECKVISIBLE because we called IsWindowVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4820
    // above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4821
    SendMessage(WM_PRINT, (WPARAM)hMemoryDC, PRF_CLIENT | PRF_NONCLIENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4822
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4823
    // First make sure the system completed any drawing to the bitmap.
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4824
    ::GdiFlush();
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4825
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4826
    // WM_PRINT does not fill the alpha-channel of the ARGB bitmap
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4827
    // leaving it equal to zero. Hence we need to fill it manually. Otherwise
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4828
    // the pixels will be considered transparent when interpreting the data.
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4829
    FillAlpha(bitmapBits, size, alpha);
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  4830
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4831
    ::SelectObject(hMemoryDC, hOldBitmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4832
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4833
    BITMAPINFO bmi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4834
    memset(&bmi, 0, sizeof(BITMAPINFO));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4835
    bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4836
    bmi.bmiHeader.biWidth = size.cx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4837
    bmi.bmiHeader.biHeight = -size.cy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4838
    bmi.bmiHeader.biPlanes = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4839
    bmi.bmiHeader.biBitCount = 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4840
    bmi.bmiHeader.biCompression = BI_RGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4841
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4842
    jobject localPixelArray = env->NewIntArray(size.cx * size.cy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4843
    jintArray pixelArray = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4844
    if (localPixelArray != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4845
        pixelArray = (jintArray)env->NewGlobalRef(localPixelArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4846
        env->DeleteLocalRef(localPixelArray); localPixelArray = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4847
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4848
        jboolean isCopy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4849
        jint *pixels = env->GetIntArrayElements(pixelArray, &isCopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4850
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4851
        ::GetDIBits(hMemoryDC, hBitmap, 0, size.cy, (LPVOID)pixels, &bmi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4852
                    DIB_RGB_COLORS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4853
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4854
        env->ReleaseIntArrayElements(pixelArray, pixels, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4855
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4856
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4857
    VERIFY(::DeleteObject(hBitmap));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4858
    VERIFY(::DeleteDC(hMemoryDC));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4859
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4860
    return pixelArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4861
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4862
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4863
void* AwtComponent::SetNativeFocusOwner(void *self) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4864
    if (self == NULL) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4865
        // It means that the KFM wants to set focus to null
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4866
        sm_focusOwner = NULL;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4867
        return NULL;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4868
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4869
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4870
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4871
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4872
    AwtComponent *c = NULL;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4873
    jobject peer = (jobject)self;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4874
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4875
    PDATA pData;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4876
    JNI_CHECK_NULL_GOTO(peer, "peer", ret);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4877
    pData = JNI_GET_PDATA(peer);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4878
    if (pData == NULL) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4879
        goto ret;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4880
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4881
    c = (AwtComponent *)pData;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4882
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4883
ret:
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4884
    if (c && ::IsWindow(c->GetHWnd())) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4885
        sm_focusOwner = c->GetHWnd();
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4886
    } else {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4887
        sm_focusOwner = NULL;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4888
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4889
    env->DeleteGlobalRef(peer);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4890
    return NULL;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4891
}
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4892
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4893
void* AwtComponent::GetNativeFocusedWindow() {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4894
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4895
    AwtComponent *comp =
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
  4896
        AwtComponent::GetComponent(AwtComponent::GetFocusedWindow());
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4897
    return (comp != NULL) ? comp->GetTargetAsGlobalRef(env) : NULL;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4898
}
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4899
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  4900
void* AwtComponent::GetNativeFocusOwner() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4901
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4902
    AwtComponent *comp =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4903
        AwtComponent::GetComponent(AwtComponent::sm_focusOwner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4904
    return (comp != NULL) ? comp->GetTargetAsGlobalRef(env) : NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4905
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4906
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4907
AwtComponent* AwtComponent::SearchChild(UINT id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4908
    ChildListItem* child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4909
    for (child = m_childList; child != NULL;child = child->m_next) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4910
        if (child->m_ID == id)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4911
            return child->m_Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4912
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4913
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4914
     * DASSERT(FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4915
     * This should not be happend if all children are recorded
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4916
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4917
    return NULL;        /* make compiler happy */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4918
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4919
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4920
void AwtComponent::RemoveChild(UINT id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4921
    ChildListItem* child = m_childList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4922
    ChildListItem* lastChild = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4923
    while (child != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4924
        if (child->m_ID == id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4925
            if (lastChild == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4926
                m_childList = child->m_next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4927
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4928
                lastChild->m_next = child->m_next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4929
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4930
            child->m_next = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4931
            DASSERT(child != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4932
            delete child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4933
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4934
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4935
        lastChild = child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4936
        child = child->m_next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4937
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4938
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4939
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4940
void AwtComponent::SendKeyEvent(jint id, jlong when, jint raw, jint cooked,
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4941
                                jint modifiers, jint keyLocation, jlong nativeCode, MSG *pMsg)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4942
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4943
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4944
    CriticalSection::Lock l(GetLock());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4945
    if (GetPeer(env) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4946
        /* event received during termination. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4947
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4948
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4949
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4950
    static jclass keyEventCls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4951
    if (keyEventCls == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4952
        jclass keyEventClsLocal = env->FindClass("java/awt/event/KeyEvent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4953
        DASSERT(keyEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4954
        if (keyEventClsLocal == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4955
            /* exception already thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4956
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4957
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4958
        keyEventCls = (jclass)env->NewGlobalRef(keyEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4959
        env->DeleteLocalRef(keyEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4960
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4961
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4962
    static jmethodID keyEventConst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4963
    if (keyEventConst == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4964
        keyEventConst =  env->GetMethodID(keyEventCls, "<init>",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4965
                                          "(Ljava/awt/Component;IJIICI)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4966
        DASSERT(keyEventConst);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4967
        CHECK_NULL(keyEventConst);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4968
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4969
    if (env->EnsureLocalCapacity(2) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4970
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4971
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4972
    jobject target = GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4973
    jobject keyEvent = env->NewObject(keyEventCls, keyEventConst, target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4974
                                      id, when, modifiers, raw, cooked,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4975
                                      keyLocation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4976
    if (safe_ExceptionOccurred(env)) env->ExceptionDescribe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4977
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4978
    DASSERT(keyEvent != NULL);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4979
    if (keyEvent == NULL) {
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4980
        env->DeleteLocalRef(target);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4981
        return;
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  4982
    }
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4983
    env->SetLongField(keyEvent, AwtKeyEvent::rawCodeID, nativeCode);
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4984
    if( nativeCode && nativeCode < 256 ) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4985
        env->SetLongField(keyEvent, AwtKeyEvent::primaryLevelUnicodeID, (jlong)(dynPrimaryKeymap[nativeCode].unicode));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4986
        env->SetLongField(keyEvent, AwtKeyEvent::extendedKeyCodeID, (jlong)(dynPrimaryKeymap[nativeCode].jkey));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4987
        if( nativeCode < 255 ) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4988
            env->SetLongField(keyEvent, AwtKeyEvent::scancodeID, (jlong)(dynPrimaryKeymap[nativeCode].scancode));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4989
        }else if( pMsg != NULL ) {
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4990
            // unknown key with virtual keycode 0xFF.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4991
            // Its scancode is not in the table, pickup it from the message.
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4992
            env->SetLongField(keyEvent, AwtKeyEvent::scancodeID, (jlong)(HIWORD(pMsg->lParam) & 0xFF));
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4993
        }
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  4994
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4995
    if (pMsg != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4996
        AwtAWTEvent::saveMSG(env, pMsg, keyEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4997
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4998
    SendEvent(keyEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  4999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5000
    env->DeleteLocalRef(keyEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5001
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5002
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5004
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5005
AwtComponent::SendKeyEventToFocusOwner(jint id, jlong when,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5006
                                       jint raw, jint cooked,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5007
                                       jint modifiers, jint keyLocation,
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  5008
                                       jlong nativeCode,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5009
                                       MSG *msg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5010
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5011
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5012
     * if focus owner is null, but focused window isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5013
     * we will send key event to focused window
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5014
     */
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
  5015
    HWND hwndTarget = ((sm_focusOwner != NULL) ? sm_focusOwner : AwtComponent::GetFocusedWindow());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5016
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5017
    if (hwndTarget == GetHWnd()) {
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  5018
        SendKeyEvent(id, when, raw, cooked, modifiers, keyLocation, nativeCode, msg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5019
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5020
        AwtComponent *target = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5021
        if (hwndTarget != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5022
            target = AwtComponent::GetComponent(hwndTarget);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5023
            if (target == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5024
                target = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5025
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5026
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5027
        if (target != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5028
            target->SendKeyEvent(id, when, raw, cooked, modifiers,
2473
3f4bbd3be2f1 6680988: KeyEvent is still missing VK values for many keyboards
yan
parents: 2472
diff changeset
  5029
              keyLocation, nativeCode, msg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5030
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5031
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5032
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5033
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5034
void AwtComponent::SetDragCapture(UINT flags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5035
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5036
    // don't want to interfere with other controls
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5037
    if (::GetCapture() == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5038
        ::SetCapture(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5039
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5040
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5042
void AwtComponent::ReleaseDragCapture(UINT flags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5043
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5044
    if ((::GetCapture() == GetHWnd()) && ((flags & ALL_MK_BUTTONS) == 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5045
        // user has released all buttons, so release the capture
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5046
        ::ReleaseCapture();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5047
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5048
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5049
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5050
void AwtComponent::SendMouseEvent(jint id, jlong when, jint x, jint y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5051
                                  jint modifiers, jint clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5052
                                  jboolean popupTrigger, jint button,
47384
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  5053
                                  MSG *pMsg, BOOL causedByTouchEvent)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5054
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5055
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5056
    CriticalSection::Lock l(GetLock());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5057
    if (GetPeer(env) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5058
        /* event received during termination. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5059
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5060
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5062
    static jclass mouseEventCls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5063
    if (mouseEventCls == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5064
        jclass mouseEventClsLocal =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5065
            env->FindClass("java/awt/event/MouseEvent");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5066
        CHECK_NULL(mouseEventClsLocal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5067
        mouseEventCls = (jclass)env->NewGlobalRef(mouseEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5068
        env->DeleteLocalRef(mouseEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5069
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5070
    RECT insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5071
    GetInsets(&insets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5072
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5073
    static jmethodID mouseEventConst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5074
    if (mouseEventConst == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5075
        mouseEventConst =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5076
            env->GetMethodID(mouseEventCls, "<init>",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5077
                 "(Ljava/awt/Component;IJIIIIIIZI)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5078
        DASSERT(mouseEventConst);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5079
        CHECK_NULL(mouseEventConst);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5080
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5081
    if (env->EnsureLocalCapacity(2) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5082
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5083
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5084
    jobject target = GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5085
    DWORD curMousePos = ::GetMessagePos();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5086
    int xAbs = GET_X_LPARAM(curMousePos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5087
    int yAbs = GET_Y_LPARAM(curMousePos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5088
    jobject mouseEvent = env->NewObject(mouseEventCls, mouseEventConst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5089
                                        target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5090
                                        id, when, modifiers,
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  5091
                                        ScaleDownX(x + insets.left),
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  5092
                                        ScaleDownY(y + insets.top),
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  5093
                                        ScaleDownX(xAbs), ScaleDownY(yAbs),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5094
                                        clickCount, popupTrigger, button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5095
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5096
    if (safe_ExceptionOccurred(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5097
        env->ExceptionDescribe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5098
        env->ExceptionClear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5099
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5100
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5101
    DASSERT(mouseEvent != NULL);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5102
    CHECK_NULL(mouseEvent);
47384
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  5103
    if (causedByTouchEvent) {
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  5104
        env->SetBooleanField(mouseEvent, AwtMouseEvent::causedByTouchEventID,
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  5105
            JNI_TRUE);
3b244a98d5ab 8166772: Touch keyboard is not shown for text components on a screen touch
alitvinov
parents: 47216
diff changeset
  5106
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5107
    if (pMsg != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5108
        AwtAWTEvent::saveMSG(env, pMsg, mouseEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5110
    SendEvent(mouseEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5111
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5112
    env->DeleteLocalRef(mouseEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5113
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5114
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5116
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5117
AwtComponent::SendMouseWheelEvent(jint id, jlong when, jint x, jint y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5118
                                  jint modifiers, jint clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5119
                                  jboolean popupTrigger, jint scrollType,
121
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 108
diff changeset
  5120
                                  jint scrollAmount, jint roundedWheelRotation,
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 108
diff changeset
  5121
                                  jdouble preciseWheelRotation, MSG *pMsg)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5122
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5123
    /* Code based not so loosely on AwtComponent::SendMouseEvent */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5124
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5125
    CriticalSection::Lock l(GetLock());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5126
    if (GetPeer(env) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5127
        /* event received during termination. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5128
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5130
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5131
    static jclass mouseWheelEventCls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5132
    if (mouseWheelEventCls == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5133
        jclass mouseWheelEventClsLocal =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5134
            env->FindClass("java/awt/event/MouseWheelEvent");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5135
        CHECK_NULL(mouseWheelEventClsLocal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5136
        mouseWheelEventCls = (jclass)env->NewGlobalRef(mouseWheelEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5137
        env->DeleteLocalRef(mouseWheelEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5139
    RECT insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5140
    GetInsets(&insets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5141
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5142
    static jmethodID mouseWheelEventConst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5143
    if (mouseWheelEventConst == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5144
        mouseWheelEventConst =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5145
            env->GetMethodID(mouseWheelEventCls, "<init>",
121
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 108
diff changeset
  5146
                           "(Ljava/awt/Component;IJIIIIIIZIIID)V");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5147
        DASSERT(mouseWheelEventConst);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5148
        CHECK_NULL(mouseWheelEventConst);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5150
    if (env->EnsureLocalCapacity(2) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5151
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5153
    jobject target = GetTarget(env);
32295
5ba453554637 6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents: 30480
diff changeset
  5154
    DWORD curMousePos = ::GetMessagePos();
5ba453554637 6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents: 30480
diff changeset
  5155
    int xAbs = GET_X_LPARAM(curMousePos);
5ba453554637 6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents: 30480
diff changeset
  5156
    int yAbs = GET_Y_LPARAM(curMousePos);
5ba453554637 6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents: 30480
diff changeset
  5157
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5158
    DTRACE_PRINTLN("creating MWE in JNI");
121
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 108
diff changeset
  5159
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5160
    jobject mouseWheelEvent = env->NewObject(mouseWheelEventCls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5161
                                             mouseWheelEventConst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5162
                                             target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5163
                                             id, when, modifiers,
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  5164
                                             ScaleDownX(x + insets.left),
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  5165
                                             ScaleDownY(y + insets.top),
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  5166
                                             ScaleDownX(xAbs),
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  5167
                                             ScaleDownY(yAbs),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5168
                                             clickCount, popupTrigger,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5169
                                             scrollType, scrollAmount,
121
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 108
diff changeset
  5170
                                             roundedWheelRotation, preciseWheelRotation);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5171
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5172
    DASSERT(mouseWheelEvent != NULL);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5173
    if (mouseWheelEvent == NULL || safe_ExceptionOccurred(env)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5174
        env->ExceptionDescribe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5175
        env->ExceptionClear();
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5176
        env->DeleteLocalRef(target);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5177
        return;
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5178
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5179
    if (pMsg != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5180
        AwtAWTEvent::saveMSG(env, pMsg, mouseWheelEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5182
    SendEvent(mouseWheelEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5183
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5184
    env->DeleteLocalRef(mouseWheelEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5185
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5186
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5187
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5188
void AwtComponent::SendFocusEvent(jint id, HWND opposite)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5189
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5190
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5191
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5192
    CriticalSection::Lock l(GetLock());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5193
    if (GetPeer(env) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5194
        /* event received during termination. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5195
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5197
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5198
    static jclass focusEventCls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5199
    if (focusEventCls == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5200
        jclass focusEventClsLocal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5201
            = env->FindClass("java/awt/event/FocusEvent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5202
        DASSERT(focusEventClsLocal);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5203
        CHECK_NULL(focusEventClsLocal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5204
        focusEventCls = (jclass)env->NewGlobalRef(focusEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5205
        env->DeleteLocalRef(focusEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5207
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5208
    static jmethodID focusEventConst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5209
    if (focusEventConst == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5210
        focusEventConst =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5211
            env->GetMethodID(focusEventCls, "<init>",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5212
                             "(Ljava/awt/Component;IZLjava/awt/Component;)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5213
        DASSERT(focusEventConst);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5214
        CHECK_NULL(focusEventConst);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5217
    static jclass sequencedEventCls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5218
    if (sequencedEventCls == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5219
        jclass sequencedEventClsLocal =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5220
            env->FindClass("java/awt/SequencedEvent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5221
        DASSERT(sequencedEventClsLocal);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5222
        CHECK_NULL(sequencedEventClsLocal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5223
        sequencedEventCls =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5224
            (jclass)env->NewGlobalRef(sequencedEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5225
        env->DeleteLocalRef(sequencedEventClsLocal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5227
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5228
    static jmethodID sequencedEventConst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5229
    if (sequencedEventConst == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5230
        sequencedEventConst =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5231
            env->GetMethodID(sequencedEventCls, "<init>",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5232
                             "(Ljava/awt/AWTEvent;)V");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5233
        DASSERT(sequencedEventConst);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5234
        CHECK_NULL(sequencedEventConst);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5236
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5237
    if (env->EnsureLocalCapacity(3) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5238
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5241
    jobject target = GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5242
    jobject jOpposite = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5243
    if (opposite != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5244
        AwtComponent *awtOpposite = AwtComponent::GetComponent(opposite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5245
        if (awtOpposite != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5246
            jOpposite = awtOpposite->GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5247
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5249
    jobject focusEvent = env->NewObject(focusEventCls, focusEventConst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5250
                                        target, id, JNI_FALSE, jOpposite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5251
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5252
    DASSERT(focusEvent != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5253
    if (jOpposite != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5254
        env->DeleteLocalRef(jOpposite); jOpposite = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5256
    env->DeleteLocalRef(target); target = NULL;
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5257
    CHECK_NULL(focusEvent);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5258
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5259
    jobject sequencedEvent = env->NewObject(sequencedEventCls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5260
                                            sequencedEventConst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5261
                                            focusEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5262
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5263
    DASSERT(sequencedEvent != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5264
    env->DeleteLocalRef(focusEvent); focusEvent = NULL;
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5265
    CHECK_NULL(sequencedEvent);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5266
    SendEvent(sequencedEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5267
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5268
    env->DeleteLocalRef(sequencedEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5269
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5270
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5271
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5272
 * Forward a filtered event directly to the subclassed window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5273
 * This method is needed so that DefWindowProc is invoked on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5274
 * component's owning thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5275
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5276
MsgRouting AwtComponent::HandleEvent(MSG *msg, BOOL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5277
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5278
    DefWindowProc(msg->message, msg->wParam, msg->lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5279
    delete msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5280
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5281
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5283
/* Post a WM_AWT_HANDLE_EVENT message which invokes HandleEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5284
   on the toolkit thread. This method may pre-filter the messages. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5285
BOOL AwtComponent::PostHandleEventMessage(MSG *msg, BOOL synthetic)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5286
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5287
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5288
    // We should cut off keyboard events to disabled components
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5289
    // to avoid the components responding visually to keystrokes when disabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5290
    // we shouldn't cut off WM_SYS* messages as they aren't used for normal activity
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5291
    // but to activate menus, close windows, etc
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5292
    switch(msg->message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5293
        case WM_KEYDOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5294
        case WM_KEYUP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5295
        case WM_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5296
        case WM_DEADCHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5297
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5298
                if (!isRecursivelyEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5299
                    goto quit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5300
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5301
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5302
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5304
    if (PostMessage(GetHWnd(), WM_AWT_HANDLE_EVENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5305
        (WPARAM) synthetic, (LPARAM) msg)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5306
            return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5307
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5308
        JNU_ThrowInternalError(env, "Message not posted, native event queue may be full.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5310
quit:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5311
    delete msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5312
    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5313
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5314
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5315
void AwtComponent::SynthesizeKeyMessage(JNIEnv *env, jobject keyEvent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5316
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5317
    jint id = (env)->GetIntField(keyEvent, AwtAWTEvent::idID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5318
    UINT message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5319
    switch (id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5320
      case java_awt_event_KeyEvent_KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5321
          message = WM_KEYDOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5322
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5323
      case java_awt_event_KeyEvent_KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5324
          message = WM_KEYUP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5325
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5326
      case java_awt_event_KeyEvent_KEY_TYPED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5327
          message = WM_CHAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5328
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5329
      default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5330
          return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5332
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5333
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5334
     * KeyEvent.modifiers aren't supported -- the Java apppwd must send separate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5335
     * KEY_PRESSED and KEY_RELEASED events for the modifier virtual keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5336
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5337
    if (id == java_awt_event_KeyEvent_KEY_TYPED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5338
        // WM_CHAR message must be posted using WM_AWT_FORWARD_CHAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5339
        // (for Edit control)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5340
        jchar keyChar = (jchar)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5341
          (env)->GetCharField(keyEvent, AwtKeyEvent::keyCharID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5342
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5343
        // Bugid 4724007.  If it is a Delete character, don't send the fake
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5344
        // KEY_TYPED we created back to the native window: Windows doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5345
        // expect a WM_CHAR for Delete in TextFields, so it tries to enter a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5346
        // character after deleting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5347
        if (keyChar == '\177') { // the Delete character
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5348
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5349
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5350
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5351
        // Disable forwarding WM_CHAR messages to disabled components
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5352
        if (isRecursivelyEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5353
            if (!::PostMessage(GetHWnd(), WM_AWT_FORWARD_CHAR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5354
                MAKEWPARAM(keyChar, TRUE), 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5355
                JNU_ThrowInternalError(env, "Message not posted, native event queue may be full.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5356
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5357
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5358
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5359
        jint keyCode =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5360
          (env)->GetIntField(keyEvent, AwtKeyEvent::keyCodeID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5361
        UINT key, modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5362
        AwtComponent::JavaKeyToWindowsKey(keyCode, &key, &modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5363
        MSG* msg = CreateMessage(message, key, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5364
        PostHandleEventMessage(msg, TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5365
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5366
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5367
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5368
void AwtComponent::SynthesizeMouseMessage(JNIEnv *env, jobject mouseEvent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5369
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5370
    /*    DebugBreak(); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5371
    jint button = (env)->GetIntField(mouseEvent, AwtMouseEvent::buttonID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5372
    jint modifiers = (env)->GetIntField(mouseEvent, AwtInputEvent::modifiersID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5373
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5374
    WPARAM wParam = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5375
    WORD wLow = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5376
    jint wheelAmt = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5377
    jint id = (env)->GetIntField(mouseEvent, AwtAWTEvent::idID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5378
    UINT message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5379
    switch (id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5380
      case java_awt_event_MouseEvent_MOUSE_PRESSED: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5381
          switch (button) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5382
            case java_awt_event_MouseEvent_BUTTON1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5383
                message = WM_LBUTTONDOWN; break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5384
            case java_awt_event_MouseEvent_BUTTON3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5385
                message = WM_MBUTTONDOWN; break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5386
            case java_awt_event_MouseEvent_BUTTON2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5387
                message = WM_RBUTTONDOWN; break;
35682
5861cf47d8c4 8080492: [Parfait] Uninitialised variable in jdk/src/java/desktop/windows/native/libawt/
serb
parents: 35653
diff changeset
  5388
            default:
5861cf47d8c4 8080492: [Parfait] Uninitialised variable in jdk/src/java/desktop/windows/native/libawt/
serb
parents: 35653
diff changeset
  5389
                return;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5390
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5391
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5392
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5393
      case java_awt_event_MouseEvent_MOUSE_RELEASED: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5394
          switch (button) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5395
            case java_awt_event_MouseEvent_BUTTON1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5396
                message = WM_LBUTTONUP; break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5397
            case java_awt_event_MouseEvent_BUTTON3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5398
                message = WM_MBUTTONUP; break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5399
            case java_awt_event_MouseEvent_BUTTON2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5400
                message = WM_RBUTTONUP; break;
35682
5861cf47d8c4 8080492: [Parfait] Uninitialised variable in jdk/src/java/desktop/windows/native/libawt/
serb
parents: 35653
diff changeset
  5401
            default:
5861cf47d8c4 8080492: [Parfait] Uninitialised variable in jdk/src/java/desktop/windows/native/libawt/
serb
parents: 35653
diff changeset
  5402
                return;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5403
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5404
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5405
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5406
      case java_awt_event_MouseEvent_MOUSE_MOVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5407
          /* MOUSE_DRAGGED events must first have sent a MOUSE_PRESSED event. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5408
      case java_awt_event_MouseEvent_MOUSE_DRAGGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5409
          message = WM_MOUSEMOVE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5410
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5411
      case java_awt_event_MouseEvent_MOUSE_WHEEL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5412
          if (modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5413
              wLow |= MK_CONTROL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5414
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5415
          if (modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5416
              wLow |= MK_SHIFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5417
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5418
          if (modifiers & java_awt_event_InputEvent_BUTTON1_DOWN_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5419
              wLow |= MK_LBUTTON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5420
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5421
          if (modifiers & java_awt_event_InputEvent_BUTTON2_DOWN_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5422
              wLow |= MK_RBUTTON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5423
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5424
          if (modifiers & java_awt_event_InputEvent_BUTTON3_DOWN_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5425
              wLow |= MK_MBUTTON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5426
          }
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  5427
          if (modifiers & X1_BUTTON) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  5428
              wLow |= GetButtonMK(X1_BUTTON);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  5429
          }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  5430
          if (modifiers & X2_BUTTON) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  5431
              wLow |= GetButtonMK(X2_BUTTON);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  5432
          }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5433
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5434
          wheelAmt = (jint)JNU_CallMethodByName(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5435
                                               NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5436
                                               mouseEvent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5437
                                               "getWheelRotation",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5438
                                               "()I").i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5439
          DASSERT(!safe_ExceptionOccurred(env));
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  5440
          JNU_CHECK_EXCEPTION(env);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5441
          DTRACE_PRINTLN1("wheelAmt = %i\n", wheelAmt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5442
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5443
          // convert Java wheel amount value to Win32
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5444
          wheelAmt *= -1 * WHEEL_DELTA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5445
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  5446
          message = WM_MOUSEWHEEL;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  5447
          wParam = MAKEWPARAM(wLow, wheelAmt);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5448
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5449
          break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5450
      default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5451
          return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5452
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5453
    jint x = (env)->GetIntField(mouseEvent, AwtMouseEvent::xID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5454
    jint y = (env)->GetIntField(mouseEvent, AwtMouseEvent::yID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5455
    MSG* msg = CreateMessage(message, wParam, MAKELPARAM(x, y), x, y);
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5456
    PostHandleEventMessage(msg, TRUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5457
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5458
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5459
BOOL AwtComponent::InheritsNativeMouseWheelBehavior() {return false;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5460
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5461
void AwtComponent::Invalidate(RECT* r)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5462
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5463
    ::InvalidateRect(GetHWnd(), r, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5464
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5465
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5466
void AwtComponent::BeginValidate()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5467
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5468
    DASSERT(m_validationNestCount >= 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5469
           m_validationNestCount < 1000); // sanity check
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5470
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5471
    if (m_validationNestCount == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5472
    // begin deferred window positioning if we're not inside
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5473
    // another Begin/EndValidate pair
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5474
        DASSERT(m_hdwp == NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5475
        m_hdwp = ::BeginDeferWindowPos(32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5477
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5478
    m_validationNestCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5479
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5480
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5481
void AwtComponent::EndValidate()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5482
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5483
    DASSERT(m_validationNestCount > 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5484
           m_validationNestCount < 1000); // sanity check
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5485
    DASSERT(m_hdwp != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5486
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5487
    m_validationNestCount--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5488
    if (m_validationNestCount == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5489
    // if this call to EndValidate is not nested inside another
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5490
    // Begin/EndValidate pair, end deferred window positioning
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5491
        ::EndDeferWindowPos(m_hdwp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5492
        m_hdwp = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5494
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5495
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5496
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5497
 * HWND, AwtComponent and Java Peer interaction
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5498
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5499
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5500
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5501
 *Link the C++, Java peer, and HWNDs together.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5502
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5503
void AwtComponent::LinkObjects(JNIEnv *env, jobject peer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5504
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5505
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5506
     * Bind all three objects together thru this C++ object, two-way to each:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5507
     *     JavaPeer <-> C++ <-> HWND
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5508
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5509
     * C++ -> JavaPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5510
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5511
    if (m_peerObject == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5512
        // This may have already been set up by CreateHWnd
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5513
        // And we don't want to create two references so we
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5514
        // will leave the prior one alone
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5515
        m_peerObject = env->NewGlobalRef(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5516
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5517
    /* JavaPeer -> HWND */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5518
    env->SetLongField(peer, AwtComponent::hwndID, reinterpret_cast<jlong>(m_hwnd));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5519
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5520
    /* JavaPeer -> C++ */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5521
    JNI_SET_PDATA(peer, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5522
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5523
    /* HWND -> C++ */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5524
    SetComponentInHWND();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5525
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5526
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5527
/* Cleanup above linking */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5528
void AwtComponent::UnlinkObjects()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5529
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5530
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5531
    if (m_peerObject) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5532
        env->SetLongField(m_peerObject, AwtComponent::hwndID, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5533
        JNI_SET_PDATA(m_peerObject, static_cast<PDATA>(NULL));
108
deaaed5cedb7 6592751: EmbeddedFrame disposal is fragile and breaks clean AppContext termination
son
parents: 105
diff changeset
  5534
        JNI_SET_DESTROYED(m_peerObject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5535
        env->DeleteGlobalRef(m_peerObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5536
        m_peerObject = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5537
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5538
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5539
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5540
void AwtComponent::Enable(BOOL bEnable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5541
{
122
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 121
diff changeset
  5542
    if (bEnable && IsTopLevel()) {
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 121
diff changeset
  5543
        // we should not enable blocked toplevels
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 121
diff changeset
  5544
        bEnable = !::IsWindow(AwtWindow::GetModalBlocker(GetHWnd()));
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 121
diff changeset
  5545
    }
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5546
    // Shouldn't trigger native focus change
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5547
    // (only the proxy may be the native focus owner).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5548
    ::EnableWindow(GetHWnd(), bEnable);
122
0a8658c7d538 6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents: 121
diff changeset
  5549
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5550
    CriticalSection::Lock l(GetLock());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5551
    VerifyState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5552
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5553
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5554
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5555
 * associate an AwtDropTarget with this AwtComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5556
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5557
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5558
AwtDropTarget* AwtComponent::CreateDropTarget(JNIEnv* env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5559
    m_dropTarget = new AwtDropTarget(env, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5560
    m_dropTarget->RegisterTarget(TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5561
    return m_dropTarget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5562
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5563
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5564
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5565
 * disassociate an AwtDropTarget with this AwtComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5566
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5567
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5568
void AwtComponent::DestroyDropTarget() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5569
    if (m_dropTarget != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5570
        m_dropTarget->RegisterTarget(FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5571
        m_dropTarget->Release();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5572
        m_dropTarget = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5573
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5574
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5575
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5576
BOOL AwtComponent::IsFocusingMouseMessage(MSG *pMsg) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5577
    return pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONDBLCLK;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5578
}
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5579
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5580
BOOL AwtComponent::IsFocusingKeyMessage(MSG *pMsg) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5581
    return pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_SPACE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5582
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5583
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5584
void AwtComponent::_Show(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5585
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5586
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5587
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5588
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5589
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5590
    AwtComponent *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5591
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5592
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5593
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5594
    p = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5595
    if (::IsWindow(p->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5596
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5597
        p->SendMessage(WM_AWT_COMPONENT_SHOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5598
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5599
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5600
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5601
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5602
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5603
void AwtComponent::_Hide(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5604
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5605
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5606
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5607
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5608
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5609
    AwtComponent *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5610
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5611
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5612
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5613
    p = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5614
    if (::IsWindow(p->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5615
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5616
        p->SendMessage(WM_AWT_COMPONENT_HIDE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5617
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5618
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5619
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5620
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5621
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5622
void AwtComponent::_Enable(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5623
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5624
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5625
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5626
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5627
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5628
    AwtComponent *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5629
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5630
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5631
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5632
    p = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5633
    if (::IsWindow(p->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5634
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5635
        p->Enable(TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5636
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5637
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5638
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5639
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5640
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5641
void AwtComponent::_Disable(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5642
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5643
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5644
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5645
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5646
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5647
    AwtComponent *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5648
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5649
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5650
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5651
    p = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5652
    if (::IsWindow(p->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5653
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5654
        p->Enable(FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5655
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5656
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5657
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5658
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5659
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5660
jobject AwtComponent::_GetLocationOnScreen(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5661
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5662
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5663
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5664
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5665
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5666
    jobject result = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5667
    AwtComponent *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5668
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5669
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5670
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5671
    p = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5672
    if (::IsWindow(p->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5673
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5674
        RECT rect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5675
        VERIFY(::GetWindowRect(p->GetHWnd(),&rect));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5676
        result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  5677
                                     p->ScaleDownX(rect.left),
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  5678
                                     p->ScaleDownY(rect.top));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5679
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5680
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5681
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5682
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5683
    if (result != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5684
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5685
        jobject resultGlobalRef = env->NewGlobalRef(result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5686
        env->DeleteLocalRef(result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5687
        return resultGlobalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5688
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5689
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5690
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5691
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5692
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5693
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5694
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5695
void AwtComponent::_Reshape(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5696
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5697
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5698
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5699
    ReshapeStruct *rs = (ReshapeStruct*)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5700
    jobject self = rs->component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5701
    jint x = rs->x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5702
    jint y = rs->y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5703
    jint w = rs->w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5704
    jint h = rs->h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5705
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5706
    AwtComponent *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5707
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5708
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5709
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5710
    p = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5711
    if (::IsWindow(p->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5712
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5713
        RECT* r = new RECT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5714
        ::SetRect(r, x, y, x + w, y + h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5715
        p->SendMessage(WM_AWT_RESHAPE_COMPONENT, CHECK_EMBEDDED, (LPARAM)r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5716
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5717
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5718
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5719
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5720
    delete rs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5721
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5722
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5723
void AwtComponent::_ReshapeNoCheck(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5724
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5725
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5726
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5727
    ReshapeStruct *rs = (ReshapeStruct*)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5728
    jobject self = rs->component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5729
    jint x = rs->x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5730
    jint y = rs->y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5731
    jint w = rs->w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5732
    jint h = rs->h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5733
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5734
    AwtComponent *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5735
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5736
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5737
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5738
    p = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5739
    if (::IsWindow(p->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5740
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5741
        RECT* r = new RECT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5742
        ::SetRect(r, x, y, x + w, y + h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5743
        p->SendMessage(WM_AWT_RESHAPE_COMPONENT, DONT_CHECK_EMBEDDED, (LPARAM)r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5744
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5745
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5746
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5747
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5748
    delete rs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5749
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5750
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5751
void AwtComponent::_NativeHandleEvent(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5752
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5753
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5754
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5755
    NativeHandleEventStruct *nhes = (NativeHandleEventStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5756
    jobject self = nhes->component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5757
    jobject event = nhes->event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5758
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5759
    AwtComponent *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5760
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5761
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5762
    JNI_CHECK_NULL_GOTO(self, "peer", ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5763
    pData = JNI_GET_PDATA(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5764
    if (pData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5765
        env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5766
        if (event != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5767
            env->DeleteGlobalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5768
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5769
        delete nhes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5770
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5771
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5772
    JNI_CHECK_NULL_GOTO(event, "null AWTEvent", ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5773
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5774
    p = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5775
    if (::IsWindow(p->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5776
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5777
        if (env->EnsureLocalCapacity(1) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5778
            env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5779
            env->DeleteGlobalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5780
            delete nhes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5781
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5782
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5783
        jbyteArray bdata = (jbyteArray)(env)->GetObjectField(event, AwtAWTEvent::bdataID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5784
        int id = (env)->GetIntField(event, AwtAWTEvent::idID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5785
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5786
        if (bdata != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5787
            MSG msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5788
            (env)->GetByteArrayRegion(bdata, 0, sizeof(MSG), (jbyte *)&msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5789
            (env)->DeleteLocalRef(bdata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5790
            static BOOL keyDownConsumed = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5791
            static BOOL bCharChanged = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5792
            static WCHAR modifiedChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5793
            WCHAR unicodeChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5794
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5795
            /* Remember if a KEY_PRESSED event is consumed, as an old model
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5796
             * program won't consume a subsequent KEY_TYPED event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5797
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5798
            jboolean consumed =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5799
                (env)->GetBooleanField(event, AwtAWTEvent::consumedID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5800
            DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5801
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5802
            if (consumed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5803
                keyDownConsumed = (id == java_awt_event_KeyEvent_KEY_PRESSED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5804
                env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5805
                env->DeleteGlobalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5806
                delete nhes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5807
                return;
419
2d7b6a4f8002 6637607: 1st char. is discarded after a modal dialogue shows up and disappears
ant
parents: 122
diff changeset
  5808
2d7b6a4f8002 6637607: 1st char. is discarded after a modal dialogue shows up and disappears
ant
parents: 122
diff changeset
  5809
            } else if (id == java_awt_event_KeyEvent_KEY_PRESSED) {
2d7b6a4f8002 6637607: 1st char. is discarded after a modal dialogue shows up and disappears
ant
parents: 122
diff changeset
  5810
                // Fix for 6637607: reset consuming
2d7b6a4f8002 6637607: 1st char. is discarded after a modal dialogue shows up and disappears
ant
parents: 122
diff changeset
  5811
                keyDownConsumed = FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5812
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5813
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5814
            /* Consume a KEY_TYPED event if a KEY_PRESSED had been, to support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5815
             * the old model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5816
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5817
            if ((id == java_awt_event_KeyEvent_KEY_TYPED) && keyDownConsumed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5818
                keyDownConsumed = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5819
                env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5820
                env->DeleteGlobalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5821
                delete nhes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5822
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5823
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5824
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5825
            /* Modify any event parameters, if necessary. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5826
            if (self && pData &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5827
                id >= java_awt_event_KeyEvent_KEY_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5828
                id <= java_awt_event_KeyEvent_KEY_LAST) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5829
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5830
                    AwtComponent* p = (AwtComponent*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5831
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5832
                    jint keyCode =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5833
                      (env)->GetIntField(event, AwtKeyEvent::keyCodeID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5834
                    jchar keyChar =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5835
                      (env)->GetCharField(event, AwtKeyEvent::keyCharID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5836
                    jint modifiers =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5837
                      (env)->GetIntField(event, AwtInputEvent::modifiersID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5838
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5839
                    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5840
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5841
                /* Check to see whether the keyCode or modifiers were changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5842
                   on the keyPressed event, and tweak the following keyTyped
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5843
                   event (if any) accodingly.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5844
                switch (id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5845
                case java_awt_event_KeyEvent_KEY_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5846
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5847
                    UINT winKey = (UINT)msg.wParam;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5848
                    bCharChanged = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5849
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5850
                    if (winKey == VK_PROCESSKEY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5851
                        // Leave it up to IME
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5852
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5853
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5854
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5855
                    if (keyCode != java_awt_event_KeyEvent_VK_UNDEFINED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5856
                        UINT newWinKey, ignored;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5857
                        p->JavaKeyToWindowsKey(keyCode, &newWinKey, &ignored, winKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5858
                        if (newWinKey != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5859
                            winKey = newWinKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5860
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5861
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5862
13995
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  5863
                    BOOL isDeadKey = FALSE;
903cc17d889c 7197619: Using modifiers for the dead key detection on Windows
alexsch
parents: 13144
diff changeset
  5864
                    modifiedChar = p->WindowsKeyToJavaChar(winKey, modifiers, AwtComponent::NONE, isDeadKey);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5865
                    bCharChanged = (keyChar != modifiedChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5866
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5867
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5868
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5869
                case java_awt_event_KeyEvent_KEY_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5870
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5871
                    keyDownConsumed = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5872
                    bCharChanged = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5873
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5874
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5875
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5876
                case java_awt_event_KeyEvent_KEY_TYPED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5877
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5878
                    if (bCharChanged)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5879
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5880
                        unicodeChar = modifiedChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5881
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5882
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5883
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5884
                        unicodeChar = keyChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5885
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5886
                    bCharChanged = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5887
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5888
                    // Disable forwarding KEY_TYPED messages to peers of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5889
                    // disabled components
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5890
                    if (p->isRecursivelyEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5891
                        // send the character back to the native window for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5892
                        // processing. The WM_AWT_FORWARD_CHAR handler will send
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5893
                        // this character to DefWindowProc
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5894
                        if (!::PostMessage(p->GetHWnd(), WM_AWT_FORWARD_CHAR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5895
                            MAKEWPARAM(unicodeChar, FALSE), msg.lParam)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5896
                            JNU_ThrowInternalError(env, "Message not posted, native event queue may be full.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5897
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5898
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5899
                    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5900
                    env->DeleteGlobalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5901
                    delete nhes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5902
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5903
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5904
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5905
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5906
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5907
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5908
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5909
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5910
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5911
            // ignore all InputMethodEvents
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5912
            if (self && (pData = JNI_GET_PDATA(self)) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5913
                id >= java_awt_event_InputMethodEvent_INPUT_METHOD_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5914
                id <= java_awt_event_InputMethodEvent_INPUT_METHOD_LAST) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5915
                env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5916
                env->DeleteGlobalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5917
                delete nhes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5918
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5919
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5920
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5921
            // Create copy for local msg
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5922
            MSG* pCopiedMsg = new MSG;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5923
            memmove(pCopiedMsg, &msg, sizeof(MSG));
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5924
            // Event handler deletes msg
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5925
            p->PostHandleEventMessage(pCopiedMsg, FALSE);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  5926
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5927
            env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5928
            env->DeleteGlobalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5929
            delete nhes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5930
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5931
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5932
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5933
        /* Forward any valid synthesized events.  Currently only mouse and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5934
         * key events are supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5935
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5936
        if (self == NULL || (pData = JNI_GET_PDATA(self)) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5937
            env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5938
            env->DeleteGlobalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5939
            delete nhes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5940
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5941
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5942
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5943
        AwtComponent* p = (AwtComponent*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5944
        if (id >= java_awt_event_KeyEvent_KEY_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5945
            id <= java_awt_event_KeyEvent_KEY_LAST) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5946
            p->SynthesizeKeyMessage(env, event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5947
        } else if (id >= java_awt_event_MouseEvent_MOUSE_FIRST &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5948
                   id <= java_awt_event_MouseEvent_MOUSE_LAST) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5949
            p->SynthesizeMouseMessage(env, event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5950
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5951
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5952
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5953
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5954
    if (self != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5955
        env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5956
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5957
    if (event != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5958
        env->DeleteGlobalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5959
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5960
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5961
    delete nhes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5962
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5963
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5964
void AwtComponent::_SetForeground(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5965
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5966
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5967
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5968
    SetColorStruct *scs = (SetColorStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5969
    jobject self = scs->component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5970
    jint rgb = scs->rgb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5971
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5972
    AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5973
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5974
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5975
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5976
    c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5977
    if (::IsWindow(c->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5978
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5979
        c->SetColor(PALETTERGB((rgb>>16)&0xff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5980
                               (rgb>>8)&0xff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5981
                               (rgb)&0xff));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5982
        c->VerifyState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5983
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5984
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5985
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5986
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5987
    delete scs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5988
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5989
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5990
void AwtComponent::_SetBackground(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5991
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5992
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5993
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5994
    SetColorStruct *scs = (SetColorStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5995
    jobject self = scs->component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5996
    jint rgb = scs->rgb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5997
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5998
    AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  5999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6000
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6001
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6002
    c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6003
    if (::IsWindow(c->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6004
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6005
        c->SetBackgroundColor(PALETTERGB((rgb>>16)&0xff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6006
                                         (rgb>>8)&0xff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6007
                                         (rgb)&0xff));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6008
        c->VerifyState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6009
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6010
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6011
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6012
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6013
    delete scs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6014
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6015
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6016
void AwtComponent::_SetFont(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6017
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6018
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6019
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6020
    SetFontStruct *sfs = (SetFontStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6021
    jobject self = sfs->component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6022
    jobject font = sfs->font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6024
    AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6025
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6026
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6027
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6028
    JNI_CHECK_NULL_GOTO(font, "null font", ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6029
    c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6030
    if (::IsWindow(c->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6031
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6032
        AwtFont *awtFont = (AwtFont *)env->GetLongField(font, AwtFont::pDataID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6033
        if (awtFont == NULL) {
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  6034
            /*arguments of AwtFont::Create are changed for multifont component */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6035
            awtFont = AwtFont::Create(env, font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6036
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6037
        env->SetLongField(font, AwtFont::pDataID, (jlong)awtFont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6038
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6039
        c->SetFont(awtFont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6040
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6041
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6042
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6043
    env->DeleteGlobalRef(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6044
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6045
    delete sfs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6046
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6047
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6048
// Sets or kills focus for a component.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6049
void AwtComponent::_SetFocus(void *param)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6050
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6051
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6052
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6053
    SetFocusStruct *sfs = (SetFocusStruct *)param;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6054
    jobject self = sfs->component;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6055
    jboolean doSetFocus = sfs->doSetFocus;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6056
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6057
    AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6058
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6059
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6060
    JNI_CHECK_NULL_GOTO(self, "peer", ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6061
    pData = JNI_GET_PDATA(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6062
    if (pData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6063
        // do nothing just return false
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6064
        goto ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6065
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6066
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6067
    c = (AwtComponent *)pData;
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6068
    if (::IsWindow(c->GetHWnd())) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6069
        c->SendMessage(WM_AWT_COMPONENT_SETFOCUS, (WPARAM)doSetFocus, 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6070
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6071
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6072
    env->DeleteGlobalRef(self);
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6073
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6074
    delete sfs;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6075
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6076
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6077
void AwtComponent::_Start(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6078
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6079
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6080
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6081
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6082
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6083
    AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6084
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6085
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6086
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6087
    c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6088
    if (::IsWindow(c->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6089
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6090
        jobject target = c->GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6091
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6092
        /* Disable window if specified -- windows are enabled by default. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6093
        jboolean enabled = (jboolean)env->GetBooleanField(target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6094
                                                          AwtComponent::enabledID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6095
        if (!enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6096
            ::EnableWindow(c->GetHWnd(), FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6097
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6098
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6099
        /* The peer is now ready for callbacks, since this is the last
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6100
         * initialization call
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6101
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6102
        c->EnableCallbacks(TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6103
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6104
        // Fix 4745222: we need to invalidate region since we validated it before initialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6105
        ::InvalidateRgn(c->GetHWnd(), NULL, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6106
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6107
        // Fix 4530093: WM_PAINT after EnableCallbacks
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6108
        ::UpdateWindow(c->GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6109
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6110
        env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6112
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6113
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6114
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6116
void AwtComponent::_BeginValidate(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6117
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6118
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6119
    if (AwtToolkit::IsMainThread()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6120
        jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6121
        if (self != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6122
            PDATA pData = JNI_GET_PDATA(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6123
            if (pData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6124
                AwtComponent *c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6125
                if (::IsWindow(c->GetHWnd())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6126
                    c->SendMessage(WM_AWT_BEGIN_VALIDATE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6127
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6128
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6129
            env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6130
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6131
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6132
        AwtToolkit::GetInstance().InvokeFunction(AwtComponent::_BeginValidate, param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6134
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6135
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6136
void AwtComponent::_EndValidate(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6137
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6138
    if (AwtToolkit::IsMainThread()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6139
        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6140
        jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6141
        if (self != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6142
            PDATA pData = JNI_GET_PDATA(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6143
            if (pData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6144
                AwtComponent *c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6145
                if (::IsWindow(c->GetHWnd())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6146
                    c->SendMessage(WM_AWT_END_VALIDATE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6147
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6148
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6149
            env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6150
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6151
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6152
        AwtToolkit::GetInstance().InvokeFunction(AwtComponent::_EndValidate, param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6154
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6155
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6156
void AwtComponent::_UpdateWindow(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6157
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6158
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6159
    if (AwtToolkit::IsMainThread()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6160
        jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6161
        AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6162
        PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6163
        JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6164
        c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6165
        if (::IsWindow(c->GetHWnd())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6166
            ::UpdateWindow(c->GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6168
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6169
        env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6170
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6171
        AwtToolkit::GetInstance().InvokeFunction(AwtComponent::_UpdateWindow, param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6173
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6174
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6175
jlong AwtComponent::_AddNativeDropTarget(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6176
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6177
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6178
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6179
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6180
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6181
    jlong result = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6182
    AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6183
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6184
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6185
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6186
    c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6187
    if (::IsWindow(c->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6188
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6189
        result = (jlong)(c->CreateDropTarget(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6191
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6192
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6193
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6194
    return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6195
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6196
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6197
void AwtComponent::_RemoveNativeDropTarget(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6198
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6199
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6200
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6201
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6202
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6203
    AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6204
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6205
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6206
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6207
    c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6208
    if (::IsWindow(c->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6209
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6210
        c->DestroyDropTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6212
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6213
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6214
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6215
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6216
jintArray AwtComponent::_CreatePrintedPixels(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6217
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6218
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6219
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6220
    CreatePrintedPixelsStruct *cpps = (CreatePrintedPixelsStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6221
    jobject self = cpps->component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6222
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6223
    jintArray result = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6224
    AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6225
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6226
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6227
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6228
    c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6229
    if (::IsWindow(c->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6230
    {
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  6231
        result = (jintArray)c->SendMessage(WM_AWT_CREATE_PRINTED_PIXELS, (WPARAM)cpps, 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6233
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6234
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6235
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6236
    delete cpps;
3085
0c2f4bcb2728 6736247: Component.printAll Invalid local JNI handle
dcherepanov
parents: 2952
diff changeset
  6237
    return result; // this reference is global
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6238
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6239
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6240
jboolean AwtComponent::_IsObscured(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6241
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6242
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6243
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6244
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6246
    jboolean result = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6247
    AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6248
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6249
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6250
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6251
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6252
    c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6253
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6254
    if (::IsWindow(c->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6255
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6256
        HWND hWnd = c->GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6257
        HDC hDC = ::GetDC(hWnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6258
        RECT clipbox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6259
        int callresult = ::GetClipBox(hDC, &clipbox);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6260
        switch(callresult) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6261
            case NULLREGION :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6262
                result = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6263
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6264
            case SIMPLEREGION : {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6265
                RECT windowRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6266
                if (!::GetClientRect(hWnd, &windowRect)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6267
                    result = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6268
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6269
                    result  = (jboolean)((clipbox.bottom != windowRect.bottom)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6270
                        || (clipbox.left != windowRect.left)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6271
                        || (clipbox.right != windowRect.right)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6272
                        || (clipbox.top != windowRect.top));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6273
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6274
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6276
            case COMPLEXREGION :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6277
            default :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6278
                result = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6279
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6280
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6281
        ::ReleaseDC(hWnd, hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6283
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6284
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6285
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6286
    return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6287
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6288
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6289
jboolean AwtComponent::_NativeHandlesWheelScrolling(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6290
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6291
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6292
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6293
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6294
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6295
    jboolean result = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6296
    AwtComponent *c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6297
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6298
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6299
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6300
    c = (AwtComponent *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6301
    if (::IsWindow(c->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6302
    {
24145
2af65706b254 8035736: [parfait] JNI primitive type mismatch in jdk/src/windows/native/sun/windows/awt_Component.cpp
serb
parents: 23613
diff changeset
  6303
        result = JNI_IS_TRUE(c->InheritsNativeMouseWheelBehavior());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6304
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6305
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6306
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6307
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6308
    return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6309
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6310
47404
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6311
void AwtComponent::_SetParent(void * param)
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6312
{
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6313
    if (AwtToolkit::IsMainThread()) {
47404
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6314
        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6315
        SetParentStruct *data = (SetParentStruct*) param;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6316
        jobject self = data->component;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6317
        jobject parent = data->parentComp;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6318
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6319
        AwtComponent *awtComponent = NULL;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6320
        AwtComponent *awtParent = NULL;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6321
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6322
        PDATA pData;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6323
        JNI_CHECK_PEER_GOTO(self, ret);
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6324
        awtComponent = (AwtComponent *)pData;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6325
        JNI_CHECK_PEER_GOTO(parent, ret);
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6326
        awtParent = (AwtComponent *)pData;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6327
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6328
        HWND selfWnd = awtComponent->GetHWnd();
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6329
        HWND parentWnd = awtParent->GetHWnd();
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6330
        if (::IsWindow(selfWnd) && ::IsWindow(parentWnd)) {
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6331
            // Shouldn't trigger native focus change
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6332
            // (only the proxy may be the native focus owner).
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6333
            ::SetParent(selfWnd, parentWnd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6334
        }
47404
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6335
ret:
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6336
        env->DeleteGlobalRef(self);
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6337
        env->DeleteGlobalRef(parent);
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6338
        delete data;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6339
    } else {
47404
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  6340
        AwtToolkit::GetInstance().InvokeFunction(AwtComponent::_SetParent, param);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6342
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6343
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6344
void AwtComponent::_SetRectangularShape(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6345
{
7149
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6346
    if (!AwtToolkit::IsMainThread()) {
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6347
        AwtToolkit::GetInstance().InvokeFunction(AwtComponent::_SetRectangularShape, param);
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6348
    } else {
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6349
        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6350
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6351
        SetRectangularShapeStruct *data = (SetRectangularShapeStruct *)param;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6352
        jobject self = data->component;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6353
        jint x1 = data->x1;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6354
        jint x2 = data->x2;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6355
        jint y1 = data->y1;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6356
        jint y2 = data->y2;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6357
        jobject region = data->region;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6358
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6359
        AwtComponent *c = NULL;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6360
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6361
        PDATA pData;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6362
        JNI_CHECK_PEER_GOTO(self, ret);
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6363
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6364
        c = (AwtComponent *)pData;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6365
        if (::IsWindow(c->GetHWnd())) {
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6366
            HRGN hRgn = NULL;
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6367
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6368
            // If all the params are zeros, the shape must be simply reset.
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6369
            // Otherwise, convert it into a region.
7149
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6370
            if (region || x1 || x2 || y1 || y2) {
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6371
                RECT_T rects[256];
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6372
                RECT_T *pRect = rects;
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6373
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6374
                const int numrects = RegionToYXBandedRectangles(env, x1, y1, x2, y2,
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6375
                        region, &pRect, sizeof(rects)/sizeof(rects[0]));
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6376
                if (!pRect) {
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6377
                    // RegionToYXBandedRectangles doesn't use safe_Malloc(),
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6378
                    // so throw the exception explicitly
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6379
                    throw std::bad_alloc();
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6380
                }
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6381
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6382
                RGNDATA *pRgnData = (RGNDATA *) SAFE_SIZE_STRUCT_ALLOC(safe_Malloc,
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6383
                        sizeof(RGNDATAHEADER), sizeof(RECT_T), numrects);
18239
4af5dc2d5794 8011154: java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java failed since 7u25b03 on windows
anthony
parents: 18232
diff changeset
  6384
                memcpy((BYTE*)pRgnData + sizeof(RGNDATAHEADER), pRect, sizeof(RECT_T) * numrects);
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6385
                if (pRect != rects) {
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6386
                    free(pRect);
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6387
                }
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6388
                pRect = NULL;
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6389
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6390
                RGNDATAHEADER *pRgnHdr = (RGNDATAHEADER *) pRgnData;
7149
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6391
                pRgnHdr->dwSize = sizeof(RGNDATAHEADER);
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6392
                pRgnHdr->iType = RDH_RECTANGLES;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6393
                pRgnHdr->nRgnSize = 0;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6394
                pRgnHdr->rcBound.top = 0;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6395
                pRgnHdr->rcBound.left = 0;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6396
                pRgnHdr->rcBound.bottom = LONG(y2 - y1);
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6397
                pRgnHdr->rcBound.right = LONG(x2 - x1);
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6398
                pRgnHdr->nCount = numrects;
7149
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6399
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6400
                hRgn = ::ExtCreateRegion(NULL,
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6401
                        sizeof(RGNDATAHEADER) + sizeof(RECT_T) * pRgnHdr->nCount, pRgnData);
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6402
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6403
                free(pRgnData);
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6404
            }
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6405
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6406
            ::SetWindowRgn(c->GetHWnd(), hRgn, TRUE);
1978
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1962
diff changeset
  6407
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6408
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6409
ret:
7149
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6410
        env->DeleteGlobalRef(self);
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6411
        if (region) {
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6412
            env->DeleteGlobalRef(region);
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6413
        }
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6414
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6415
        delete data;
2fe42889b598 6988428: Shape is not applied sometimes
anthony
parents: 6635
diff changeset
  6416
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6417
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6418
2462
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6419
void AwtComponent::_SetZOrder(void *param) {
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6420
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6421
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6422
    SetZOrderStruct *data = (SetZOrderStruct *)param;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6423
    jobject self = data->component;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6424
    HWND above = HWND_TOP;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6425
    if (data->above != 0) {
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6426
        above = reinterpret_cast<HWND>(data->above);
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6427
    }
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6428
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6429
    AwtComponent *c = NULL;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6430
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6431
    PDATA pData;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6432
    JNI_CHECK_PEER_GOTO(self, ret);
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6433
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6434
    c = (AwtComponent *)pData;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6435
    if (::IsWindow(c->GetHWnd())) {
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6436
        ::SetWindowPos(c->GetHWnd(), above, 0, 0, 0, 0,
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6437
                       SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_DEFERERASE | SWP_ASYNCWINDOWPOS);
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6438
    }
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6439
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6440
ret:
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6441
    env->DeleteGlobalRef(self);
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6442
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6443
    delete data;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6444
}
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  6445
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6446
void AwtComponent::PostUngrabEvent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6447
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6448
    jobject target = GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6449
    jobject event = JNU_NewObjectByName(env, "sun/awt/UngrabEvent", "(Ljava/awt/Component;)V",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6450
                                        target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6451
    if (safe_ExceptionOccurred(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6452
        env->ExceptionDescribe();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6453
        env->ExceptionClear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6455
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6456
    if (event != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6457
        SendEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6458
        env->DeleteLocalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6460
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6461
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
  6462
void AwtComponent::SetFocusedWindow(HWND window)
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
  6463
{
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
  6464
    HWND old = sm_focusedWindow;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
  6465
    sm_focusedWindow = window;
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
  6466
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
  6467
    AwtWindow::FocusedWindowChanged(old, window);
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
  6468
}
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2469
diff changeset
  6469
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6470
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6471
 * Component native methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6472
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6473
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6474
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6475
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6476
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6477
 * This method is called from the WGL pipeline when it needs to retrieve
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6478
 * the HWND associated with a ComponentPeer's C++ level object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6479
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6480
HWND
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6481
AwtComponent_GetHWnd(JNIEnv *env, jlong pData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6482
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6483
    AwtComponent *p = (AwtComponent *)jlong_to_ptr(pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6484
    if (p == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6485
        return (HWND)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6486
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6487
    return p->GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6488
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6489
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6490
static void _GetInsets(void* param)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6491
{
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6492
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6493
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6494
    GetInsetsStruct *gis = (GetInsetsStruct *)param;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6495
    jobject self = gis->window;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6496
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6497
    gis->insets->left = gis->insets->top =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6498
        gis->insets->right = gis->insets->bottom = 0;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6499
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6500
    PDATA pData;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6501
    JNI_CHECK_PEER_GOTO(self, ret);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6502
    AwtComponent *component = (AwtComponent *)pData;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6503
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6504
    component->GetInsets(gis->insets);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6505
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6506
  ret:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6507
    env->DeleteGlobalRef(self);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6508
    delete gis;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6509
}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6510
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6511
/**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6512
 * This method is called from the WGL pipeline when it needs to retrieve
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6513
 * the insets associated with a ComponentPeer's C++ level object.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6514
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6515
void AwtComponent_GetInsets(JNIEnv *env, jobject peer, RECT *insets)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6516
{
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6517
    TRY;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6518
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6519
    GetInsetsStruct *gis = new GetInsetsStruct;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6520
    gis->window = env->NewGlobalRef(peer);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6521
    gis->insets = insets;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6522
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6523
    AwtToolkit::GetInstance().InvokeFunction(_GetInsets, gis);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6524
    // global refs and mds are deleted in _UpdateWindow
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6525
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6526
    CATCH_BAD_ALLOC;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6527
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6528
}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
  6529
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6530
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6531
Java_java_awt_Component_initIDs(JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6532
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6533
    TRY;
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  6534
    jclass inputEventClazz = env->FindClass("java/awt/event/InputEvent");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6535
    CHECK_NULL(inputEventClazz);
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  6536
    jmethodID getButtonDownMasksID = env->GetStaticMethodID(inputEventClazz, "getButtonDownMasks", "()[I");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6537
    CHECK_NULL(getButtonDownMasksID);
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  6538
    jintArray obj = (jintArray)env->CallStaticObjectMethod(inputEventClazz, getButtonDownMasksID);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  6539
    jint * tmp = env->GetIntArrayElements(obj, JNI_FALSE);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6540
    CHECK_NULL(tmp);
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  6541
    jsize len = env->GetArrayLength(obj);
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 13995
diff changeset
  6542
    AwtComponent::masks = SAFE_SIZE_NEW_ARRAY(jint, len);
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  6543
    for (int i = 0; i < len; i++) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  6544
        AwtComponent::masks[i] = tmp[i];
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  6545
    }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  6546
    env->ReleaseIntArrayElements(obj, tmp, 0);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 1960
diff changeset
  6547
    env->DeleteLocalRef(obj);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6548
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6549
    /* class ids */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6550
    jclass peerCls = env->FindClass("sun/awt/windows/WComponentPeer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6551
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6552
    DASSERT(peerCls);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6553
    CHECK_NULL(peerCls);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6554
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6555
    /* field ids */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6556
    AwtComponent::peerID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6557
      env->GetFieldID(cls, "peer", "Ljava/awt/peer/ComponentPeer;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6558
    DASSERT(AwtComponent::peerID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6559
    CHECK_NULL(AwtComponent::peerID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6560
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6561
    AwtComponent::xID = env->GetFieldID(cls, "x", "I");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6562
    DASSERT(AwtComponent::xID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6563
    CHECK_NULL(AwtComponent::xID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6564
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6565
    AwtComponent::yID = env->GetFieldID(cls, "y", "I");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6566
    DASSERT(AwtComponent::yID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6567
    CHECK_NULL(AwtComponent::yID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6568
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6569
    AwtComponent::heightID = env->GetFieldID(cls, "height", "I");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6570
    DASSERT(AwtComponent::heightID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6571
    CHECK_NULL(AwtComponent::heightID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6572
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6573
    AwtComponent::widthID = env->GetFieldID(cls, "width", "I");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6574
    DASSERT(AwtComponent::widthID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6575
    CHECK_NULL(AwtComponent::widthID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6576
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6577
    AwtComponent::visibleID = env->GetFieldID(cls, "visible", "Z");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6578
    DASSERT(AwtComponent::visibleID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6579
    CHECK_NULL(AwtComponent::visibleID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6580
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6581
    AwtComponent::backgroundID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6582
        env->GetFieldID(cls, "background", "Ljava/awt/Color;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6583
    DASSERT(AwtComponent::backgroundID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6584
    CHECK_NULL(AwtComponent::backgroundID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6585
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6586
    AwtComponent::foregroundID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6587
        env->GetFieldID(cls, "foreground", "Ljava/awt/Color;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6588
    DASSERT(AwtComponent::foregroundID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6589
    CHECK_NULL(AwtComponent::foregroundID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6590
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6591
    AwtComponent::enabledID = env->GetFieldID(cls, "enabled", "Z");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6592
    DASSERT(AwtComponent::enabledID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6593
    CHECK_NULL(AwtComponent::enabledID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6594
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6595
    AwtComponent::parentID = env->GetFieldID(cls, "parent", "Ljava/awt/Container;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6596
    DASSERT(AwtComponent::parentID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6597
    CHECK_NULL(AwtComponent::parentID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6598
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6599
    AwtComponent::graphicsConfigID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6600
     env->GetFieldID(cls, "graphicsConfig", "Ljava/awt/GraphicsConfiguration;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6601
    DASSERT(AwtComponent::graphicsConfigID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6602
    CHECK_NULL(AwtComponent::graphicsConfigID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6603
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6604
    AwtComponent::focusableID = env->GetFieldID(cls, "focusable", "Z");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6605
    DASSERT(AwtComponent::focusableID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6606
    CHECK_NULL(AwtComponent::focusableID);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6607
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6608
    AwtComponent::appContextID = env->GetFieldID(cls, "appContext",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6609
                                                 "Lsun/awt/AppContext;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6610
    DASSERT(AwtComponent::appContextID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6611
    CHECK_NULL(AwtComponent::appContextID);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6612
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6613
    AwtComponent::peerGCID = env->GetFieldID(peerCls, "winGraphicsConfig",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6614
                                        "Lsun/awt/Win32GraphicsConfig;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6615
    DASSERT(AwtComponent::peerGCID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6616
    CHECK_NULL(AwtComponent::peerGCID);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6617
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6618
    AwtComponent::hwndID = env->GetFieldID(peerCls, "hwnd", "J");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6619
    DASSERT(AwtComponent::hwndID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6620
    CHECK_NULL(AwtComponent::hwndID);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6621
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6622
    AwtComponent::cursorID = env->GetFieldID(cls, "cursor", "Ljava/awt/Cursor;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6623
    DASSERT(AwtComponent::cursorID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6624
    CHECK_NULL(AwtComponent::cursorID);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6625
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6626
    /* method ids */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6627
    AwtComponent::getFontMID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6628
        env->GetMethodID(cls, "getFont_NoClientCode", "()Ljava/awt/Font;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6629
    DASSERT(AwtComponent::getFontMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6630
    CHECK_NULL(AwtComponent::getFontMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6631
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6632
    AwtComponent::getToolkitMID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6633
        env->GetMethodID(cls, "getToolkitImpl", "()Ljava/awt/Toolkit;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6634
    DASSERT(AwtComponent::getToolkitMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6635
    CHECK_NULL(AwtComponent::getToolkitMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6636
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6637
    AwtComponent::isEnabledMID = env->GetMethodID(cls, "isEnabledImpl", "()Z");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6638
    DASSERT(AwtComponent::isEnabledMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6639
    CHECK_NULL(AwtComponent::isEnabledMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6640
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6641
    AwtComponent::getLocationOnScreenMID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6642
        env->GetMethodID(cls, "getLocationOnScreen_NoTreeLock", "()Ljava/awt/Point;");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6643
    DASSERT(AwtComponent::getLocationOnScreenMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6644
    CHECK_NULL(AwtComponent::getLocationOnScreenMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6645
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6646
    AwtComponent::replaceSurfaceDataMID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6647
        env->GetMethodID(peerCls, "replaceSurfaceData", "()V");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6648
    DASSERT(AwtComponent::replaceSurfaceDataMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6649
    CHECK_NULL(AwtComponent::replaceSurfaceDataMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6650
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6651
    AwtComponent::replaceSurfaceDataLaterMID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6652
        env->GetMethodID(peerCls, "replaceSurfaceDataLater", "()V");
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6653
    DASSERT(AwtComponent::replaceSurfaceDataLaterMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6654
    CHECK_NULL(AwtComponent::replaceSurfaceDataLaterMID);
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6655
10689
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  6656
    AwtComponent::disposeLaterMID = env->GetMethodID(peerCls, "disposeLater", "()V");
080571e66cc6 7073337: Crash after playing Java game on Pogo
bagiras
parents: 10088
diff changeset
  6657
    DASSERT(AwtComponent::disposeLaterMID);
23613
3e2d84f3b5eb 8035325: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Component.cpp
pchelko
parents: 23010
diff changeset
  6658
    CHECK_NULL(AwtComponent::disposeLaterMID);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6659
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6660
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6661
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6662
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6663
} /* extern "C" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6664
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6665
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6666
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6667
 * ComponentPeer native methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6668
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6669
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6670
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6671
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6672
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6673
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6674
 * Method:    pShow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6675
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6676
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6677
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6678
Java_sun_awt_windows_WComponentPeer_pShow(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6679
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6680
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6681
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6682
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6683
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6684
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_Show, (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6685
    // selfGlobalRef is deleted in _Show
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6686
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6687
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6688
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6689
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6690
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6691
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6692
 * Method:    hide
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6693
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6694
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6695
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6696
Java_sun_awt_windows_WComponentPeer_hide(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6697
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6698
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6699
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6700
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6701
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6702
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_Hide, (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6703
    // selfGlobalRef is deleted in _Hide
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6704
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6705
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6706
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6707
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6708
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6709
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6710
 * Method:    enable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6711
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6712
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6713
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6714
Java_sun_awt_windows_WComponentPeer_enable(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6715
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6716
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6717
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6718
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6719
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6720
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_Enable, (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6721
    // selfGlobalRef is deleted in _Enable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6722
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6723
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6724
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6725
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6726
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6727
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6728
 * Method:    disable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6729
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6730
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6731
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6732
Java_sun_awt_windows_WComponentPeer_disable(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6733
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6734
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6735
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6736
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6737
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6738
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_Disable, (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6739
    // selfGlobalRef is deleted in _Disable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6740
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6741
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6742
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6743
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6744
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6745
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6746
 * Method:    getLocationOnScreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6747
 * Signature: ()Ljava/awt/Point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6748
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6749
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6750
Java_sun_awt_windows_WComponentPeer_getLocationOnScreen(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6751
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6752
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6753
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6754
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6755
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6756
    jobject resultGlobalRef = (jobject)AwtToolkit::GetInstance().SyncCall(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6757
        (void*(*)(void*))AwtComponent::_GetLocationOnScreen, (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6758
    // selfGlobalRef is deleted in _GetLocationOnScreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6759
    if (resultGlobalRef != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6760
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6761
        jobject resultLocalRef = env->NewLocalRef(resultGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6762
        env->DeleteGlobalRef(resultGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6763
        return resultLocalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6764
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6765
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6766
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6767
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6768
    CATCH_BAD_ALLOC_RET(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6769
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6770
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6771
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6772
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6773
 * Method:    reshape
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6774
 * Signature: (IIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6775
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6776
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6777
Java_sun_awt_windows_WComponentPeer_reshape(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6778
                                            jint x, jint y, jint w, jint h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6779
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6780
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6781
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6782
    ReshapeStruct *rs = new ReshapeStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6783
    rs->component = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6784
    rs->x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6785
    rs->y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6786
    rs->w = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6787
    rs->h = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6788
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6789
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_Reshape, rs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6790
    // global ref and rs are deleted in _Reshape
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6791
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6792
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6793
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6794
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6795
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6796
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6797
 * Method:    reshape
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6798
 * Signature: (IIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6799
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6800
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6801
Java_sun_awt_windows_WComponentPeer_reshapeNoCheck(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6802
                                            jint x, jint y, jint w, jint h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6803
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6804
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6805
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6806
    ReshapeStruct *rs = new ReshapeStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6807
    rs->component = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6808
    rs->x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6809
    rs->y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6810
    rs->w = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6811
    rs->h = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6812
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6813
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_ReshapeNoCheck, rs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6814
    // global ref and rs are deleted in _ReshapeNoCheck
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6815
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6816
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6817
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6818
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6819
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6820
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6821
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6822
 * Method:    nativeHandleEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6823
 * Signature: (Ljava/awt/AWTEvent;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6824
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6825
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6826
Java_sun_awt_windows_WComponentPeer_nativeHandleEvent(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6827
                                                      jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6828
                                                      jobject event)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6829
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6830
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6831
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6832
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6833
    jobject eventGlobalRef = env->NewGlobalRef(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6834
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6835
    NativeHandleEventStruct *nhes = new NativeHandleEventStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6836
    nhes->component = selfGlobalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6837
    nhes->event = eventGlobalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6838
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6839
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_NativeHandleEvent, nhes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6840
    // global refs and nhes are deleted in _NativeHandleEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6841
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6842
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6843
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6844
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6845
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6846
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6847
 * Method:    _dispose
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6848
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6849
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6850
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6851
Java_sun_awt_windows_WComponentPeer__1dispose(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6852
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6853
    TRY_NO_HANG;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6854
9476
148209fd1cf5 6998716: client vm crashes making browser fails to respond under some scenarios
denis
parents: 7149
diff changeset
  6855
    AwtObject::_Dispose(self);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6856
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6857
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6858
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6859
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6860
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6861
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6862
 * Method:    _setForeground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6863
 * Signature: (I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6864
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6865
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6866
Java_sun_awt_windows_WComponentPeer__1setForeground(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6867
                                                    jint rgb)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6868
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6869
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6870
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6871
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6872
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6873
    SetColorStruct *scs = new SetColorStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6874
    scs->component = selfGlobalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6875
    scs->rgb = rgb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6876
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6877
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_SetForeground, scs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6878
    // selfGlobalRef and scs are deleted in _SetForeground()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6879
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6880
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6881
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6882
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6883
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6884
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6885
 * Method:    _setBackground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6886
 * Signature: (I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6887
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6888
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6889
Java_sun_awt_windows_WComponentPeer__1setBackground(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6890
                                                    jint rgb)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6891
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6892
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6893
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6894
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6895
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6896
    SetColorStruct *scs = new SetColorStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6897
    scs->component = selfGlobalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6898
    scs->rgb = rgb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6899
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6900
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_SetBackground, scs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6901
    // selfGlobalRef and scs are deleted in _SetBackground()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6902
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6903
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6904
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6905
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6906
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6907
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6908
 * Method:    _setFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6909
 * Signature: (Ljava/awt/Font;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6910
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6911
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6912
Java_sun_awt_windows_WComponentPeer__1setFont(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6913
                        jobject font)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6914
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6915
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6916
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6917
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6918
    jobject fontGlobalRef = env->NewGlobalRef(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6919
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6920
    SetFontStruct *sfs = new SetFontStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6921
    sfs->component = selfGlobalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6922
    sfs->font = fontGlobalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6923
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6924
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_SetFont, sfs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6925
    // global refs and sfs are deleted in _SetFont()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6926
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6927
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6928
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6929
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6930
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6931
 * Class:     sun_awt_windows_WComponentPeer
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6932
 * Method:    focusGained
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6933
 * Signature: (Z)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6934
 */
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6935
JNIEXPORT void JNICALL Java_sun_awt_windows_WComponentPeer_setFocus
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6936
    (JNIEnv *env, jobject self, jboolean doSetFocus)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6937
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6938
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6939
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6940
    jobject selfGlobalRef = env->NewGlobalRef(self);
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6941
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6942
    SetFocusStruct *sfs = new SetFocusStruct;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6943
    sfs->component = selfGlobalRef;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6944
    sfs->doSetFocus = doSetFocus;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6945
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6946
    AwtToolkit::GetInstance().SyncCall(
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6947
        (void*(*)(void*))AwtComponent::_SetFocus, sfs);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6948
    // global refs and self are deleted in _SetFocus
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6949
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
  6950
    CATCH_BAD_ALLOC;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6951
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6952
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6953
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6954
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6955
 * Method:    start
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6956
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6957
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6958
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6959
Java_sun_awt_windows_WComponentPeer_start(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6960
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6961
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6962
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6963
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6964
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6965
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_Start, (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6966
    // selfGlobalRef is deleted in _Start
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6967
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6968
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6969
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6970
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6971
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6972
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6973
 * Method:    beginValidate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6974
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6975
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6976
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6977
Java_sun_awt_windows_WComponentPeer_beginValidate(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6978
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6979
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6980
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6981
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6982
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6983
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_BeginValidate, (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6984
    // selfGlobalRef is deleted in _BeginValidate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6985
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6986
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6987
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6988
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6989
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6990
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6991
 * Method:    endValidate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6992
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6993
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6994
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6995
Java_sun_awt_windows_WComponentPeer_endValidate(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6996
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6997
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6998
90ce3da70b43 Initial load
duke
parents:
diff changeset
  6999
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7000
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7001
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_EndValidate, (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7002
    // selfGlobalRef is deleted in _EndValidate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7004
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7005
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7006
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7007
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7008
Java_sun_awt_windows_WComponentPeer_updateWindow(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7009
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7010
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7011
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7012
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7013
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7014
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_UpdateWindow, (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7015
    // selfGlobalRef is deleted in _UpdateWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7016
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7017
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7018
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7019
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7020
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7021
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7022
 * Method:    addNativeDropTarget
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7023
 * Signature: ()L
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7024
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7025
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7026
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7027
Java_sun_awt_windows_WComponentPeer_addNativeDropTarget(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7028
                                                        jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7029
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7030
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7031
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7032
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7033
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7034
    return ptr_to_jlong(AwtToolkit::GetInstance().SyncCall(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7035
        (void*(*)(void*))AwtComponent::_AddNativeDropTarget,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7036
        (void *)selfGlobalRef));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7037
    // selfGlobalRef is deleted in _AddNativeDropTarget
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7038
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7039
    CATCH_BAD_ALLOC_RET(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7040
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7042
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7043
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7044
 * Method:    removeNativeDropTarget
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7045
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7046
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7048
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7049
Java_sun_awt_windows_WComponentPeer_removeNativeDropTarget(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7050
                                                           jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7051
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7052
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7054
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7056
    AwtToolkit::GetInstance().SyncCall(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7057
        AwtComponent::_RemoveNativeDropTarget, (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7058
    // selfGlobalRef is deleted in _RemoveNativeDropTarget
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7060
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7061
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7062
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7063
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7064
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7065
 * Method:    getTargetGC
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7066
 * Signature: ()Ljava/awt/GraphicsConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7067
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7068
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7069
Java_sun_awt_windows_WComponentPeer_getTargetGC(JNIEnv* env, jobject theThis)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7070
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7071
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7072
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7073
    jobject targetObj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7074
    jobject gc = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7075
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7076
    targetObj = env->GetObjectField(theThis, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7077
    DASSERT(targetObj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7078
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7079
    gc = env->GetObjectField(targetObj, AwtComponent::graphicsConfigID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7080
    return gc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7082
    CATCH_BAD_ALLOC_RET(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7083
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7084
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7085
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7086
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7087
 * Method:    createPrintedPixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7088
 * Signature: (IIIIII)I[
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7089
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7090
JNIEXPORT jintArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7091
Java_sun_awt_windows_WComponentPeer_createPrintedPixels(JNIEnv* env,
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  7092
    jobject self, jint srcX, jint srcY, jint srcW, jint srcH, jint alpha)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7093
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7094
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7095
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7096
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7097
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7098
    CreatePrintedPixelsStruct *cpps = new CreatePrintedPixelsStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7099
    cpps->component = selfGlobalRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7100
    cpps->srcx = srcX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7101
    cpps->srcy = srcY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7102
    cpps->srcw = srcW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7103
    cpps->srch = srcH;
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2646
diff changeset
  7104
    cpps->alpha = alpha;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7105
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7106
    jintArray globalRef = (jintArray)AwtToolkit::GetInstance().SyncCall(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7107
        (void*(*)(void*))AwtComponent::_CreatePrintedPixels, cpps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7108
    // selfGlobalRef and cpps are deleted in _CreatePrintedPixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7109
    if (globalRef != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7110
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7111
        jintArray localRef = (jintArray)env->NewLocalRef(globalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7112
        env->DeleteGlobalRef(globalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7113
        return localRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7115
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7116
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7117
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7119
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7120
    CATCH_BAD_ALLOC_RET(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7121
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7123
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7124
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7125
 * Method:    nativeHandlesWheelScrolling
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7126
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7127
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7128
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7129
Java_sun_awt_windows_WComponentPeer_nativeHandlesWheelScrolling (JNIEnv* env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7130
    jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7131
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7132
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7133
49303
440ba068d981 8198895: Compilation errors in java.desktop with VS 2017
serb
parents: 49214
diff changeset
  7134
    return (jboolean)((intptr_t)AwtToolkit::GetInstance().SyncCall(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7135
        (void *(*)(void *))AwtComponent::_NativeHandlesWheelScrolling,
49303
440ba068d981 8198895: Compilation errors in java.desktop with VS 2017
serb
parents: 49214
diff changeset
  7136
        env->NewGlobalRef(self)));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7137
    // global ref is deleted in _NativeHandlesWheelScrolling
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7138
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7139
    CATCH_BAD_ALLOC_RET(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7140
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7141
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7142
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7143
 * Class:     sun_awt_windows_WComponentPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7144
 * Method:    isObscured
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7145
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7146
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7147
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7148
Java_sun_awt_windows_WComponentPeer_isObscured(JNIEnv* env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7149
    jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7150
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7151
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7152
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7153
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7154
49303
440ba068d981 8198895: Compilation errors in java.desktop with VS 2017
serb
parents: 49214
diff changeset
  7155
    return (jboolean)((intptr_t)AwtToolkit::GetInstance().SyncCall(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7156
        (void*(*)(void*))AwtComponent::_IsObscured,
49303
440ba068d981 8198895: Compilation errors in java.desktop with VS 2017
serb
parents: 49214
diff changeset
  7157
        (void *)selfGlobalRef));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7158
    // selfGlobalRef is deleted in _IsObscured
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7159
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7160
    CATCH_BAD_ALLOC_RET(NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7161
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7162
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7163
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7164
Java_sun_awt_windows_WComponentPeer_pSetParent(JNIEnv* env, jobject self, jobject parent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7165
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7166
47404
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  7167
    SetParentStruct * data = new SetParentStruct;
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  7168
    data->component = env->NewGlobalRef(self);
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  7169
    data->parentComp = env->NewGlobalRef(parent);
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  7170
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  7171
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_SetParent, data);
e0aec2769cff 8165543: Better window framing
serb
parents: 47384
diff changeset
  7172
    // global refs and data are deleted in SetParent
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7173
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7174
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7175
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7176
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7177
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7178
Java_sun_awt_windows_WComponentPeer_setRectangularShape(JNIEnv* env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7179
        jint x1, jint y1, jint x2, jint y2, jobject region)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7180
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7181
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7182
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7183
    SetRectangularShapeStruct * data = new SetRectangularShapeStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7184
    data->component = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7185
    data->x1 = x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7186
    data->x2 = x2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7187
    data->y1 = y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7188
    data->y2 = y2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7189
    if (region) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7190
        data->region = env->NewGlobalRef(region);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7191
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7192
        data->region = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7194
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7195
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_SetRectangularShape, data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7196
    // global refs and data are deleted in _SetRectangularShape
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7197
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7198
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7199
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7200
2462
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7201
JNIEXPORT void JNICALL
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7202
Java_sun_awt_windows_WComponentPeer_setZOrder(JNIEnv* env, jobject self, jlong above)
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7203
{
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7204
    TRY;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7205
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7206
    SetZOrderStruct * data = new SetZOrderStruct;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7207
    data->component = env->NewGlobalRef(self);
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7208
    data->above = above;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7209
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7210
    AwtToolkit::GetInstance().SyncCall(AwtComponent::_SetZOrder, data);
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7211
    // global refs and data are deleted in _SetLower
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7212
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7213
    CATCH_BAD_ALLOC;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7214
}
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2451
diff changeset
  7215
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7216
} /* extern "C" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7217
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7218
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7219
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7220
 * Diagnostic routines
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7221
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7222
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7223
#ifdef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7224
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7225
void AwtComponent::VerifyState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7226
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7227
    if (AwtToolkit::GetInstance().VerifyComponents() == FALSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7228
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7230
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7231
    if (m_callbacksEnabled == FALSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7232
        /* Component is not fully setup yet. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7233
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7235
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7236
    /* Get target bounds. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7237
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7238
    if (env->PushLocalFrame(10) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7239
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7241
    jobject target = GetTarget(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7242
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7243
    jint x = env->GetIntField(target, AwtComponent::xID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7244
    jint y = env->GetIntField(target, AwtComponent::yID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7245
    jint width = env->GetIntField(target, AwtComponent::widthID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7246
    jint height = env->GetIntField(target, AwtComponent::heightID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7247
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7248
    /* Convert target origin to absolute coordinates */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7249
    while (TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7250
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7251
        jobject parent = env->GetObjectField(target, AwtComponent::parentID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7252
        if (parent == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7253
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7255
        x += env->GetIntField(parent, AwtComponent::xID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7256
        y += env->GetIntField(parent, AwtComponent::yID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7257
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7258
        /* If this component has insets, factor them in, but ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7259
         * top-level windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7260
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7261
        jobject parent2 = env->GetObjectField(parent, AwtComponent::parentID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7262
        if (parent2 != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7263
            jobject peer = GetPeerForTarget(env, parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7264
            if (peer != NULL &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7265
                JNU_IsInstanceOfByName(env, peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7266
                                       "sun/awt/windows/WPanelPeer") > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7267
                jobject insets =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7268
                    JNU_CallMethodByName(env, NULL, peer,"insets",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7269
                                         "()Ljava/awt/Insets;").l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7270
                x += (env)->GetIntField(insets, AwtInsets::leftID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7271
                y += (env)->GetIntField(insets, AwtInsets::topID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7272
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7273
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7274
        env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7275
        target = parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7277
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  7278
    x = ScaleUpX(x);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  7279
    y = ScaleUpY(y);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  7280
    width = ScaleUpX(width);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  7281
    height = ScaleUpY(height);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 33508
diff changeset
  7282
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7283
    // Test whether component's bounds match the native window's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7284
    RECT rect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7285
    VERIFY(::GetWindowRect(GetHWnd(), &rect));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7286
#if 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7287
    DASSERT( (x == rect.left) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7288
            (y == rect.top) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7289
            (width == (rect.right-rect.left)) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7290
            (height == (rect.bottom-rect.top)) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7291
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7292
    BOOL fSizeValid = ( (x == rect.left) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7293
            (y == rect.top) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7294
            (width == (rect.right-rect.left)) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7295
            (height == (rect.bottom-rect.top)) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7296
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7297
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7298
    // See if visible state matches
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7299
    BOOL wndVisible = ::IsWindowVisible(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7300
    jboolean targetVisible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7301
    // To avoid possibly running client code on the toolkit thread, don't
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7302
    // do the following check if we're running on the toolkit thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7303
    if (AwtToolkit::MainThread() != ::GetCurrentThreadId()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7304
        targetVisible = JNU_CallMethodByName(env, NULL, GetTarget(env),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7305
                                                  "isShowing", "()Z").z;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7306
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7307
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7308
        targetVisible = wndVisible ? 1 : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7310
#if 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7311
    DASSERT( (targetVisible && wndVisible) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7312
            (!targetVisible && !wndVisible) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7313
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7314
    BOOL fVisibleValid = ( (targetVisible && wndVisible) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7315
            (!targetVisible && !wndVisible) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7316
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7317
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7318
    // Check enabled state
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7319
    BOOL wndEnabled = ::IsWindowEnabled(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7320
    jboolean enabled = (jboolean)env->GetBooleanField(target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7321
                                                      AwtComponent::enabledID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7322
#if 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7323
    DASSERT( (enabled && wndEnabled) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7324
            (!enabled && !wndEnabled) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7325
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7326
    BOOL fEnabledValid = ((enabled && wndEnabled) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7327
                          (!(enabled && !wndEnabled) ));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7329
    if (!fSizeValid || !fVisibleValid || !fEnabledValid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7330
        printf("AwtComponent::ValidateState() failed:\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7331
        // To avoid possibly running client code on the toolkit thread, don't
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7332
        // do the following call if we're running on the toolkit thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7333
        if (AwtToolkit::MainThread() != ::GetCurrentThreadId()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7334
            jstring targetStr =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7335
                (jstring)JNU_CallMethodByName(env, NULL, GetTarget(env),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7336
                                              "getName",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7337
                                              "()Ljava/lang/String;").l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7338
            DASSERT(!safe_ExceptionOccurred(env));
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  7339
            LPCWSTR targetStrW = JNU_GetStringPlatformChars(env, targetStr, NULL);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  7340
            printf("\t%S\n", targetStrW);
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 889
diff changeset
  7341
            JNU_ReleaseStringPlatformChars(env, targetStr, targetStrW);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7342
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7343
        printf("\twas:       [%d,%d,%dx%d]\n", x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7344
        if (!fSizeValid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7345
            printf("\tshould be: [%d,%d,%dx%d]\n", rect.left, rect.top,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7346
                   rect.right-rect.left, rect.bottom-rect.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7347
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7348
        if (!fVisibleValid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7349
            printf("\tshould be: %s\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7350
                   (targetVisible) ? "visible" : "hidden");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7351
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7352
        if (!fEnabledValid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7353
            printf("\tshould be: %s\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7354
                   enabled ? "enabled" : "disabled");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7356
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7357
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7358
    env->PopLocalFrame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7359
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7360
#endif //DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7361
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7362
// Methods for globally managed DC list
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7363
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7364
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7365
 * Add a new DC to the DC list for this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7366
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7367
void DCList::AddDC(HDC hDC, HWND hWnd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7368
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7369
    DCItem *newItem = new DCItem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7370
    newItem->hDC = hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7371
    newItem->hWnd = hWnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7372
    AddDCItem(newItem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7373
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7374
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7375
void DCList::AddDCItem(DCItem *newItem)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7376
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7377
    listLock.Enter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7378
    newItem->next = head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7379
    head = newItem;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7380
    listLock.Leave();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7381
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7382
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7383
/**
33508
75a3d3923c24 8130136: Swing window sometimes fails to repaint partially when it becomes exposed
aivanov
parents: 33249
diff changeset
  7384
 * Given a DC and window handle, remove the DC from the DC list
75a3d3923c24 8130136: Swing window sometimes fails to repaint partially when it becomes exposed
aivanov
parents: 33249
diff changeset
  7385
 * and return TRUE if it exists on the current list.  Otherwise
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7386
 * return FALSE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7387
 * A DC may not exist on the list because it has already
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7388
 * been released elsewhere (for example, the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7389
 * destruction process may release a DC while a rendering
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7390
 * thread may also want to release a DC when it notices that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7391
 * its DC is obsolete for the current window).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7392
 */
33508
75a3d3923c24 8130136: Swing window sometimes fails to repaint partially when it becomes exposed
aivanov
parents: 33249
diff changeset
  7393
DCItem *DCList::RemoveDC(HDC hDC, HWND hWnd)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7394
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7395
    listLock.Enter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7396
    DCItem **prevPtrPtr = &head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7397
    DCItem *listPtr = head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7398
    while (listPtr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7399
        DCItem *nextPtr = listPtr->next;
33508
75a3d3923c24 8130136: Swing window sometimes fails to repaint partially when it becomes exposed
aivanov
parents: 33249
diff changeset
  7400
        if (listPtr->hDC == hDC && listPtr->hWnd == hWnd) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7401
            *prevPtrPtr = nextPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7402
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7403
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7404
        prevPtrPtr = &listPtr->next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7405
        listPtr = nextPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7407
    listLock.Leave();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7408
    return listPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7409
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7410
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7411
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7412
 * Remove all DCs from the DC list which are associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7413
 * the same window as hWnd.  Return the list of those
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7414
 * DC's to the caller (which will then probably want to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7415
 * call ReleaseDC() for the returned DCs).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7416
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7417
DCItem *DCList::RemoveAllDCs(HWND hWnd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7418
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7419
    listLock.Enter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7420
    DCItem **prevPtrPtr = &head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7421
    DCItem *listPtr = head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7422
    DCItem *newListPtr = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7423
    BOOL ret = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7424
    while (listPtr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7425
        DCItem *nextPtr = listPtr->next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7426
        if (listPtr->hWnd == hWnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7427
            *prevPtrPtr = nextPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7428
            listPtr->next = newListPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7429
            newListPtr = listPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7430
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7431
            prevPtrPtr = &listPtr->next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7432
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7433
        listPtr = nextPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7434
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7435
    listLock.Leave();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7436
    return newListPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7437
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7438
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7439
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7440
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7441
 * Realize palettes of all existing HDC objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7442
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7443
void DCList::RealizePalettes(int screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7444
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7445
    listLock.Enter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7446
    DCItem *listPtr = head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7447
    while (listPtr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7448
        AwtWin32GraphicsDevice::RealizePalette(listPtr->hDC, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7449
        listPtr = listPtr->next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7450
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7451
    listLock.Leave();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7452
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7453
33508
75a3d3923c24 8130136: Swing window sometimes fails to repaint partially when it becomes exposed
aivanov
parents: 33249
diff changeset
  7454
void MoveDCToPassiveList(HDC hDC, HWND hWnd) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7455
    DCItem *removedDC;
33508
75a3d3923c24 8130136: Swing window sometimes fails to repaint partially when it becomes exposed
aivanov
parents: 33249
diff changeset
  7456
    if ((removedDC = activeDCList.RemoveDC(hDC, hWnd)) != NULL) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7457
        passiveDCList.AddDCItem(removedDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7459
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7460
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7461
void ReleaseDCList(HWND hwnd, DCList &list) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7462
    DCItem *removedDCs = list.RemoveAllDCs(hwnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7463
    while (removedDCs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7464
        DCItem *tmpDCList = removedDCs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7465
        DASSERT(::GetObjectType(tmpDCList->hDC) == OBJ_DC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7466
        int retValue = ::ReleaseDC(tmpDCList->hWnd, tmpDCList->hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7467
        VERIFY(retValue != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7468
        if (retValue != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7469
            // Valid ReleaseDC call; need to decrement GDI object counter
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7470
            AwtGDIObject::Decrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7471
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7472
        removedDCs = removedDCs->next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7473
        delete tmpDCList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  7474
    }
35682
5861cf47d8c4 8080492: [Parfait] Uninitialised variable in jdk/src/java/desktop/windows/native/libawt/
serb
parents: 35653
diff changeset
  7475
}