diff options
| author | Zufu Liu <unknown> | 2020-02-09 09:19:56 +1100 |
|---|---|---|
| committer | Zufu Liu <unknown> | 2020-02-09 09:19:56 +1100 |
| commit | 90a498aa44da18855534f4e8b001de07460ccb72 (patch) | |
| tree | af1d8fef272b53b1b0d261eb1a24314fbaba9dbe /win32/ScintillaWin.cxx | |
| parent | fb900ef3e4342b79a529a99fd120e628ab53f400 (diff) | |
| download | scintilla-mirror-90a498aa44da18855534f4e8b001de07460ccb72.tar.gz | |
Backport: Feature [feature-requests:#1340] Move and use Point functions to avoid casting.
Backport of changeset 7976:4ba647207671.
Diffstat (limited to 'win32/ScintillaWin.cxx')
| -rw-r--r-- | win32/ScintillaWin.cxx | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index b17cf6510..3984cc461 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -155,15 +155,10 @@ void SetWindowID(HWND hWnd, int identifier) noexcept { ::SetWindowLongPtr(hWnd, GWLP_ID, identifier); } -Point PointFromPOINT(POINT pt) noexcept { - return Point::FromInts(pt.x, pt.y); -} Point PointFromLParam(sptr_t lpoint) noexcept { return Point::FromInts(GET_X_LPARAM(lpoint), GET_Y_LPARAM(lpoint)); } -constexpr POINT POINTFromPoint(Point pt) noexcept { - return POINT{ static_cast<LONG>(pt.x), static_cast<LONG>(pt.y) }; -} + bool KeyboardIsKeyDown(int key) noexcept { return (::GetKeyState(key) & 0x80000000) != 0; } @@ -1337,7 +1332,7 @@ Window::Cursor ScintillaWin::ContextCursor() { sptr_t ScintillaWin::ShowContextMenu(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { Point pt = PointFromLParam(lParam); - POINT rpt = { static_cast<int>(pt.x), static_cast<int>(pt.y) }; + POINT rpt = POINTFromPoint(pt); ::ScreenToClient(MainHWND(), &rpt); const Point ptClient = PointFromPOINT(rpt); if (ShouldDisplayPopup(ptClient)) { @@ -1426,9 +1421,7 @@ sptr_t ScintillaWin::MouseMessage(unsigned int iMessage, uptr_t wParam, sptr_t l // handle the message but pass it on. RECT rc; GetWindowRect(MainHWND(), &rc); - POINT pt; - pt.x = GET_X_LPARAM(lParam); - pt.y = GET_Y_LPARAM(lParam); + const POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; if (!PtInRect(&rc, pt)) return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); } |
