diff options
author | Neil <nyamatongwe@gmail.com> | 2020-07-31 08:41:23 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2020-07-31 08:41:23 +1000 |
commit | 7dbceab39619db8c2cbe9fadc45a3c83f99dbbb2 (patch) | |
tree | 258b3db436108425cbc5742a04abf0c94e9e0259 | |
parent | d3edcc88f7534bd3456596ea683e4a74ad6f231c (diff) | |
download | scintilla-mirror-7dbceab39619db8c2cbe9fadc45a3c83f99dbbb2.tar.gz |
Refactored ContextCursor to avoid multiple Point conversions.
Reversed order of selection checks as SelectionEmpty is lighter than
PointInSelection.
-rw-r--r-- | win32/ScintillaWin.cxx | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 7c5c1a6ae..ce6f8279e 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -449,7 +449,7 @@ class ScintillaWin : void ChangeScrollPos(int barType, Sci::Position pos); sptr_t GetTextLength(); sptr_t GetText(uptr_t wParam, sptr_t lParam); - Window::Cursor ContextCursor(); + Window::Cursor ContextCursor(Point pt); sptr_t ShowContextMenu(unsigned int iMessage, uptr_t wParam, sptr_t lParam); void SizeWindow(); sptr_t MouseMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam); @@ -1363,23 +1363,19 @@ sptr_t ScintillaWin::GetText(uptr_t wParam, sptr_t lParam) { } } -Window::Cursor ScintillaWin::ContextCursor() { +Window::Cursor ScintillaWin::ContextCursor(Point pt) { if (inDragDrop == ddDragging) { return Window::cursorUp; } else { // Display regular (drag) cursor over selection - POINT pt; - if (0 != ::GetCursorPos(&pt)) { - ::ScreenToClient(MainHWND(), &pt); - if (PointInSelMargin(PointFromPOINT(pt))) { - return GetMarginCursor(PointFromPOINT(pt)); - } else if (PointInSelection(PointFromPOINT(pt)) && !SelectionEmpty()) { - return Window::cursorArrow; - } else if (PointIsHotspot(PointFromPOINT(pt))) { - return Window::cursorHand; - } else if (hoverIndicatorPos != Sci::invalidPosition) { - return Window::cursorHand; - } + if (PointInSelMargin(pt)) { + return GetMarginCursor(pt); + } else if (!SelectionEmpty() && PointInSelection(pt)) { + return Window::cursorArrow; + } else if (PointIsHotspot(pt)) { + return Window::cursorHand; + } else if (hoverIndicatorPos != Sci::invalidPosition) { + return Window::cursorHand; } } return Window::cursorText; @@ -1921,7 +1917,11 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case WM_SETCURSOR: if (LOWORD(lParam) == HTCLIENT) { - DisplayCursor(ContextCursor()); + POINT pt; + if (::GetCursorPos(&pt)) { + ::ScreenToClient(MainHWND(), &pt); + DisplayCursor(ContextCursor(PointFromPOINT(pt))); + } return TRUE; } else { return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); |