From 1a37b64fe697ceb8c1aa4ce8683d1ea38dee5c8c Mon Sep 17 00:00:00 2001 From: Udo Hoffmann Date: Tue, 22 Sep 2020 16:48:28 +0200 Subject: [PATCH] Avoid unnecessary notifications This is an enhancement of PR #8475 which fixed (and still fixes) #8466. It takes into account, that `WM_ACTIVATE` is not called only, when the window is being activated, but also, when the window is being **de**activated. In the latter case it is not necessary to do the activation actions. This was pointed out to me by @Predelnik, who had a problem with the additional `SCN_UPDATEUI/SC_UPDATE_H_SCROLL` notification occurring when the window is being deactivated, see https://github.com/Predelnik/DSpellCheck/issues/221#issuecomment-696652074 for details. --- PowerEditor/src/NppBigSwitch.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 8315ce064..46cb3d116 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1645,11 +1645,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case WM_ACTIVATE: { - _pEditView->getFocus(); - auto x = _pEditView->execute(SCI_GETXOFFSET); - _pEditView->execute(SCI_SETXOFFSET, x); - x = _pNonEditView->execute(SCI_GETXOFFSET); - _pNonEditView->execute(SCI_SETXOFFSET, x); + if (wParam != WA_INACTIVE) + { + _pEditView->getFocus(); + auto x = _pEditView->execute(SCI_GETXOFFSET); + _pEditView->execute(SCI_SETXOFFSET, x); + x = _pNonEditView->execute(SCI_GETXOFFSET); + _pNonEditView->execute(SCI_SETXOFFSET, x); + } return TRUE; }