user32: edit control scrolling follows selection
Henry Kroll III
henry at comptune.com
Sun Apr 4 20:21:13 CDT 2010
Fixes Bug 22274 (patch and test program attached to the bug.)
* Scroll horizontally by thumb size, not single characters.
* Don't scroll vertically when selection grows horizontally.
* Stop selection from growing while mouse is stationary.
-------------- next part --------------
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index 9898bc4..ebe0ae3 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -3796,15 +3796,19 @@ static LRESULT EDIT_WM_SysKeyDown(EDITSTATE *es, INT key, DWORD key_data)
*/
static void EDIT_WM_Timer(EDITSTATE *es)
{
- if (es->region_posx < 0) {
- EDIT_MoveBackward(es, TRUE);
- } else if (es->region_posx > 0) {
- EDIT_MoveForward(es, TRUE);
- }
-/*
- * FIXME: gotta do some vertical scrolling here, like
- * EDIT_EM_LineScroll(hwnd, 0, 1);
- */
+ INT fw = es->format_rect.right - es->format_rect.left;
+ INT max_x_offset = es->text_width - fw;
+ INT page = fw / HSCROLL_FRACTION / es->char_width * es->char_width;
+
+ /* scroll to selection */
+ INT dx = es->region_posx * page;
+ INT dy = es->region_posy;
+
+ /* sanity check */
+ if (dx + es->x_offset > max_x_offset)
+ dx = max_x_offset - es->x_offset;
+
+ if (dx || dy) EDIT_EM_LineScroll_internal(es, dx, dy);
}
/*********************************************************************
More information about the wine-patches
mailing list