Added patch to fix groupbox rectangle calculation and font handling.

This commit is contained in:
Sebastian Lackner 2016-12-21 01:34:53 +01:00
parent 760b632ad6
commit 846b6ab6b9
5 changed files with 210 additions and 0 deletions

View File

@ -332,6 +332,7 @@ patch_enable_all ()
enable_user32_DrawMenuItem="$1"
enable_user32_DrawTextExW="$1"
enable_user32_GetSystemMetrics="$1"
enable_user32_Groupbox_Rectangle="$1"
enable_user32_Invalidate_Key_State="$1"
enable_user32_LR_LOADFROMFILE="$1"
enable_user32_ListBox_Size="$1"
@ -1182,6 +1183,9 @@ patch_enable ()
user32-GetSystemMetrics)
enable_user32_GetSystemMetrics="$2"
;;
user32-Groupbox_Rectangle)
enable_user32_Groupbox_Rectangle="$2"
;;
user32-Invalidate_Key_State)
enable_user32_Invalidate_Key_State="$2"
;;
@ -6969,6 +6973,25 @@ if test "$enable_user32_GetSystemMetrics" -eq 1; then
) >> "$patchlist"
fi
# Patchset user32-Groupbox_Rectangle
# |
# | This patchset fixes the following Wine bugs:
# | * [#41830] Fix groupbox rectangle calculation and font handling
# |
# | Modified files:
# | * dlls/user32/button.c
# |
if test "$enable_user32_Groupbox_Rectangle" -eq 1; then
patch_apply user32-Groupbox_Rectangle/0001-user32-Always-restore-previously-selected-font-in-th.patch
patch_apply user32-Groupbox_Rectangle/0002-user32-BUTTON_CalcLabelRect-should-use-the-button-fo.patch
patch_apply user32-Groupbox_Rectangle/0003-user32-Fix-groupbox-rectangle-calculation-in-the-but.patch
(
echo '+ { "Dmitry Timoshkov", "user32: Always restore previously selected font in the button painting helpers.", 1 },';
echo '+ { "Dmitry Timoshkov", "user32: BUTTON_CalcLabelRect should use the button font.", 1 },';
echo '+ { "Dmitry Timoshkov", "user32: Fix groupbox rectangle calculation in the button'\''s WM_SETTEXT handler.", 1 },';
) >> "$patchlist"
fi
# Patchset user32-Invalidate_Key_State
# |
# | This patchset fixes the following Wine bugs:

View File

@ -0,0 +1,119 @@
From c9fc6254889cae885e831b77f945b5c38b019fc4 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 27 Nov 2016 14:00:12 +0800
Subject: user32: Always restore previously selected font in the button
painting helpers.
---
dlls/user32/button.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index 98d8289..e4074cd 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -750,7 +750,7 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action )
HBRUSH hOldBrush;
INT oldBkMode;
COLORREF oldTxtColor;
- HFONT hFont;
+ HFONT hFont, hPrevFont = 0;
LONG state = get_button_state( hwnd );
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
BOOL pushedState = (state & BST_PUSHED);
@@ -760,7 +760,7 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action )
GetClientRect( hwnd, &rc );
/* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
- if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
+ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
parent = GetParent(hwnd);
if (!parent) parent = hwnd;
SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
@@ -827,6 +827,7 @@ draw_focus:
SetBkMode(hDC, oldBkMode);
SelectClipRgn( hDC, hrgn );
if (hrgn) DeleteObject( hrgn );
+ if (hPrevFont) SelectObject( hDC, hPrevFont );
}
/**********************************************************************
@@ -839,7 +840,7 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
HBRUSH hBrush;
int delta, text_offset, checkBoxWidth, checkBoxHeight;
UINT dtFlags;
- HFONT hFont;
+ HFONT hFont, hPrevFont = 0;
LONG state = get_button_state( hwnd );
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
LONG ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
@@ -858,7 +859,7 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1;
checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1;
- if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
+ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
GetCharWidthW( hDC, '0', '0', &text_offset );
text_offset /= 2;
@@ -960,6 +961,7 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
}
SelectClipRgn( hDC, hrgn );
if (hrgn) DeleteObject( hrgn );
+ if (hPrevFont) SelectObject( hDC, hPrevFont );
}
@@ -993,14 +995,14 @@ static void GB_Paint( HWND hwnd, HDC hDC, UINT action )
{
RECT rc, rcFrame;
HBRUSH hbr;
- HFONT hFont;
+ HFONT hFont, hPrevFont = 0;
UINT dtFlags;
TEXTMETRICW tm;
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
HWND parent;
HRGN hrgn;
- if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
+ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
/* GroupBox acts like static control, so it sends CTLCOLORSTATIC */
parent = GetParent(hwnd);
if (!parent) parent = hwnd;
@@ -1035,6 +1037,7 @@ static void GB_Paint( HWND hwnd, HDC hDC, UINT action )
}
SelectClipRgn( hDC, hrgn );
if (hrgn) DeleteObject( hrgn );
+ if (hPrevFont) SelectObject( hDC, hPrevFont );
}
@@ -1046,13 +1049,13 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action )
{
RECT rc;
HBRUSH hBrush;
- HFONT hFont;
+ HFONT hFont, hPrevFont = 0;
LONG state = get_button_state( hwnd );
HWND parent;
GetClientRect( hwnd, &rc);
- if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
+ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
parent = GetParent(hwnd);
if (!parent) parent = hwnd;
@@ -1079,6 +1082,8 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action )
BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT );
break;
}
+
+ if (hPrevFont) SelectObject( hDC, hPrevFont );
}
--
2.9.0

View File

@ -0,0 +1,40 @@
From 3452ba066216b5c7175a66cf612812bab5c81cd8 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 27 Nov 2016 14:01:58 +0800
Subject: user32: BUTTON_CalcLabelRect should use the button font.
Otherwise WM_SETTEXT handler gets wrong rectangle to erase an old text.
---
dlls/user32/button.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index e4074cd..623b425 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -596,15 +596,22 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
switch (style & (BS_ICON|BS_BITMAP))
{
case BS_TEXT:
+ {
+ HFONT hFont, hPrevFont = 0;
+
if (!(text = get_button_text( hwnd ))) goto empty_rect;
if (!text[0])
{
HeapFree( GetProcessHeap(), 0, text );
goto empty_rect;
}
+
+ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hdc, hFont );
DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT);
+ if (hPrevFont) SelectObject( hdc, hPrevFont );
HeapFree( GetProcessHeap(), 0, text );
break;
+ }
case BS_ICON:
if (!GetIconInfo((HICON)GetWindowLongPtrW( hwnd, HIMAGE_GWL_OFFSET ), &iconInfo))
--
2.9.0

View File

@ -0,0 +1,27 @@
From 62276b1f14a98c34737b195705c79f60a2561f59 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 27 Nov 2016 14:07:12 +0800
Subject: user32: Fix groupbox rectangle calculation in the button's WM_SETTEXT
handler.
---
dlls/user32/button.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index 623b425..86b3b1e 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -394,6 +394,9 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
GetClientRect(hWnd, &client);
rc = client;
+ /* FIXME: check other BS_* handlers */
+ if (btn_type == BS_GROUPBOX)
+ InflateRect(&rc, -7, 1); /* GB_Paint does this */
BUTTON_CalcLabelRect(hWnd, hdc, &rc);
/* Clip by client rect bounds */
if (rc.right > client.right) rc.right = client.right;
--
2.9.0

View File

@ -0,0 +1 @@
Fixes: [41830] Fix groupbox rectangle calculation and font handling