Nikolay Sivov : comctl32/button: Invalidate on BM_SETSTATE.
Alexandre Julliard
julliard at winehq.org
Mon Feb 12 16:10:36 CST 2018
Module: wine
Branch: master
Commit: f8eb74e10c450335eac706818df95d42514a7322
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f8eb74e10c450335eac706818df95d42514a7322
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun Feb 11 19:19:54 2018 +0300
comctl32/button: Invalidate on BM_SETSTATE.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/comctl32/button.c | 22 +++++++++++++++-------
dlls/comctl32/tests/button.c | 10 +++-------
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c
index c8f85d9..85aa47f 100644
--- a/dlls/comctl32/button.c
+++ b/dlls/comctl32/button.c
@@ -305,7 +305,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
POINT pt;
LONG style = GetWindowLongW( hWnd, GWL_STYLE );
UINT btn_type = get_button_type( style );
- LONG state;
+ LONG state, new_state;
HANDLE oldHbitmap;
HTHEME theme;
@@ -674,12 +674,21 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
case BM_SETSTATE:
state = get_button_state( hWnd );
- if (wParam)
- set_button_state( hWnd, state | BST_PUSHED );
- else
- set_button_state( hWnd, state & ~BST_PUSHED );
+ new_state = wParam ? BST_PUSHED : 0;
+
+ if ((state ^ new_state) & BST_PUSHED)
+ {
+ if (wParam)
+ state |= BST_PUSHED;
+ else
+ state &= ~BST_PUSHED;
- paint_button( hWnd, btn_type, ODA_SELECT );
+ if (btn_type == BS_USERBUTTON)
+ BUTTON_NOTIFY_PARENT( hWnd, (state & BST_PUSHED) ? BN_HILITE : BN_UNHILITE );
+ set_button_state( hWnd, state );
+
+ InvalidateRect( hWnd, NULL, FALSE );
+ }
break;
case WM_NCHITTEST:
@@ -1206,7 +1215,6 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action )
break;
default:
- BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT );
break;
}
}
diff --git a/dlls/comctl32/tests/button.c b/dlls/comctl32/tests/button.c
index 425e145..38446aa 100644
--- a/dlls/comctl32/tests/button.c
+++ b/dlls/comctl32/tests/button.c
@@ -350,8 +350,6 @@ static const struct message setstate_seq[] =
{ BM_SETSTATE, sent },
{ WM_APP, sent|wparam|lparam, 0, 0 },
{ WM_PAINT, sent },
- { WM_NCPAINT, sent|optional }, /* FIXME: Wine sends it */
- { WM_ERASEBKGND, sent|defwinproc|optional },
{ WM_PAINT, sent|optional },
{ 0 }
};
@@ -372,8 +370,6 @@ static const struct message setstate_user_seq[] =
{ WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_HILITE) },
{ WM_APP, sent|wparam|lparam, 0, 0 },
{ WM_PAINT, sent },
- { WM_NCPAINT, sent|optional }, /* FIXME: Wine sends it */
- { WM_ERASEBKGND, sent|defwinproc|optional },
{ 0 }
};
@@ -596,7 +592,7 @@ static void test_button_messages(void)
SendMessageA(hwnd, BM_SETSTYLE, button[i].style | BS_BOTTOM, TRUE);
SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
- todo = button[i].style == BS_USERBUTTON || button[i].style == BS_OWNERDRAW;
+ todo = button[i].style == BS_OWNERDRAW;
ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setstyle, "BM_SETSTYLE on a button", todo);
style = GetWindowLongA(hwnd, GWL_STYLE);
@@ -612,7 +608,7 @@ static void test_button_messages(void)
SendMessageA(hwnd, BM_SETSTATE, TRUE, 0);
SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
- ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setstate, "BM_SETSTATE/TRUE on a button", TRUE);
+ ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setstate, "BM_SETSTATE/TRUE on a button", FALSE);
state = SendMessageA(hwnd, BM_GETSTATE, 0, 0);
ok(state == BST_PUSHED, "expected state 0x0004, got %04x\n", state);
@@ -626,7 +622,7 @@ static void test_button_messages(void)
SendMessageA(hwnd, BM_SETSTATE, FALSE, 0);
SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
- ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].clearstate, "BM_SETSTATE/FALSE on a button", TRUE);
+ ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].clearstate, "BM_SETSTATE/FALSE on a button", FALSE);
state = SendMessageA(hwnd, BM_GETSTATE, 0, 0);
ok(state == 0, "expected state 0, got %04x\n", state);
More information about the wine-cvs
mailing list