aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2024-02-28 09:02:47 +1100
committerNeil <nyamatongwe@gmail.com>2024-02-28 09:02:47 +1100
commit788c7b6cd96bd6734a77e654d1c59b3b48117953 (patch)
tree7ad7e717a82edf6a12dcbf72d5dfd3b3dcb8cf35
parentc596111b25cc19cc31945b28dbc00a57f9172689 (diff)
downloadscintilla-mirror-788c7b6cd96bd6734a77e654d1c59b3b48117953.tar.gz
Encapsulate LPARAM to POINT conversion. Make PointFromLParam constexpr.
-rw-r--r--win32/ScintillaWin.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index f45c4e626..de1bf2fb7 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -133,7 +133,11 @@ void SetWindowID(HWND hWnd, int identifier) noexcept {
::SetWindowLongPtr(hWnd, GWLP_ID, identifier);
}
-Point PointFromLParam(sptr_t lpoint) noexcept {
+constexpr POINT POINTFromLParam(sptr_t lParam) noexcept {
+ return { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
+};
+
+constexpr Point PointFromLParam(sptr_t lpoint) noexcept {
return Point::FromInts(GET_X_LPARAM(lpoint), GET_Y_LPARAM(lpoint));
}
@@ -1613,7 +1617,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);
- const POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
+ const POINT pt = POINTFromLParam(lParam);
if (!PtInRect(&rc, pt))
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
}
@@ -3696,8 +3700,8 @@ LRESULT PASCAL ScintillaWin::CTWndProc(
::EndPaint(hWnd, &ps);
return 0;
} else if ((iMessage == WM_NCLBUTTONDOWN) || (iMessage == WM_NCLBUTTONDBLCLK)) {
- POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
- ScreenToClient(hWnd, &pt);
+ POINT pt = POINTFromLParam(lParam);
+ ::ScreenToClient(hWnd, &pt);
sciThis->ct.MouseClick(PointFromPOINT(pt));
sciThis->CallTipClick();
return 0;