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 | 304a8152dfb4d5e4e7775da3f61aa9343d161472 (patch) | |
tree | d2551d7064abf048a16e0dc14ec5773a5de17349 | |
parent | 12ff4f9958a3803560ce9a0a57c5f50100bc4004 (diff) | |
download | scintilla-mirror-304a8152dfb4d5e4e7775da3f61aa9343d161472.tar.gz |
Backport: Refactored ContextCursor to avoid multiple Point conversions.
Reversed order of selection checks as SelectionEmpty is lighter than
PointInSelection.
Backport of changeset 8468:7b1106eeebbb.
-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 cc2f6f90e..11f411ba2 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -444,7 +444,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); @@ -1351,23 +1351,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; @@ -1896,7 +1892,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); |