< prev index next >
src/windows/native/sun/windows/awt_Component.cpp
Print this page
*** 214,223 ****
--- 214,227 ----
*/
AwtComponent::AwtComponent()
{
m_mouseButtonClickAllowed = 0;
+ m_touchDownOccurred = FALSE;
+ m_touchUpOccurred = FALSE;
+ m_touchDownPoint.x = m_touchDownPoint.y = 0;
+ m_touchUpPoint.x = m_touchUpPoint.y = 0;
m_callbacksEnabled = FALSE;
m_hwnd = NULL;
m_colorForeground = 0;
m_colorBackground = 0;
*** 578,587 ****
--- 582,596 ----
LinkObjects(env, peer);
/* Subclass the window now so that we can snoop on its messages */
SubclassHWND();
+ AwtToolkit& tk = AwtToolkit::GetInstance();
+ if (tk.IsWin8OrLater() && tk.IsTouchKeyboardAutoShowEnabled()) {
+ tk.TIRegisterTouchWindow(GetHWnd(), TWF_WANTPALM);
+ }
+
/*
* Fix for 4046446.
*/
SetWindowPos(GetHWnd(), 0, x, y, w, h, SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOACTIVATE);
*** 1698,1707 ****
--- 1707,1719 ----
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
GET_WHEEL_DELTA_WPARAM(wParam));
break;
}
break;
+ case WM_TOUCH:
+ WmTouch(wParam, lParam);
+ break;
case WM_SETCURSOR:
mr = mrDoDefault;
if (LOWORD(lParam) == HTCLIENT) {
if (AwtComponent* comp =
AwtComponent::GetComponent((HWND)wParam)) {
*** 2289,2298 ****
--- 2301,2342 ----
}
MsgRouting AwtComponent::WmWindowPosChanged(LPARAM windowPos) {
return mrDoDefault;
}
+ void AwtComponent::WmTouch(WPARAM wParam, LPARAM lParam) {
+ AwtToolkit& tk = AwtToolkit::GetInstance();
+ if (!tk.IsWin8OrLater() || !tk.IsTouchKeyboardAutoShowEnabled()) {
+ return;
+ }
+
+ UINT inputsCount = LOWORD(wParam);
+ TOUCHINPUT* pInputs = new TOUCHINPUT[inputsCount];
+ if (pInputs != NULL) {
+ if (tk.TIGetTouchInputInfo((HTOUCHINPUT)lParam, inputsCount, pInputs,
+ sizeof(TOUCHINPUT)) != 0) {
+ for (UINT i = 0; i < inputsCount; i++) {
+ TOUCHINPUT ti = pInputs[i];
+ if (ti.dwFlags & TOUCHEVENTF_PRIMARY) {
+ if (ti.dwFlags & TOUCHEVENTF_DOWN) {
+ m_touchDownPoint.x = ti.x / 100;
+ m_touchDownPoint.y = ti.y / 100;
+ ::ScreenToClient(GetHWnd(), &m_touchDownPoint);
+ m_touchDownOccurred = TRUE;
+ } else if (ti.dwFlags & TOUCHEVENTF_UP) {
+ m_touchUpPoint.x = ti.x / 100;
+ m_touchUpPoint.y = ti.y / 100;
+ ::ScreenToClient(GetHWnd(), &m_touchUpPoint);
+ m_touchUpOccurred = TRUE;
+ }
+ }
+ }
+ }
+ delete[] pInputs;
+ }
+ }
+
/* Double-click variables. */
static jlong multiClickTime = ::GetDoubleClickTime();
static int multiClickMaxX = ::GetSystemMetrics(SM_CXDOUBLECLK);
static int multiClickMaxY = ::GetSystemMetrics(SM_CYDOUBLECLK);
static AwtComponent* lastClickWnd = NULL;
*** 2331,2340 ****
--- 2375,2392 ----
*Set appropriate bit of the mask on WM_MOUSE_DOWN message.
*/
m_mouseButtonClickAllowed |= GetButtonMK(button);
lastTime = now;
+ BOOL causedByTouchEvent = FALSE;
+ if (m_touchDownOccurred &&
+ (abs(m_touchDownPoint.x - x) <= TOUCH_MOUSE_COORDS_DELTA) &&
+ (abs(m_touchDownPoint.y - y) <= TOUCH_MOUSE_COORDS_DELTA)) {
+ causedByTouchEvent = TRUE;
+ m_touchDownOccurred = FALSE;
+ }
+
MSG msg;
InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
AwtWindow *toplevel = GetContainer();
if (toplevel && !toplevel->IsSimpleWindow()) {
*** 2349,2359 ****
}
}
SendMouseEvent(java_awt_event_MouseEvent_MOUSE_PRESSED, now, x, y,
GetJavaModifiers(), clickCount, JNI_FALSE,
! GetButton(button), &msg);
/*
* NOTE: this call is intentionally placed after all other code,
* since AwtComponent::WmMouseDown() assumes that the cached id of the
* latest retrieved message (see lastMessage in awt_Component.cpp)
* matches the mouse message being processed.
--- 2401,2411 ----
}
}
SendMouseEvent(java_awt_event_MouseEvent_MOUSE_PRESSED, now, x, y,
GetJavaModifiers(), clickCount, JNI_FALSE,
! GetButton(button), &msg, causedByTouchEvent);
/*
* NOTE: this call is intentionally placed after all other code,
* since AwtComponent::WmMouseDown() assumes that the cached id of the
* latest retrieved message (see lastMessage in awt_Component.cpp)
* matches the mouse message being processed.
*** 2371,2387 ****
return mrConsume;
}
MsgRouting AwtComponent::WmMouseUp(UINT flags, int x, int y, int button)
{
MSG msg;
InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
SendMouseEvent(java_awt_event_MouseEvent_MOUSE_RELEASED, TimeHelper::getMessageTimeUTC(),
x, y, GetJavaModifiers(), clickCount,
(GetButton(button) == java_awt_event_MouseEvent_BUTTON3 ?
! TRUE : FALSE), GetButton(button), &msg);
/*
* If no movement, then report a click following the button release.
* When WM_MOUSEUP comes to a window without previous WM_MOUSEDOWN,
* spurous MOUSE_CLICK is about to happen. See 6430553.
*/
--- 2423,2447 ----
return mrConsume;
}
MsgRouting AwtComponent::WmMouseUp(UINT flags, int x, int y, int button)
{
+ BOOL causedByTouchEvent = FALSE;
+ if (m_touchUpOccurred &&
+ (abs(m_touchUpPoint.x - x) <= TOUCH_MOUSE_COORDS_DELTA) &&
+ (abs(m_touchUpPoint.y - y) <= TOUCH_MOUSE_COORDS_DELTA)) {
+ causedByTouchEvent = TRUE;
+ m_touchUpOccurred = FALSE;
+ }
+
MSG msg;
InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
SendMouseEvent(java_awt_event_MouseEvent_MOUSE_RELEASED, TimeHelper::getMessageTimeUTC(),
x, y, GetJavaModifiers(), clickCount,
(GetButton(button) == java_awt_event_MouseEvent_BUTTON3 ?
! TRUE : FALSE), GetButton(button), &msg, causedByTouchEvent);
/*
* If no movement, then report a click following the button release.
* When WM_MOUSEUP comes to a window without previous WM_MOUSEDOWN,
* spurous MOUSE_CLICK is about to happen. See 6430553.
*/
*** 4892,4902 ****
}
void AwtComponent::SendMouseEvent(jint id, jlong when, jint x, jint y,
jint modifiers, jint clickCount,
jboolean popupTrigger, jint button,
! MSG *pMsg)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
CriticalSection::Lock l(GetLock());
if (GetPeer(env) == NULL) {
/* event received during termination. */
--- 4952,4962 ----
}
void AwtComponent::SendMouseEvent(jint id, jlong when, jint x, jint y,
jint modifiers, jint clickCount,
jboolean popupTrigger, jint button,
! MSG *pMsg, BOOL causedByTouchEvent)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
CriticalSection::Lock l(GetLock());
if (GetPeer(env) == NULL) {
/* event received during termination. */
*** 4941,4950 ****
--- 5001,5014 ----
env->ExceptionClear();
}
DASSERT(mouseEvent != NULL);
CHECK_NULL(mouseEvent);
+ if (causedByTouchEvent) {
+ env->SetBooleanField(mouseEvent, AwtMouseEvent::causedByTouchEventID,
+ JNI_TRUE);
+ }
if (pMsg != 0) {
AwtAWTEvent::saveMSG(env, pMsg, mouseEvent);
}
SendEvent(mouseEvent);
< prev index next >