308 case NIN_BALLOONUSERCLICK: 309 mr = WmBalloonUserClick(0, pos.x, pos.y); 310 break; 311 } 312 return mr; 313 } 314 315 /* Double-click variables. */ 316 static jlong multiClickTime = ::GetDoubleClickTime(); 317 static int multiClickMaxX = ::GetSystemMetrics(SM_CXDOUBLECLK); 318 static int multiClickMaxY = ::GetSystemMetrics(SM_CYDOUBLECLK); 319 static AwtTrayIcon* lastClickTrIc = NULL; 320 static jlong lastTime = 0; 321 static int lastClickX = 0; 322 static int lastClickY = 0; 323 static int lastButton = 0; 324 static int clickCount = 0; 325 326 MsgRouting AwtTrayIcon::WmMouseDown(UINT flags, int x, int y, int button) 327 { 328 jlong now = TimeHelper::windowsToUTC(::GetTickCount()); 329 jint javaModif = AwtComponent::GetJavaModifiers(); 330 331 if (lastClickTrIc == this && 332 lastButton == button && 333 (now - lastTime) <= multiClickTime && 334 abs(x - lastClickX) <= multiClickMaxX && 335 abs(y - lastClickY) <= multiClickMaxY) 336 { 337 clickCount++; 338 } else { 339 clickCount = 1; 340 lastClickTrIc = this; 341 lastButton = button; 342 lastClickX = x; 343 lastClickY = y; 344 } 345 lastTime = now; 346 // it's needed only if WM_LBUTTONUP doesn't come for some reason 347 m_mouseButtonClickAllowed |= AwtComponent::GetButtonMK(button); 348 349 MSG msg; 350 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 351 352 SendMouseEvent(java_awt_event_MouseEvent_MOUSE_PRESSED, now, x, y, 353 javaModif, clickCount, JNI_FALSE, 354 AwtComponent::GetButton(button), &msg); 355 356 return mrConsume; 357 } 358 359 MsgRouting AwtTrayIcon::WmMouseUp(UINT flags, int x, int y, int button) 360 { 361 MSG msg; 362 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 363 364 SendMouseEvent(java_awt_event_MouseEvent_MOUSE_RELEASED, TimeHelper::windowsToUTC(::GetTickCount()), 365 x, y, AwtComponent::GetJavaModifiers(), clickCount, 366 (AwtComponent::GetButton(button) == java_awt_event_MouseEvent_BUTTON3 ? 367 TRUE : FALSE), AwtComponent::GetButton(button), &msg); 368 369 if ((m_mouseButtonClickAllowed & AwtComponent::GetButtonMK(button)) != 0) { // No up-button in the drag-state 370 SendMouseEvent(java_awt_event_MouseEvent_MOUSE_CLICKED, 371 TimeHelper::windowsToUTC(::GetTickCount()), x, y, AwtComponent::GetJavaModifiers(), 372 clickCount, JNI_FALSE, AwtComponent::GetButton(button)); 373 } 374 m_mouseButtonClickAllowed &= ~AwtComponent::GetButtonMK(button); // Exclude the up-button from the drag-state 375 376 return mrConsume; 377 } 378 379 MsgRouting AwtTrayIcon::WmMouseMove(UINT flags, int x, int y) 380 { 381 MSG msg; 382 static AwtTrayIcon* lastComp = NULL; 383 static int lastX = 0; 384 static int lastY = 0; 385 386 /* 387 * Workaround for CR#6267980 388 * Windows sends WM_MOUSEMOVE if mouse is motionless 389 */ 390 if (lastComp != this || x != lastX || y != lastY) { 391 lastComp = this; 392 lastX = x; 393 lastY = y; 394 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 395 if ((flags & ALL_MK_BUTTONS) != 0) { 396 m_mouseButtonClickAllowed = 0; 397 } else { 398 SendMouseEvent(java_awt_event_MouseEvent_MOUSE_MOVED, TimeHelper::windowsToUTC(::GetTickCount()), x, y, 399 AwtComponent::GetJavaModifiers(), 0, JNI_FALSE, 400 java_awt_event_MouseEvent_NOBUTTON, &msg); 401 } 402 } 403 return mrConsume; 404 } 405 406 MsgRouting AwtTrayIcon::WmBalloonUserClick(UINT flags, int x, int y) 407 { 408 if (AwtComponent::GetJavaModifiers() & java_awt_event_InputEvent_BUTTON1_DOWN_MASK) { 409 MSG msg; 410 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 411 SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, TimeHelper::windowsToUTC(::GetTickCount()), 412 AwtComponent::GetJavaModifiers(), &msg); 413 } 414 return mrConsume; 415 } 416 417 MsgRouting AwtTrayIcon::WmKeySelect(UINT flags, int x, int y) 418 { 419 static jlong lastKeySelectTime = 0; 420 jlong now = TimeHelper::windowsToUTC(::GetTickCount()); 421 422 // If a user selects a notify icon with the ENTER key, 423 // Shell 5.0 sends double NIN_KEYSELECT notification. 424 if (lastKeySelectTime != now) { 425 MSG msg; 426 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 427 SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, TimeHelper::windowsToUTC(::GetTickCount()), 428 AwtComponent::GetJavaModifiers(), &msg); 429 } 430 lastKeySelectTime = now; 431 432 return mrConsume; 433 } 434 435 MsgRouting AwtTrayIcon::WmSelect(UINT flags, int x, int y) 436 { 437 438 // If a user click on a notify icon with the mouse, 439 // Shell 5.0 sends NIN_SELECT notification on every click. 440 // To be compatible with JDK6.0 only second click is important. 441 if (clickCount == 2) { 442 MSG msg; 443 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 444 SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, TimeHelper::windowsToUTC(::GetTickCount()), 445 AwtComponent::GetJavaModifiers(), &msg); 446 } 447 return mrConsume; 448 } 449 450 MsgRouting AwtTrayIcon::WmContextMenu(UINT flags, int x, int y) 451 { 452 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); 453 jobject peer = GetPeer(env); 454 if (peer != NULL) { 455 JNU_CallMethodByName(env, NULL, peer, "showPopupMenu", 456 "(II)V", x, y); 457 } 458 return mrConsume; 459 } 460 461 /* 462 * Adds all icons we already have to taskbar. 463 * We use this method on taskbar recreation (see 6369062). 464 */ | 308 case NIN_BALLOONUSERCLICK: 309 mr = WmBalloonUserClick(0, pos.x, pos.y); 310 break; 311 } 312 return mr; 313 } 314 315 /* Double-click variables. */ 316 static jlong multiClickTime = ::GetDoubleClickTime(); 317 static int multiClickMaxX = ::GetSystemMetrics(SM_CXDOUBLECLK); 318 static int multiClickMaxY = ::GetSystemMetrics(SM_CYDOUBLECLK); 319 static AwtTrayIcon* lastClickTrIc = NULL; 320 static jlong lastTime = 0; 321 static int lastClickX = 0; 322 static int lastClickY = 0; 323 static int lastButton = 0; 324 static int clickCount = 0; 325 326 MsgRouting AwtTrayIcon::WmMouseDown(UINT flags, int x, int y, int button) 327 { 328 jlong now = TimeHelper::getMessageTimeUTC(); 329 jint javaModif = AwtComponent::GetJavaModifiers(); 330 331 if (lastClickTrIc == this && 332 lastButton == button && 333 (now - lastTime) <= multiClickTime && 334 abs(x - lastClickX) <= multiClickMaxX && 335 abs(y - lastClickY) <= multiClickMaxY) 336 { 337 clickCount++; 338 } else { 339 clickCount = 1; 340 lastClickTrIc = this; 341 lastButton = button; 342 lastClickX = x; 343 lastClickY = y; 344 } 345 lastTime = now; 346 // it's needed only if WM_LBUTTONUP doesn't come for some reason 347 m_mouseButtonClickAllowed |= AwtComponent::GetButtonMK(button); 348 349 MSG msg; 350 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 351 352 SendMouseEvent(java_awt_event_MouseEvent_MOUSE_PRESSED, now, x, y, 353 javaModif, clickCount, JNI_FALSE, 354 AwtComponent::GetButton(button), &msg); 355 356 return mrConsume; 357 } 358 359 MsgRouting AwtTrayIcon::WmMouseUp(UINT flags, int x, int y, int button) 360 { 361 MSG msg; 362 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 363 364 SendMouseEvent(java_awt_event_MouseEvent_MOUSE_RELEASED, TimeHelper::getMessageTimeUTC(), 365 x, y, AwtComponent::GetJavaModifiers(), clickCount, 366 (AwtComponent::GetButton(button) == java_awt_event_MouseEvent_BUTTON3 ? 367 TRUE : FALSE), AwtComponent::GetButton(button), &msg); 368 369 if ((m_mouseButtonClickAllowed & AwtComponent::GetButtonMK(button)) != 0) { // No up-button in the drag-state 370 SendMouseEvent(java_awt_event_MouseEvent_MOUSE_CLICKED, 371 TimeHelper::getMessageTimeUTC(), x, y, AwtComponent::GetJavaModifiers(), 372 clickCount, JNI_FALSE, AwtComponent::GetButton(button)); 373 } 374 m_mouseButtonClickAllowed &= ~AwtComponent::GetButtonMK(button); // Exclude the up-button from the drag-state 375 376 return mrConsume; 377 } 378 379 MsgRouting AwtTrayIcon::WmMouseMove(UINT flags, int x, int y) 380 { 381 MSG msg; 382 static AwtTrayIcon* lastComp = NULL; 383 static int lastX = 0; 384 static int lastY = 0; 385 386 /* 387 * Workaround for CR#6267980 388 * Windows sends WM_MOUSEMOVE if mouse is motionless 389 */ 390 if (lastComp != this || x != lastX || y != lastY) { 391 lastComp = this; 392 lastX = x; 393 lastY = y; 394 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 395 if ((flags & ALL_MK_BUTTONS) != 0) { 396 m_mouseButtonClickAllowed = 0; 397 } else { 398 SendMouseEvent(java_awt_event_MouseEvent_MOUSE_MOVED, TimeHelper::getMessageTimeUTC(), x, y, 399 AwtComponent::GetJavaModifiers(), 0, JNI_FALSE, 400 java_awt_event_MouseEvent_NOBUTTON, &msg); 401 } 402 } 403 return mrConsume; 404 } 405 406 MsgRouting AwtTrayIcon::WmBalloonUserClick(UINT flags, int x, int y) 407 { 408 if (AwtComponent::GetJavaModifiers() & java_awt_event_InputEvent_BUTTON1_DOWN_MASK) { 409 MSG msg; 410 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 411 SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, TimeHelper::getMessageTimeUTC(), 412 AwtComponent::GetJavaModifiers(), &msg); 413 } 414 return mrConsume; 415 } 416 417 MsgRouting AwtTrayIcon::WmKeySelect(UINT flags, int x, int y) 418 { 419 static jlong lastKeySelectTime = 0; 420 jlong now = TimeHelper::getMessageTimeUTC(); 421 422 // If a user selects a notify icon with the ENTER key, 423 // Shell 5.0 sends double NIN_KEYSELECT notification. 424 if (lastKeySelectTime != now) { 425 MSG msg; 426 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 427 SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, TimeHelper::getMessageTimeUTC(), 428 AwtComponent::GetJavaModifiers(), &msg); 429 } 430 lastKeySelectTime = now; 431 432 return mrConsume; 433 } 434 435 MsgRouting AwtTrayIcon::WmSelect(UINT flags, int x, int y) 436 { 437 438 // If a user click on a notify icon with the mouse, 439 // Shell 5.0 sends NIN_SELECT notification on every click. 440 // To be compatible with JDK6.0 only second click is important. 441 if (clickCount == 2) { 442 MSG msg; 443 AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y); 444 SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, TimeHelper::getMessageTimeUTC(), 445 AwtComponent::GetJavaModifiers(), &msg); 446 } 447 return mrConsume; 448 } 449 450 MsgRouting AwtTrayIcon::WmContextMenu(UINT flags, int x, int y) 451 { 452 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); 453 jobject peer = GetPeer(env); 454 if (peer != NULL) { 455 JNU_CallMethodByName(env, NULL, peer, "showPopupMenu", 456 "(II)V", x, y); 457 } 458 return mrConsume; 459 } 460 461 /* 462 * Adds all icons we already have to taskbar. 463 * We use this method on taskbar recreation (see 6369062). 464 */ |