[PATCH 2/4] user32: Clip painting to the items_rect.
Huw Davies
huw at codeweavers.com
Wed Mar 29 04:42:04 CDT 2017
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
dlls/user32/menu.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index da0e54b352..28222dcb6e 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -1402,6 +1402,7 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
UINT arrow_bitmap_width = 0, arrow_bitmap_height = 0;
POPUPMENU *menu = MENU_GetMenu(hmenu);
RECT bmprc;
+ HRGN old_clip = NULL, clip;
debug_print_menuitem("MENU_DrawMenuItem: ", lpitem, "");
@@ -1450,6 +1451,16 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
rect = lpitem->rect;
MENU_AdjustMenuItemRect(MENU_GetMenu(hmenu), &rect);
+ old_clip = CreateRectRgn( 0, 0, 0, 0 );
+ if (GetClipRgn( hdc, old_clip ) <= 0)
+ {
+ DeleteObject( old_clip );
+ old_clip = NULL;
+ }
+ clip = CreateRectRgnIndirect( &menu->items_rect );
+ ExtSelectClipRgn( hdc, clip, RGN_AND );
+ DeleteObject( clip );
+
if (lpitem->fType & MF_OWNERDRAW)
{
/*
@@ -1489,10 +1500,10 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
if (lpitem->fType & MF_POPUP)
draw_popup_arrow( hdc, rect, arrow_bitmap_width,
arrow_bitmap_height);
- return;
+ goto done;
}
- if (menuBar && (lpitem->fType & MF_SEPARATOR)) return;
+ if (menuBar && (lpitem->fType & MF_SEPARATOR)) goto done;
if (lpitem->fState & MF_HILITE)
{
@@ -1554,7 +1565,7 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
}
else
DrawEdge (hdc, &rc, EDGE_ETCHED, BF_TOP);
- return;
+ goto done;
}
/* helper lines for debugging */
@@ -1736,6 +1747,10 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
if (hfontOld)
SelectObject (hdc, hfontOld);
}
+
+done:
+ ExtSelectClipRgn( hdc, old_clip, RGN_COPY );
+ if (old_clip) DeleteObject( old_clip );
}
--
2.12.0
More information about the wine-patches
mailing list