From e6ff2b49ace25784afe188a0c82678bbdd88c5e9 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 5 Feb 2017 07:20:17 +0100 Subject: [PATCH] Added patch to set focus to dialog itself when it has no controls. --- patches/patchinstall.sh | 21 +++++ ...-a-focus-test-for-an-empty-dialog-th.patch | 89 +++++++++++++++++++ ...is-no-dialog-controls-to-set-focus-t.patch | 57 ++++++++++++ patches/user32-Dialog_Focus/definition | 1 + 4 files changed, 168 insertions(+) create mode 100644 patches/user32-Dialog_Focus/0001-user32-tests-Add-a-focus-test-for-an-empty-dialog-th.patch create mode 100644 patches/user32-Dialog_Focus/0002-user32-If-there-is-no-dialog-controls-to-set-focus-t.patch create mode 100644 patches/user32-Dialog_Focus/definition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index a122cd2c..7503703a 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -347,6 +347,7 @@ patch_enable_all () enable_user32_DM_SETDEFID="$1" enable_user32_DeferWindowPos="$1" enable_user32_DialogBoxParam="$1" + enable_user32_Dialog_Focus="$1" enable_user32_Dialog_Paint_Event="$1" enable_user32_DrawMenuItem="$1" enable_user32_DrawTextExW="$1" @@ -1247,6 +1248,9 @@ patch_enable () user32-DialogBoxParam) enable_user32_DialogBoxParam="$2" ;; + user32-Dialog_Focus) + enable_user32_Dialog_Focus="$2" + ;; user32-Dialog_Paint_Event) enable_user32_Dialog_Paint_Event="$2" ;; @@ -7264,6 +7268,23 @@ if test "$enable_user32_DialogBoxParam" -eq 1; then ) >> "$patchlist" fi +# Patchset user32-Dialog_Focus +# | +# | This patchset fixes the following Wine bugs: +# | * [#37425] Set focus to dialog itself when it has no controls +# | +# | Modified files: +# | * dlls/user32/dialog.c, dlls/user32/tests/msg.c +# | +if test "$enable_user32_Dialog_Focus" -eq 1; then + patch_apply user32-Dialog_Focus/0001-user32-tests-Add-a-focus-test-for-an-empty-dialog-th.patch + patch_apply user32-Dialog_Focus/0002-user32-If-there-is-no-dialog-controls-to-set-focus-t.patch + ( + printf '%s\n' '+ { "Dmitry Timoshkov", "user32/tests: Add a focus test for an empty dialog that returns TRUE in WM_INITDIALOG.", 1 },'; + printf '%s\n' '+ { "Dmitry Timoshkov", "user32: If there is no dialog controls to set focus to then set focus to dialog itself.", 1 },'; + ) >> "$patchlist" +fi + # Patchset user32-Dialog_Paint_Event # | # | This patchset fixes the following Wine bugs: diff --git a/patches/user32-Dialog_Focus/0001-user32-tests-Add-a-focus-test-for-an-empty-dialog-th.patch b/patches/user32-Dialog_Focus/0001-user32-tests-Add-a-focus-test-for-an-empty-dialog-th.patch new file mode 100644 index 00000000..939faa43 --- /dev/null +++ b/patches/user32-Dialog_Focus/0001-user32-tests-Add-a-focus-test-for-an-empty-dialog-th.patch @@ -0,0 +1,89 @@ +From 49eb0726c01fea7c23da79baef3624a71830b65b Mon Sep 17 00:00:00 2001 +From: Dmitry Timoshkov +Date: Tue, 31 Jan 2017 18:21:22 +0800 +Subject: user32/tests: Add a focus test for an empty dialog that returns TRUE + in WM_INITDIALOG. + +--- + dlls/user32/tests/msg.c | 42 +++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 41 insertions(+), 1 deletion(-) + +diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c +index c608c11c223..39093a528e1 100644 +--- a/dlls/user32/tests/msg.c ++++ b/dlls/user32/tests/msg.c +@@ -12169,6 +12169,8 @@ static INT_PTR WINAPI test_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPAR + switch (message) + { + case WM_INITDIALOG: ++ return lParam; ++ + case WM_GETDLGCODE: + return 0; + } +@@ -12277,6 +12279,20 @@ static const struct message WmDefDlgSetFocus_2[] = { + { 0 } + }; + /* Creation of a dialog */ ++static const struct message WmCreateDialogParamSeq_0[] = { ++ { HCBT_CREATEWND, hook }, ++ { WM_NCCREATE, sent }, ++ { WM_NCCALCSIZE, sent|wparam, 0 }, ++ { WM_CREATE, sent }, ++ { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 }, ++ { WM_SIZE, sent|wparam, SIZE_RESTORED }, ++ { WM_MOVE, sent }, ++ { WM_SETFONT, sent }, ++ { WM_INITDIALOG, sent }, ++ { WM_CHANGEUISTATE, sent|optional }, ++ { 0 } ++}; ++/* Creation of a dialog */ + static const struct message WmCreateDialogParamSeq_1[] = { + { HCBT_CREATEWND, hook }, + { WM_NCCREATE, sent }, +@@ -12287,6 +12303,14 @@ static const struct message WmCreateDialogParamSeq_1[] = { + { WM_MOVE, sent }, + { WM_SETFONT, sent }, + { WM_INITDIALOG, sent }, ++ { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 }, ++ { HCBT_SETFOCUS, hook }, ++ { HCBT_ACTIVATE, hook }, ++ { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE }, ++ { WM_ACTIVATEAPP, sent|wparam, 1 }, ++ { WM_NCACTIVATE, sent }, ++ { WM_ACTIVATE, sent|wparam, 1 }, ++ { WM_SETFOCUS, sent }, + { WM_CHANGEUISTATE, sent|optional }, + { 0 } + }; +@@ -12450,9 +12474,25 @@ static void test_dialog_messages(void) + cls.lpfnWndProc = test_dlg_proc; + if (!RegisterClassA(&cls)) assert(0); + ++ SetFocus(0); ++ flush_sequence(); + hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0); + ok(IsWindow(hdlg), "CreateDialogParam failed\n"); +- ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE); ++ ok_sequence(WmCreateDialogParamSeq_0, "CreateDialogParam_0", FALSE); ++ hfocus = GetFocus(); ++ ok(hfocus == 0, "wrong focus %p\n", hfocus); ++ EndDialog(hdlg, 0); ++ DestroyWindow(hdlg); ++ flush_sequence(); ++ ++ SetFocus(0); ++ flush_sequence(); ++ hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 1); ++ ok(IsWindow(hdlg), "CreateDialogParam failed\n"); ++ ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", TRUE); ++ hfocus = GetFocus(); ++todo_wine ++ ok(hfocus == hdlg, "wrong focus %p\n", hfocus); + EndDialog(hdlg, 0); + DestroyWindow(hdlg); + flush_sequence(); +-- +2.11.0 + diff --git a/patches/user32-Dialog_Focus/0002-user32-If-there-is-no-dialog-controls-to-set-focus-t.patch b/patches/user32-Dialog_Focus/0002-user32-If-there-is-no-dialog-controls-to-set-focus-t.patch new file mode 100644 index 00000000..4e90adc7 --- /dev/null +++ b/patches/user32-Dialog_Focus/0002-user32-If-there-is-no-dialog-controls-to-set-focus-t.patch @@ -0,0 +1,57 @@ +From 502fd4e2b80cd483ad3db0ed39a92998b4860777 Mon Sep 17 00:00:00 2001 +From: Dmitry Timoshkov +Date: Tue, 31 Jan 2017 18:50:38 +0800 +Subject: user32: If there is no dialog controls to set focus to then set focus + to dialog itself. + +--- + dlls/user32/dialog.c | 2 ++ + dlls/user32/tests/msg.c | 9 +++++---- + 2 files changed, 7 insertions(+), 4 deletions(-) + +diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c +index 8b77ae2158b..61aa6d3eff3 100644 +--- a/dlls/user32/dialog.c ++++ b/dlls/user32/dialog.c +@@ -690,6 +690,8 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate, + SendMessageW( focus, EM_SETSEL, 0, MAXLONG ); + SetFocus( focus ); + } ++ else ++ SetFocus( hwnd ); + } + } + +diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c +index 39093a528e1..6f835f9f6cd 100644 +--- a/dlls/user32/tests/msg.c ++++ b/dlls/user32/tests/msg.c +@@ -12303,10 +12303,12 @@ static const struct message WmCreateDialogParamSeq_1[] = { + { WM_MOVE, sent }, + { WM_SETFONT, sent }, + { WM_INITDIALOG, sent }, +- { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 }, ++ { WM_GETDLGCODE, sent|wparam|lparam|optional, 0, 0 }, /* FIXME: Wine doesn't send it */ + { HCBT_SETFOCUS, hook }, + { HCBT_ACTIVATE, hook }, +- { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE }, ++ { WM_QUERYNEWPALETTE, sent|optional }, ++ { WM_PALETTEISCHANGING, sent|optional }, ++ { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, + { WM_ACTIVATEAPP, sent|wparam, 1 }, + { WM_NCACTIVATE, sent }, + { WM_ACTIVATE, sent|wparam, 1 }, +@@ -12489,9 +12491,8 @@ static void test_dialog_messages(void) + flush_sequence(); + hdlg = CreateDialogParamA(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 1); + ok(IsWindow(hdlg), "CreateDialogParam failed\n"); +- ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", TRUE); ++ ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE); + hfocus = GetFocus(); +-todo_wine + ok(hfocus == hdlg, "wrong focus %p\n", hfocus); + EndDialog(hdlg, 0); + DestroyWindow(hdlg); +-- +2.11.0 + diff --git a/patches/user32-Dialog_Focus/definition b/patches/user32-Dialog_Focus/definition new file mode 100644 index 00000000..704ba7d0 --- /dev/null +++ b/patches/user32-Dialog_Focus/definition @@ -0,0 +1 @@ +Fixes: [37425] Set focus to dialog itself when it has no controls