< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Component.cpp

Print this page




 234     m_validationNestCount = 0;
 235 
 236     m_dropTarget = NULL;
 237 
 238     m_InputMethod = NULL;
 239     m_useNativeCompWindow = TRUE;
 240     m_PendingLeadByte = 0;
 241     m_bitsCandType = 0;
 242 
 243     windowMoveLockPosX = 0;
 244     windowMoveLockPosY = 0;
 245     windowMoveLockPosCX = 0;
 246     windowMoveLockPosCY = 0;
 247 
 248     m_hCursorCache = NULL;
 249 
 250     m_bSubclassed = FALSE;
 251     m_bPauseDestroy = FALSE;
 252 
 253     m_MessagesProcessing = 0;
 254     m_wheelRotationAmount = 0;

 255     if (!sm_PrimaryDynamicTableBuilt) {
 256         // do it once.
 257         AwtComponent::BuildPrimaryDynamicTable();
 258         sm_PrimaryDynamicTableBuilt = TRUE;
 259     }
 260 
 261     deadKeyActive = FALSE;
 262 }
 263 
 264 AwtComponent::~AwtComponent()
 265 {
 266     DASSERT(AwtToolkit::IsMainThread());
 267 
 268     /* Disconnect all links. */
 269     UnlinkObjects();
 270 
 271     /*
 272      * All the messages for this component are processed, native
 273      * resources are freed, and Java object is not connected to
 274      * the native one anymore. So we can safely destroy component's


1191         WIN_MSG(WM_CTLCOLOREDIT)
1192         WIN_MSG(WM_CTLCOLORLISTBOX)
1193         WIN_MSG(WM_CTLCOLORBTN)
1194         WIN_MSG(WM_CTLCOLORDLG)
1195         WIN_MSG(WM_CTLCOLORSCROLLBAR)
1196         WIN_MSG(WM_CTLCOLORSTATIC)
1197         WIN_MSG(WM_MOUSEMOVE)
1198         WIN_MSG(WM_LBUTTONDOWN)
1199         WIN_MSG(WM_LBUTTONUP)
1200         WIN_MSG(WM_LBUTTONDBLCLK)
1201         WIN_MSG(WM_RBUTTONDOWN)
1202         WIN_MSG(WM_RBUTTONUP)
1203         WIN_MSG(WM_RBUTTONDBLCLK)
1204         WIN_MSG(WM_MBUTTONDOWN)
1205         WIN_MSG(WM_MBUTTONUP)
1206         WIN_MSG(WM_MBUTTONDBLCLK)
1207         WIN_MSG(WM_XBUTTONDBLCLK)
1208         WIN_MSG(WM_XBUTTONDOWN)
1209         WIN_MSG(WM_XBUTTONUP)
1210         WIN_MSG(WM_MOUSEWHEEL)

1211         WIN_MSG(WM_PARENTNOTIFY)
1212         WIN_MSG(WM_ENTERMENULOOP)
1213         WIN_MSG(WM_EXITMENULOOP)
1214         WIN_MSG(WM_NEXTMENU)
1215         WIN_MSG(WM_SIZING)
1216         WIN_MSG(WM_CAPTURECHANGED)
1217         WIN_MSG(WM_MOVING)
1218         WIN_MSG(WM_POWERBROADCAST)
1219         WIN_MSG(WM_DEVICECHANGE)
1220         WIN_MSG(WM_MDICREATE)
1221         WIN_MSG(WM_MDIDESTROY)
1222         WIN_MSG(WM_MDIACTIVATE)
1223         WIN_MSG(WM_MDIRESTORE)
1224         WIN_MSG(WM_MDINEXT)
1225         WIN_MSG(WM_MDIMAXIMIZE)
1226         WIN_MSG(WM_MDITILE)
1227         WIN_MSG(WM_MDICASCADE)
1228         WIN_MSG(WM_MDIICONARRANGE)
1229         WIN_MSG(WM_MDIGETACTIVE)
1230         WIN_MSG(WM_MDISETMENU)


1622           if (ignoreNextLBTNUP) {
1623               ignoreNextLBTNUP = FALSE;
1624               return mrDoDefault;
1625           }
1626           //fall-through
1627       case WM_LBUTTONDOWN:
1628           ignoreNextLBTNUP = FALSE;
1629           //fall-through
1630       case WM_LBUTTONDBLCLK:
1631       case WM_RBUTTONDOWN:
1632       case WM_RBUTTONDBLCLK:
1633       case WM_RBUTTONUP:
1634       case WM_MBUTTONDOWN:
1635       case WM_MBUTTONDBLCLK:
1636       case WM_MBUTTONUP:
1637       case WM_XBUTTONDBLCLK:
1638       case WM_XBUTTONDOWN:
1639       case WM_XBUTTONUP:
1640       case WM_MOUSEMOVE:
1641       case WM_MOUSEWHEEL:

1642       case WM_AWT_MOUSEENTER:
1643       case WM_AWT_MOUSEEXIT:
1644           curPos = ::GetMessagePos();
1645           POINT myPos;
1646           myPos.x = GET_X_LPARAM(curPos);
1647           myPos.y = GET_Y_LPARAM(curPos);
1648           ::ScreenToClient(GetHWnd(), &myPos);
1649           switch(switchMessage) {
1650           case WM_AWT_MOUSEENTER:
1651               mr = WmMouseEnter(static_cast<UINT>(wParam), myPos.x, myPos.y);
1652               break;
1653           case WM_LBUTTONDOWN:
1654           case WM_LBUTTONDBLCLK:
1655               mr = WmMouseDown(static_cast<UINT>(wParam), myPos.x, myPos.y,
1656                                LEFT_BUTTON);
1657               break;
1658           case WM_LBUTTONUP:
1659               mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
1660                              LEFT_BUTTON);
1661               break;


1692                   }
1693               }
1694               break;
1695           case WM_RBUTTONDOWN:
1696           case WM_RBUTTONDBLCLK:
1697               mr = WmMouseDown(static_cast<UINT>(wParam), myPos.x, myPos.y,
1698                                RIGHT_BUTTON);
1699               break;
1700           case WM_RBUTTONUP:
1701               mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
1702                              RIGHT_BUTTON);
1703               break;
1704           case WM_MBUTTONUP:
1705               mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
1706                              MIDDLE_BUTTON);
1707               break;
1708           case WM_AWT_MOUSEEXIT:
1709               mr = WmMouseExit(static_cast<UINT>(wParam), myPos.x, myPos.y);
1710               break;
1711           case  WM_MOUSEWHEEL:

1712               mr = WmMouseWheel(GET_KEYSTATE_WPARAM(wParam),
1713                                 GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
1714                                 GET_WHEEL_DELTA_WPARAM(wParam));

1715               break;
1716           }
1717           break;
1718       case WM_SETCURSOR:
1719           mr = mrDoDefault;
1720           if (LOWORD(lParam) == HTCLIENT) {
1721               if (AwtComponent* comp =
1722                                     AwtComponent::GetComponent((HWND)wParam)) {
1723                   AwtCursor::UpdateCursor(comp);
1724                   mr = mrConsume;
1725               }
1726           }
1727           break;
1728 
1729       case WM_KEYDOWN:
1730           mr = WmKeyDown(static_cast<UINT>(wParam),
1731                          LOWORD(lParam), HIWORD(lParam), FALSE);
1732           break;
1733       case WM_KEYUP:
1734           mr = WmKeyUp(static_cast<UINT>(wParam),


2061     return mrDoDefault;
2062 }
2063 
2064 MsgRouting AwtComponent::WmEnterMenuLoop(BOOL isTrackPopupMenu)
2065 {
2066     return mrDoDefault;
2067 }
2068 
2069 MsgRouting AwtComponent::WmExitMenuLoop(BOOL isTrackPopupMenu)
2070 {
2071     return mrDoDefault;
2072 }
2073 
2074 MsgRouting AwtComponent::WmShowWindow(BOOL show, UINT status)
2075 {
2076     return mrDoDefault;
2077 }
2078 
2079 MsgRouting AwtComponent::WmSetFocus(HWND hWndLostFocus)
2080 {
2081     m_wheelRotationAmount = 0;

2082     return mrDoDefault;
2083 }
2084 
2085 MsgRouting AwtComponent::WmKillFocus(HWND hWndGotFocus)
2086 {
2087     m_wheelRotationAmount = 0;

2088     return mrDoDefault;
2089 }
2090 
2091 MsgRouting AwtComponent::WmCtlColor(HDC hDC, HWND hCtrl,
2092                                     UINT ctlColor, HBRUSH& retBrush)
2093 {
2094     AwtComponent* child = AwtComponent::GetComponent(hCtrl);
2095     if (child) {
2096         ::SetBkColor(hDC, child->GetBackgroundColor());
2097         ::SetTextColor(hDC, child->GetColor());
2098         retBrush = child->GetBackgroundBrush();
2099         return mrConsume;
2100     }
2101     return mrDoDefault;
2102 /*
2103     switch (ctlColor) {
2104         case CTLCOLOR_MSGBOX:
2105         case CTLCOLOR_EDIT:
2106         case CTLCOLOR_LISTBOX:
2107         case CTLCOLOR_BTN:


2444             MSG msg;
2445             InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
2446             SendMouseEvent(java_awt_event_MouseEvent_MOUSE_MOVED, ::JVM_CurrentTimeMillis(NULL, 0), x, y,
2447                            GetJavaModifiers(), 0, JNI_FALSE,
2448                            java_awt_event_MouseEvent_NOBUTTON, &msg);
2449         }
2450     }
2451 
2452     return mrConsume;
2453 }
2454 
2455 MsgRouting AwtComponent::WmMouseExit(UINT flags, int x, int y)
2456 {
2457     SendMouseEvent(java_awt_event_MouseEvent_MOUSE_EXITED, ::JVM_CurrentTimeMillis(NULL, 0), x,
2458                    y, GetJavaModifiers(), 0, JNI_FALSE);
2459     sm_cursorOn = NULL;
2460     return mrConsume;   /* Don't pass our synthetic event on! */
2461 }
2462 
2463 MsgRouting AwtComponent::WmMouseWheel(UINT flags, int x, int y,
2464                                       int wheelRotation)
2465 {
2466     // convert coordinates to be Component-relative, not screen relative
2467     // for wheeling when outside the window, this works similar to
2468     // coordinates during a drag
2469     POINT eventPt;
2470     eventPt.x = x;
2471     eventPt.y = y;
2472     DTRACE_PRINT2("  original coords: %i,%i\n", x, y);
2473     ::ScreenToClient(GetHWnd(), &eventPt);
2474     DTRACE_PRINT2("  new coords: %i,%i\n\n", eventPt.x, eventPt.y);
2475 
2476     // set some defaults
2477     jint scrollType = java_awt_event_MouseWheelEvent_WHEEL_UNIT_SCROLL;
2478     jint scrollLines = 3;
2479 
2480     BOOL result;
2481     UINT platformLines;
2482 
2483     m_wheelRotationAmount += wheelRotation;
2484 
2485     // AWT interprets wheel rotation differently than win32, so we need to
2486     // decode wheel amount.
2487     jint roundedWheelRotation = m_wheelRotationAmount / (-1 * WHEEL_DELTA);
2488     jdouble preciseWheelRotation = (jdouble) wheelRotation / (-1 * WHEEL_DELTA);













2489 
2490     MSG msg;
2491     result = ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
2492                                     &platformLines, 0);
2493     InitMessage(&msg, lastMessage, MAKEWPARAM(flags, wheelRotation),
2494                 MAKELPARAM(x, y));
2495 
2496     if (result) {
2497         if (platformLines == WHEEL_PAGESCROLL) {
2498             scrollType = java_awt_event_MouseWheelEvent_WHEEL_BLOCK_SCROLL;
2499             scrollLines = 1;
2500         }
2501         else {
2502             scrollType = java_awt_event_MouseWheelEvent_WHEEL_UNIT_SCROLL;
2503             scrollLines = platformLines;
2504         }
2505     }
2506 
2507     DTRACE_PRINTLN("calling SendMouseWheelEvent");
2508 
2509     SendMouseWheelEvent(java_awt_event_MouseEvent_MOUSE_WHEEL, ::JVM_CurrentTimeMillis(NULL, 0),
2510                         eventPt.x, eventPt.y, GetJavaModifiers(), 0, 0, scrollType,
2511                         scrollLines, roundedWheelRotation, preciseWheelRotation, &msg);
2512 
2513     m_wheelRotationAmount %= WHEEL_DELTA;

2514     // this message could be propagated up to the parent chain
2515     // by the mouse message post processors
2516     return mrConsume;
2517 }
2518 
2519 jint AwtComponent::GetKeyLocation(UINT wkey, UINT flags) {
2520     // Rector+Newcomer page 413
2521     // The extended keys are the Alt and Control on the right of
2522     // the space bar, the non-Numpad arrow keys, the non-Numpad
2523     // Insert, PageUp, etc. keys, and the Numpad Divide and Enter keys.
2524     // Note that neither Shift key is extended.
2525     // Although not listed in Rector+Newcomer, both Windows keys
2526     // (91 and 92) are extended keys, the Context Menu key
2527     // (property key or application key - 93) is extended,
2528     // and so is the NumLock key.
2529 
2530     // wkey is the wParam, flags is the HIWORD of the lParam
2531 
2532     // "Extended" bit is 24th in lParam, so it's 8th in flags = HIWORD(lParam)
2533     BOOL extended = ((1<<8) & flags);




 234     m_validationNestCount = 0;
 235 
 236     m_dropTarget = NULL;
 237 
 238     m_InputMethod = NULL;
 239     m_useNativeCompWindow = TRUE;
 240     m_PendingLeadByte = 0;
 241     m_bitsCandType = 0;
 242 
 243     windowMoveLockPosX = 0;
 244     windowMoveLockPosY = 0;
 245     windowMoveLockPosCX = 0;
 246     windowMoveLockPosCY = 0;
 247 
 248     m_hCursorCache = NULL;
 249 
 250     m_bSubclassed = FALSE;
 251     m_bPauseDestroy = FALSE;
 252 
 253     m_MessagesProcessing = 0;
 254     m_wheelRotationAmountX = 0;
 255     m_wheelRotationAmountY = 0;
 256     if (!sm_PrimaryDynamicTableBuilt) {
 257         // do it once.
 258         AwtComponent::BuildPrimaryDynamicTable();
 259         sm_PrimaryDynamicTableBuilt = TRUE;
 260     }
 261 
 262     deadKeyActive = FALSE;
 263 }
 264 
 265 AwtComponent::~AwtComponent()
 266 {
 267     DASSERT(AwtToolkit::IsMainThread());
 268 
 269     /* Disconnect all links. */
 270     UnlinkObjects();
 271 
 272     /*
 273      * All the messages for this component are processed, native
 274      * resources are freed, and Java object is not connected to
 275      * the native one anymore. So we can safely destroy component's


1192         WIN_MSG(WM_CTLCOLOREDIT)
1193         WIN_MSG(WM_CTLCOLORLISTBOX)
1194         WIN_MSG(WM_CTLCOLORBTN)
1195         WIN_MSG(WM_CTLCOLORDLG)
1196         WIN_MSG(WM_CTLCOLORSCROLLBAR)
1197         WIN_MSG(WM_CTLCOLORSTATIC)
1198         WIN_MSG(WM_MOUSEMOVE)
1199         WIN_MSG(WM_LBUTTONDOWN)
1200         WIN_MSG(WM_LBUTTONUP)
1201         WIN_MSG(WM_LBUTTONDBLCLK)
1202         WIN_MSG(WM_RBUTTONDOWN)
1203         WIN_MSG(WM_RBUTTONUP)
1204         WIN_MSG(WM_RBUTTONDBLCLK)
1205         WIN_MSG(WM_MBUTTONDOWN)
1206         WIN_MSG(WM_MBUTTONUP)
1207         WIN_MSG(WM_MBUTTONDBLCLK)
1208         WIN_MSG(WM_XBUTTONDBLCLK)
1209         WIN_MSG(WM_XBUTTONDOWN)
1210         WIN_MSG(WM_XBUTTONUP)
1211         WIN_MSG(WM_MOUSEWHEEL)
1212         WIN_MSG(WM_MOUSEHWHEEL)
1213         WIN_MSG(WM_PARENTNOTIFY)
1214         WIN_MSG(WM_ENTERMENULOOP)
1215         WIN_MSG(WM_EXITMENULOOP)
1216         WIN_MSG(WM_NEXTMENU)
1217         WIN_MSG(WM_SIZING)
1218         WIN_MSG(WM_CAPTURECHANGED)
1219         WIN_MSG(WM_MOVING)
1220         WIN_MSG(WM_POWERBROADCAST)
1221         WIN_MSG(WM_DEVICECHANGE)
1222         WIN_MSG(WM_MDICREATE)
1223         WIN_MSG(WM_MDIDESTROY)
1224         WIN_MSG(WM_MDIACTIVATE)
1225         WIN_MSG(WM_MDIRESTORE)
1226         WIN_MSG(WM_MDINEXT)
1227         WIN_MSG(WM_MDIMAXIMIZE)
1228         WIN_MSG(WM_MDITILE)
1229         WIN_MSG(WM_MDICASCADE)
1230         WIN_MSG(WM_MDIICONARRANGE)
1231         WIN_MSG(WM_MDIGETACTIVE)
1232         WIN_MSG(WM_MDISETMENU)


1624           if (ignoreNextLBTNUP) {
1625               ignoreNextLBTNUP = FALSE;
1626               return mrDoDefault;
1627           }
1628           //fall-through
1629       case WM_LBUTTONDOWN:
1630           ignoreNextLBTNUP = FALSE;
1631           //fall-through
1632       case WM_LBUTTONDBLCLK:
1633       case WM_RBUTTONDOWN:
1634       case WM_RBUTTONDBLCLK:
1635       case WM_RBUTTONUP:
1636       case WM_MBUTTONDOWN:
1637       case WM_MBUTTONDBLCLK:
1638       case WM_MBUTTONUP:
1639       case WM_XBUTTONDBLCLK:
1640       case WM_XBUTTONDOWN:
1641       case WM_XBUTTONUP:
1642       case WM_MOUSEMOVE:
1643       case WM_MOUSEWHEEL:
1644       case WM_MOUSEHWHEEL:
1645       case WM_AWT_MOUSEENTER:
1646       case WM_AWT_MOUSEEXIT:
1647           curPos = ::GetMessagePos();
1648           POINT myPos;
1649           myPos.x = GET_X_LPARAM(curPos);
1650           myPos.y = GET_Y_LPARAM(curPos);
1651           ::ScreenToClient(GetHWnd(), &myPos);
1652           switch(switchMessage) {
1653           case WM_AWT_MOUSEENTER:
1654               mr = WmMouseEnter(static_cast<UINT>(wParam), myPos.x, myPos.y);
1655               break;
1656           case WM_LBUTTONDOWN:
1657           case WM_LBUTTONDBLCLK:
1658               mr = WmMouseDown(static_cast<UINT>(wParam), myPos.x, myPos.y,
1659                                LEFT_BUTTON);
1660               break;
1661           case WM_LBUTTONUP:
1662               mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
1663                              LEFT_BUTTON);
1664               break;


1695                   }
1696               }
1697               break;
1698           case WM_RBUTTONDOWN:
1699           case WM_RBUTTONDBLCLK:
1700               mr = WmMouseDown(static_cast<UINT>(wParam), myPos.x, myPos.y,
1701                                RIGHT_BUTTON);
1702               break;
1703           case WM_RBUTTONUP:
1704               mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
1705                              RIGHT_BUTTON);
1706               break;
1707           case WM_MBUTTONUP:
1708               mr = WmMouseUp(static_cast<UINT>(wParam), myPos.x, myPos.y,
1709                              MIDDLE_BUTTON);
1710               break;
1711           case WM_AWT_MOUSEEXIT:
1712               mr = WmMouseExit(static_cast<UINT>(wParam), myPos.x, myPos.y);
1713               break;
1714           case WM_MOUSEWHEEL:
1715           case WM_MOUSEHWHEEL:
1716               mr = WmMouseWheel(GET_KEYSTATE_WPARAM(wParam),
1717                                 GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
1718                                 GET_WHEEL_DELTA_WPARAM(wParam),
1719                                 switchMessage == WM_MOUSEHWHEEL);
1720               break;
1721           }
1722           break;
1723       case WM_SETCURSOR:
1724           mr = mrDoDefault;
1725           if (LOWORD(lParam) == HTCLIENT) {
1726               if (AwtComponent* comp =
1727                                     AwtComponent::GetComponent((HWND)wParam)) {
1728                   AwtCursor::UpdateCursor(comp);
1729                   mr = mrConsume;
1730               }
1731           }
1732           break;
1733 
1734       case WM_KEYDOWN:
1735           mr = WmKeyDown(static_cast<UINT>(wParam),
1736                          LOWORD(lParam), HIWORD(lParam), FALSE);
1737           break;
1738       case WM_KEYUP:
1739           mr = WmKeyUp(static_cast<UINT>(wParam),


2066     return mrDoDefault;
2067 }
2068 
2069 MsgRouting AwtComponent::WmEnterMenuLoop(BOOL isTrackPopupMenu)
2070 {
2071     return mrDoDefault;
2072 }
2073 
2074 MsgRouting AwtComponent::WmExitMenuLoop(BOOL isTrackPopupMenu)
2075 {
2076     return mrDoDefault;
2077 }
2078 
2079 MsgRouting AwtComponent::WmShowWindow(BOOL show, UINT status)
2080 {
2081     return mrDoDefault;
2082 }
2083 
2084 MsgRouting AwtComponent::WmSetFocus(HWND hWndLostFocus)
2085 {
2086     m_wheelRotationAmountX = 0;
2087     m_wheelRotationAmountY = 0;
2088     return mrDoDefault;
2089 }
2090 
2091 MsgRouting AwtComponent::WmKillFocus(HWND hWndGotFocus)
2092 {
2093     m_wheelRotationAmountX = 0;
2094     m_wheelRotationAmountY = 0;
2095     return mrDoDefault;
2096 }
2097 
2098 MsgRouting AwtComponent::WmCtlColor(HDC hDC, HWND hCtrl,
2099                                     UINT ctlColor, HBRUSH& retBrush)
2100 {
2101     AwtComponent* child = AwtComponent::GetComponent(hCtrl);
2102     if (child) {
2103         ::SetBkColor(hDC, child->GetBackgroundColor());
2104         ::SetTextColor(hDC, child->GetColor());
2105         retBrush = child->GetBackgroundBrush();
2106         return mrConsume;
2107     }
2108     return mrDoDefault;
2109 /*
2110     switch (ctlColor) {
2111         case CTLCOLOR_MSGBOX:
2112         case CTLCOLOR_EDIT:
2113         case CTLCOLOR_LISTBOX:
2114         case CTLCOLOR_BTN:


2451             MSG msg;
2452             InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
2453             SendMouseEvent(java_awt_event_MouseEvent_MOUSE_MOVED, ::JVM_CurrentTimeMillis(NULL, 0), x, y,
2454                            GetJavaModifiers(), 0, JNI_FALSE,
2455                            java_awt_event_MouseEvent_NOBUTTON, &msg);
2456         }
2457     }
2458 
2459     return mrConsume;
2460 }
2461 
2462 MsgRouting AwtComponent::WmMouseExit(UINT flags, int x, int y)
2463 {
2464     SendMouseEvent(java_awt_event_MouseEvent_MOUSE_EXITED, ::JVM_CurrentTimeMillis(NULL, 0), x,
2465                    y, GetJavaModifiers(), 0, JNI_FALSE);
2466     sm_cursorOn = NULL;
2467     return mrConsume;   /* Don't pass our synthetic event on! */
2468 }
2469 
2470 MsgRouting AwtComponent::WmMouseWheel(UINT flags, int x, int y,
2471                                       int wheelRotation, BOOL isHorizontal)
2472 {
2473     // convert coordinates to be Component-relative, not screen relative
2474     // for wheeling when outside the window, this works similar to
2475     // coordinates during a drag
2476     POINT eventPt;
2477     eventPt.x = x;
2478     eventPt.y = y;
2479     DTRACE_PRINT2("  original coords: %i,%i\n", x, y);
2480     ::ScreenToClient(GetHWnd(), &eventPt);
2481     DTRACE_PRINT2("  new coords: %i,%i\n\n", eventPt.x, eventPt.y);
2482 
2483     // set some defaults
2484     jint scrollType = java_awt_event_MouseWheelEvent_WHEEL_UNIT_SCROLL;
2485     jint toScroll = 3;
2486 
2487     BOOL result;
2488     UINT platformUnits;
2489     jint roundedWheelRotation;
2490     jdouble preciseWheelRotation;
2491 
2492     // AWT interprets wheel rotation differently than win32, so we need to
2493     // decode wheel amount.
2494     jint modifiers = GetJavaModifiers();
2495     if (isHorizontal) {
2496         modifiers |= java_awt_event_InputEvent_SHIFT_DOWN_MASK;
2497         m_wheelRotationAmountX += wheelRotation;
2498         roundedWheelRotation = m_wheelRotationAmountX / (WHEEL_DELTA);
2499         preciseWheelRotation = (jdouble) wheelRotation / (WHEEL_DELTA);
2500         result = ::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0,
2501                                         &platformUnits, 0);
2502     } else {
2503         m_wheelRotationAmountY += wheelRotation;
2504         roundedWheelRotation = m_wheelRotationAmountY / (-1 * WHEEL_DELTA);
2505         preciseWheelRotation = (jdouble) wheelRotation / (-1 * WHEEL_DELTA);
2506         result = ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
2507                                         &platformUnits, 0);
2508     }
2509 
2510     MSG msg;


2511     InitMessage(&msg, lastMessage, MAKEWPARAM(flags, wheelRotation),
2512                 MAKELPARAM(x, y));
2513 
2514     if (result) {
2515         if (platformUnits == WHEEL_PAGESCROLL) {
2516             scrollType = java_awt_event_MouseWheelEvent_WHEEL_BLOCK_SCROLL;
2517             toScroll = 1;
2518         }
2519         else {
2520             scrollType = java_awt_event_MouseWheelEvent_WHEEL_UNIT_SCROLL;
2521             toScroll = platformUnits;
2522         }
2523     }
2524 
2525     DTRACE_PRINTLN("calling SendMouseWheelEvent");
2526 
2527     SendMouseWheelEvent(java_awt_event_MouseEvent_MOUSE_WHEEL, ::JVM_CurrentTimeMillis(NULL, 0),
2528                         eventPt.x, eventPt.y, modifiers, 0, 0, scrollType,
2529                         toScroll, roundedWheelRotation, preciseWheelRotation, &msg);
2530 
2531     m_wheelRotationAmountX %= WHEEL_DELTA;
2532     m_wheelRotationAmountY %= WHEEL_DELTA;
2533     // this message could be propagated up to the parent chain
2534     // by the mouse message post processors
2535     return mrConsume;
2536 }
2537 
2538 jint AwtComponent::GetKeyLocation(UINT wkey, UINT flags) {
2539     // Rector+Newcomer page 413
2540     // The extended keys are the Alt and Control on the right of
2541     // the space bar, the non-Numpad arrow keys, the non-Numpad
2542     // Insert, PageUp, etc. keys, and the Numpad Divide and Enter keys.
2543     // Note that neither Shift key is extended.
2544     // Although not listed in Rector+Newcomer, both Windows keys
2545     // (91 and 92) are extended keys, the Context Menu key
2546     // (property key or application key - 93) is extended,
2547     // and so is the NumLock key.
2548 
2549     // wkey is the wParam, flags is the HIWORD of the lParam
2550 
2551     // "Extended" bit is 24th in lParam, so it's 8th in flags = HIWORD(lParam)
2552     BOOL extended = ((1<<8) & flags);


< prev index next >