diff options
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 35 |
2 files changed, 31 insertions, 8 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 6ee87dc4e..eaecc0075 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -593,6 +593,10 @@ previous. <a href="https://sourceforge.net/p/scintilla/feature-requests/1486/">Feature #1486</a>. </li> + <li> + On Win32 hide cursor when typing if that system preference has been chosen. + <a href="https://sourceforge.net/p/scintilla/bugs/2333/">Bug #2333</a>. + </li> </ul> <h3> <a href="https://www.scintilla.org/scintilla535.zip">Release 5.3.5</a> diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 970054f03..95bb79825 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -333,6 +333,8 @@ class ScintillaWin : bool capturedMouse; bool trackedMouseLeave; + BOOL typingWithoutCursor; + bool cursorIsHidden; SetCoalescableTimerSig SetCoalescableTimerFn; unsigned int linesPerScroll; ///< Intellimouse support @@ -445,6 +447,7 @@ class ScintillaWin : void SetMouseCapture(bool on) override; bool HaveMouseCapture() override; void SetTrackMouseLeaveEvent(bool on) noexcept; + void HideCursorIfPreferred() noexcept; void UpdateBaseElements() override; bool PaintContains(PRectangle rc) override; void ScrollText(Sci::Line linesToMove) override; @@ -470,7 +473,7 @@ class ScintillaWin : void AddToPopUp(const char *label, int cmd = 0, bool enabled = true) override; void ClaimSelection() override; - void GetIntelliMouseParameters() noexcept; + void GetMouseParameters() noexcept; void CopyToGlobal(GlobalMemory &gmUnicode, const SelectionText &selectedText); void CopyToClipboard(const SelectionText &selectedText) override; void ScrollMessage(WPARAM wParam); @@ -551,6 +554,8 @@ ScintillaWin::ScintillaWin(HWND hwnd) { capturedMouse = false; trackedMouseLeave = false; + typingWithoutCursor = false; + cursorIsHidden = false; SetCoalescableTimerFn = nullptr; linesPerScroll = 0; @@ -1260,6 +1265,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) { } view.imeCaretBlockOverride = false; + HideCursorIfPreferred(); if (lParam & GCS_RESULTSTR) { AddWString(imc.GetCompositionString(GCS_RESULTSTR), CharacterSource::ImeResult); @@ -1580,6 +1586,7 @@ sptr_t ScintillaWin::MouseMessage(unsigned int iMessage, uptr_t wParam, sptr_t l break; case WM_MOUSEMOVE: { + cursorIsHidden = false; // to be shown by ButtonMoveWithModifiers const Point pt = PointFromLParam(lParam); // Windows might send WM_MOUSEMOVE even though the mouse has not been moved: @@ -1693,6 +1700,7 @@ sptr_t ScintillaWin::KeyMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); case WM_CHAR: + HideCursorIfPreferred(); if (((wParam >= 128) || !iscntrl(static_cast<int>(wParam))) || !lastKeyDownConsumed) { wchar_t wcs[3] = { static_cast<wchar_t>(wParam), 0 }; unsigned int wclen = 1; @@ -2005,7 +2013,7 @@ sptr_t ScintillaWin::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { ctrlID = ::GetDlgCtrlID(HwndFromWindow(wMain)); UpdateBaseElements(); // Get Intellimouse scroll line parameters - GetIntelliMouseParameters(); + GetMouseParameters(); ::RegisterDragDrop(MainHWND(), &dt); break; @@ -2063,10 +2071,12 @@ sptr_t ScintillaWin::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { case WM_SETCURSOR: if (LOWORD(lParam) == HTCLIENT) { - POINT pt; - if (::GetCursorPos(&pt)) { - ::ScreenToClient(MainHWND(), &pt); - DisplayCursor(ContextCursor(PointFromPOINT(pt))); + if (!cursorIsHidden) { + POINT pt; + if (::GetCursorPos(&pt)) { + ::ScreenToClient(MainHWND(), &pt); + DisplayCursor(ContextCursor(PointFromPOINT(pt))); + } } return TRUE; } else { @@ -2089,7 +2099,7 @@ sptr_t ScintillaWin::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { #endif UpdateBaseElements(); // Get Intellimouse scroll line parameters - GetIntelliMouseParameters(); + GetMouseParameters(); InvalidateStyleRedraw(); break; @@ -2327,6 +2337,14 @@ void ScintillaWin::SetTrackMouseLeaveEvent(bool on) noexcept { trackedMouseLeave = on; } +void ScintillaWin::HideCursorIfPreferred() noexcept { + // SPI_GETMOUSEVANISH from OS. + if (typingWithoutCursor && !cursorIsHidden) { + ::SetCursor(NULL); + cursorIsHidden = true; + } +} + void ScintillaWin::UpdateBaseElements() { struct ElementToIndex { Element element; int nIndex; }; const ElementToIndex eti[] = { @@ -3175,13 +3193,14 @@ LRESULT ScintillaWin::ImeOnDocumentFeed(LPARAM lParam) const { return rcSize; // MS API says reconv structure to be returned. } -void ScintillaWin::GetIntelliMouseParameters() noexcept { +void ScintillaWin::GetMouseParameters() noexcept { // This retrieves the number of lines per scroll as configured in the Mouse Properties sheet in Control Panel ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &linesPerScroll, 0); if (!::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &charsPerScroll, 0)) { // no horizontal scrolling configuration on Windows XP charsPerScroll = (linesPerScroll == WHEEL_PAGESCROLL) ? 3 : linesPerScroll; } + ::SystemParametersInfo(SPI_GETMOUSEVANISH, 0, &typingWithoutCursor, 0); } void ScintillaWin::CopyToGlobal(GlobalMemory &gmUnicode, const SelectionText &selectedText) { |