comctl32: Simplify handling of the marquee highlight.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2017-11-14 10:56:06 +00:00 committed by Alexandre Julliard
parent 418c1d32bb
commit da419d80b7

View File

@ -3843,33 +3843,44 @@ static LRESULT LISTVIEW_MouseHover(LISTVIEW_INFO *infoPtr, INT x, INT y)
* None. * None.
*/ */
static void LISTVIEW_MarqueeHighlight(LISTVIEW_INFO *infoPtr, const POINT *coords_orig, static void LISTVIEW_MarqueeHighlight(LISTVIEW_INFO *infoPtr, const POINT *coords_orig,
const POINT *coords_offs, const POINT *offset,
INT scroll) INT scroll)
{ {
BOOL controlDown = FALSE; BOOL controlDown = FALSE;
LVITEMW item; LVITEMW item;
ITERATOR old_elems, new_elems; ITERATOR old_elems, new_elems;
RECT rect; RECT rect;
POINT coords_offs, offset;
if (coords_offs->x > infoPtr->marqueeOrigin.x) /* Ensure coordinates are within client bounds */
coords_offs.x = max(min(coords_orig->x, infoPtr->rcList.right), 0);
coords_offs.y = max(min(coords_orig->y, infoPtr->rcList.bottom), 0);
/* Get offset */
LISTVIEW_GetOrigin(infoPtr, &offset);
/* Offset coordinates by the appropriate amount */
coords_offs.x -= offset.x;
coords_offs.y -= offset.y;
if (coords_offs.x > infoPtr->marqueeOrigin.x)
{ {
rect.left = infoPtr->marqueeOrigin.x; rect.left = infoPtr->marqueeOrigin.x;
rect.right = coords_offs->x; rect.right = coords_offs.x;
} }
else else
{ {
rect.left = coords_offs->x; rect.left = coords_offs.x;
rect.right = infoPtr->marqueeOrigin.x; rect.right = infoPtr->marqueeOrigin.x;
} }
if (coords_offs->y > infoPtr->marqueeOrigin.y) if (coords_offs.y > infoPtr->marqueeOrigin.y)
{ {
rect.top = infoPtr->marqueeOrigin.y; rect.top = infoPtr->marqueeOrigin.y;
rect.bottom = coords_offs->y; rect.bottom = coords_offs.y;
} }
else else
{ {
rect.top = coords_offs->y; rect.top = coords_offs.y;
rect.bottom = infoPtr->marqueeOrigin.y; rect.bottom = infoPtr->marqueeOrigin.y;
} }
@ -3895,7 +3906,7 @@ static void LISTVIEW_MarqueeHighlight(LISTVIEW_INFO *infoPtr, const POINT *coord
infoPtr->marqueeRect = rect; infoPtr->marqueeRect = rect;
infoPtr->marqueeDrawRect = rect; infoPtr->marqueeDrawRect = rect;
OffsetRect(&infoPtr->marqueeDrawRect, offset->x, offset->y); OffsetRect(&infoPtr->marqueeDrawRect, offset.x, offset.y);
iterator_frameditems_absolute(&new_elems, infoPtr, &infoPtr->marqueeRect); iterator_frameditems_absolute(&new_elems, infoPtr, &infoPtr->marqueeRect);
iterator_remove_common_items(&old_elems, &new_elems); iterator_remove_common_items(&old_elems, &new_elems);
@ -3960,9 +3971,7 @@ static VOID CALLBACK LISTVIEW_ScrollTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent
{ {
LISTVIEW_INFO *infoPtr; LISTVIEW_INFO *infoPtr;
SCROLLINFO scrollInfo; SCROLLINFO scrollInfo;
POINT coords_orig; POINT coords;
POINT coords_offs;
POINT offset;
INT scroll = 0; INT scroll = 0;
infoPtr = (LISTVIEW_INFO *) idEvent; infoPtr = (LISTVIEW_INFO *) idEvent;
@ -3971,19 +3980,8 @@ static VOID CALLBACK LISTVIEW_ScrollTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent
return; return;
/* Get the current cursor position and convert to client coordinates */ /* Get the current cursor position and convert to client coordinates */
GetCursorPos(&coords_orig); GetCursorPos(&coords);
ScreenToClient(hWnd, &coords_orig); ScreenToClient(hWnd, &coords);
/* Ensure coordinates are within client bounds */
coords_offs.x = max(min(coords_orig.x, infoPtr->rcList.right), 0);
coords_offs.y = max(min(coords_orig.y, infoPtr->rcList.bottom), 0);
/* Get offset */
LISTVIEW_GetOrigin(infoPtr, &offset);
/* Offset coordinates by the appropriate amount */
coords_offs.x -= offset.x;
coords_offs.y -= offset.y;
scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.cbSize = sizeof(SCROLLINFO);
scrollInfo.fMask = SIF_ALL; scrollInfo.fMask = SIF_ALL;
@ -4007,12 +4005,12 @@ static VOID CALLBACK LISTVIEW_ScrollTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent
scroll |= SCROLL_RIGHT; scroll |= SCROLL_RIGHT;
} }
if (((coords_orig.x <= 0) && (scroll & SCROLL_LEFT)) || if (((coords.x <= 0) && (scroll & SCROLL_LEFT)) ||
((coords_orig.y <= 0) && (scroll & SCROLL_UP)) || ((coords.y <= 0) && (scroll & SCROLL_UP)) ||
((coords_orig.x >= infoPtr->rcList.right) && (scroll & SCROLL_RIGHT)) || ((coords.x >= infoPtr->rcList.right) && (scroll & SCROLL_RIGHT)) ||
((coords_orig.y >= infoPtr->rcList.bottom) && (scroll & SCROLL_DOWN))) ((coords.y >= infoPtr->rcList.bottom) && (scroll & SCROLL_DOWN)))
{ {
LISTVIEW_MarqueeHighlight(infoPtr, &coords_orig, &coords_offs, &offset, scroll); LISTVIEW_MarqueeHighlight(infoPtr, &coords, scroll);
} }
} }
@ -4034,6 +4032,9 @@ static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, IN
RECT rect; RECT rect;
POINT pt; POINT pt;
pt.x = x;
pt.y = y;
if (!(fwKeys & MK_LBUTTON)) if (!(fwKeys & MK_LBUTTON))
infoPtr->bLButtonDown = FALSE; infoPtr->bLButtonDown = FALSE;
@ -4046,24 +4047,6 @@ static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, IN
if (infoPtr->bMarqueeSelect) if (infoPtr->bMarqueeSelect)
{ {
POINT coords_orig;
POINT coords_offs;
POINT offset;
coords_orig.x = x;
coords_orig.y = y;
/* Get offset */
LISTVIEW_GetOrigin(infoPtr, &offset);
/* Ensure coordinates are within client bounds */
coords_offs.x = max(min(x, infoPtr->rcList.right), 0);
coords_offs.y = max(min(y, infoPtr->rcList.bottom), 0);
/* Offset coordinates by the appropriate amount */
coords_offs.x -= offset.x;
coords_offs.y -= offset.y;
/* Enable the timer if we're going outside our bounds, in case the user doesn't /* Enable the timer if we're going outside our bounds, in case the user doesn't
move the mouse again */ move the mouse again */
@ -4082,13 +4065,10 @@ static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, IN
KillTimer(infoPtr->hwndSelf, (UINT_PTR) infoPtr); KillTimer(infoPtr->hwndSelf, (UINT_PTR) infoPtr);
} }
LISTVIEW_MarqueeHighlight(infoPtr, &coords_orig, &coords_offs, &offset, 0); LISTVIEW_MarqueeHighlight(infoPtr, &pt, 0);
return 0; return 0;
} }
pt.x = x;
pt.y = y;
ht.pt = pt; ht.pt = pt;
LISTVIEW_HitTest(infoPtr, &ht, TRUE, TRUE); LISTVIEW_HitTest(infoPtr, &ht, TRUE, TRUE);