Fixes balloon tooltips so that they can be drawn outside of the work area (required for system tray icons) and improves the shape of the tooltips so that they resemble their shape on Windows.
-- v4: Diff reduce
From: "Carl J. Bialorucki" cbialo2@outlook.com
--- dlls/comctl32/tooltips.c | 61 ++++++++++++++++++++++++---------------- dlls/win32u/region.c | 3 -- 2 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index 95ef8da6794..c105b3ca7e4 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -22,11 +22,11 @@ * * This code was audited for completeness against the documented features * of Comctl32.dll version 6.0 on Sep. 08, 2004, by Robert Shearman. - * + * * Unless otherwise noted, we believe this code to be complete, as per * the specification mentioned above. * If you discover missing features or bugs please note them below. - * + * * TODO: * - Custom draw support. * - Animation. @@ -161,10 +161,10 @@ typedef struct #define BALLOON_TEXT_MARGIN (NORMAL_TEXT_MARGIN+8) /* value used for CreateRoundRectRgn that specifies how much * each corner is curved */ -#define BALLOON_ROUNDEDNESS 20 -#define BALLOON_STEMHEIGHT 13 -#define BALLOON_STEMWIDTH 10 -#define BALLOON_STEMINDENT 20 +#define BALLOON_ROUNDEDNESS 16 +#define BALLOON_STEMHEIGHT 18 +#define BALLOON_STEMWIDTH 18 +#define BALLOON_STEMINDENT 16
#define BALLOON_ICON_TITLE_SPACING 8 /* horizontal spacing between icon and title */ #define BALLOON_TITLE_TEXT_SPACING 8 /* vertical spacing between icon/title and main text */ @@ -307,7 +307,7 @@ TOOLTIPS_Refresh (const TOOLTIPS_INFO *infoPtr, HDC hdc) HFONT prevFont;
/* draw icon */ - icon_present = infoPtr->hTitleIcon && + icon_present = infoPtr->hTitleIcon && DrawIconEx(hdc, rc.left, rc.top, infoPtr->hTitleIcon, ICON_WIDTH, ICON_HEIGHT, 0, NULL, DI_NORMAL); if (icon_present) @@ -731,22 +731,35 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) mon_info.cbSize = sizeof(mon_info); GetMonitorInfoW( monitor, &mon_info );
- if( rect.right > mon_info.rcWork.right ) { - rect.left -= rect.right - mon_info.rcWork.right + 2; - rect.right = mon_info.rcWork.right - 2; + if (rect.right > mon_info.rcMonitor.right) + { + rect.left -= size.cx - (BALLOON_STEMINDENT + BALLOON_STEMWIDTH); + rect.right -= size.cx - (BALLOON_STEMINDENT + BALLOON_STEMWIDTH); + if (rect.right > mon_info.rcMonitor.right) + { + rect.left -= (rect.right - mon_info.rcMonitor.right); + rect.right = mon_info.rcMonitor.right; + } + } + if (rect.left < mon_info.rcMonitor.left) + { + rect.right += abs(rect.left); + rect.left = 0; } - if (rect.left < mon_info.rcWork.left) rect.left = mon_info.rcWork.left;
- if( rect.bottom > mon_info.rcWork.bottom ) { + if (rect.bottom > mon_info.rcMonitor.bottom) + { RECT rc; - - if (toolPtr->uFlags & TTF_IDISHWND) - GetWindowRect ((HWND)toolPtr->uId, &rc); - else { - rc = toolPtr->rect; - MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rc, 2); - } - rect.bottom = rc.top - 2; + if (toolPtr->uFlags & TTF_IDISHWND) + { + GetWindowRect((HWND)toolPtr->uId, &rc); + } + else + { + rc = toolPtr->rect; + MapWindowPoints(toolPtr->hwnd, NULL, (LPPOINT)&rc, 2); + } + rect.bottom = rc.top - 2; rect.top = rect.bottom - size.cy; }
@@ -765,7 +778,7 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) { pts[0].x = ptfx; pts[0].y = 0; - pts[1].x = max(BALLOON_STEMINDENT, ptfx - (BALLOON_STEMWIDTH / 2)); + pts[1].x = max(BALLOON_STEMINDENT, ptfx - BALLOON_STEMWIDTH); pts[1].y = BALLOON_STEMHEIGHT; pts[2].x = pts[1].x + BALLOON_STEMWIDTH; pts[2].y = pts[1].y; @@ -777,7 +790,7 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) } else { - pts[0].x = max(BALLOON_STEMINDENT, ptfx - (BALLOON_STEMWIDTH / 2)); + pts[0].x = max(BALLOON_STEMINDENT, ptfx - BALLOON_STEMWIDTH); pts[0].y = (rect.bottom - rect.top) - BALLOON_STEMHEIGHT; pts[1].x = pts[0].x + BALLOON_STEMWIDTH; pts[1].y = pts[0].y; @@ -791,7 +804,7 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) }
hrStem = CreatePolygonRgn(pts, ARRAY_SIZE(pts), ALTERNATE); - + hRgn = CreateRoundRectRgn(0, (infoPtr->bToolBelow ? BALLOON_STEMHEIGHT : 0), rect.right - rect.left, @@ -802,7 +815,7 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) DeleteObject(hrStem);
SetWindowRgn(infoPtr->hwndSelf, hRgn, FALSE); - /* we don't free the region handle as the system deletes it when + /* we don't free the region handle as the system deletes it when * it is no longer needed */ }
diff --git a/dlls/win32u/region.c b/dlls/win32u/region.c index f32984d1c54..b15183b85f7 100644 --- a/dlls/win32u/region.c +++ b/dlls/win32u/region.c @@ -701,9 +701,6 @@ HRGN WINAPI NtGdiCreateRoundRectRgn( INT left, INT top, INT right, INT bottom,
if (left > right) { INT tmp = left; left = right; right = tmp; } if (top > bottom) { INT tmp = top; top = bottom; bottom = tmp; } - /* the region is for the rectangle interior, but only at right and bottom for some reason */ - right--; - bottom--;
ellipse_width = min( right - left, abs( ellipse_width )); ellipse_height = min( bottom - top, abs( ellipse_height ));
From: "Carl J. Bialorucki" cbialo2@outlook.com
--- dlls/comctl32/tooltips.c | 2 +- dlls/win32u/region.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index c105b3ca7e4..1f553292eeb 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -808,7 +808,7 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) hRgn = CreateRoundRectRgn(0, (infoPtr->bToolBelow ? BALLOON_STEMHEIGHT : 0), rect.right - rect.left, - (infoPtr->bToolBelow ? rect.bottom - rect.top : rect.bottom - rect.top - BALLOON_STEMHEIGHT), + (infoPtr->bToolBelow ? rect.bottom - rect.top : rect.bottom - rect.top - BALLOON_STEMHEIGHT + 1), BALLOON_ROUNDEDNESS, BALLOON_ROUNDEDNESS);
CombineRgn(hRgn, hRgn, hrStem, RGN_OR); diff --git a/dlls/win32u/region.c b/dlls/win32u/region.c index b15183b85f7..f32984d1c54 100644 --- a/dlls/win32u/region.c +++ b/dlls/win32u/region.c @@ -701,6 +701,9 @@ HRGN WINAPI NtGdiCreateRoundRectRgn( INT left, INT top, INT right, INT bottom,
if (left > right) { INT tmp = left; left = right; right = tmp; } if (top > bottom) { INT tmp = top; top = bottom; bottom = tmp; } + /* the region is for the rectangle interior, but only at right and bottom for some reason */ + right--; + bottom--;
ellipse_width = min( right - left, abs( ellipse_width )); ellipse_height = min( bottom - top, abs( ellipse_height ));
From: Carl Bialorucki cbialo2@outlook.com
--- dlls/comctl32/tooltips.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index 1f553292eeb..8b6993dec37 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -22,11 +22,11 @@ * * This code was audited for completeness against the documented features * of Comctl32.dll version 6.0 on Sep. 08, 2004, by Robert Shearman. - * + * * Unless otherwise noted, we believe this code to be complete, as per * the specification mentioned above. * If you discover missing features or bugs please note them below. - * + * * TODO: * - Custom draw support. * - Animation. @@ -307,7 +307,7 @@ TOOLTIPS_Refresh (const TOOLTIPS_INFO *infoPtr, HDC hdc) HFONT prevFont;
/* draw icon */ - icon_present = infoPtr->hTitleIcon && + icon_present = infoPtr->hTitleIcon && DrawIconEx(hdc, rc.left, rc.top, infoPtr->hTitleIcon, ICON_WIDTH, ICON_HEIGHT, 0, NULL, DI_NORMAL); if (icon_present) @@ -804,7 +804,7 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) }
hrStem = CreatePolygonRgn(pts, ARRAY_SIZE(pts), ALTERNATE); - + hRgn = CreateRoundRectRgn(0, (infoPtr->bToolBelow ? BALLOON_STEMHEIGHT : 0), rect.right - rect.left, @@ -815,7 +815,7 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) DeleteObject(hrStem);
SetWindowRgn(infoPtr->hwndSelf, hRgn, FALSE); - /* we don't free the region handle as the system deletes it when + /* we don't free the region handle as the system deletes it when * it is no longer needed */ }
The commits need sqashing together and need to have a proper commit message. See: https://gitlab.winehq.org/wine/wine/-/wikis/Submitting-Patches