From eea3df558f3293ebedc7b88773e0706cdae23972 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Sun, 9 Feb 2020 09:19:56 +1100 Subject: Feature [feature-requests:#1340] Move and use Point functions to avoid casting. --- win32/ScintillaWin.cxx | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'win32/ScintillaWin.cxx') diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 232352224..8844e01c5 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -156,15 +156,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(pt.x), static_cast(pt.y) }; -} + bool KeyboardIsKeyDown(int key) noexcept { return (::GetKeyState(key) & 0x80000000) != 0; } @@ -1347,7 +1342,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(pt.x), static_cast(pt.y) }; + POINT rpt = POINTFromPoint(pt); ::ScreenToClient(MainHWND(), &rpt); const Point ptClient = PointFromPOINT(rpt); if (ShouldDisplayPopup(ptClient)) { @@ -1436,9 +1431,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); } -- cgit v1.2.3