aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32
diff options
context:
space:
mode:
authorjohnsonj <unknown>2023-06-08 17:26:18 +1000
committerjohnsonj <unknown>2023-06-08 17:26:18 +1000
commit885ea19c889636d05b3f6ed906576e67811fe057 (patch)
tree6001549f79af8ad9a36c64c0043c002de82baa75 /win32
parent857368f6792ddf9940aef7c384a65aa911a2f41e (diff)
downloadscintilla-mirror-885ea19c889636d05b3f6ed906576e67811fe057.tar.gz
Bug [#2333]. Hide cursor when typing if SPI_GETMOUSEVANISH system setting is on.
Diffstat (limited to 'win32')
-rw-r--r--win32/ScintillaWin.cxx35
1 files changed, 27 insertions, 8 deletions
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) {