richedit: Only notify selection change when selection has actually changed from previous notification.

Otherwise, redundant and early notifications are sent to apps that do not expect them. Fixes crash #1 with Perfect! TextEdit.
This commit is contained in:
Alex Villacís Lasso 2008-04-27 13:08:55 -05:00 committed by Alexandre Julliard
parent cac55008c9
commit 1fa39b50c0
3 changed files with 14 additions and 1 deletions

View File

@ -1330,7 +1330,15 @@ void ME_SendSelChange(ME_TextEditor *editor)
sc.seltyp |= SEL_TEXT;
if (sc.chrg.cpMin < sc.chrg.cpMax+1) /* wth were RICHEDIT authors thinking ? */
sc.seltyp |= SEL_MULTICHAR;
SendMessageW(GetParent(editor->hWnd), WM_NOTIFY, sc.nmhdr.idFrom, (LPARAM)&sc);
TRACE("cpMin=%d cpMax=%d seltyp=%d (%s %s)\n",
sc.chrg.cpMin, sc.chrg.cpMax, sc.seltyp,
(sc.seltyp & SEL_TEXT) ? "SEL_TEXT" : "",
(sc.seltyp & SEL_MULTICHAR) ? "SEL_MULTICHAR" : "");
if (sc.chrg.cpMin != editor->notified_cr.cpMin || sc.chrg.cpMax != editor->notified_cr.cpMax)
{
editor->notified_cr = sc.chrg;
SendMessageW(GetParent(editor->hWnd), WM_NOTIFY, sc.nmhdr.idFrom, (LPARAM)&sc);
}
}
BOOL

View File

@ -1665,6 +1665,8 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
else
ed->cPasswordMask = 0;
ed->notified_cr.cpMin = ed->notified_cr.cpMax = 0;
return ed;
}

View File

@ -331,6 +331,9 @@ typedef struct tagME_TextEditor
/*for IME */
int imeStartIndex;
DWORD selofs, linesel, sely;
/* Track previous notified selection */
CHARRANGE notified_cr;
} ME_TextEditor;
typedef struct tagME_Context