Date: Wed, 5 Nov 2014 12:57:03 +0100
Subject: [PATCH] website: download: adjusted openSUSE versions
---
templates/de/download.template | 2 +-
templates/en/download.template | 2 +-
templates/fr/download.template | 2 +-
templates/he/download.template | 2 +-
templates/pl/download.template | 2 +-
templates/pt/download.template | 2 +-
templates/tr/download.template | 2 +-
templates/uk/download.template | 2 +-
templates/zh-cn/download.template | 2 +-
9 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/templates/de/download.template b/templates/de/download.template
index fbf449e..bc7717e 100644
--- a/templates/de/download.template
+++ b/templates/de/download.template
@@ -94,7 +94,7 @@ erbeten hat, dass sie die Wine-Website hosten.
SUSE
- stellt binär und Quellcode .rpms und tägliche snapshot RPMs für alle openSUSE Versionen (derzeit 11.4 bis 13.1) sowie SUSE Linux Enterprise 11 bereit.
+ stellt binär und Quellcode .rpms und tägliche snapshot RPMs für alle openSUSE Versionen (derzeit 12.3 bis 13.2) sowie SUSE Linux Enterprise 11 bereit.
|
Marcus Meissner |
diff --git a/templates/en/download.template b/templates/en/download.template
index 275fd05..ca13e58 100644
--- a/templates/en/download.template
+++ b/templates/en/download.template
@@ -93,7 +93,7 @@ requested in exchange for hosting the Wine web site.
Download SUSE packages
- - release binary and source .rpms and daily snapshot RPMs for all openSUSE versions (11.4 up to 13.1) and SUSE Linux Enterprise 11.
+ - release binary and source .rpms and daily snapshot RPMs for all openSUSE versions (12.3 up to 13.2) and SUSE Linux Enterprise 11.
|
Marcus Meissner |
diff --git a/templates/fr/download.template b/templates/fr/download.template
index 893c88f..4f7384e 100644
--- a/templates/fr/download.template
+++ b/templates/fr/download.template
@@ -99,7 +99,7 @@ center;">Voyez la
Paquets SUSE
- .rpm binaires et sources et instantan?s quotidiens pour openSUSE
- 11.4 - 13.1 ainsi que SUSE Linux Enterprise 11.
+ 12.3 - 13.2 ainsi que SUSE Linux Enterprise 11.
|
Marcus Meissner |
diff --git a/templates/he/download.template b/templates/he/download.template
index 1573b95..d17ea6f 100644
--- a/templates/he/download.template
+++ b/templates/he/download.template
@@ -93,7 +93,7 @@
????? ?????? SUSE
- - release binary and source .rpms and daily snapshot RPMs for openSUSE 11.4 - 13.1 and SUSE Linux Enterprise 11.
+ - release binary and source .rpms and daily snapshot RPMs for openSUSE 12.3 - 13.2 and SUSE Linux Enterprise 11.
|
Marcus Meissner |
diff --git a/templates/pl/download.template b/templates/pl/download.template
index 929f1c3..f3a4d00 100644
--- a/templates/pl/download.template
+++ b/templates/pl/download.template
@@ -92,7 +92,7 @@
Pobierz paczki dla SUSE
- - binarne i ?r?d?owe paczki .rpm oraz dzienne zrzuty dla openSUSE 11.4 - 13.1 i SUSE Linux Enterprise 11.
+ - binarne i ?r?d?owe paczki .rpm oraz dzienne zrzuty dla openSUSE 12.3 - 13.2 i SUSE Linux Enterprise 11.
|
Marcus Meissner |
diff --git a/templates/pt/download.template b/templates/pt/download.template
index ba1b076..32055f0 100644
--- a/templates/pt/download.template
+++ b/templates/pt/download.template
@@ -90,7 +90,7 @@
Descarregar pacotes para SUSE
- - .rpms bin?rios e do c?digo fonte e RPMs com snapshots di?rios para openSUSE 11.4 - 13.1 e SUSE Linux Enterprise 11.
+ - .rpms bin?rios e do c?digo fonte e RPMs com snapshots di?rios para openSUSE 12.3 - 13.2 e SUSE Linux Enterprise 11.
|
Marcus Meissner |
diff --git a/templates/tr/download.template b/templates/tr/download.template
index 77b7efe..d689dff 100644
--- a/templates/tr/download.template
+++ b/templates/tr/download.template
@@ -89,7 +89,7 @@
SUSE paketleri indirin
- - s?r?m ikili ve kaynak .rpm dosyalar? ve g?nl?k RPM derlemeleri. openSUSE 11.4 - 13.1 ve SUSE Linux Enterprise 11 i?in.
+ - s?r?m ikili ve kaynak .rpm dosyalar? ve g?nl?k RPM derlemeleri. openSUSE 12.3 - 13.2 ve SUSE Linux Enterprise 11 i?in.
|
Marcus Meissner |
diff --git a/templates/uk/download.template b/templates/uk/download.template
index 42350c1..fd2fae6 100644
--- a/templates/uk/download.template
+++ b/templates/uk/download.template
@@ -92,7 +92,7 @@
??????????? ??????? SUSE
- - ??????? ?? ??????? .rpm ????? ?? ??????? RPM ?????? ??? ???? ?????? openSUSE (??? 11.4 ?? 13.1) ?? SUSE Linux Enterprise 11.
+ - ??????? ?? ??????? .rpm ????? ?? ??????? RPM ?????? ??? ???? ?????? openSUSE (??? 12.3 ?? 13.2) ?? SUSE Linux Enterprise 11.
|
Marcus Meissner |
diff --git a/templates/zh-cn/download.template b/templates/zh-cn/download.template
index 41eaffb..1b70cd7 100644
--- a/templates/zh-cn/download.template
+++ b/templates/zh-cn/download.template
@@ -91,7 +91,7 @@ requested in exchange for hosting the Wine web site.
?? SUSE ???
- - ????? openSUSE ?11.4 ? 13.1?? SUSE Linux Enterprise 11 ????????? .rpms ????? RPMs?
+ - ????? openSUSE ?12.3 ? 13.2?? SUSE Linux Enterprise 11 ????????? .rpms ????? RPMs?
|
Marcus Meissner |
--
2.1.2
From mstefani at redhat.de Wed Nov 5 07:13:23 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Wed, 5 Nov 2014 14:13:23 +0100
Subject: advapi32/tests: Avoid a crash on some linux hosts.
Message-ID: <20141105131323.GA18181@redhat.com>
---
While researching the w7u timeout for this tests stumbled upon some
Linux hosts that crash. This should fix it and provide further
troubleshooting info.
dlls/advapi32/tests/service.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c
index ad81a25..1d2c4a7 100644
--- a/dlls/advapi32/tests/service.c
+++ b/dlls/advapi32/tests/service.c
@@ -1399,7 +1399,8 @@ static void test_enum_svc(void)
/* lpServiceName and lpDisplayName should always be filled */
ok(services[i].lpServiceName[0], "Expected a service name\n");
- ok(services[i].lpDisplayName[0], "Expected a display name\n");
+ ok(services[i].lpDisplayName && services[i].lpDisplayName[0],
+ "Expected a display name for service '%s'\n", services[i].lpServiceName);
/* Decrement the counters to see if the functions calls return the same
* numbers as the contents of these structures.
--
1.8.3.1
From piotr at codeweavers.com Wed Nov 5 08:23:15 2014
From: piotr at codeweavers.com (Piotr Caban)
Date: Wed, 05 Nov 2014 15:23:15 +0100
Subject: user32: Move IME Window Procedure to user32
Message-ID: <545A32D3.90708@codeweavers.com>
---
dlls/imm32/imm.c | 104 +++++-----------------------------------
dlls/user32/class.c | 1 +
dlls/user32/controls.h | 4 ++
dlls/user32/misc.c | 120
++++++++++++++++++++++++++++++++++++++++++++--
dlls/user32/tests/class.c | 11 ++---
dlls/user32/user_main.c | 5 ++
dlls/user32/winproc.c | 1 +
7 files changed, 144 insertions(+), 102 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-user32-Move-IME-Window-Procedure-to-user32.txt
Type: text/x-patch
Size: 15022 bytes
Desc: not available
URL:
From sebastian at fds-team.de Wed Nov 5 11:25:28 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Wed, 05 Nov 2014 18:25:28 +0100
Subject: [1/2] d3dx9_36: Implement D3DXCreatePolygon. (resend)
Message-ID: <545A5D88.2020803@fds-team.de>
Based on a patch by David Adam.
---
dlls/d3dx9_36/d3dx9_36.spec | 2 +-
dlls/d3dx9_36/mesh.c | 88 +++++++++++++++++++++++++++++++++++++++++++++
include/d3dx9shape.h | 2 ++
3 files changed, 91 insertions(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-d3dx9_36-Implement-D3DXCreatePolygon.patch
Type: text/x-patch
Size: 4953 bytes
Desc: not available
URL:
From sebastian at fds-team.de Wed Nov 5 11:25:38 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Wed, 05 Nov 2014 18:25:38 +0100
Subject: [2/2] d3dx9_36/tests: Add tests for D3DXCreatePolygon. (try 4)
Message-ID: <545A5D92.4050802@fds-team.de>
Changes in try 4:
* Use smaller buffer
* Fix typo
* Remove error checking & goto
Changes in try 3:
* Replace ~0 -> ~0U.
Changes in try 2:
* Lot of style cleanups - hopefully I didn't miss anything.
* Fix condition for 'sides' argument (should be >= 3, not just != 0)
* Added test to check if *mesh is cleared on error - tests show that this is not the case.
I only kept a single test for that to avoid making the test code too ugly.
Based on a patch by David Adam.
---
dlls/d3dx9_36/tests/mesh.c | 155 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 155 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-d3dx9_36-tests-Add-tests-for-D3DXCreatePolygon.patch
Type: text/x-patch
Size: 5927 bytes
Desc: not available
URL:
From sebastian at fds-team.de Wed Nov 5 11:47:34 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Wed, 05 Nov 2014 18:47:34 +0100
Subject: [1/2] d3dx9_36: Implement D3DXCreatePolygon. (try 5)
Message-ID: <545A62B6.5010701@fds-team.de>
Argh, head->wall - accidentially made the changes to v2 instead of v3. ;)
Again replace ~0 -> ~0U.
Based on a patch by David Adam.
---
dlls/d3dx9_36/d3dx9_36.spec | 2 +-
dlls/d3dx9_36/mesh.c | 88 +++++++++++++++++++++++++++++++++++++++++++++
include/d3dx9shape.h | 2 ++
3 files changed, 91 insertions(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-d3dx9_36-Implement-D3DXCreatePolygon.patch
Type: text/x-patch
Size: 4954 bytes
Desc: not available
URL:
From sebastian at fds-team.de Wed Nov 5 11:47:37 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Wed, 05 Nov 2014 18:47:37 +0100
Subject: [2/2] d3dx9_36/tests: Add tests for D3DXCreatePolygon. (try 5)
Message-ID: <545A62B9.8070005@fds-team.de>
Based on a patch by David Adam.
---
dlls/d3dx9_36/tests/mesh.c | 155 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 155 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-d3dx9_36-tests-Add-tests-for-D3DXCreatePolygon.patch
Type: text/x-patch
Size: 5928 bytes
Desc: not available
URL:
From sebastian at fds-team.de Wed Nov 5 11:54:02 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Wed, 05 Nov 2014 18:54:02 +0100
Subject: d3dx9_36/tests: Remove code to skip test which should never fail.
Message-ID: <545A643A.1090203@fds-team.de>
---
dlls/d3dx9_36/tests/mesh.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-d3dx9_36-tests-Remove-code-to-skip-test-which-should.patch
Type: text/x-patch
Size: 1250 bytes
Desc: not available
URL:
From matellanesivan at gmail.com Wed Nov 5 15:55:44 2014
From: matellanesivan at gmail.com (=?UTF-8?B?SXbDoW4gTWF0ZWxsYW5lcw==?=)
Date: Wed, 05 Nov 2014 22:55:44 +0100
Subject: [1/4] msvcrt: Added _getc_nolock implementation
Message-ID: <545A9CE0.7010904@gmail.com>
The following patches implement the getc/putc_nolock functions
associating them with their counterpart fgetc/fputc_nolock functions.
---
dlls/msvcr100/msvcr100.spec | 2 +-
dlls/msvcr110/msvcr110.spec | 2 +-
dlls/msvcr120/msvcr120.spec | 2 +-
dlls/msvcr80/msvcr80.spec | 1 +
dlls/msvcr90/msvcr90.spec | 2 +-
include/msvcrt/stdio.h | 1 +
6 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 45a04cf..931d826 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -888,7 +888,7 @@
@ cdecl _get_tzname(ptr str long long) MSVCRT__get_tzname
@ cdecl _get_unexpected() MSVCRT__get_unexpected
@ cdecl _get_wpgmptr(ptr)
-@ stub _getc_nolock
+@ cdecl _getc_nolock(ptr) MSVCRT__fgetc_nolock
@ cdecl _getch()
@ stub _getch_nolock
@ cdecl _getche()
diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec
index 5fc4ee5..3939ccf 100644
--- a/dlls/msvcr110/msvcr110.spec
+++ b/dlls/msvcr110/msvcr110.spec
@@ -1236,7 +1236,7 @@
@ cdecl _get_tzname(ptr str long long) MSVCRT__get_tzname
@ cdecl _get_unexpected() MSVCRT__get_unexpected
@ cdecl _get_wpgmptr(ptr)
-@ stub _getc_nolock
+@ cdecl _getc_nolock(ptr) MSVCRT__fgetc_nolock
@ cdecl _getch()
@ stub _getch_nolock
@ cdecl _getche()
diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index c3edd61..2ee3800 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -1234,7 +1234,7 @@
@ cdecl _get_tzname(ptr str long long) MSVCRT__get_tzname
@ cdecl _get_unexpected() MSVCRT__get_unexpected
@ cdecl _get_wpgmptr(ptr)
-@ stub _getc_nolock
+@ cdecl _getc_nolock(ptr) MSVCRT__fgetc_nolock
@ cdecl _getch()
@ stub _getch_nolock
@ cdecl _getche()
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 9877784..36421f3 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -562,6 +562,7 @@
@ stub _get_winminor
@ stub _get_winver
@ cdecl _get_wpgmptr(ptr)
+@ cdecl _getc_nolock(ptr) MSVCRT__fgetc_nolock
@ cdecl _getch()
@ stub _getch_nolock
@ cdecl _getche()
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 4df9203..e9790be 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -539,7 +539,7 @@
@ cdecl _get_tzname(ptr str long long) MSVCRT__get_tzname
@ cdecl _get_unexpected() MSVCRT__get_unexpected
@ cdecl _get_wpgmptr(ptr)
-@ stub _getc_nolock
+@ cdecl _getc_nolock(ptr) MSVCRT__fgetc_nolock
@ cdecl _getch()
@ stub _getch_nolock
@ cdecl _getche()
diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h
index 7512efc..9a2f338 100644
--- a/include/msvcrt/stdio.h
+++ b/include/msvcrt/stdio.h
@@ -137,6 +137,7 @@ int __cdecl _fseek_nolock(FILE*,__msvcrt_long,int);
int __cdecl _fseeki64_nolock(FILE*,__int64,int);
__msvcrt_long __cdecl _ftell_nolock(FILE*);
__int64 __cdecl _ftelli64_nolock(FILE*);
+int __cdecl _getc_nolock(FILE*);
int __cdecl _ungetc_nolock(int,FILE*);
void __cdecl clearerr(FILE*);
--
1.9.1
From matellanesivan at gmail.com Wed Nov 5 15:55:50 2014
From: matellanesivan at gmail.com (=?UTF-8?B?SXbDoW4gTWF0ZWxsYW5lcw==?=)
Date: Wed, 05 Nov 2014 22:55:50 +0100
Subject: [2/4] msvcrt: Added _getwc_nolock implementation
Message-ID: <545A9CE6.4090608@gmail.com>
---
dlls/msvcr100/msvcr100.spec | 1 +
dlls/msvcr110/msvcr110.spec | 1 +
dlls/msvcr120/msvcr120.spec | 1 +
dlls/msvcr80/msvcr80.spec | 1 +
dlls/msvcr90/msvcr90.spec | 1 +
include/msvcrt/stdio.h | 1 +
6 files changed, 6 insertions(+)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 931d826..0fbe506 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -906,6 +906,7 @@
@ cdecl _getptd()
@ stub _getsystime(ptr)
@ cdecl _getw(ptr) MSVCRT__getw
+@ cdecl _getwc_nolock(ptr) MSVCRT__fgetwc_nolock
@ stub _getwch
@ stub _getwch_nolock
@ stub _getwche
diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec
index 3939ccf..368ca37 100644
--- a/dlls/msvcr110/msvcr110.spec
+++ b/dlls/msvcr110/msvcr110.spec
@@ -1253,6 +1253,7 @@
@ cdecl _getptd()
@ stub _getsystime(ptr)
@ cdecl _getw(ptr) MSVCRT__getw
+@ cdecl _getwc_nolock(ptr) MSVCRT__fgetwc_nolock
@ stub _getwch
@ stub _getwch_nolock
@ stub _getwche
diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index 2ee3800..2b647b8 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -1251,6 +1251,7 @@
@ cdecl _getptd()
@ stub _getsystime(ptr)
@ cdecl _getw(ptr) MSVCRT__getw
+@ cdecl _getwc_nolock(ptr) MSVCRT__fgetwc_nolock
@ stub _getwch
@ stub _getwch_nolock
@ stub _getwche
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 36421f3..0137ac4 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -580,6 +580,7 @@
@ cdecl _getptd()
@ stub _getsystime(ptr)
@ cdecl _getw(ptr) MSVCRT__getw
+@ cdecl _getwc_nolock(ptr) MSVCRT__fgetwc_nolock
@ stub _getwch
@ stub _getwch_nolock
@ stub _getwche
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index e9790be..c028cba 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -557,6 +557,7 @@
@ cdecl _getptd()
@ stub _getsystime(ptr)
@ cdecl _getw(ptr) MSVCRT__getw
+@ cdecl _getwc_nolock(ptr) MSVCRT__fgetwc_nolock
@ stub _getwch
@ stub _getwch_nolock
@ stub _getwche
diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h
index 9a2f338..8b23def 100644
--- a/include/msvcrt/stdio.h
+++ b/include/msvcrt/stdio.h
@@ -203,6 +203,7 @@ wint_t __cdecl _fgetwc_nolock(FILE*);
wint_t __cdecl _fgetwchar(void);
wint_t __cdecl _fputwc_nolock(wint_t,FILE*);
wint_t __cdecl _fputwchar(wint_t);
+wint_t __cdecl _getwc_nolock(FILE*);
wchar_t* __cdecl _getws(wchar_t*);
int __cdecl _putws(const wchar_t*);
int __cdecl _snwprintf(wchar_t*,size_t,const wchar_t*,...);
--
1.9.1
From matellanesivan at gmail.com Wed Nov 5 15:55:57 2014
From: matellanesivan at gmail.com (=?UTF-8?B?SXbDoW4gTWF0ZWxsYW5lcw==?=)
Date: Wed, 05 Nov 2014 22:55:57 +0100
Subject: [3/4] msvcrt: Added _putc_nolock implementation
Message-ID: <545A9CED.4080802@gmail.com>
---
dlls/msvcr100/msvcr100.spec | 1 +
dlls/msvcr110/msvcr110.spec | 1 +
dlls/msvcr120/msvcr120.spec | 1 +
dlls/msvcr80/msvcr80.spec | 1 +
dlls/msvcr90/msvcr90.spec | 1 +
include/msvcrt/stdio.h | 1 +
6 files changed, 6 insertions(+)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 0fbe506..0e1ec19 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -1232,6 +1232,7 @@
@ stub _printf_p_l
@ stub _printf_s_l
@ cdecl _purecall()
+@ cdecl _putc_nolock(long ptr) MSVCRT__fputc_nolock
@ cdecl _putch(long)
@ stub _putch_nolock
@ cdecl _putenv(str)
diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec
index 368ca37..609e7ba 100644
--- a/dlls/msvcr110/msvcr110.spec
+++ b/dlls/msvcr110/msvcr110.spec
@@ -1590,6 +1590,7 @@
@ stub _printf_p_l
@ stub _printf_s_l
@ cdecl _purecall()
+@ cdecl _putc_nolock(long ptr) MSVCRT__fputc_nolock
@ cdecl _putch(long)
@ stub _putch_nolock
@ cdecl _putenv(str)
diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index 2b647b8..1afacf5 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -1598,6 +1598,7 @@
@ stub _printf_p_l
@ stub _printf_s_l
@ cdecl _purecall()
+@ cdecl _putc_nolock(long ptr) MSVCRT__fputc_nolock
@ cdecl _putch(long)
@ stub _putch_nolock
@ cdecl _putenv(str)
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 0137ac4..960a23c 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -907,6 +907,7 @@
@ stub _printf_p_l
@ stub _printf_s_l
@ cdecl _purecall()
+@ cdecl _putc_nolock(long ptr) MSVCRT__fputc_nolock
@ cdecl _putch(long)
@ stub _putch_nolock
@ cdecl _putenv(str)
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index c028cba..8b74dea 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -882,6 +882,7 @@
@ stub _printf_p_l
@ stub _printf_s_l
@ cdecl _purecall()
+@ cdecl _putc_nolock(long ptr) MSVCRT__fputc_nolock
@ cdecl _putch(long)
@ stub _putch_nolock
@ cdecl _putenv(str)
diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h
index 8b23def..d7316b5 100644
--- a/include/msvcrt/stdio.h
+++ b/include/msvcrt/stdio.h
@@ -138,6 +138,7 @@ int __cdecl _fseeki64_nolock(FILE*,__int64,int);
__msvcrt_long __cdecl _ftell_nolock(FILE*);
__int64 __cdecl _ftelli64_nolock(FILE*);
int __cdecl _getc_nolock(FILE*);
+int __cdecl _putc_nolock(int,FILE*);
int __cdecl _ungetc_nolock(int,FILE*);
void __cdecl clearerr(FILE*);
--
1.9.1
From matellanesivan at gmail.com Wed Nov 5 15:56:11 2014
From: matellanesivan at gmail.com (=?UTF-8?B?SXbDoW4gTWF0ZWxsYW5lcw==?=)
Date: Wed, 05 Nov 2014 22:56:11 +0100
Subject: [4/4] msvcrt: Added _putwc_nolock implementation
Message-ID: <545A9CFB.6020500@gmail.com>
---
dlls/msvcr100/msvcr100.spec | 1 +
dlls/msvcr110/msvcr110.spec | 1 +
dlls/msvcr120/msvcr120.spec | 1 +
dlls/msvcr80/msvcr80.spec | 1 +
dlls/msvcr90/msvcr90.spec | 1 +
include/msvcrt/stdio.h | 1 +
6 files changed, 6 insertions(+)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 0e1ec19..cb45506 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -1238,6 +1238,7 @@
@ cdecl _putenv(str)
@ cdecl _putenv_s(str str)
@ cdecl _putw(long ptr) MSVCRT__putw
+@ cdecl _putwc_nolock(long ptr) MSVCRT__fputwc_nolock
@ cdecl _putwch(long) MSVCRT__putwch
@ stub _putwch_nolock
@ cdecl _putws(wstr) MSVCRT__putws
diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec
index 609e7ba..d41699d 100644
--- a/dlls/msvcr110/msvcr110.spec
+++ b/dlls/msvcr110/msvcr110.spec
@@ -1596,6 +1596,7 @@
@ cdecl _putenv(str)
@ cdecl _putenv_s(str str)
@ cdecl _putw(long ptr) MSVCRT__putw
+@ cdecl _putwc_nolock(long ptr) MSVCRT__fputwc_nolock
@ cdecl _putwch(long) MSVCRT__putwch
@ stub _putwch_nolock
@ cdecl _putws(wstr) MSVCRT__putws
diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index 1afacf5..fbf688e 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -1604,6 +1604,7 @@
@ cdecl _putenv(str)
@ cdecl _putenv_s(str str)
@ cdecl _putw(long ptr) MSVCRT__putw
+@ cdecl _putwc_nolock(long ptr) MSVCRT__fputwc_nolock
@ cdecl _putwch(long) MSVCRT__putwch
@ stub _putwch_nolock
@ cdecl _putws(wstr) MSVCRT__putws
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 960a23c..efb4539 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -913,6 +913,7 @@
@ cdecl _putenv(str)
@ cdecl _putenv_s(str str)
@ cdecl _putw(long ptr) MSVCRT__putw
+@ cdecl _putwc_nolock(long ptr) MSVCRT__fputwc_nolock
@ cdecl _putwch(long) MSVCRT__putwch
@ stub _putwch_nolock
@ cdecl _putws(wstr) MSVCRT__putws
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 8b74dea..fa62366 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -888,6 +888,7 @@
@ cdecl _putenv(str)
@ cdecl _putenv_s(str str)
@ cdecl _putw(long ptr) MSVCRT__putw
+@ cdecl _putwc_nolock(long ptr) MSVCRT__fputwc_nolock
@ cdecl _putwch(long) MSVCRT__putwch
@ stub _putwch_nolock
@ cdecl _putws(wstr) MSVCRT__putws
diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h
index d7316b5..eda89e6 100644
--- a/include/msvcrt/stdio.h
+++ b/include/msvcrt/stdio.h
@@ -206,6 +206,7 @@ wint_t __cdecl _fputwc_nolock(wint_t,FILE*);
wint_t __cdecl _fputwchar(wint_t);
wint_t __cdecl _getwc_nolock(FILE*);
wchar_t* __cdecl _getws(wchar_t*);
+wint_t __cdecl _putwc_nolock(wint_t,FILE*);
int __cdecl _putws(const wchar_t*);
int __cdecl _snwprintf(wchar_t*,size_t,const wchar_t*,...);
int __cdecl _snwprintf_s(wchar_t*,size_t,size_t,const wchar_t*,...);
--
1.9.1
From dimesio at earthlink.net Wed Nov 5 20:41:20 2014
From: dimesio at earthlink.net (Rosanne DiMesio)
Date: Wed, 5 Nov 2014 20:41:20 -0600
Subject: [website] Add a disclaimer to the Downloads page
Message-ID: <20141105204120.0b968b6c6bc18a99e2254398@earthlink.net>
Needed to make it clear to users that packages listed are not "official" and may contain unsupported patches.
---
templates/en/download.template | 2 ++
1 file changed, 2 insertions(+)
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Website-Add-a-disclaimer-to-the-Downloads-page.txt
URL:
From nsivov at codeweavers.com Wed Nov 5 23:54:08 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Thu, 06 Nov 2014 08:54:08 +0300
Subject: [PATCH] user32/tests: Use win_skip() where appropriate
Message-ID: <545B0D00.5060201@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-user32-tests-Use-win_skip-where-appropriate.patch
Type: text/x-patch
Size: 1929 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Wed Nov 5 23:58:44 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Thu, 06 Nov 2014 08:58:44 +0300
Subject: [PATCH 1/5] dwrite: Don't cache fontface instance in font data
Message-ID: <545B0E14.9090902@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-dwrite-Don-t-cache-fontface-instance-in-font-data.patch
Type: text/x-patch
Size: 5459 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Wed Nov 5 23:58:58 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Thu, 06 Nov 2014 08:58:58 +0300
Subject: [PATCH 2/5] dwrite: File and factory are always set now for all
collections
Message-ID: <545B0E22.7010606@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-dwrite-File-and-factory-are-always-set-now-for-all-c.patch
Type: text/x-patch
Size: 1002 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Wed Nov 5 23:59:15 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Thu, 06 Nov 2014 08:59:15 +0300
Subject: [PATCH 3/5] dwrite: Added a separate helper to fill font metrics
structure
Message-ID: <545B0E33.4040500@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-dwrite-Added-a-separate-helper-to-fill-font-metrics-.patch
Type: text/x-patch
Size: 6485 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Wed Nov 5 23:59:32 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Thu, 06 Nov 2014 08:59:32 +0300
Subject: [PATCH 4/5] dwrite: Use public APIs to get file streams from fontface
Message-ID: <545B0E44.6000702@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-dwrite-Use-public-APIs-to-get-file-streams-from-font.patch
Type: text/x-patch
Size: 6414 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Thu Nov 6 00:00:02 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Thu, 06 Nov 2014 09:00:02 +0300
Subject: [PATCH 5/5] dwrite: Implement GetMetrics() for fontface
Message-ID: <545B0E62.6070000@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-dwrite-Implement-GetMetrics-for-fontface.patch
Type: text/x-patch
Size: 4742 bytes
Desc: not available
URL:
From christopherwuy at gmail.com Tue Nov 4 02:22:06 2014
From: christopherwuy at gmail.com (YongHao Hu)
Date: Tue, 04 Nov 2014 16:22:06 +0800
Subject: msvcp90: Add std_Ctraits::Isnan implementation.
Message-ID: <54588CAE.6040805@gmail.com>
---
dlls/msvcp90/math.c | 9 +++++++++
dlls/msvcp90/msvcp90.spec | 6 +++---
dlls/msvcp90/tests/misc.c | 48
+++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 3 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0058-msvcp90-Add-std_Ctraits-Isnan-implementation.txt
Type: text/x-patch
Size: 5563 bytes
Desc: not available
URL:
From christopherwuy at gmail.com Wed Nov 5 22:07:59 2014
From: christopherwuy at gmail.com (YongHao Hu)
Date: Thu, 06 Nov 2014 12:07:59 +0800
Subject: msvcp90: Add std_Ctraits::Isnan implementation. (resend)
Message-ID: <545AF41F.3010208@gmail.com>
---
dlls/msvcp90/math.c | 9 +++++++++
dlls/msvcp90/msvcp90.spec | 6 +++---
dlls/msvcp90/tests/misc.c | 48
+++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 3 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0058-msvcp90-Add-std_Ctraits-Isnan-implementation.txt
Type: text/x-patch
Size: 5564 bytes
Desc: not available
URL:
From alexhenrie24 at gmail.com Thu Nov 6 01:11:24 2014
From: alexhenrie24 at gmail.com (Alex Henrie)
Date: Thu, 6 Nov 2014 00:11:24 -0700
Subject: [PATCH (try 2) 1/2] kernel32/tests: Add UTF-7 non-encoded surrounding
characters tests.
Message-ID: <1415257885-7337-1-git-send-email-alexhenrie24@gmail.com>
---
dlls/kernel32/tests/codepage.c | 73 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 8423c75..89bbd60 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -20,6 +20,7 @@
*/
#include
+#include
#include
#include "wine/test.h"
@@ -412,6 +413,76 @@ static void test_string_conversion(LPBOOL bUsedDefaultChar)
ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
}
+static void test_utf7_encoding(void)
+{
+ WCHAR input[16];
+ char output[16], expected[16];
+ int i, len, expected_len;
+
+ static const BOOL directly_encodable_table[] =
+ {
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, /* 0x00 - 0x0F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x1F */
+ 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* 0x20 - 0x2F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 0x30 - 0x3F */
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 0x50 - 0x5F */
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6F */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 /* 0x70 - 0x7F */
+ };
+ static const char base64_encoding_table[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+ if (WideCharToMultiByte(CP_UTF7, 0, foobarW, -1, NULL, 0, NULL, NULL) == 0 &&
+ GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+ {
+ skip("UTF-7 encoding not implemented\n");
+ return;
+ }
+
+ /* test which characters are encoded if surrounded by non-encoded characters */
+ for (i = 0; i <= 0xFFFF; i++)
+ {
+ input[0] = ' ';
+ input[1] = i;
+ input[2] = ' ';
+ input[3] = 0;
+
+ memset(output, '#', sizeof(output) - 1);
+ output[sizeof(output) - 1] = 0;
+
+ len = WideCharToMultiByte(CP_UTF7, 0, input, 4, output, sizeof(output) - 1, NULL, NULL);
+
+ if (i == '+')
+ {
+ /* '+' is a special case and is encoded as "+-" */
+ expected_len = 5;
+ strcpy(expected, " +- ");
+ }
+ else if (i <= 0x7F && directly_encodable_table[i])
+ {
+ /* encodes directly */
+ expected_len = 4;
+ sprintf(expected, " %c ", i);
+ }
+ else
+ {
+ /* base64-encodes */
+ expected_len = 8;
+ sprintf(expected, " +%c%c%c- ",
+ base64_encoding_table[(i & 0xFC00) >> 10],
+ base64_encoding_table[(i & 0x03F0) >> 4],
+ base64_encoding_table[(i & 0x000F) << 2]);
+ }
+
+ ok(len == expected_len, "i=0x%04x: expected len=%i, got len=%i\n", i, expected_len, len);
+ ok(memcmp(output, expected, expected_len) == 0,
+ "i=0x%04x: expected output='%s', got output='%s'\n", i, expected, output);
+ ok(output[expected_len] == '#', "i=0x%04x: expected output[%i]='#', got output[%i]=%i\n",
+ i, expected_len, expected_len, output[expected_len]);
+ }
+}
+
static void test_undefined_byte_char(void)
{
static const struct tag_testset {
@@ -618,6 +689,8 @@ START_TEST(codepage)
test_string_conversion(NULL);
test_string_conversion(&bUsedDefaultChar);
+ test_utf7_encoding();
+
test_undefined_byte_char();
test_threadcp();
}
--
2.1.3
From alexhenrie24 at gmail.com Thu Nov 6 01:11:25 2014
From: alexhenrie24 at gmail.com (Alex Henrie)
Date: Thu, 6 Nov 2014 00:11:25 -0700
Subject: [PATCH (try 2) 2/2] kernel32/tests: Add UTF-7 encoded surrounding
characters tests.
In-Reply-To: <1415257885-7337-1-git-send-email-alexhenrie24@gmail.com>
References: <1415257885-7337-1-git-send-email-alexhenrie24@gmail.com>
Message-ID: <1415257885-7337-2-git-send-email-alexhenrie24@gmail.com>
---
dlls/kernel32/tests/codepage.c | 44 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 89bbd60..147989b 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -481,6 +481,50 @@ static void test_utf7_encoding(void)
ok(output[expected_len] == '#', "i=0x%04x: expected output[%i]='#', got output[%i]=%i\n",
i, expected_len, expected_len, output[expected_len]);
}
+
+ /* test which one-byte characters are absorbed into surrounding base64 blocks
+ * (Windows always ends the base64 block when it encounters a directly encodable character) */
+ for (i = 0; i <= 0xFFFF; i++)
+ {
+ input[0] = 0x2672;
+ input[1] = i;
+ input[2] = 0x2672;
+ input[3] = 0;
+
+ memset(output, '#', sizeof(output) - 1);
+ output[sizeof(output) - 1] = 0;
+
+ len = WideCharToMultiByte(CP_UTF7, 0, input, 4, output, sizeof(output) - 1, NULL, NULL);
+
+ if (i == '+')
+ {
+ /* '+' is a special case and is encoded as "+-" */
+ expected_len = 13;
+ strcpy(expected, "+JnI-+-+JnI-");
+ }
+ else if (i <= 0x7F && directly_encodable_table[i])
+ {
+ /* encodes directly */
+ expected_len = 12;
+ sprintf(expected, "+JnI-%c+JnI-", i);
+ }
+ else
+ {
+ /* base64-encodes */
+ expected_len = 11;
+ sprintf(expected, "+Jn%c%c%c%cZy-",
+ base64_encoding_table[8 | ((i & 0xC000) >> 14)],
+ base64_encoding_table[(i & 0x3F00) >> 8],
+ base64_encoding_table[(i & 0x00FC) >> 2],
+ base64_encoding_table[((i & 0x0003) << 4) | 2]);
+ }
+
+ ok(len == expected_len, "i=0x%04x: expected len=%i, got len=%i\n", i, expected_len, len);
+ ok(memcmp(output, expected, expected_len) == 0,
+ "i=0x%04x: expected output='%s', got output='%s'\n", i, expected, output);
+ ok(output[expected_len] == '#', "i=0x%04x: expected output[%i]='#', got output[%i]=%i\n",
+ i, expected_len, expected_len, output[expected_len]);
+ }
}
static void test_undefined_byte_char(void)
--
2.1.3
From hverbeet at codeweavers.com Thu Nov 6 01:20:13 2014
From: hverbeet at codeweavers.com (Henri Verbeet)
Date: Thu, 6 Nov 2014 08:20:13 +0100
Subject: [PATCH 1/5] d3d10core/tests: Port alpha_test() to d3d10core.
Message-ID: <1415258417-14414-1-git-send-email-hverbeet@codeweavers.com>
---
dlls/d3d10core/tests/device.c | 247 +++++++++++++++++++++++++++++++++++++++++
dlls/d3d8/tests/visual.c | 4 +-
dlls/d3d9/tests/visual.c | 4 +-
dlls/ddraw/tests/visual.c | 4 +-
4 files changed, 253 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 7387231..2d0bcc0 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -22,6 +22,11 @@
#include "wine/test.h"
#include
+struct vec3
+{
+ float x, y, z;
+};
+
static ULONG get_refcount(IUnknown *iface)
{
IUnknown_AddRef(iface);
@@ -2053,6 +2058,247 @@ float4 main(float4 color : COLOR) : SV_TARGET
ok(!refcount, "Device has %u references left.\n", refcount);
}
+static void test_blend(void)
+{
+ ID3D10RenderTargetView *backbuffer_rtv, *offscreen_rtv;
+ ID3D10BlendState *src_blend, *dst_blend;
+ ID3D10Texture2D *backbuffer, *offscreen;
+ D3D10_SUBRESOURCE_DATA buffer_data;
+ D3D10_TEXTURE2D_DESC texture_desc;
+ ID3D10InputLayout *input_layout;
+ D3D10_BUFFER_DESC buffer_desc;
+ D3D10_BLEND_DESC blend_desc;
+ unsigned int stride, offset;
+ IDXGISwapChain *swapchain;
+ ID3D10VertexShader *vs;
+ ID3D10PixelShader *ps;
+ ID3D10Device *device;
+ D3D10_VIEWPORT vp;
+ ID3D10Buffer *vb;
+ ULONG refcount;
+ DWORD color;
+ HWND window;
+ HRESULT hr;
+
+ static const DWORD vs_code[] =
+ {
+#if 0
+ struct vs_out
+ {
+ float4 position : SV_POSITION;
+ float4 color : COLOR;
+ };
+
+ struct vs_out main(float4 position : POSITION, float4 color : COLOR)
+ {
+ struct vs_out o;
+
+ o.position = position;
+ o.color = color;
+
+ return o;
+ }
+#endif
+ 0x43425844, 0x5c73b061, 0x5c71125f, 0x3f8b345f, 0xce04b9ab, 0x00000001, 0x00000140, 0x00000003,
+ 0x0000002c, 0x0000007c, 0x000000d0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
+ 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x505f5653,
+ 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040, 0x0000001a,
+ 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067, 0x001020f2,
+ 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2, 0x00000000,
+ 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x0100003e,
+ };
+ static const DWORD ps_code[] =
+ {
+#if 0
+ struct vs_out
+ {
+ float4 position : SV_POSITION;
+ float4 color : COLOR;
+ };
+
+ float4 main(struct vs_out i) : SV_TARGET
+ {
+ return i.color;
+ }
+#endif
+ 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
+ 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
+ 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
+ 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
+ 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
+ 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
+ };
+ static const struct
+ {
+ struct vec3 position;
+ DWORD diffuse;
+ }
+ quads[] =
+ {
+ /* quad1 */
+ {{-1.0f, -1.0f, 0.1f}, 0x4000ff00},
+ {{-1.0f, 0.0f, 0.1f}, 0x4000ff00},
+ {{ 1.0f, -1.0f, 0.1f}, 0x4000ff00},
+ {{ 1.0f, 0.0f, 0.1f}, 0x4000ff00},
+ /* quad2 */
+ {{-1.0f, 0.0f, 0.1f}, 0xc00000ff},
+ {{-1.0f, 1.0f, 0.1f}, 0xc00000ff},
+ {{ 1.0f, 0.0f, 0.1f}, 0xc00000ff},
+ {{ 1.0f, 1.0f, 0.1f}, 0xc00000ff},
+ };
+ static const D3D10_INPUT_ELEMENT_DESC layout_desc[] =
+ {
+ {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
+ {"COLOR", 0, DXGI_FORMAT_B8G8R8A8_UNORM, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
+ };
+ static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const float red[] = {1.0f, 0.0f, 0.0f, 0.5f};
+
+ if (!(device = create_device()))
+ {
+ skip("Failed to create device, skipping tests.\n");
+ return;
+ }
+ window = CreateWindowA("static", "d3d10core_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ swapchain = create_swapchain(device, window, TRUE);
+ hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_ID3D10Texture2D, (void **)&backbuffer);
+ ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
+
+ hr = ID3D10Device_CreateInputLayout(device, layout_desc, sizeof(layout_desc) / sizeof(*layout_desc),
+ vs_code, sizeof(vs_code), &input_layout);
+ ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
+
+ buffer_desc.ByteWidth = sizeof(quads);
+ buffer_desc.Usage = D3D10_USAGE_DEFAULT;
+ buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
+ buffer_desc.CPUAccessFlags = 0;
+ buffer_desc.MiscFlags = 0;
+
+ buffer_data.pSysMem = quads;
+ buffer_data.SysMemPitch = 0;
+ buffer_data.SysMemSlicePitch = 0;
+
+ hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &buffer_data, &vb);
+ ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+ hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &vs);
+ ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+ hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+
+ hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)backbuffer, NULL, &backbuffer_rtv);
+ ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr);
+
+ texture_desc.Width = 128;
+ texture_desc.Height = 128;
+ texture_desc.MipLevels = 1;
+ texture_desc.ArraySize = 1;
+ texture_desc.Format = DXGI_FORMAT_B8G8R8X8_UNORM;
+ texture_desc.SampleDesc.Count = 1;
+ texture_desc.SampleDesc.Quality = 0;
+ texture_desc.Usage = D3D10_USAGE_DEFAULT;
+ texture_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE | D3D10_BIND_RENDER_TARGET;
+ texture_desc.CPUAccessFlags = 0;
+ texture_desc.MiscFlags = 0;
+
+ hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &offscreen);
+ ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+ hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)offscreen, NULL, &offscreen_rtv);
+ ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr);
+
+ memset(&blend_desc, 0, sizeof(blend_desc));
+ blend_desc.BlendEnable[0] = TRUE;
+ blend_desc.SrcBlend = D3D10_BLEND_SRC_ALPHA;
+ blend_desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA;
+ blend_desc.BlendOp = D3D10_BLEND_OP_ADD;
+ blend_desc.SrcBlendAlpha = D3D10_BLEND_SRC_ALPHA;
+ blend_desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA;
+ blend_desc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
+ blend_desc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;
+
+ hr = ID3D10Device_CreateBlendState(device, &blend_desc, &src_blend);
+ ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr);
+
+ blend_desc.SrcBlend = D3D10_BLEND_DEST_ALPHA;
+ blend_desc.DestBlend = D3D10_BLEND_INV_DEST_ALPHA;
+ blend_desc.SrcBlendAlpha = D3D10_BLEND_DEST_ALPHA;
+ blend_desc.DestBlendAlpha = D3D10_BLEND_INV_DEST_ALPHA;
+
+ hr = ID3D10Device_CreateBlendState(device, &blend_desc, &dst_blend);
+ ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr);
+
+ ID3D10Device_OMSetRenderTargets(device, 1, &backbuffer_rtv, NULL);
+ ID3D10Device_IASetInputLayout(device, input_layout);
+ ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+ stride = sizeof(*quads);
+ offset = 0;
+ ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &stride, &offset);
+ ID3D10Device_VSSetShader(device, vs);
+ ID3D10Device_PSSetShader(device, ps);
+
+ vp.TopLeftX = 0;
+ vp.TopLeftY = 0;
+ vp.Width = 640;
+ vp.Height = 480;
+ vp.MinDepth = 0.0f;
+ vp.MaxDepth = 1.0f;
+ ID3D10Device_RSSetViewports(device, 1, &vp);
+
+ ID3D10Device_ClearRenderTargetView(device, backbuffer_rtv, red);
+
+ ID3D10Device_OMSetBlendState(device, src_blend, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
+ ID3D10Device_Draw(device, 4, 0);
+ ID3D10Device_OMSetBlendState(device, dst_blend, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
+ ID3D10Device_Draw(device, 4, 4);
+
+ color = get_texture_color(backbuffer, 320, 360);
+ ok(compare_color(color, 0x700040bf, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(backbuffer, 320, 120);
+ ok(compare_color(color, 0xa080007f, 1), "Got unexpected color 0x%08x.\n", color);
+
+ ID3D10Device_OMSetRenderTargets(device, 1, &offscreen_rtv, NULL);
+
+ vp.TopLeftX = 0;
+ vp.TopLeftY = 0;
+ vp.Width = 128;
+ vp.Height = 128;
+ vp.MinDepth = 0.0f;
+ vp.MaxDepth = 1.0f;
+ ID3D10Device_RSSetViewports(device, 1, &vp);
+
+ ID3D10Device_ClearRenderTargetView(device, offscreen_rtv, red);
+
+ ID3D10Device_OMSetBlendState(device, src_blend, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
+ ID3D10Device_Draw(device, 4, 0);
+ ID3D10Device_OMSetBlendState(device, dst_blend, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
+ ID3D10Device_Draw(device, 4, 4);
+
+ color = get_texture_color(offscreen, 64, 96) & 0x00ffffff;
+ ok(compare_color(color, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(offscreen, 64, 32) & 0x00ffffff;
+ ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+
+ ID3D10BlendState_Release(dst_blend);
+ ID3D10BlendState_Release(src_blend);
+ ID3D10PixelShader_Release(ps);
+ ID3D10VertexShader_Release(vs);
+ ID3D10Buffer_Release(vb);
+ ID3D10InputLayout_Release(input_layout);
+ ID3D10RenderTargetView_Release(offscreen_rtv);
+ ID3D10Texture2D_Release(offscreen);
+ ID3D10RenderTargetView_Release(backbuffer_rtv);
+ ID3D10Texture2D_Release(backbuffer);
+ IDXGISwapChain_Release(swapchain);
+ refcount = ID3D10Device_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(device)
{
test_create_texture2d();
@@ -2069,4 +2315,5 @@ START_TEST(device)
test_device_removed_reason();
test_scissor();
test_clear_state();
+ test_blend();
}
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index 9895a73..1b9c107 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -2104,7 +2104,7 @@ done:
DestroyWindow(window);
}
-static void alpha_test(void)
+static void test_blend(void)
{
IDirect3DSurface8 *backbuffer, *offscreen, *depthstencil;
IDirect3DTexture8 *offscreenTexture;
@@ -5249,7 +5249,7 @@ START_TEST(visual)
fog_test();
z_range_test();
offscreen_test();
- alpha_test();
+ test_blend();
test_scalar_instructions();
fog_with_shader_test();
cnd_test();
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index d1d7447..77291e9 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -7776,7 +7776,7 @@ done:
DestroyWindow(window);
}
-static void alpha_test(void)
+static void test_blend(void)
{
IDirect3DSurface9 *backbuffer, *offscreen;
IDirect3DTexture9 *offscreenTexture;
@@ -16859,7 +16859,7 @@ START_TEST(visual)
maxmip_test();
offscreen_test();
ds_size_test();
- alpha_test();
+ test_blend();
shademode_test();
srgbtexture_test();
release_buffer_test();
diff --git a/dlls/ddraw/tests/visual.c b/dlls/ddraw/tests/visual.c
index 0385044..94d6984 100644
--- a/dlls/ddraw/tests/visual.c
+++ b/dlls/ddraw/tests/visual.c
@@ -929,7 +929,7 @@ out:
}
}
-static void alpha_test(IDirect3DDevice7 *device)
+static void test_blend(IDirect3DDevice7 *device)
{
HRESULT hr;
IDirectDrawSurface7 *backbuffer = NULL, *offscreen = NULL;
@@ -3277,7 +3277,7 @@ START_TEST(visual)
clear_test(Direct3DDevice);
fog_test(Direct3DDevice);
offscreen_test(Direct3DDevice);
- alpha_test(Direct3DDevice);
+ test_blend(Direct3DDevice);
rhw_zero_test(Direct3DDevice);
cubemap_test(Direct3DDevice);
--
1.7.10.4
From hverbeet at codeweavers.com Thu Nov 6 01:20:15 2014
From: hverbeet at codeweavers.com (Henri Verbeet)
Date: Thu, 6 Nov 2014 08:20:15 +0100
Subject: [PATCH 3/5] d2d1: Implement d2d_solid_color_brush_SetColor().
Message-ID: <1415258417-14414-3-git-send-email-hverbeet@codeweavers.com>
---
dlls/d2d1/brush.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c
index b2a1664..04b273a 100644
--- a/dlls/d2d1/brush.c
+++ b/dlls/d2d1/brush.c
@@ -243,7 +243,11 @@ static void STDMETHODCALLTYPE d2d_solid_color_brush_GetTransform(ID2D1SolidColor
static void STDMETHODCALLTYPE d2d_solid_color_brush_SetColor(ID2D1SolidColorBrush *iface, const D2D1_COLOR_F *color)
{
- FIXME("iface %p, color %p stub!\n", iface, color);
+ struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
+
+ TRACE("iface %p, color %p.\n", iface, color);
+
+ brush->u.solid.color = *color;
}
static D2D1_COLOR_F * STDMETHODCALLTYPE d2d_solid_color_brush_GetColor(ID2D1SolidColorBrush *iface, D2D1_COLOR_F *color)
--
1.7.10.4
From hverbeet at codeweavers.com Thu Nov 6 01:20:14 2014
From: hverbeet at codeweavers.com (Henri Verbeet)
Date: Thu, 6 Nov 2014 08:20:14 +0100
Subject: [PATCH 2/5] d2d1: Add an initial
d2d_d3d_render_target_FillRectangle() implementation.
Message-ID: <1415258417-14414-2-git-send-email-hverbeet@codeweavers.com>
---
dlls/d2d1/brush.c | 19 ++-
dlls/d2d1/d2d1_private.h | 30 +++-
dlls/d2d1/render_target.c | 348 +++++++++++++++++++++++++++++----------------
3 files changed, 269 insertions(+), 128 deletions(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c
index 99b111f..b2a1664 100644
--- a/dlls/d2d1/brush.c
+++ b/dlls/d2d1/brush.c
@@ -145,10 +145,11 @@ HRESULT d2d_gradient_init(struct d2d_gradient *gradient, ID2D1RenderTarget *rend
}
static void d2d_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *render_target,
- const D2D1_BRUSH_PROPERTIES *desc, const struct ID2D1BrushVtbl *vtbl)
+ enum d2d_brush_type type, const D2D1_BRUSH_PROPERTIES *desc, const struct ID2D1BrushVtbl *vtbl)
{
brush->ID2D1Brush_iface.lpVtbl = vtbl;
brush->refcount = 1;
+ brush->type = type;
}
static inline struct d2d_brush *impl_from_ID2D1SolidColorBrush(ID2D1SolidColorBrush *iface)
@@ -274,7 +275,9 @@ void d2d_solid_color_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *rend
{
FIXME("Ignoring brush properties.\n");
- d2d_brush_init(brush, render_target, desc, (ID2D1BrushVtbl *)&d2d_solid_color_brush_vtbl);
+ d2d_brush_init(brush, render_target, D2D_BRUSH_TYPE_SOLID, desc,
+ (ID2D1BrushVtbl *)&d2d_solid_color_brush_vtbl);
+ brush->u.solid.color = *color;
}
static inline struct d2d_brush *impl_from_ID2D1LinearGradientBrush(ID2D1LinearGradientBrush *iface)
@@ -430,5 +433,15 @@ void d2d_linear_gradient_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *
{
FIXME("Ignoring brush properties.\n");
- d2d_brush_init(brush, render_target, brush_desc, (ID2D1BrushVtbl *)&d2d_linear_gradient_brush_vtbl);
+ d2d_brush_init(brush, render_target, D2D_BRUSH_TYPE_LINEAR, brush_desc,
+ (ID2D1BrushVtbl *)&d2d_linear_gradient_brush_vtbl);
+}
+
+struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface)
+{
+ if (!iface)
+ return NULL;
+ assert(iface->lpVtbl == (const ID2D1BrushVtbl *)&d2d_solid_color_brush_vtbl
+ || iface->lpVtbl == (const ID2D1BrushVtbl *)&d2d_linear_gradient_brush_vtbl);
+ return CONTAINING_RECORD(iface, struct d2d_brush, ID2D1Brush_iface);
}
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index 294c765..0a99633 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -21,6 +21,7 @@
#include "wine/debug.h"
+#include
#include
#define COBJMACROS
#include "d2d1.h"
@@ -29,6 +30,12 @@
#endif
#include "dwrite.h"
+enum d2d_brush_type
+{
+ D2D_BRUSH_TYPE_SOLID,
+ D2D_BRUSH_TYPE_LINEAR,
+};
+
struct d2d_clip_stack
{
D2D1_RECT_F *stack;
@@ -45,13 +52,14 @@ struct d2d_d3d_render_target
ID3D10Device *device;
ID3D10RenderTargetView *view;
ID3D10StateBlock *stateblock;
+ ID3D10InputLayout *il;
+ unsigned int vb_stride;
+ ID3D10Buffer *vb;
+ ID3D10VertexShader *vs;
+ ID3D10RasterizerState *rs;
+ ID3D10BlendState *bs;
- ID3D10InputLayout *clear_il;
- unsigned int clear_vb_stride;
- ID3D10Buffer *clear_vb;
- ID3D10VertexShader *clear_vs;
- ID3D10PixelShader *clear_ps;
- ID3D10RasterizerState *clear_rs;
+ ID3D10PixelShader *rect_solid_ps;
D2D1_SIZE_U pixel_size;
D2D1_MATRIX_3X2_F transform;
@@ -98,6 +106,15 @@ struct d2d_brush
{
ID2D1Brush ID2D1Brush_iface;
LONG refcount;
+
+ enum d2d_brush_type type;
+ union
+ {
+ struct
+ {
+ D2D1_COLOR_F color;
+ } solid;
+ } u;
};
void d2d_solid_color_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *render_target,
@@ -105,6 +122,7 @@ void d2d_solid_color_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *rend
void d2d_linear_gradient_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *render_target,
const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
ID2D1GradientStopCollection *gradient) DECLSPEC_HIDDEN;
+struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface) DECLSPEC_HIDDEN;
struct d2d_stroke_style
{
diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c
index 035df2b..1dd5122 100644
--- a/dlls/d2d1/render_target.c
+++ b/dlls/d2d1/render_target.c
@@ -121,6 +121,63 @@ static void d2d_clip_stack_pop(struct d2d_clip_stack *stack)
--stack->count;
}
+static void d2d_draw(struct d2d_d3d_render_target *render_target, ID3D10Buffer *vs_cb,
+ ID3D10PixelShader *ps, ID3D10Buffer *ps_cb, BOOL blend)
+{
+ ID3D10Device *device = render_target->device;
+ unsigned int offset;
+ D3D10_VIEWPORT vp;
+ HRESULT hr;
+ static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+ vp.TopLeftX = 0;
+ vp.TopLeftY = 0;
+ vp.Width = render_target->pixel_size.width;
+ vp.Height = render_target->pixel_size.height;
+ vp.MinDepth = 0.0f;
+ vp.MaxDepth = 1.0f;
+
+ if (FAILED(hr = render_target->stateblock->lpVtbl->Capture(render_target->stateblock)))
+ {
+ WARN("Failed to capture stateblock, hr %#x.\n", hr);
+ return;
+ }
+
+ ID3D10Device_ClearState(device);
+
+ ID3D10Device_IASetInputLayout(device, render_target->il);
+ ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+ offset = 0;
+ ID3D10Device_IASetVertexBuffers(device, 0, 1, &render_target->vb,
+ &render_target->vb_stride, &offset);
+ ID3D10Device_VSSetConstantBuffers(device, 0, 1, &vs_cb);
+ ID3D10Device_VSSetShader(device, render_target->vs);
+ ID3D10Device_PSSetConstantBuffers(device, 0, 1, &ps_cb);
+ ID3D10Device_PSSetShader(device, ps);
+ ID3D10Device_RSSetViewports(device, 1, &vp);
+ if (render_target->clip_stack.count)
+ {
+ const D2D1_RECT_F *clip_rect;
+ D3D10_RECT scissor_rect;
+
+ clip_rect = &render_target->clip_stack.stack[render_target->clip_stack.count - 1];
+ scissor_rect.left = clip_rect->left + 0.5f;
+ scissor_rect.top = clip_rect->top + 0.5f;
+ scissor_rect.right = clip_rect->right + 0.5f;
+ scissor_rect.bottom = clip_rect->bottom + 0.5f;
+ ID3D10Device_RSSetScissorRects(device, 1, &scissor_rect);
+ ID3D10Device_RSSetState(device, render_target->rs);
+ }
+ ID3D10Device_OMSetRenderTargets(device, 1, &render_target->view, NULL);
+ if (blend)
+ ID3D10Device_OMSetBlendState(device, render_target->bs, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
+
+ ID3D10Device_Draw(device, 4, 0);
+
+ if (FAILED(hr = render_target->stateblock->lpVtbl->Apply(render_target->stateblock)))
+ WARN("Failed to apply stateblock, hr %#x.\n", hr);
+}
+
static inline struct d2d_d3d_render_target *impl_from_ID2D1RenderTarget(ID2D1RenderTarget *iface)
{
return CONTAINING_RECORD(iface, struct d2d_d3d_render_target, ID2D1RenderTarget_iface);
@@ -165,13 +222,14 @@ static ULONG STDMETHODCALLTYPE d2d_d3d_render_target_Release(ID2D1RenderTarget *
if (!refcount)
{
d2d_clip_stack_cleanup(&render_target->clip_stack);
- ID3D10RenderTargetView_Release(render_target->view);
- ID3D10RasterizerState_Release(render_target->clear_rs);
- ID3D10PixelShader_Release(render_target->clear_ps);
- ID3D10VertexShader_Release(render_target->clear_vs);
- ID3D10Buffer_Release(render_target->clear_vb);
- ID3D10InputLayout_Release(render_target->clear_il);
+ ID3D10PixelShader_Release(render_target->rect_solid_ps);
+ ID3D10BlendState_Release(render_target->bs);
+ ID3D10RasterizerState_Release(render_target->rs);
+ ID3D10VertexShader_Release(render_target->vs);
+ ID3D10Buffer_Release(render_target->vb);
+ ID3D10InputLayout_Release(render_target->il);
render_target->stateblock->lpVtbl->Release(render_target->stateblock);
+ ID3D10RenderTargetView_Release(render_target->view);
ID3D10Device_Release(render_target->device);
HeapFree(GetProcessHeap(), 0, render_target);
}
@@ -438,7 +496,82 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_DrawRectangle(ID2D1RenderTar
static void STDMETHODCALLTYPE d2d_d3d_render_target_FillRectangle(ID2D1RenderTarget *iface,
const D2D1_RECT_F *rect, ID2D1Brush *brush)
{
- FIXME("iface %p, rect %p, brush %p stub!\n", iface, rect, brush);
+ struct d2d_d3d_render_target *render_target = impl_from_ID2D1RenderTarget(iface);
+ struct d2d_brush *brush_impl = unsafe_impl_from_ID2D1Brush(brush);
+ D3D10_SUBRESOURCE_DATA buffer_data;
+ D3D10_BUFFER_DESC buffer_desc;
+ ID3D10Buffer *vs_cb, *ps_cb;
+ float tmp_x, tmp_y;
+ HRESULT hr;
+ struct
+ {
+ float _11, _21, _31, pad0;
+ float _12, _22, _32, pad1;
+ } transform;
+
+ TRACE("iface %p, rect %p, brush %p.\n", iface, rect, brush);
+
+ if (brush_impl->type != D2D_BRUSH_TYPE_SOLID)
+ {
+ FIXME("Unhandled brush type %#x.\n", brush_impl->type);
+ return;
+ }
+
+ /* Translate from clip space to world (D2D rendertarget) space, taking the
+ * dpi and rendertarget transform into account. */
+ tmp_x = (2.0f * render_target->dpi_x) / (96.0f * render_target->pixel_size.width);
+ tmp_y = -(2.0f * render_target->dpi_y) / (96.0f * render_target->pixel_size.height);
+ transform._11 = render_target->transform._11 * tmp_x;
+ transform._21 = render_target->transform._21 * tmp_x;
+ transform._31 = render_target->transform._31 * tmp_x - 1.0f;
+ transform.pad0 = 0.0f;
+ transform._12 = render_target->transform._12 * tmp_y;
+ transform._22 = render_target->transform._22 * tmp_y;
+ transform._32 = render_target->transform._32 * tmp_y + 1.0f;
+ transform.pad1 = 0.0f;
+
+ /* Translate from world space to object space. */
+ tmp_x = rect->left + (rect->right - rect->left) / 2.0f;
+ tmp_y = rect->top + (rect->bottom - rect->top) / 2.0f;
+ transform._31 += tmp_x * transform._11 + tmp_y * transform._21;
+ transform._32 += tmp_x * transform._12 + tmp_y * transform._22;
+ tmp_x = (rect->right - rect->left) / 2.0f;
+ tmp_y = (rect->bottom - rect->top) / 2.0f;
+ transform._11 *= tmp_x;
+ transform._12 *= tmp_x;
+ transform._21 *= tmp_y;
+ transform._22 *= tmp_y;
+
+ buffer_desc.ByteWidth = sizeof(transform);
+ buffer_desc.Usage = D3D10_USAGE_DEFAULT;
+ buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
+ buffer_desc.CPUAccessFlags = 0;
+ buffer_desc.MiscFlags = 0;
+
+ buffer_data.pSysMem = &transform;
+ buffer_data.SysMemPitch = 0;
+ buffer_data.SysMemSlicePitch = 0;
+
+ if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->device, &buffer_desc, &buffer_data, &vs_cb)))
+ {
+ WARN("Failed to create constant buffer, hr %#x.\n", hr);
+ return;
+ }
+
+ buffer_desc.ByteWidth = sizeof(brush_impl->u.solid.color);
+ buffer_data.pSysMem = &brush_impl->u.solid.color;
+
+ if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->device, &buffer_desc, &buffer_data, &ps_cb)))
+ {
+ WARN("Failed to create constant buffer, hr %#x.\n", hr);
+ ID3D10Buffer_Release(vs_cb);
+ return;
+ }
+
+ d2d_draw(render_target, vs_cb, render_target->rect_solid_ps, ps_cb, TRUE);
+
+ ID3D10Buffer_Release(ps_cb);
+ ID3D10Buffer_Release(vs_cb);
}
static void STDMETHODCALLTYPE d2d_d3d_render_target_DrawRoundedRectangle(ID2D1RenderTarget *iface,
@@ -683,75 +816,47 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_Clear(ID2D1RenderTarget *ifa
struct d2d_d3d_render_target *render_target = impl_from_ID2D1RenderTarget(iface);
D3D10_SUBRESOURCE_DATA buffer_data;
D3D10_BUFFER_DESC buffer_desc;
- unsigned int offset;
- D3D10_VIEWPORT vp;
- ID3D10Buffer *cb;
+ ID3D10Buffer *vs_cb, *ps_cb;
HRESULT hr;
+ static float transform[] =
+ {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f, 0.0f,
+ };
+
TRACE("iface %p, color %p.\n", iface, color);
- buffer_desc.ByteWidth = sizeof(*color);
+ buffer_desc.ByteWidth = sizeof(transform);
buffer_desc.Usage = D3D10_USAGE_DEFAULT;
buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
buffer_desc.CPUAccessFlags = 0;
buffer_desc.MiscFlags = 0;
- buffer_data.pSysMem = color;
+ buffer_data.pSysMem = transform;
buffer_data.SysMemPitch = 0;
buffer_data.SysMemSlicePitch = 0;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->device, &buffer_desc, &buffer_data, &cb)))
+ if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->device, &buffer_desc, &buffer_data, &vs_cb)))
{
WARN("Failed to create constant buffer, hr %#x.\n", hr);
return;
}
- vp.TopLeftX = 0;
- vp.TopLeftY = 0;
- vp.Width = render_target->pixel_size.width;
- vp.Height = render_target->pixel_size.height;
- vp.MinDepth = 0.0f;
- vp.MaxDepth = 1.0f;
+ buffer_desc.ByteWidth = sizeof(*color);
+ buffer_data.pSysMem = color;
- if (FAILED(hr = render_target->stateblock->lpVtbl->Capture(render_target->stateblock)))
+ if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->device, &buffer_desc, &buffer_data, &ps_cb)))
{
- WARN("Failed to capture stateblock, hr %#x.\n", hr);
- ID3D10Buffer_Release(cb);
+ WARN("Failed to create constant buffer, hr %#x.\n", hr);
+ ID3D10Buffer_Release(vs_cb);
return;
}
- ID3D10Device_ClearState(render_target->device);
-
- ID3D10Device_IASetInputLayout(render_target->device, render_target->clear_il);
- ID3D10Device_IASetPrimitiveTopology(render_target->device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
- offset = 0;
- ID3D10Device_IASetVertexBuffers(render_target->device, 0, 1,
- &render_target->clear_vb, &render_target->clear_vb_stride, &offset);
- ID3D10Device_VSSetShader(render_target->device, render_target->clear_vs);
- ID3D10Device_PSSetConstantBuffers(render_target->device, 0, 1, &cb);
- ID3D10Device_PSSetShader(render_target->device, render_target->clear_ps);
- ID3D10Device_RSSetViewports(render_target->device, 1, &vp);
- if (render_target->clip_stack.count)
- {
- const D2D1_RECT_F *clip_rect;
- D3D10_RECT scissor_rect;
+ d2d_draw(render_target, vs_cb, render_target->rect_solid_ps, ps_cb, FALSE);
- clip_rect = &render_target->clip_stack.stack[render_target->clip_stack.count - 1];
- scissor_rect.left = clip_rect->left + 0.5f;
- scissor_rect.top = clip_rect->top + 0.5f;
- scissor_rect.right = clip_rect->right + 0.5f;
- scissor_rect.bottom = clip_rect->bottom + 0.5f;
- ID3D10Device_RSSetScissorRects(render_target->device, 1, &scissor_rect);
- ID3D10Device_RSSetState(render_target->device, render_target->clear_rs);
- }
- ID3D10Device_OMSetRenderTargets(render_target->device, 1, &render_target->view, NULL);
-
- ID3D10Device_Draw(render_target->device, 4, 0);
-
- if (FAILED(hr = render_target->stateblock->lpVtbl->Apply(render_target->stateblock)))
- WARN("Failed to apply stateblock, hr %#x.\n", hr);
-
- ID3D10Buffer_Release(cb);
+ ID3D10Buffer_Release(ps_cb);
+ ID3D10Buffer_Release(vs_cb);
}
static void STDMETHODCALLTYPE d2d_d3d_render_target_BeginDraw(ID2D1RenderTarget *iface)
@@ -1032,35 +1137,34 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
DXGI_SURFACE_DESC surface_desc;
D3D10_RASTERIZER_DESC rs_desc;
D3D10_BUFFER_DESC buffer_desc;
+ D3D10_BLEND_DESC blend_desc;
ID3D10Resource *resource;
HRESULT hr;
- static const D3D10_INPUT_ELEMENT_DESC clear_il_desc[] =
+ static const D3D10_INPUT_ELEMENT_DESC il_desc[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
};
- static const DWORD clear_vs_code[] =
+ static const DWORD vs_code[] =
{
- /* float4 main(float4 position : POSITION) : SV_POSITION
+ /* float3x2 transform;
+ *
+ * float4 main(float4 position : POSITION) : SV_POSITION
* {
- * return position;
+ * return float4(mul(position.xyw, transform), position.zw);
* } */
- 0x43425844, 0x1fa8c27f, 0x52d2f21d, 0xc196fdb7, 0x376f283a, 0x00000001, 0x000001b4, 0x00000005,
- 0x00000034, 0x0000008c, 0x000000c0, 0x000000f4, 0x00000138, 0x46454452, 0x00000050, 0x00000000,
- 0x00000000, 0x00000000, 0x0000001c, 0xfffe0400, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f,
- 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e30332e,
- 0x30303239, 0x3336312e, 0xab003438, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x43425844, 0x0add3194, 0x205f74ec, 0xab527fe7, 0xbe6ad704, 0x00000001, 0x00000128, 0x00000003,
+ 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
- 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
- 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
- 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x54415453, 0x00000074,
- 0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000008c, 0x00010040,
+ 0x00000023, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x0300005f, 0x001010f2, 0x00000000,
+ 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x08000010, 0x00102012, 0x00000000, 0x00101346,
+ 0x00000000, 0x00208246, 0x00000000, 0x00000000, 0x08000010, 0x00102022, 0x00000000, 0x00101346,
+ 0x00000000, 0x00208246, 0x00000000, 0x00000001, 0x05000036, 0x001020c2, 0x00000000, 0x00101ea6,
+ 0x00000000, 0x0100003e,
};
- static const DWORD clear_ps_code[] =
+ static const DWORD rect_solid_ps_code[] =
{
/* float4 color;
*
@@ -1068,35 +1172,24 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
* {
* return color;
* } */
- 0x43425844, 0xecd3cc9d, 0x0025bc77, 0x7a333165, 0x5b04c7e4, 0x00000001, 0x0000022c, 0x00000005,
- 0x00000034, 0x00000100, 0x00000134, 0x00000168, 0x000001b0, 0x46454452, 0x000000c4, 0x00000001,
- 0x00000048, 0x00000001, 0x0000001c, 0xffff0400, 0x00000100, 0x00000090, 0x0000003c, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x6f6c4724, 0x736c6162,
- 0xababab00, 0x0000003c, 0x00000001, 0x00000060, 0x00000010, 0x00000000, 0x00000000, 0x00000078,
- 0x00000000, 0x00000010, 0x00000002, 0x00000080, 0x00000000, 0x6f6c6f63, 0xabab0072, 0x00030001,
- 0x00040001, 0x00000000, 0x00000000, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53,
- 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
- 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
- 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4e47534f, 0x0000002c, 0x00000001,
- 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
- 0x65677261, 0xabab0074, 0x52444853, 0x00000040, 0x00000040, 0x00000010, 0x04000059, 0x00208e46,
- 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x06000036, 0x001020f2, 0x00000000,
- 0x00208e46, 0x00000000, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000,
- 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000,
+ 0x43425844, 0x88eefcfd, 0x93d6fd47, 0x173c242f, 0x0106d07a, 0x00000001, 0x000000dc, 0x00000003,
+ 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
+ 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000040, 0x00000040,
+ 0x00000010, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000,
+ 0x06000036, 0x001020f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x0100003e,
};
static const struct
{
float x, y;
}
- clear_quad[] =
+ quad[] =
{
- {-1.0f, -1.0f},
{-1.0f, 1.0f},
- { 1.0f, -1.0f},
+ {-1.0f, -1.0f},
{ 1.0f, 1.0f},
+ { 1.0f, -1.0f},
};
static const D2D1_MATRIX_3X2_F identity =
{
@@ -1143,46 +1236,39 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
goto err;
}
- if (FAILED(hr = ID3D10Device_CreateInputLayout(render_target->device, clear_il_desc,
- sizeof(clear_il_desc) / sizeof(*clear_il_desc), clear_vs_code, sizeof(clear_vs_code),
- &render_target->clear_il)))
+ if (FAILED(hr = ID3D10Device_CreateInputLayout(render_target->device, il_desc,
+ sizeof(il_desc) / sizeof(*il_desc), vs_code, sizeof(vs_code),
+ &render_target->il)))
{
WARN("Failed to create clear input layout, hr %#x.\n", hr);
goto err;
}
- buffer_desc.ByteWidth = sizeof(clear_quad);
+ buffer_desc.ByteWidth = sizeof(quad);
buffer_desc.Usage = D3D10_USAGE_DEFAULT;
buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
buffer_desc.CPUAccessFlags = 0;
buffer_desc.MiscFlags = 0;
- buffer_data.pSysMem = clear_quad;
+ buffer_data.pSysMem = quad;
buffer_data.SysMemPitch = 0;
buffer_data.SysMemSlicePitch = 0;
- render_target->clear_vb_stride = sizeof(*clear_quad);
+ render_target->vb_stride = sizeof(*quad);
if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->device,
- &buffer_desc, &buffer_data, &render_target->clear_vb)))
+ &buffer_desc, &buffer_data, &render_target->vb)))
{
WARN("Failed to create clear vertex buffer, hr %#x.\n", hr);
goto err;
}
if (FAILED(hr = ID3D10Device_CreateVertexShader(render_target->device,
- clear_vs_code, sizeof(clear_vs_code), &render_target->clear_vs)))
+ vs_code, sizeof(vs_code), &render_target->vs)))
{
WARN("Failed to create clear vertex shader, hr %#x.\n", hr);
goto err;
}
- if (FAILED(hr = ID3D10Device_CreatePixelShader(render_target->device,
- clear_ps_code, sizeof(clear_ps_code), &render_target->clear_ps)))
- {
- WARN("Failed to create clear pixel shader, hr %#x.\n", hr);
- goto err;
- }
-
rs_desc.FillMode = D3D10_FILL_SOLID;
rs_desc.CullMode = D3D10_CULL_BACK;
rs_desc.FrontCounterClockwise = FALSE;
@@ -1193,12 +1279,34 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
rs_desc.ScissorEnable = TRUE;
rs_desc.MultisampleEnable = FALSE;
rs_desc.AntialiasedLineEnable = FALSE;
- if (FAILED(hr = ID3D10Device_CreateRasterizerState(render_target->device, &rs_desc, &render_target->clear_rs)))
+ if (FAILED(hr = ID3D10Device_CreateRasterizerState(render_target->device, &rs_desc, &render_target->rs)))
{
WARN("Failed to create clear rasterizer state, hr %#x.\n", hr);
goto err;
}
+ memset(&blend_desc, 0, sizeof(blend_desc));
+ blend_desc.BlendEnable[0] = TRUE;
+ blend_desc.SrcBlend = D3D10_BLEND_SRC_ALPHA;
+ blend_desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA;
+ blend_desc.BlendOp = D3D10_BLEND_OP_ADD;
+ blend_desc.SrcBlendAlpha = D3D10_BLEND_ZERO;
+ blend_desc.DestBlendAlpha = D3D10_BLEND_ONE;
+ blend_desc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
+ blend_desc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;
+ if (FAILED(hr = ID3D10Device_CreateBlendState(render_target->device, &blend_desc, &render_target->bs)))
+ {
+ WARN("Failed to create blend state, hr %#x.\n", hr);
+ goto err;
+ }
+
+ if (FAILED(hr = ID3D10Device_CreatePixelShader(render_target->device,
+ rect_solid_ps_code, sizeof(rect_solid_ps_code), &render_target->rect_solid_ps)))
+ {
+ WARN("Failed to create clear pixel shader, hr %#x.\n", hr);
+ goto err;
+ }
+
if (FAILED(hr = IDXGISurface_GetDesc(surface, &surface_desc)))
{
WARN("Failed to get surface desc, hr %#x.\n", hr);
@@ -1228,20 +1336,22 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
return S_OK;
err:
- if (render_target->view)
- ID3D10RenderTargetView_Release(render_target->view);
- if (render_target->clear_rs)
- ID3D10RasterizerState_Release(render_target->clear_rs);
- if (render_target->clear_ps)
- ID3D10PixelShader_Release(render_target->clear_ps);
- if (render_target->clear_vs)
- ID3D10VertexShader_Release(render_target->clear_vs);
- if (render_target->clear_vb)
- ID3D10Buffer_Release(render_target->clear_vb);
- if (render_target->clear_il)
- ID3D10InputLayout_Release(render_target->clear_il);
+ if (render_target->rect_solid_ps)
+ ID3D10PixelShader_Release(render_target->rect_solid_ps);
+ if (render_target->bs)
+ ID3D10BlendState_Release(render_target->bs);
+ if (render_target->rs)
+ ID3D10RasterizerState_Release(render_target->rs);
+ if (render_target->vs)
+ ID3D10VertexShader_Release(render_target->vs);
+ if (render_target->vb)
+ ID3D10Buffer_Release(render_target->vb);
+ if (render_target->il)
+ ID3D10InputLayout_Release(render_target->il);
if (render_target->stateblock)
render_target->stateblock->lpVtbl->Release(render_target->stateblock);
+ if (render_target->view)
+ ID3D10RenderTargetView_Release(render_target->view);
if (render_target->device)
ID3D10Device_Release(render_target->device);
return hr;
--
1.7.10.4
From hverbeet at codeweavers.com Thu Nov 6 01:20:16 2014
From: hverbeet at codeweavers.com (Henri Verbeet)
Date: Thu, 6 Nov 2014 08:20:16 +0100
Subject: [PATCH 4/5] d2d1: Implement d2d_solid_color_brush_GetColor().
Message-ID: <1415258417-14414-4-git-send-email-hverbeet@codeweavers.com>
---
dlls/d2d1/brush.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c
index 04b273a..eacbebb 100644
--- a/dlls/d2d1/brush.c
+++ b/dlls/d2d1/brush.c
@@ -252,11 +252,11 @@ static void STDMETHODCALLTYPE d2d_solid_color_brush_SetColor(ID2D1SolidColorBrus
static D2D1_COLOR_F * STDMETHODCALLTYPE d2d_solid_color_brush_GetColor(ID2D1SolidColorBrush *iface, D2D1_COLOR_F *color)
{
- static const D2D1_COLOR_F black = {0.0f, 0.0f, 0.0f, 1.0f};
+ struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
- FIXME("iface %p, color %p stub!\n", iface, color);
+ TRACE("iface %p, color %p.\n", iface, color);
- *color = black;
+ *color = brush->u.solid.color;
return color;
}
--
1.7.10.4
From hverbeet at codeweavers.com Thu Nov 6 01:20:17 2014
From: hverbeet at codeweavers.com (Henri Verbeet)
Date: Thu, 6 Nov 2014 08:20:17 +0100
Subject: [PATCH 5/5] d2d1: Implement d2d_solid_color_brush_SetOpacity().
Message-ID: <1415258417-14414-5-git-send-email-hverbeet@codeweavers.com>
---
dlls/d2d1/brush.c | 7 ++++++-
dlls/d2d1/d2d1_private.h | 2 ++
dlls/d2d1/render_target.c | 11 +++++++++--
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c
index eacbebb..8837cee 100644
--- a/dlls/d2d1/brush.c
+++ b/dlls/d2d1/brush.c
@@ -149,6 +149,7 @@ static void d2d_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *render_ta
{
brush->ID2D1Brush_iface.lpVtbl = vtbl;
brush->refcount = 1;
+ brush->opacity = desc ? desc->opacity : 1.0f;
brush->type = type;
}
@@ -210,7 +211,11 @@ static void STDMETHODCALLTYPE d2d_solid_color_brush_GetFactory(ID2D1SolidColorBr
static void STDMETHODCALLTYPE d2d_solid_color_brush_SetOpacity(ID2D1SolidColorBrush *iface, float opacity)
{
- FIXME("iface %p, opacity %.8e stub!\n", iface, opacity);
+ struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
+
+ TRACE("iface %p, opacity %.8e.\n", iface, opacity);
+
+ brush->opacity = opacity;
}
static void STDMETHODCALLTYPE d2d_solid_color_brush_SetTransform(ID2D1SolidColorBrush *iface,
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index 0a99633..8504e68 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -107,6 +107,8 @@ struct d2d_brush
ID2D1Brush ID2D1Brush_iface;
LONG refcount;
+ float opacity;
+
enum d2d_brush_type type;
union
{
diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c
index 1dd5122..0f5907f 100644
--- a/dlls/d2d1/render_target.c
+++ b/dlls/d2d1/render_target.c
@@ -501,6 +501,7 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_FillRectangle(ID2D1RenderTar
D3D10_SUBRESOURCE_DATA buffer_data;
D3D10_BUFFER_DESC buffer_desc;
ID3D10Buffer *vs_cb, *ps_cb;
+ D2D1_COLOR_F color;
float tmp_x, tmp_y;
HRESULT hr;
struct
@@ -558,8 +559,14 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_FillRectangle(ID2D1RenderTar
return;
}
- buffer_desc.ByteWidth = sizeof(brush_impl->u.solid.color);
- buffer_data.pSysMem = &brush_impl->u.solid.color;
+ color = brush_impl->u.solid.color;
+ color.r *= brush_impl->opacity;
+ color.g *= brush_impl->opacity;
+ color.b *= brush_impl->opacity;
+ color.a *= brush_impl->opacity;
+
+ buffer_desc.ByteWidth = sizeof(color);
+ buffer_data.pSysMem = &color;
if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->device, &buffer_desc, &buffer_data, &ps_cb)))
{
--
1.7.10.4
From sebastian at fds-team.de Thu Nov 6 01:34:27 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Thu, 06 Nov 2014 08:34:27 +0100
Subject: user32/tests: Add tests for MsgWaitForMultipleObjectsEx.
Message-ID: <545B2483.6070002@fds-team.de>
Shows that MsgWaitForMultipleObjectsEx is working correctly, and only CoWaitForMultipleHandles suffers from bug 32568 (should prefer APC calls over window messages).
Test failures on w7u and w8 are also present with a noop patch:
http://newtestbot.winehq.org/JobDetails.pl?Key=10052
---
dlls/user32/tests/msg.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-user32-tests-Add-tests-for-MsgWaitForMultipleObjects.patch
Type: text/x-patch
Size: 2752 bytes
Desc: not available
URL:
From jnvsor at gmail.com Thu Nov 6 02:13:11 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 09:13:11 +0100
Subject: [PATCH] reg/tests: Test for empty type and empty binary input
Message-ID: <1415261591-1849-1-git-send-email-jnvsor@gmail.com>
---
programs/reg/tests/reg.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 9449429..240a795 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -108,6 +108,11 @@ static void test_add(void)
err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
ok(err == ERROR_SUCCESS, "key creation failed, got %d\n", err);
+ /* Test empty type */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\" /d WineTest /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
+ verify_reg(hkey, "emptyType", REG_SZ, "WineTest", 9, 0);
+
/* Test input key formats */
run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
@@ -225,6 +230,10 @@ static void test_add(void)
todo_wine ok(memcmp(buffer, buffer+12, 6) == 0 ||
broken(memcmp(buffer+6, buffer+12, 6) == 0 /* WinXP */), "got wrong data\n");
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin5 /d \"\" /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
+ verify_reg(hkey, "bin5", REG_BINARY, buffer, 0, 0);
+
/* REG_DWORD */
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /f /d 12345678", &r);
ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 04:07:26 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 11:07:26 +0100
Subject: [fixed] reg/tests: Test for empty type and empty binary input
Message-ID: <1415268446-9442-1-git-send-email-jnvsor@gmail.com>
---
programs/reg/tests/reg.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 9449429..81394c0 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -108,6 +108,15 @@ static void test_add(void)
err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
ok(err == ERROR_SUCCESS, "key creation failed, got %d\n", err);
+ /* Test empty type */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\" /d WineTest /f", &r);
+ todo_wine ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
+ "got exit code %u\n", r);
+ if (r == REG_EXIT_SUCCESS)
+ todo_wine verify_reg(hkey, "emptyType", REG_SZ, "", 1, 0);
+ else
+ todo_wine win_skip("broken reg.exe detected\n");
+
/* Test input key formats */
run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
@@ -225,6 +234,10 @@ static void test_add(void)
todo_wine ok(memcmp(buffer, buffer+12, 6) == 0 ||
broken(memcmp(buffer+6, buffer+12, 6) == 0 /* WinXP */), "got wrong data\n");
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin5 /d \"\" /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
+ verify_reg(hkey, "bin5", REG_BINARY, buffer, 0, 0);
+
/* REG_DWORD */
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /f /d 12345678", &r);
ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
--
2.1.1
From sebastian at fds-team.de Thu Nov 6 04:30:40 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Thu, 06 Nov 2014 11:30:40 +0100
Subject: usp10: Silence repeated GSUB_apply_ChainContext[Subst|Pos] FIXMEs.
Message-ID: <545B4DD0.3000305@fds-team.de>
A lot of installers are spamming those FIXMEs.
---
dlls/usp10/opentype.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-usp10-Silence-repeated-GSUB_apply_ChainContext-Subst.patch
Type: text/x-patch
Size: 2226 bytes
Desc: not available
URL:
From jacek at codeweavers.com Thu Nov 6 04:42:45 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Thu, 06 Nov 2014 11:42:45 +0100
Subject: mshtml: Added IHTMLTable:cellPadding property implementation.
Message-ID: <545B50A5.4070601@codeweavers.com>
---
dlls/mshtml/htmltable.c | 30 ++++++++++++++++++++++++++----
dlls/mshtml/mshtml_private.h | 7 +++++++
dlls/mshtml/tests/dom.c | 39 ++++++++++++++++++++++++++++++++++++++-
3 files changed, 71 insertions(+), 5 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Added-IHTMLTable-cellPadding-property-implemen.diff
Type: text/x-patch
Size: 4682 bytes
Desc: not available
URL:
From jacek at codeweavers.com Thu Nov 6 05:09:54 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Thu, 06 Nov 2014 12:09:54 +0100
Subject: mshtml: Added IHTMLScriptElement:onerror property semi-stub
implementation.
Message-ID: <545B5702.6040707@codeweavers.com>
---
dlls/mshtml/htmlscript.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Added-IHTMLScriptElement-onerror-property-semi.diff
Type: text/x-patch
Size: 1066 bytes
Desc: not available
URL:
From jacek at codeweavers.com Thu Nov 6 05:21:47 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Thu, 06 Nov 2014 12:21:47 +0100
Subject: [PATCH try2] mshtml: Added IHTMLScriptElement:onerror property
semi-stub implementation.
Message-ID: <545B59CB.1080201@codeweavers.com>
---
dlls/mshtml/htmlscript.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Added-IHTMLScriptElement-onerror-property-semi.diff
Type: text/x-patch
Size: 1228 bytes
Desc: not available
URL:
From huw at codeweavers.com Thu Nov 6 09:55:39 2014
From: huw at codeweavers.com (Huw Davies)
Date: Thu, 6 Nov 2014 15:55:39 +0000
Subject: mlang: Accept "ascii" as an alias for "us-ascii".
Message-ID: <1415289339-9166-1-git-send-email-huw@codeweavers.com>
---
dlls/mlang/mlang.c | 13 ++++++++++++-
dlls/mlang/tests/mlang.c | 12 ++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/dlls/mlang/mlang.c b/dlls/mlang/mlang.c
index e44e862..8a4e78f 100644
--- a/dlls/mlang/mlang.c
+++ b/dlls/mlang/mlang.c
@@ -65,6 +65,7 @@ typedef struct
const char *web_charset;
const char *header_charset;
const char *body_charset;
+ const WCHAR *alias;
} MIME_CP_INFO;
/* These data are based on the codepage info in libs/unicode/cpmap.pl */
@@ -363,6 +364,9 @@ static const MIME_CP_INFO vietnamese_cp[] =
MIMECONTF_MIME_LATEST,
"windows-1258", "windows-1258", "windows-1258" }
};
+
+static const WCHAR asciiW[] = {'a','s','c','i','i',0};
+
static const MIME_CP_INFO western_cp[] =
{
{ "IBM EBCDIC (US-Canada)",
@@ -415,7 +419,7 @@ static const MIME_CP_INFO western_cp[] =
20127, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT | MIMECONTF_EXPORT |
MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_VALID |
MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
- "us-ascii", "us-ascii", "us-ascii" },
+ "us-ascii", "us-ascii", "us-ascii", asciiW },
{ "Western European (ISO)",
28591, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
@@ -2600,6 +2604,13 @@ static HRESULT WINAPI fnIMultiLanguage3_GetCharsetInfo(
strcpyW(pCharsetInfo->wszCharset, csetW);
return S_OK;
}
+ if (mlang_data[i].mime_cp_info[n].alias && !lstrcmpiW(Charset, mlang_data[i].mime_cp_info[n].alias))
+ {
+ pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
+ pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
+ strcpyW(pCharsetInfo->wszCharset, mlang_data[i].mime_cp_info[n].alias);
+ return S_OK;
+ }
}
}
diff --git a/dlls/mlang/tests/mlang.c b/dlls/mlang/tests/mlang.c
index 1d52af6..a840b4a 100644
--- a/dlls/mlang/tests/mlang.c
+++ b/dlls/mlang/tests/mlang.c
@@ -696,6 +696,17 @@ static void test_EnumCodePages(IMultiLanguage2 *iML2, DWORD flags)
IEnumCodePage_Release(iEnumCP);
}
+static void test_GetCharsetInfo_alias(IMultiLanguage *ml)
+{
+ WCHAR asciiW[] = {'a','s','c','i','i',0};
+ MIMECSETINFO info;
+ HRESULT hr;
+
+ hr = IMultiLanguage_GetCharsetInfo(ml, asciiW, &info);
+ ok(hr == S_OK, "got %08x\n", hr);
+ ok(!lstrcmpW(info.wszCharset, asciiW), "got %s\n", wine_dbgstr_w(info.wszCharset));
+}
+
static void scriptinfo_cmp(SCRIPTINFO *sinfo1, SCRIPTINFO *sinfo2)
{
ok(sinfo1->ScriptId == sinfo2->ScriptId, "ScriptId mismatch: %d != %d\n", sinfo1->ScriptId, sinfo2->ScriptId);
@@ -2000,6 +2011,7 @@ START_TEST(mlang)
test_GetNumberOfCodePageInfo((IMultiLanguage2 *)iML);
test_IMLangConvertCharset(iML);
+ test_GetCharsetInfo_alias(iML);
IMultiLanguage_Release(iML);
--
1.8.0
From madewokherd at gmail.com Thu Nov 6 11:40:39 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Thu, 6 Nov 2014 11:40:39 -0600
Subject: windowscodecs: Fix race condition loading libpng.
Message-ID:
-------------- next part --------------
From 715e26aa786028f9b78e00755c4fbb7e801397f9 Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Thu, 6 Nov 2014 11:37:46 -0600
Subject: [PATCH] windowscodecs: Fix race condition loading libpng.
---
dlls/windowscodecs/pngformat.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
index a8ecb73..b3e6cc6 100644
--- a/dlls/windowscodecs/pngformat.c
+++ b/dlls/windowscodecs/pngformat.c
@@ -200,13 +200,28 @@ MAKE_FUNCPTR(png_write_info);
MAKE_FUNCPTR(png_write_rows);
#undef MAKE_FUNCPTR
+static CRITICAL_SECTION init_png_cs;
+static CRITICAL_SECTION_DEBUG init_png_cs_debug =
+{
+ 0, 0, &init_png_cs,
+ { &init_png_cs_debug.ProcessLocksList,
+ &init_png_cs_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": init_png_cs") }
+};
+static CRITICAL_SECTION init_png_cs = { &init_png_cs_debug, -1, 0, 0, 0, 0 };
+
static void *load_libpng(void)
{
- if((libpng_handle = wine_dlopen(SONAME_LIBPNG, RTLD_NOW, NULL, 0)) != NULL) {
+ void *result;
+
+ EnterCriticalSection(&init_png_cs);
+
+ if(!libpng_handle && (libpng_handle = wine_dlopen(SONAME_LIBPNG, RTLD_NOW, NULL, 0)) != NULL) {
#define LOAD_FUNCPTR(f) \
if((p##f = wine_dlsym(libpng_handle, #f, NULL, 0)) == NULL) { \
libpng_handle = NULL; \
+ LeaveCriticalSection(&init_png_cs); \
return NULL; \
}
LOAD_FUNCPTR(png_create_read_struct);
@@ -251,7 +266,12 @@ static void *load_libpng(void)
#undef LOAD_FUNCPTR
}
- return libpng_handle;
+
+ result = libpng_handle;
+
+ LeaveCriticalSection(&init_png_cs);
+
+ return result;
}
static void user_error_fn(png_structp png_ptr, png_const_charp error_message)
@@ -997,7 +1017,7 @@ HRESULT PngDecoder_CreateInstance(REFIID iid, void** ppv)
*ppv = NULL;
- if (!libpng_handle && !load_libpng())
+ if (!load_libpng())
{
ERR("Failed reading PNG because unable to find %s\n",SONAME_LIBPNG);
return E_FAIL;
@@ -1726,7 +1746,7 @@ HRESULT PngEncoder_CreateInstance(REFIID iid, void** ppv)
*ppv = NULL;
- if (!libpng_handle && !load_libpng())
+ if (!load_libpng())
{
ERR("Failed writing PNG because unable to find %s\n",SONAME_LIBPNG);
return E_FAIL;
--
2.1.0
From jnvsor at gmail.com Thu Nov 6 12:03:53 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 19:03:53 +0100
Subject: [PATCH 1/3] advapi32/tests: Add trailing slashes tests for
RegOpen/CreateKey
Message-ID: <1415297035-6992-1-git-send-email-jnvsor@gmail.com>
---
dlls/advapi32/tests/registry.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 382d8cc..3aff541 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -953,6 +953,11 @@ static void test_reg_open_key(void)
ok(hkResult != NULL, "hkResult != NULL\n");
RegCloseKey(hkResult);
+ /* trailing slashes */
+ ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test\\\\", &hkResult);
+ ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
+ RegCloseKey(hkResult);
+
/* open nonexistent key
* check that hkResult is set to NULL
*/
@@ -1218,6 +1223,12 @@ static void test_reg_create_key(void)
RegCloseKey(hkey1);
}
+ /* trailing backslash characters */
+ ret = RegCreateKeyExA(hkey_main, "Subkey4\\\\", 0, NULL, 0, KEY_NOTIFY, NULL, &hkey1, NULL);
+ ok(ret == ERROR_SUCCESS, "RegCreateKeyExA failed with error %d\n", ret);
+ RegDeleteKeyA(hkey1, "");
+ RegCloseKey(hkey1);
+
/* WOW64 flags - open an existing key */
hkey1 = NULL;
ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0, KEY_READ|KEY_WOW64_32KEY, NULL, &hkey1, NULL);
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 12:03:55 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 19:03:55 +0100
Subject: [PATCH 3/3] advapi32/tests: Test RegDeleteKey with empty string
parameter
In-Reply-To: <1415297035-6992-1-git-send-email-jnvsor@gmail.com>
References: <1415297035-6992-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415297035-6992-3-git-send-email-jnvsor@gmail.com>
---
dlls/advapi32/tests/registry.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 23eafab..4f311cd 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -1372,6 +1372,7 @@ static void test_reg_close_key(void)
static void test_reg_delete_key(void)
{
DWORD ret;
+ HKEY key;
ret = RegDeleteKeyA(hkey_main, NULL);
@@ -1390,6 +1391,11 @@ static void test_reg_delete_key(void)
ret == ERROR_ACCESS_DENIED ||
ret == ERROR_BADKEY, /* Win95 */
"ret=%d\n", ret);
+
+ ret = RegCreateKeyExA(hkey_main, "deleteme", 0, NULL, 0, NULL, NULL, &key, NULL);
+ ret = RegDeleteKeyA(key, "");
+ ok(ret == ERROR_SUCCESS, "RegDeleteKeyA failed, got %d\n", ret);
+ RegCloseKey(key);
}
static void test_reg_save_key(void)
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 12:03:54 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 19:03:54 +0100
Subject: [PATCH 2/3] advapi32/tests: Fix bad cleanup in test_reg_create_key
In-Reply-To: <1415297035-6992-1-git-send-email-jnvsor@gmail.com>
References: <1415297035-6992-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415297035-6992-2-git-send-email-jnvsor@gmail.com>
---
dlls/advapi32/tests/registry.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 3aff541..23eafab 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -1219,7 +1219,7 @@ static void test_reg_create_key(void)
ok(ret == ERROR_BAD_PATHNAME, "expected ERROR_BAD_PATHNAME, got %d\n", ret);
else {
ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
- RegDeleteKeyA(hkey1, NULL);
+ RegDeleteKeyA(hkey1, "");
RegCloseKey(hkey1);
}
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 12:18:23 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 19:18:23 +0100
Subject: [PATCH] advapi32/tests: Test RegDeleteKey with empty string parameter
Message-ID: <1415297903-11758-1-git-send-email-jnvsor@gmail.com>
---
dlls/advapi32/tests/registry.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 23eafab..55a74f6 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -1372,6 +1372,7 @@ static void test_reg_close_key(void)
static void test_reg_delete_key(void)
{
DWORD ret;
+ HKEY key;
ret = RegDeleteKeyA(hkey_main, NULL);
@@ -1390,6 +1391,15 @@ static void test_reg_delete_key(void)
ret == ERROR_ACCESS_DENIED ||
ret == ERROR_BADKEY, /* Win95 */
"ret=%d\n", ret);
+
+ ret = RegCreateKeyA(hkey_main, "deleteme", &key);
+ ok(ret == ERROR_SUCCESS, "Could not create key, got %d\n", ret);
+ ret = RegDeleteKeyA(key, "");
+ ok(ret == ERROR_SUCCESS, "RegDeleteKeyA failed, got %d\n", ret);
+ RegCloseKey(key);
+ ret = RegOpenKeyA(hkey_main, "deleteme", &key);
+ ok(ret == ERROR_FILE_NOT_FOUND, "Key was not deleted, got %d\n", ret);
+ RegCloseKey(key);
}
static void test_reg_save_key(void)
--
2.1.1
From joachim.priesner at web.de Thu Nov 6 13:04:39 2014
From: joachim.priesner at web.de (Joachim Priesner)
Date: Thu, 6 Nov 2014 20:04:39 +0100
Subject: [1/2] wined3d: Set D3DPMISCCAPS_FOGVERTEXCLAMPED flag in
get_device_caps (resend)
Message-ID: <201411062004.42071.joachim.priesner@web.de>
Wine clamps the oFog output of vertex shaders. Tests for the flag follow
in the second part of this patch.
---
dlls/wined3d/directx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index d428d94..41bad21 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -4148,12 +4148,12 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
WINED3DPMISCCAPS_MASKZ |
WINED3DPMISCCAPS_BLENDOP |
+ WINED3DPMISCCAPS_FOGVERTEXCLAMPED |
WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
/* TODO:
WINED3DPMISCCAPS_NULLREFERENCE
WINED3DPMISCCAPS_FOGANDSPECULARALPHA
- WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
- WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
+ WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS */
if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
--
1.8.4.5
From joachim.priesner at web.de Thu Nov 6 13:04:44 2014
From: joachim.priesner at web.de (Joachim Priesner)
Date: Thu, 6 Nov 2014 20:04:44 +0100
Subject: [2/2] wined3d: Take abs() of vertex z coordinate as FFP fog
coordinate (try 4)
Message-ID: <201411062004.45710.joachim.priesner@web.de>
Take the absolute value of vertex.z as fog coordinate instead of just
the z coordinate. This fixes e.g. fog for applications that use
right-handed projection matrices.
Also test the clamp behavior of the oFog vertex shader output.
Tested on openSuse 13.1 and Windows 8.1 (VMware Player).
Try 4 which hard-codes the projection matrix in the vertex shaders.
---
dlls/d3d8/tests/visual.c | 297 +++++++++++++++++++++++++++++++++++++
dlls/d3d9/tests/visual.c | 360 +++++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 161 ++++++++++++++++++++
dlls/wined3d/glsl_shader.c | 2 +-
4 files changed, 819 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index 163110c..af61005 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -696,6 +696,302 @@ done:
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void fog_negative_z_test(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000,
+ C_CLAMPED_FOG = 0xdeadbeef /* triggers special codepath when used as middle_color */
+ };
+
+ /* Fill the null-shader entry with the FVF (SetVertexShader is "overloaded" on d3d8). */
+ DWORD vertex_shader[3] = {D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, 0, 0};
+ DWORD pixel_shader[2] = {0, 0};
+ IDirect3D8 *d3d;
+ IDirect3DDevice8 *device;
+ BOOL has_vs_support, has_ps_support, has_table_fog_support;
+ unsigned int i, ps, y;
+ D3DCOLOR color, expected_middle_color;
+ ULONG refcount;
+ D3DCAPS8 caps;
+ HWND window;
+ HRESULT hr;
+
+ /* Basic vertex shader without fog computation ("non foggy") */
+ static const DWORD vertex_shader_code1[] =
+ {
+ 0xfffe0100, /* vs_1_0 */
+ 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x0000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"). Outputs the z coordinate of the vertex
+ * as its fog intensity value. */
+ static const DWORD vertex_shader_code2[] =
+ {
+ 0xfffe0100, /* vs_1_0 */
+ 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x0000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x00000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic pixel shader */
+ static const DWORD pixel_shader_code[] =
+ {
+ 0xffff0101, /* ps_1_1 */
+ 0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
+ 0x0000ffff
+ };
+
+ static const struct
+ {
+ struct vec3 position;
+ DWORD diffuse;
+ DWORD specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+ static const DWORD vertex_decl[] =
+ {
+ D3DVSD_STREAM(0),
+ D3DVSD_REG(0, D3DVSDT_FLOAT3), /* position, v0 */
+ D3DVSD_REG(1, D3DVSDT_D3DCOLOR), /* diffuse color, v1 */
+ D3DVSD_REG(2, D3DVSDT_D3DCOLOR), /* specular color, v2 */
+ D3DVSD_END()
+ };
+ static const struct
+ {
+ int vshader;
+ D3DFOGMODE vfog;
+ D3DFOGMODE tfog;
+ DWORD color_left;
+ DWORD color_middle_top;
+ DWORD color_middle_bottom;
+ DWORD color_right;
+ }
+ test_data[] =
+ {
+ /* Using z-based fog, the bottom quad should have a gradient UNFOGGED->FOGGED
+ * for table fog, and be completely fogged for vertex fog.
+ * When the fog coordinate returned by the vertex shader is used instead,
+ * the result is a gradient FOGGED->UNFOGGED. */
+
+ /* No vertex shader */
+ {0, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {0, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader without vertex fog computation */
+ {1, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader with vertex fog computation.
+ * As drivers inconsistently clamp or don't clamp the oFog output of vertex shaders,
+ * the special value C_CLAMPED_FOG allows both C_HALF_FOGGED (clamped) and C_FOGGED. */
+ {2, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {2, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1.
+ * Note that for the tests with vertex shaders, this matrix is hard-coded in the shaders. */
+ static const D3DMATRIX proj_mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f
+ }}};
+
+ window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate8(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps (%#x)\n", hr);
+
+ has_table_fog_support = caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests\n");
+
+ has_ps_support = caps.PixelShaderVersion >= D3DPS_VERSION(1, 1);
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice8_CreatePixelShader(device, pixel_shader_code, &pixel_shader[1]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No ps_1_1 support, skipping some fog tests\n");
+ }
+
+ has_vs_support = caps.VertexShaderVersion >= D3DVS_VERSION(1, 0);
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice8_CreateVertexShader(device, vertex_decl, vertex_shader_code1, &vertex_shader[1], 0);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_CreateVertexShader(device, vertex_decl, vertex_shader_code2, &vertex_shader[2], 0);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No vs_1_0 support, skipping some fog tests\n");
+ }
+
+ /* Setup initial states: No depth test, no lighting, fog on, fog color */
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Turning off depth test failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Turning off lighting failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Turning on fog calculations failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Setting fog color failed (%#x)\n", hr);
+
+ hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform (%#x)\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].vshader != 0 && !vertex_shader[test_data[i].vshader])
+ continue;
+ if (test_data[i].tfog != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ hr = IDirect3DDevice8_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
+ ok(SUCCEEDED(hr), "SetVertexShader failed (%#x)\n", hr);
+
+ for (ps = 0; ps < sizeof(pixel_shader)/sizeof(pixel_shader[0]); ps++)
+ {
+ if (ps != 0 && !pixel_shader[ps])
+ continue;
+
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice8_SetPixelShader(device, pixel_shader[ps]);
+ ok(SUCCEEDED(hr), "SetPixelShader failed (%#x)\n", hr);
+ }
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, test_data[i].vfog);
+ ok(SUCCEEDED(hr), "Setting fog vertex mode to %d failed (%#x)\n", test_data[i].vfog, hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, test_data[i].tfog);
+ ok(SUCCEEDED(hr), "Setting fog table mode to %d failed (%#x)\n", test_data[i].tfog, hr);
+
+ hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Clear failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_BeginScene(device);
+ ok(SUCCEEDED(hr), "BeginScene failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &top_quad[0], sizeof(top_quad[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_1[0], sizeof(bottom_quad_1[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_2[0], sizeof(bottom_quad_2[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_EndScene(device);
+ ok(SUCCEEDED(hr), "EndScene failed (%#x)\n", hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = getPixelColor(device, 2, y);
+ ok(color_match(color, test_data[i].color_left, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got left color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_left);
+ color = getPixelColor(device, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ if (expected_middle_color == C_CLAMPED_FOG)
+ {
+ ok(color_match(color, C_HALF_FOGGED, 13) || color_match(color, C_FOGGED, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got middle color %08x, "
+ "expected %08x+-5%% or %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, C_HALF_FOGGED, C_FOGGED);
+ }
+ else
+ {
+ ok(color_match(color, expected_middle_color, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got middle color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, expected_middle_color);
+ }
+ color = getPixelColor(device, 638, y);
+ ok(color_match(color, test_data[i].color_right, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got right color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_right);
+ }
+
+ hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Present failed (%#x)\n", hr);
+ }
+ }
+ for (i = 0; i < sizeof(vertex_shader)/sizeof(vertex_shader[0]); i++)
+ if (vertex_shader[i])
+ IDirect3DDevice8_DeleteVertexShader(device, vertex_shader[i]);
+ for (i = 0; i < sizeof(pixel_shader)/sizeof(pixel_shader[0]); i++)
+ if (pixel_shader[i])
+ IDirect3DDevice8_DeletePixelShader(device, pixel_shader[i]);
+ refcount = IDirect3DDevice8_Release(device);
+ ok(!refcount, "Device has %u references left\n", refcount);
+done:
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+}
+
/* This tests fog in combination with shaders.
* What's tested: linear fog (vertex and table) with pixel shader
* linear table fog with non foggy vertex shader
@@ -5092,6 +5388,7 @@ START_TEST(visual)
offscreen_test();
alpha_test();
test_scalar_instructions();
+ fog_negative_z_test();
fog_with_shader_test();
cnd_test();
p8_texture_test();
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 117c8eb..28ecff7 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -1825,6 +1825,365 @@ done:
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void fog_negative_z_test(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000,
+ C_CLAMPED_FOG = 0xdeadbeef /* triggers special codepath when used as middle_color */
+ };
+
+ IDirect3DVertexShader9 *vertex_shader[4] = {NULL, NULL, NULL, NULL};
+ IDirect3DPixelShader9 *pixel_shader[3] = {NULL, NULL, NULL};
+ IDirect3DVertexDeclaration9 *vertex_declaration = NULL;
+ IDirect3DDevice9 *device;
+ BOOL has_vs_support, has_ps_support, has_table_fog_support, is_fog_vertex_clamped;
+ unsigned int i, ps, y;
+ IDirect3D9 *d3d;
+ ULONG refcount;
+ D3DCAPS9 caps;
+ DWORD color, expected_middle_color;
+ HWND window;
+ HRESULT hr;
+
+ /* Basic vertex shader without fog computation ("non foggy") */
+ static const DWORD vertex_shader_code1[] =
+ {
+ 0xfffe0101, /* vs_1_1 */
+ 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x0000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0000001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"). Outputs the z coordinate of the vertex
+ * as its fog intensity value. */
+ static const DWORD vertex_shader_code2[] =
+ {
+ 0xfffe0101, /* vs_1_1 */
+ 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x0000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0000001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x00000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"), vs_2_0 */
+ static const DWORD vertex_shader_code3[] =
+ {
+ 0xfffe0200, /* vs_2_0 */
+ 0x05000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x0000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0200001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x03000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x03000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x02000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x02000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x02000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic pixel shader */
+ static const DWORD pixel_shader_code[] =
+ {
+ 0xffff0101, /* ps_1_1 */
+ 0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
+ 0x0000ffff
+ };
+ static const DWORD pixel_shader_code2[] =
+ {
+ 0xffff0200, /* ps_2_0 */
+ 0x0200001f, 0x80000000, 0x900f0000, /* dcl v0 */
+ 0x02000001, 0x800f0800, 0x90e40000, /* mov oC0, v0 */
+ 0x0000ffff
+ };
+ static const struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+
+ static const D3DVERTEXELEMENT9 decl_elements[] =
+ {
+ {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
+ {0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, /* diffuse */
+ {0, 16, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, /* specular */
+ D3DDECL_END()
+ };
+ static const struct
+ {
+ int vshader;
+ D3DFOGMODE vfog;
+ D3DFOGMODE tfog;
+ DWORD color_left;
+ DWORD color_middle_top;
+ DWORD color_middle_bottom;
+ DWORD color_right;
+ }
+ test_data[] =
+ {
+ /* Using z-based fog, the bottom quad should have a gradient UNFOGGED->FOGGED
+ * for table fog, and be completely fogged for vertex fog.
+ * When the fog coordinate returned by the vertex shader is used instead,
+ * the result is a gradient FOGGED->UNFOGGED in the right half of the screen.
+ *
+ * C_CLAMPED_FOG will be replaced by the correct expected value based on
+ * the value of D3DPMISCCAPS_FOGVERTEXCLAMPED. If the driver clamps the oFog
+ * output of vertex shaders, it should be C_HALF_FOGGED, else C_FOGGED. */
+
+ /* No vertex shader */
+ {0, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {0, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader without vertex fog computation */
+ {1, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader vs_1_1 with vertex fog computation */
+ {2, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {2, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+
+ /* Vertex shader vs_2_0 with vertex fog computation */
+ {3, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {3, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {3, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {3, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1.
+ * Note that for the tests with vertex shaders, this matrix is hard-coded in the shaders. */
+ static const D3DMATRIX proj_mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f,
+ }}};
+
+ window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate9(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps (%#x)\n", hr);
+
+ has_table_fog_support = caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests\n");
+
+ has_vs_support = caps.VertexShaderVersion >= D3DVS_VERSION(1, 1);
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code1, &vertex_shader[1]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code2, &vertex_shader[2]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+
+ if (caps.VertexShaderVersion >= D3DVS_VERSION(2, 0))
+ {
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code3, &vertex_shader[3]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No vs_2_0 support, skipping some fog tests\n");
+ }
+ }
+ else
+ {
+ skip("No vs_1_1 support, skipping some fog tests\n");
+ }
+
+ has_ps_support = caps.PixelShaderVersion >= D3DPS_VERSION(1, 1);
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code, &pixel_shader[1]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+
+ if (caps.PixelShaderVersion >= D3DPS_VERSION(2, 0))
+ {
+ hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code2, &pixel_shader[2]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No ps_2_0 support, skipping some fog tests\n");
+ }
+ }
+ else
+ {
+ skip("No ps_1_1 support, skipping some fog tests\n");
+ }
+
+ is_fog_vertex_clamped = caps.PrimitiveMiscCaps & D3DPMISCCAPS_FOGVERTEXCLAMPED;
+
+ hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
+ ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%#x)\n", hr);
+
+ /* Setup initial states: No depth test, no lighting, fog on, fog color */
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Turning off depth test failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Turning off lighting failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Turning on fog calculations failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Setting fog color failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
+ ok(SUCCEEDED(hr), "SetVertexDeclaration failed (%#x)\n", hr);
+
+ hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform (%#x)\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].vshader != 0 && !vertex_shader[test_data[i].vshader])
+ continue;
+ if (test_data[i].tfog != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice9_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
+ ok(SUCCEEDED(hr), "SetVertexShader failed (%#x)\n", hr);
+ }
+
+ for (ps = 0; ps < sizeof(pixel_shader)/sizeof(pixel_shader[0]); ps++)
+ {
+ if (ps != 0 && !pixel_shader[ps])
+ continue;
+
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice9_SetPixelShader(device, pixel_shader[ps]);
+ ok(SUCCEEDED(hr), "SetPixelShader failed (%#x)\n", hr);
+ }
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, test_data[i].vfog);
+ ok(SUCCEEDED(hr), "Setting fog vertex mode to %d failed (%#x)\n", test_data[i].vfog, hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, test_data[i].tfog);
+ ok(SUCCEEDED(hr), "Setting fog table mode to %d failed (%#x)\n", test_data[i].tfog, hr);
+
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Clear failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_BeginScene(device);
+ ok(SUCCEEDED(hr), "BeginScene failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &top_quad[0], sizeof(top_quad[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_1[0], sizeof(bottom_quad_1[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_2[0], sizeof(bottom_quad_2[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_EndScene(device);
+ ok(SUCCEEDED(hr), "EndScene failed (%#x)\n", hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = getPixelColor(device, 2, y);
+ ok(color_match(color, test_data[i].color_left, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got left color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_left);
+ color = getPixelColor(device, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ if (expected_middle_color == C_CLAMPED_FOG)
+ {
+ expected_middle_color = is_fog_vertex_clamped ? C_HALF_FOGGED : C_FOGGED;
+ }
+ ok(color_match(color, expected_middle_color, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got middle color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, expected_middle_color);
+ color = getPixelColor(device, 638, y);
+ ok(color_match(color, test_data[i].color_right, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got right color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_right);
+
+ }
+
+ hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Present failed (%#x)\n", hr);
+ }
+ }
+
+ for (i = 0; i < sizeof(vertex_shader)/sizeof(vertex_shader[0]); i++)
+ if (vertex_shader[i])
+ IDirect3DVertexShader9_Release(vertex_shader[i]);
+ for (i = 0; i < sizeof(pixel_shader)/sizeof(pixel_shader[0]); i++)
+ if (pixel_shader[i])
+ IDirect3DPixelShader9_Release(pixel_shader[i]);
+ IDirect3DVertexDeclaration9_Release(vertex_declaration);
+ refcount = IDirect3DDevice9_Release(device);
+ ok(!refcount, "Device has %u references left\n", refcount);
+done:
+ IDirect3D9_Release(d3d);
+ DestroyWindow(window);
+}
+
/* This test tests fog in combination with shaders.
* What's tested: linear fog (vertex and table) with pixel shader
* linear table fog with non foggy vertex shader
@@ -16729,6 +17088,7 @@ START_TEST(visual)
test_vshader_input();
test_vshader_float16();
stream_test();
+ fog_negative_z_test();
fog_with_shader_test();
texbem_test();
texdepth_test();
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index ec50fb8..4e999f7 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -3384,6 +3384,166 @@ static void test_fog_special(void)
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void test_fog_negative_z(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000
+ };
+
+ D3DCOLOR color, expected_middle_color;
+ HRESULT hr;
+ ULONG refcount;
+ BOOL has_table_fog_support;
+ unsigned int i, y;
+ HWND window;
+ IDirect3DDevice7 *device;
+ IDirectDrawSurface7 *rt;
+ D3DDEVICEDESC7 caps;
+
+ static struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+ static const struct
+ {
+ DWORD vertexmode, tablemode;
+ D3DCOLOR color_left, color_middle_top, color_middle_bottom, color_right;
+ }
+ test_data[] =
+ {
+ {D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1. */
+ static D3DMATRIX proj_mat =
+ {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f
+ };
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+
+ if (!(device = create_device(window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create a 3D device, skipping test.\n");
+ DestroyWindow(window);
+ return;
+ }
+
+ memset(&caps, 0, sizeof(caps));
+ hr = IDirect3DDevice7_GetCaps(device, &caps);
+ ok(SUCCEEDED(hr), "IDirect3DDevice7_GetCaps failed, hr %#x.\n", hr);
+
+ has_table_fog_support = caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests.\n");
+
+ hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
+ ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Failed to enable fog, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Failed to set fog color, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].tablemode != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Failed to clear render target, i=%d, hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, test_data[i].vertexmode);
+ ok(SUCCEEDED(hr), "Failed to set fog vertex mode, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, test_data[i].tablemode);
+ ok(SUCCEEDED(hr), "Failed to set fog table mode, i=%d, hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice7_BeginScene(device);
+ ok(SUCCEEDED(hr), "Failed to begin scene, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, top_quad, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, bottom_quad_1, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, bottom_quad_2, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_EndScene(device);
+ ok(SUCCEEDED(hr), "Failed to end scene, i=%d, hr %#x.\n", i, hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = get_surface_color(rt, 2, y);
+ ok(compare_color(color, test_data[i].color_left, 13),
+ "fog fvm%i ftm%i y=%i: got left color %08x, expected %08x+-5%%.\n",
+ test_data[i].vertexmode, test_data[i].tablemode, color, y,
+ test_data[i].color_left);
+ color = get_surface_color(rt, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ ok(compare_color(color, expected_middle_color, 13),
+ "fog fvm%i ftm%i y=%i: got middle color %08x, expected %08x+-5%%.\n",
+ test_data[i].vertexmode, test_data[i].tablemode, y,
+ color, expected_middle_color);
+ color = get_surface_color(rt, 638, y);
+ ok(compare_color(color, test_data[i].color_right, 13),
+ "fog fvm%i ftm%i y=%i: got right color %08x, expected %08x+-5%%.\n",
+ test_data[i].vertexmode, test_data[i].tablemode, y,
+ color, test_data[i].color_right);
+ }
+ }
+
+ IDirectDrawSurface7_Release(rt);
+ refcount = IDirect3DDevice7_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
static void test_lighting_interface_versions(void)
{
IDirect3DDevice7 *device;
@@ -7671,6 +7831,7 @@ START_TEST(ddraw7)
test_clear_rect_count();
test_coop_level_versions();
test_fog_special();
+ test_fog_negative_z();
test_lighting_interface_versions();
test_coop_level_activateapp();
test_texturemanage();
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 7379ba2..907e895 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -5005,7 +5005,7 @@ static GLhandleARB shader_glsl_generate_ffp_vertex_shader(struct wined3d_shader_
/* Need to undo the [0.0 - 1.0] -> [-1.0 - 1.0] transformation from D3D to GL coordinates. */
shader_addline(buffer, "gl_FogFragCoord = gl_Position.z * 0.5 + 0.5;\n");
else
- shader_addline(buffer, "gl_FogFragCoord = ec_pos.z;\n");
+ shader_addline(buffer, "gl_FogFragCoord = abs(ec_pos.z);\n");
break;
default:
--
1.8.4.5
From joachim.priesner at web.de Thu Nov 6 14:51:37 2014
From: joachim.priesner at web.de (Joachim Priesner)
Date: Thu, 6 Nov 2014 21:51:37 +0100
Subject: [1/2] wined3d: Set D3DPMISCCAPS_FOGVERTEXCLAMPED flag in
get_device_caps (resend)
Message-ID: <201411062151.39635.joachim.priesner@web.de>
Wine clamps the oFog output of vertex shaders. Tests for the flag follow
in the second part of this patch.
---
dlls/wined3d/directx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index d428d94..41bad21 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -4148,12 +4148,12 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
WINED3DPMISCCAPS_MASKZ |
WINED3DPMISCCAPS_BLENDOP |
+ WINED3DPMISCCAPS_FOGVERTEXCLAMPED |
WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
/* TODO:
WINED3DPMISCCAPS_NULLREFERENCE
WINED3DPMISCCAPS_FOGANDSPECULARALPHA
- WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
- WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
+ WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS */
if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
--
1.8.4.5
From joachim.priesner at web.de Thu Nov 6 14:51:55 2014
From: joachim.priesner at web.de (Joachim Priesner)
Date: Thu, 6 Nov 2014 21:51:55 +0100
Subject: [2/2] wined3d: Take abs() of vertex z coordinate as FFP fog
coordinate (try 5)
Message-ID: <201411062151.56812.joachim.priesner@web.de>
Take the absolute value of vertex.z as fog coordinate instead of just
the z coordinate. This fixes e.g. fog for applications that use
right-handed projection matrices.
Also test the clamp behavior of the oFog vertex shader output.
Tested on openSuse 13.1 and Windows 8.1 (VMware Player).
Try 5 that fixes a test failure I overlooked.
---
dlls/d3d8/tests/visual.c | 296 +++++++++++++++++++++++++++++++++++++
dlls/d3d9/tests/visual.c | 360 +++++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 161 ++++++++++++++++++++
dlls/wined3d/glsl_shader.c | 2 +-
4 files changed, 818 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index 163110c..a1eabcd 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -696,6 +696,301 @@ done:
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void fog_negative_z_test(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000,
+ C_CLAMPED_FOG = 0xdeadbeef /* triggers special codepath when used as middle_color */
+ };
+
+ /* Fill the null-shader entry with the FVF (SetVertexShader is "overloaded" on d3d8). */
+ DWORD vertex_shader[3] = {D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, 0, 0};
+ DWORD pixel_shader[2] = {0, 0};
+ IDirect3D8 *d3d;
+ IDirect3DDevice8 *device;
+ BOOL has_vs_support, has_ps_support, has_table_fog_support;
+ unsigned int i, ps, y;
+ D3DCOLOR color, expected_middle_color;
+ ULONG refcount;
+ D3DCAPS8 caps;
+ HWND window;
+ HRESULT hr;
+
+ /* Basic vertex shader without fog computation ("non foggy") */
+ static const DWORD vertex_shader_code1[] =
+ {
+ 0xfffe0100, /* vs_1_0 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"). Outputs the z coordinate of the vertex
+ * as its fog intensity value. */
+ static const DWORD vertex_shader_code2[] =
+ {
+ 0xfffe0100, /* vs_1_0 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x00000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic pixel shader */
+ static const DWORD pixel_shader_code[] =
+ {
+ 0xffff0101, /* ps_1_1 */
+ 0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
+ 0x0000ffff
+ };
+
+ static const struct
+ {
+ struct vec3 position;
+ DWORD diffuse;
+ DWORD specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+ static const DWORD vertex_decl[] =
+ {
+ D3DVSD_STREAM(0),
+ D3DVSD_REG(0, D3DVSDT_FLOAT3), /* position, v0 */
+ D3DVSD_REG(1, D3DVSDT_D3DCOLOR), /* diffuse color, v1 */
+ D3DVSD_REG(2, D3DVSDT_D3DCOLOR), /* specular color, v2 */
+ D3DVSD_CONST(0, 1), 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ D3DVSD_END()
+ };
+ static const struct
+ {
+ int vshader;
+ D3DFOGMODE vfog;
+ D3DFOGMODE tfog;
+ DWORD color_left;
+ DWORD color_middle_top;
+ DWORD color_middle_bottom;
+ DWORD color_right;
+ }
+ test_data[] =
+ {
+ /* Using z-based fog, the bottom quad should have a gradient UNFOGGED->FOGGED
+ * for table fog, and be completely fogged for vertex fog.
+ * When the fog coordinate returned by the vertex shader is used instead,
+ * the result is a gradient FOGGED->UNFOGGED. */
+
+ /* No vertex shader */
+ {0, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {0, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader without vertex fog computation */
+ {1, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader with vertex fog computation.
+ * As drivers inconsistently clamp or don't clamp the oFog output of vertex shaders,
+ * the special value C_CLAMPED_FOG allows both C_HALF_FOGGED (clamped) and C_FOGGED. */
+ {2, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {2, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1.
+ * Note that for the tests with vertex shaders, this matrix is hard-coded in the shaders. */
+ static const D3DMATRIX proj_mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f
+ }}};
+
+ window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate8(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps (%#x)\n", hr);
+
+ has_table_fog_support = caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests\n");
+
+ has_ps_support = caps.PixelShaderVersion >= D3DPS_VERSION(1, 1);
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice8_CreatePixelShader(device, pixel_shader_code, &pixel_shader[1]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No ps_1_1 support, skipping some fog tests\n");
+ }
+
+ has_vs_support = caps.VertexShaderVersion >= D3DVS_VERSION(1, 0);
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice8_CreateVertexShader(device, vertex_decl, vertex_shader_code1, &vertex_shader[1], 0);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_CreateVertexShader(device, vertex_decl, vertex_shader_code2, &vertex_shader[2], 0);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No vs_1_0 support, skipping some fog tests\n");
+ }
+
+ /* Setup initial states: No depth test, no lighting, fog on, fog color */
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Turning off depth test failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Turning off lighting failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Turning on fog calculations failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Setting fog color failed (%#x)\n", hr);
+
+ hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform (%#x)\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].vshader != 0 && !vertex_shader[test_data[i].vshader])
+ continue;
+ if (test_data[i].tfog != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ hr = IDirect3DDevice8_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
+ ok(SUCCEEDED(hr), "SetVertexShader failed (%#x)\n", hr);
+
+ for (ps = 0; ps < sizeof(pixel_shader)/sizeof(pixel_shader[0]); ps++)
+ {
+ if (ps != 0 && !pixel_shader[ps])
+ continue;
+
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice8_SetPixelShader(device, pixel_shader[ps]);
+ ok(SUCCEEDED(hr), "SetPixelShader failed (%#x)\n", hr);
+ }
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, test_data[i].vfog);
+ ok(SUCCEEDED(hr), "Setting fog vertex mode to %d failed (%#x)\n", test_data[i].vfog, hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, test_data[i].tfog);
+ ok(SUCCEEDED(hr), "Setting fog table mode to %d failed (%#x)\n", test_data[i].tfog, hr);
+
+ hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Clear failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_BeginScene(device);
+ ok(SUCCEEDED(hr), "BeginScene failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &top_quad[0], sizeof(top_quad[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_1[0], sizeof(bottom_quad_1[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_2[0], sizeof(bottom_quad_2[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_EndScene(device);
+ ok(SUCCEEDED(hr), "EndScene failed (%#x)\n", hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = getPixelColor(device, 2, y);
+ ok(color_match(color, test_data[i].color_left, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got left color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_left);
+ color = getPixelColor(device, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ if (expected_middle_color == C_CLAMPED_FOG)
+ {
+ ok(color_match(color, C_HALF_FOGGED, 13) || color_match(color, C_FOGGED, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got middle color %08x, "
+ "expected %08x+-5%% or %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, C_HALF_FOGGED, C_FOGGED);
+ }
+ else
+ {
+ ok(color_match(color, expected_middle_color, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got middle color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, expected_middle_color);
+ }
+ color = getPixelColor(device, 638, y);
+ ok(color_match(color, test_data[i].color_right, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got right color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_right);
+ }
+
+ hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Present failed (%#x)\n", hr);
+ }
+ }
+ for (i = 0; i < sizeof(vertex_shader)/sizeof(vertex_shader[0]); i++)
+ if (vertex_shader[i])
+ IDirect3DDevice8_DeleteVertexShader(device, vertex_shader[i]);
+ for (i = 0; i < sizeof(pixel_shader)/sizeof(pixel_shader[0]); i++)
+ if (pixel_shader[i])
+ IDirect3DDevice8_DeletePixelShader(device, pixel_shader[i]);
+ refcount = IDirect3DDevice8_Release(device);
+ ok(!refcount, "Device has %u references left\n", refcount);
+done:
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+}
+
/* This tests fog in combination with shaders.
* What's tested: linear fog (vertex and table) with pixel shader
* linear table fog with non foggy vertex shader
@@ -5092,6 +5387,7 @@ START_TEST(visual)
offscreen_test();
alpha_test();
test_scalar_instructions();
+ fog_negative_z_test();
fog_with_shader_test();
cnd_test();
p8_texture_test();
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 117c8eb..f8ac3a6 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -1825,6 +1825,365 @@ done:
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void fog_negative_z_test(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000,
+ C_CLAMPED_FOG = 0xdeadbeef /* triggers special codepath when used as middle_color */
+ };
+
+ IDirect3DVertexShader9 *vertex_shader[4] = {NULL, NULL, NULL, NULL};
+ IDirect3DPixelShader9 *pixel_shader[3] = {NULL, NULL, NULL};
+ IDirect3DVertexDeclaration9 *vertex_declaration = NULL;
+ IDirect3DDevice9 *device;
+ BOOL has_vs_support, has_ps_support, has_table_fog_support, is_fog_vertex_clamped;
+ unsigned int i, ps, y;
+ IDirect3D9 *d3d;
+ ULONG refcount;
+ D3DCAPS9 caps;
+ DWORD color, expected_middle_color;
+ HWND window;
+ HRESULT hr;
+
+ /* Basic vertex shader without fog computation ("non foggy") */
+ static const DWORD vertex_shader_code1[] =
+ {
+ 0xfffe0101, /* vs_1_1 */
+ 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0000001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"). Outputs the z coordinate of the vertex
+ * as its fog intensity value. */
+ static const DWORD vertex_shader_code2[] =
+ {
+ 0xfffe0101, /* vs_1_1 */
+ 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0000001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x00000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"), vs_2_0 */
+ static const DWORD vertex_shader_code3[] =
+ {
+ 0xfffe0200, /* vs_2_0 */
+ 0x05000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0200001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x03000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x03000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x02000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x02000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x02000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic pixel shader */
+ static const DWORD pixel_shader_code[] =
+ {
+ 0xffff0101, /* ps_1_1 */
+ 0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
+ 0x0000ffff
+ };
+ static const DWORD pixel_shader_code2[] =
+ {
+ 0xffff0200, /* ps_2_0 */
+ 0x0200001f, 0x80000000, 0x900f0000, /* dcl v0 */
+ 0x02000001, 0x800f0800, 0x90e40000, /* mov oC0, v0 */
+ 0x0000ffff
+ };
+ static const struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+
+ static const D3DVERTEXELEMENT9 decl_elements[] =
+ {
+ {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
+ {0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, /* diffuse */
+ {0, 16, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, /* specular */
+ D3DDECL_END()
+ };
+ static const struct
+ {
+ int vshader;
+ D3DFOGMODE vfog;
+ D3DFOGMODE tfog;
+ DWORD color_left;
+ DWORD color_middle_top;
+ DWORD color_middle_bottom;
+ DWORD color_right;
+ }
+ test_data[] =
+ {
+ /* Using z-based fog, the bottom quad should have a gradient UNFOGGED->FOGGED
+ * for table fog, and be completely fogged for vertex fog.
+ * When the fog coordinate returned by the vertex shader is used instead,
+ * the result is a gradient FOGGED->UNFOGGED in the right half of the screen.
+ *
+ * C_CLAMPED_FOG will be replaced by the correct expected value based on
+ * the value of D3DPMISCCAPS_FOGVERTEXCLAMPED. If the driver clamps the oFog
+ * output of vertex shaders, it should be C_HALF_FOGGED, else C_FOGGED. */
+
+ /* No vertex shader */
+ {0, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {0, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader without vertex fog computation */
+ {1, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader vs_1_1 with vertex fog computation */
+ {2, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {2, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+
+ /* Vertex shader vs_2_0 with vertex fog computation */
+ {3, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {3, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {3, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {3, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1.
+ * Note that for the tests with vertex shaders, this matrix is hard-coded in the shaders. */
+ static const D3DMATRIX proj_mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f,
+ }}};
+
+ window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate9(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps (%#x)\n", hr);
+
+ has_table_fog_support = caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests\n");
+
+ has_vs_support = caps.VertexShaderVersion >= D3DVS_VERSION(1, 1);
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code1, &vertex_shader[1]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code2, &vertex_shader[2]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+
+ if (caps.VertexShaderVersion >= D3DVS_VERSION(2, 0))
+ {
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code3, &vertex_shader[3]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No vs_2_0 support, skipping some fog tests\n");
+ }
+ }
+ else
+ {
+ skip("No vs_1_1 support, skipping some fog tests\n");
+ }
+
+ has_ps_support = caps.PixelShaderVersion >= D3DPS_VERSION(1, 1);
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code, &pixel_shader[1]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+
+ if (caps.PixelShaderVersion >= D3DPS_VERSION(2, 0))
+ {
+ hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code2, &pixel_shader[2]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No ps_2_0 support, skipping some fog tests\n");
+ }
+ }
+ else
+ {
+ skip("No ps_1_1 support, skipping some fog tests\n");
+ }
+
+ is_fog_vertex_clamped = caps.PrimitiveMiscCaps & D3DPMISCCAPS_FOGVERTEXCLAMPED;
+
+ hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
+ ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%#x)\n", hr);
+
+ /* Setup initial states: No depth test, no lighting, fog on, fog color */
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Turning off depth test failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Turning off lighting failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Turning on fog calculations failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Setting fog color failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
+ ok(SUCCEEDED(hr), "SetVertexDeclaration failed (%#x)\n", hr);
+
+ hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform (%#x)\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].vshader != 0 && !vertex_shader[test_data[i].vshader])
+ continue;
+ if (test_data[i].tfog != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice9_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
+ ok(SUCCEEDED(hr), "SetVertexShader failed (%#x)\n", hr);
+ }
+
+ for (ps = 0; ps < sizeof(pixel_shader)/sizeof(pixel_shader[0]); ps++)
+ {
+ if (ps != 0 && !pixel_shader[ps])
+ continue;
+
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice9_SetPixelShader(device, pixel_shader[ps]);
+ ok(SUCCEEDED(hr), "SetPixelShader failed (%#x)\n", hr);
+ }
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, test_data[i].vfog);
+ ok(SUCCEEDED(hr), "Setting fog vertex mode to %d failed (%#x)\n", test_data[i].vfog, hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, test_data[i].tfog);
+ ok(SUCCEEDED(hr), "Setting fog table mode to %d failed (%#x)\n", test_data[i].tfog, hr);
+
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Clear failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_BeginScene(device);
+ ok(SUCCEEDED(hr), "BeginScene failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &top_quad[0], sizeof(top_quad[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_1[0], sizeof(bottom_quad_1[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_2[0], sizeof(bottom_quad_2[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_EndScene(device);
+ ok(SUCCEEDED(hr), "EndScene failed (%#x)\n", hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = getPixelColor(device, 2, y);
+ ok(color_match(color, test_data[i].color_left, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got left color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_left);
+ color = getPixelColor(device, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ if (expected_middle_color == C_CLAMPED_FOG)
+ {
+ expected_middle_color = is_fog_vertex_clamped ? C_HALF_FOGGED : C_FOGGED;
+ }
+ ok(color_match(color, expected_middle_color, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got middle color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, expected_middle_color);
+ color = getPixelColor(device, 638, y);
+ ok(color_match(color, test_data[i].color_right, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got right color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_right);
+
+ }
+
+ hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Present failed (%#x)\n", hr);
+ }
+ }
+
+ for (i = 0; i < sizeof(vertex_shader)/sizeof(vertex_shader[0]); i++)
+ if (vertex_shader[i])
+ IDirect3DVertexShader9_Release(vertex_shader[i]);
+ for (i = 0; i < sizeof(pixel_shader)/sizeof(pixel_shader[0]); i++)
+ if (pixel_shader[i])
+ IDirect3DPixelShader9_Release(pixel_shader[i]);
+ IDirect3DVertexDeclaration9_Release(vertex_declaration);
+ refcount = IDirect3DDevice9_Release(device);
+ ok(!refcount, "Device has %u references left\n", refcount);
+done:
+ IDirect3D9_Release(d3d);
+ DestroyWindow(window);
+}
+
/* This test tests fog in combination with shaders.
* What's tested: linear fog (vertex and table) with pixel shader
* linear table fog with non foggy vertex shader
@@ -16729,6 +17088,7 @@ START_TEST(visual)
test_vshader_input();
test_vshader_float16();
stream_test();
+ fog_negative_z_test();
fog_with_shader_test();
texbem_test();
texdepth_test();
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index ec50fb8..4e999f7 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -3384,6 +3384,166 @@ static void test_fog_special(void)
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void test_fog_negative_z(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000
+ };
+
+ D3DCOLOR color, expected_middle_color;
+ HRESULT hr;
+ ULONG refcount;
+ BOOL has_table_fog_support;
+ unsigned int i, y;
+ HWND window;
+ IDirect3DDevice7 *device;
+ IDirectDrawSurface7 *rt;
+ D3DDEVICEDESC7 caps;
+
+ static struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+ static const struct
+ {
+ DWORD vertexmode, tablemode;
+ D3DCOLOR color_left, color_middle_top, color_middle_bottom, color_right;
+ }
+ test_data[] =
+ {
+ {D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1. */
+ static D3DMATRIX proj_mat =
+ {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f
+ };
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+
+ if (!(device = create_device(window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create a 3D device, skipping test.\n");
+ DestroyWindow(window);
+ return;
+ }
+
+ memset(&caps, 0, sizeof(caps));
+ hr = IDirect3DDevice7_GetCaps(device, &caps);
+ ok(SUCCEEDED(hr), "IDirect3DDevice7_GetCaps failed, hr %#x.\n", hr);
+
+ has_table_fog_support = caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests.\n");
+
+ hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
+ ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Failed to enable fog, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Failed to set fog color, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].tablemode != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Failed to clear render target, i=%d, hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, test_data[i].vertexmode);
+ ok(SUCCEEDED(hr), "Failed to set fog vertex mode, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, test_data[i].tablemode);
+ ok(SUCCEEDED(hr), "Failed to set fog table mode, i=%d, hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice7_BeginScene(device);
+ ok(SUCCEEDED(hr), "Failed to begin scene, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, top_quad, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, bottom_quad_1, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, bottom_quad_2, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_EndScene(device);
+ ok(SUCCEEDED(hr), "Failed to end scene, i=%d, hr %#x.\n", i, hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = get_surface_color(rt, 2, y);
+ ok(compare_color(color, test_data[i].color_left, 13),
+ "fog fvm%i ftm%i y=%i: got left color %08x, expected %08x+-5%%.\n",
+ test_data[i].vertexmode, test_data[i].tablemode, color, y,
+ test_data[i].color_left);
+ color = get_surface_color(rt, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ ok(compare_color(color, expected_middle_color, 13),
+ "fog fvm%i ftm%i y=%i: got middle color %08x, expected %08x+-5%%.\n",
+ test_data[i].vertexmode, test_data[i].tablemode, y,
+ color, expected_middle_color);
+ color = get_surface_color(rt, 638, y);
+ ok(compare_color(color, test_data[i].color_right, 13),
+ "fog fvm%i ftm%i y=%i: got right color %08x, expected %08x+-5%%.\n",
+ test_data[i].vertexmode, test_data[i].tablemode, y,
+ color, test_data[i].color_right);
+ }
+ }
+
+ IDirectDrawSurface7_Release(rt);
+ refcount = IDirect3DDevice7_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
static void test_lighting_interface_versions(void)
{
IDirect3DDevice7 *device;
@@ -7671,6 +7831,7 @@ START_TEST(ddraw7)
test_clear_rect_count();
test_coop_level_versions();
test_fog_special();
+ test_fog_negative_z();
test_lighting_interface_versions();
test_coop_level_activateapp();
test_texturemanage();
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 7379ba2..907e895 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -5005,7 +5005,7 @@ static GLhandleARB shader_glsl_generate_ffp_vertex_shader(struct wined3d_shader_
/* Need to undo the [0.0 - 1.0] -> [-1.0 - 1.0] transformation from D3D to GL coordinates. */
shader_addline(buffer, "gl_FogFragCoord = gl_Position.z * 0.5 + 0.5;\n");
else
- shader_addline(buffer, "gl_FogFragCoord = ec_pos.z;\n");
+ shader_addline(buffer, "gl_FogFragCoord = abs(ec_pos.z);\n");
break;
default:
--
1.8.4.5
From jnvsor at gmail.com Thu Nov 6 15:17:13 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 22:17:13 +0100
Subject: [PATCH] reg/tests: Test result for deleting key that doesn't exist
Message-ID: <1415308633-32616-1-git-send-email-jnvsor@gmail.com>
---
programs/reg/tests/reg.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 81394c0..f93df55 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -396,6 +396,9 @@ static void test_delete(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
err = RegOpenKeyExA(HKEY_CURRENT_USER, KEY_BASE, 0, KEY_READ, &hkey);
ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
+
+ run_reg_exe("reg delete HKCU\\" KEY_BASE " /f", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
}
static void test_query(void)
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 15:17:35 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 22:17:35 +0100
Subject: [PATCH 1/8] reg: Add system error printing function
Message-ID: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 31 +++++++++++++++++++++++++++----
programs/reg/reg.h | 1 +
programs/reg/reg.rc | 1 +
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index d299cbf..d2fcabc 100644
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -67,6 +67,29 @@ static int reg_message(int msg)
return reg_printfW(formatW, msg_buffer);
}
+static int reg_print_error(LSTATUS error_code)
+{
+ switch (error_code)
+ {
+ case ERROR_SUCCESS:
+ return 0;
+ case ERROR_BAD_COMMAND:
+ return reg_message(STRING_INVALID_CMDLINE);
+ default:
+ {
+ static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
+ WCHAR *message = NULL;
+ FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
+ error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *)&message, 0, NULL);
+
+ reg_message(STRING_ERROR);
+ reg_printfW(error_string, error_code, message);
+ HeapFree(GetProcessHeap(), 0, message);
+ return 0;
+ }
+ }
+}
+
static HKEY get_rootkey(LPWSTR key)
{
static const WCHAR szHKLM[] = {'H','K','L','M',0};
@@ -397,7 +420,7 @@ int wmain(int argc, WCHAR *argvW[])
if (argc < 3)
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
@@ -433,7 +456,7 @@ int wmain(int argc, WCHAR *argvW[])
if (argc < 3)
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
@@ -464,7 +487,7 @@ int wmain(int argc, WCHAR *argvW[])
if (argc < 3)
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
@@ -488,7 +511,7 @@ int wmain(int argc, WCHAR *argvW[])
}
else
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
}
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
index 2221647..1c2ae83 100644
--- a/programs/reg/reg.h
+++ b/programs/reg/reg.h
@@ -30,3 +30,4 @@
#define STRING_INVALID_CMDLINE 107
#define STRING_NO_REMOTE 108
#define STRING_CANNOT_FIND 109
+#define STRING_ERROR 110
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 479912b..6183aaa 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -35,4 +35,5 @@ STRINGTABLE
STRING_INVALID_CMDLINE, "Error: Invalid command line parameters\n"
STRING_NO_REMOTE, "Error: Unable to add keys to remote machine\n"
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
+ STRING_ERROR, "Unexpected error: "
}
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 15:17:36 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 22:17:36 +0100
Subject: [PATCH 2/8] reg: Add sane_path function to do preliniary key
validation
In-Reply-To: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
References: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415308662-32675-2-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 26 ++++++++++++++++++++++----
programs/reg/reg.rc | 2 +-
programs/reg/tests/reg.c | 4 ++--
3 files changed, 25 insertions(+), 7 deletions(-)
mode change 100644 => 100755 programs/reg/reg.c
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
old mode 100644
new mode 100755
index d2fcabc..fa7b2df
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -20,6 +20,8 @@
#include
#include "reg.h"
+#define ERROR_NO_REMOTE 20000
+
static int reg_printfW(const WCHAR *msg, ...)
{
va_list va_args;
@@ -75,6 +77,8 @@ static int reg_print_error(LSTATUS error_code)
return 0;
case ERROR_BAD_COMMAND:
return reg_message(STRING_INVALID_CMDLINE);
+ case ERROR_NO_REMOTE:
+ return reg_message(STRING_NO_REMOTE);
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -186,6 +190,16 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r
return out_data;
}
+static LSTATUS sane_path(const WCHAR *key)
+{
+ int i = strlenW(key);
+
+ if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
+ return ERROR_NO_REMOTE;
+
+ return ERROR_SUCCESS;
+}
+
static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
{
@@ -193,12 +207,14 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
LPWSTR p;
HKEY root,subkey;
+ LONG err;
reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
- if (key_name[0]=='\\' && key_name[1]=='\\')
+ err = sane_path(key_name);
+ if (err != ERROR_SUCCESS)
{
- reg_message(STRING_NO_REMOTE);
+ reg_print_error(err);
return 1;
}
@@ -263,15 +279,17 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
{
LPWSTR p;
HKEY root,subkey;
+ LONG err;
static const WCHAR stubW[] = {'D','E','L','E','T','E',
' ','-',' ','%','s',' ','%','s',' ','%','d',' ','%','d',' ','%','d','\n'
,0};
reg_printfW(stubW, key_name, value_name, value_empty, value_all, force);
- if (key_name[0]=='\\' && key_name[1]=='\\')
+ err = sane_path(key_name);
+ if (err != ERROR_SUCCESS)
{
- reg_message(STRING_NO_REMOTE);
+ reg_print_error(err);
return 1;
}
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 6183aaa..5fc5a76 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -33,7 +33,7 @@ STRINGTABLE
STRING_SUCCESS, "The operation completed successfully\n"
STRING_INVALID_KEY, "Error: Invalid key name\n"
STRING_INVALID_CMDLINE, "Error: Invalid command line parameters\n"
- STRING_NO_REMOTE, "Error: Unable to add keys to remote machine\n"
+ STRING_NO_REMOTE, "Error: Unable to access remote machine\n"
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
STRING_ERROR, "Unexpected error: "
}
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index f93df55..57e0108 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -129,10 +129,10 @@ static void test_add(void)
ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %u\n", r);
err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest2");
- todo_wine ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
+ ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
"got exit code %d\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 15:17:37 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 22:17:37 +0100
Subject: [PATCH 3/8] reg: Add check for multiple backslashes at the end of the
key
In-Reply-To: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
References: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415308662-32675-3-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index fa7b2df..186ba47 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -77,6 +77,8 @@ static int reg_print_error(LSTATUS error_code)
return 0;
case ERROR_BAD_COMMAND:
return reg_message(STRING_INVALID_CMDLINE);
+ case ERROR_INVALID_HANDLE:
+ return reg_message(STRING_INVALID_KEY);
case ERROR_NO_REMOTE:
return reg_message(STRING_NO_REMOTE);
default:
@@ -194,6 +196,9 @@ static LSTATUS sane_path(const WCHAR *key)
{
int i = strlenW(key);
+ if (i < 3 || (key[i - 1] == '\\' && key[i - 2] == '\\'))
+ return ERROR_INVALID_HANDLE;
+
if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
return ERROR_NO_REMOTE;
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 15:17:38 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 22:17:38 +0100
Subject: [PATCH 4/8] reg: Add path/key conversion functions
In-Reply-To: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
References: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415308662-32675-4-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 145 +++++++++++++++++++++++++++++------------------------
1 file changed, 79 insertions(+), 66 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index 186ba47..f6d4bbc 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -20,8 +20,36 @@
#include
#include "reg.h"
+#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
+
#define ERROR_NO_REMOTE 20000
+static const WCHAR short_hklm[] = {'H','K','L','M',0};
+static const WCHAR short_hkcu[] = {'H','K','C','U',0};
+static const WCHAR short_hkcr[] = {'H','K','C','R',0};
+static const WCHAR short_hku[] = {'H','K','U',0};
+static const WCHAR short_hkcc[] = {'H','K','C','C',0};
+static const WCHAR long_hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
+static const WCHAR long_hkcu[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
+static const WCHAR long_hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
+static const WCHAR long_hku[] = {'H','K','E','Y','_','U','S','E','R','S',0};
+static const WCHAR long_hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
+
+static const struct
+{
+ HKEY key;
+ const WCHAR *short_name;
+ const WCHAR *long_name;
+}
+root_rels[] =
+{
+ {HKEY_LOCAL_MACHINE, short_hklm, long_hklm},
+ {HKEY_CURRENT_USER, short_hkcu, long_hkcu},
+ {HKEY_CLASSES_ROOT, short_hkcr, long_hkcr},
+ {HKEY_USERS, short_hku, long_hku},
+ {HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
+};
+
static int reg_printfW(const WCHAR *msg, ...)
{
va_list va_args;
@@ -81,6 +109,8 @@ static int reg_print_error(LSTATUS error_code)
return reg_message(STRING_INVALID_KEY);
case ERROR_NO_REMOTE:
return reg_message(STRING_NO_REMOTE);
+ case ERROR_FILE_NOT_FOUND:
+ return reg_message(STRING_CANNOT_FIND);
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -96,35 +126,40 @@ static int reg_print_error(LSTATUS error_code)
}
}
-static HKEY get_rootkey(LPWSTR key)
+static inline BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name)
+{
+ DWORD length = strlenW(rootkey_name);
+
+ return (!strncmpiW(input_path, rootkey_name, length) &&
+ (input_path[length] == 0 || input_path[length] == '\\'));
+}
+
+static HKEY path_get_rootkey(const WCHAR *path)
+{
+ DWORD i;
+
+ for (i = 0; i < ARRAY_SIZE(root_rels); i++)
+ {
+ if (path_rootname_cmp(path, root_rels[i].short_name) ||
+ path_rootname_cmp(path, root_rels[i].long_name))
+ return root_rels[i].key;
+ }
+
+ return NULL;
+}
+
+static LSTATUS path_open(const WCHAR *path, HKEY *out, BOOL create)
{
- static const WCHAR szHKLM[] = {'H','K','L','M',0};
- static const WCHAR szHKEY_LOCAL_MACHINE[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
- static const WCHAR szHKCU[] = {'H','K','C','U',0};
- static const WCHAR szHKEY_CURRENT_USER[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
- static const WCHAR szHKCR[] = {'H','K','C','R',0};
- static const WCHAR szHKEY_CLASSES_ROOT[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
- static const WCHAR szHKU[] = {'H','K','U',0};
- static const WCHAR szHKEY_USERS[] = {'H','K','E','Y','_','U','S','E','R','S',0};
- static const WCHAR szHKCC[] = {'H','K','C','C',0};
- static const WCHAR szHKEY_CURRENT_CONFIG[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
-
- if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKLM,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,18,szHKEY_LOCAL_MACHINE,18)==CSTR_EQUAL)
- return HKEY_LOCAL_MACHINE;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKCU,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,17,szHKEY_CURRENT_USER,17)==CSTR_EQUAL)
- return HKEY_CURRENT_USER;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKCR,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,17,szHKEY_CLASSES_ROOT,17)==CSTR_EQUAL)
- return HKEY_CLASSES_ROOT;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,3,szHKU,3)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,10,szHKEY_USERS,10)==CSTR_EQUAL)
- return HKEY_USERS;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKCC,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,19,szHKEY_CURRENT_CONFIG,19)==CSTR_EQUAL)
- return HKEY_CURRENT_CONFIG;
- else return NULL;
+ *out = path_get_rootkey(path);
+
+ path = strchrW(path, '\\');
+ if (path)
+ path++;
+
+ if (create)
+ return RegCreateKeyW(*out, path, out);
+ else
+ return RegOpenKeyW(*out, path, out);
}
static DWORD get_regtype(LPWSTR type)
@@ -210,8 +245,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
{
static const WCHAR stubW[] = {'A','D','D',' ','-',' ','%','s',
' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
- LPWSTR p;
- HKEY root,subkey;
+ HKEY subkey;
LONG err;
reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
@@ -223,22 +257,8 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
return 1;
}
- p = strchrW(key_name,'\\');
- if (!p)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
- p++;
-
- root = get_rootkey(key_name);
- if (!root)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
-
- if(RegCreateKeyW(root,p,&subkey)!=ERROR_SUCCESS)
+ err = path_open(key_name, &subkey, TRUE);
+ if(err != ERROR_SUCCESS)
{
reg_message(STRING_INVALID_KEY);
return 1;
@@ -282,8 +302,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
BOOL value_all, BOOL force)
{
- LPWSTR p;
- HKEY root,subkey;
+ HKEY subkey;
LONG err;
static const WCHAR stubW[] = {'D','E','L','E','T','E',
@@ -298,16 +317,8 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
return 1;
}
- p = strchrW(key_name,'\\');
- if (!p)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
- p++;
-
- root = get_rootkey(key_name);
- if (!root)
+ err = path_open(key_name, &subkey, FALSE);
+ if (err != ERROR_SUCCESS)
{
reg_message(STRING_INVALID_KEY);
return 1;
@@ -333,21 +344,23 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
/* Delete subtree only if no /v* option is given */
if (!value_name && !value_empty && !value_all)
{
- if (RegDeleteTreeW(root,p)!=ERROR_SUCCESS)
+ err = RegDeleteTreeA(subkey, NULL);
+ if (err != ERROR_SUCCESS)
{
- reg_message(STRING_CANNOT_FIND);
+ reg_print_error(err);
+ return 1;
+ }
+
+ err = RegDeleteKeyA(subkey, "");
+ if (err != ERROR_SUCCESS)
+ {
+ reg_print_error(err);
return 1;
}
reg_message(STRING_SUCCESS);
return 0;
}
- if(RegOpenKeyW(root,p,&subkey)!=ERROR_SUCCESS)
- {
- reg_message(STRING_CANNOT_FIND);
- return 1;
- }
-
if (value_all)
{
LPWSTR szValue;
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 15:17:39 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 22:17:39 +0100
Subject: [PATCH 5/8] reg: Add wchar/type conversion functions
In-Reply-To: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
References: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415308662-32675-5-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 72 +++++++++++++++++++++++++++++++++++++----------------
programs/reg/reg.h | 1 +
programs/reg/reg.rc | 1 +
3 files changed, 53 insertions(+), 21 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index f6d4bbc..facd241 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -50,6 +50,44 @@ root_rels[] =
{HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
};
+static const WCHAR type_none[] = {'R','E','G','_','N','O','N','E',0};
+static const WCHAR type_sz[] = {'R','E','G','_','S','Z',0};
+static const WCHAR type_expand_sz[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0};
+static const WCHAR type_binary[] = {'R','E','G','_','B','I','N','A','R','Y',0};
+static const WCHAR type_dword[] = {'R','E','G','_','D','W','O','R','D',0};
+static const WCHAR type_dword_le[] = {'R','E','G','_','D','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
+static const WCHAR type_dword_be[] = {'R','E','G','_','D','W','O','R','D','_','B','I','G','_','E','N','D','I','A','N',0};
+static const WCHAR type_link[] = {'R','E','G','_','L','I','N','K',0};
+static const WCHAR type_multi_sz[] = {'R','E','G','_','M','U','L','T','I','_','S','Z',0};
+static const WCHAR type_resource_list[] = {'R','E','G','_','R','E','S','O','U','R','C','E','_','L','I','S','T',0};
+static const WCHAR type_full_resource_descriptor[] = {'R','E','G','_','F','U','L','L','_','R','E','S','O','U','R','C','E','_','D','E','S','C','R','I','P','T','O','R',0};
+static const WCHAR type_resource_requirements_list[] = {'R','E','G','_','R','E','S','O','U','R','C','E','_','R','E','Q','U','I','R','E','M','E','N','T','S','_','L','I','S','T',0};
+static const WCHAR type_qword[] = {'R','E','G','_','Q','W','O','R','D',0};
+static const WCHAR type_qword_le[] = {'R','E','G','_','Q','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
+
+static const struct
+{
+ DWORD type;
+ const WCHAR *name;
+}
+type_rels[] =
+{
+ {REG_NONE, type_none},
+ {REG_SZ, type_sz},
+ {REG_EXPAND_SZ, type_expand_sz},
+ {REG_BINARY, type_binary},
+ {REG_DWORD, type_dword},
+ {REG_DWORD_LITTLE_ENDIAN, type_dword_le},
+ {REG_DWORD_BIG_ENDIAN, type_dword_be},
+ {REG_LINK, type_link},
+ {REG_MULTI_SZ, type_multi_sz},
+ {REG_RESOURCE_LIST, type_resource_list},
+ {REG_FULL_RESOURCE_DESCRIPTOR, type_full_resource_descriptor},
+ {REG_RESOURCE_REQUIREMENTS_LIST, type_resource_requirements_list},
+ {REG_QWORD, type_qword},
+ {REG_QWORD_LITTLE_ENDIAN, type_qword_le},
+};
+
static int reg_printfW(const WCHAR *msg, ...)
{
va_list va_args;
@@ -111,6 +149,8 @@ static int reg_print_error(LSTATUS error_code)
return reg_message(STRING_NO_REMOTE);
case ERROR_FILE_NOT_FOUND:
return reg_message(STRING_CANNOT_FIND);
+ case ERROR_INVALID_DATATYPE:
+ return reg_message(STRING_INVALID_TYPE);
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -162,28 +202,18 @@ static LSTATUS path_open(const WCHAR *path, HKEY *out, BOOL create)
return RegOpenKeyW(*out, path, out);
}
-static DWORD get_regtype(LPWSTR type)
+static DWORD wchar_get_type(const WCHAR *type_name)
{
- static const WCHAR szREG_SZ[] = {'R','E','G','_','S','Z',0};
- static const WCHAR szREG_MULTI_SZ[] = {'R','E','G','_','M','U','L','T','I','_','S','Z',0};
- static const WCHAR szREG_DWORD_BIG_ENDIAN[] = {'R','E','G','_','D','W','O','R','D','_','B','I','G','_','E','N','D','I','A','N',0};
- static const WCHAR szREG_DWORD[] = {'R','E','G','_','D','W','O','R','D',0};
- static const WCHAR szREG_BINARY[] = {'R','E','G','_','B','I','N','A','R','Y',0};
- static const WCHAR szREG_DWORD_LITTLE_ENDIAN[] = {'R','E','G','_','D','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
- static const WCHAR szREG_NONE[] = {'R','E','G','_','N','O','N','E',0};
- static const WCHAR szREG_EXPAND_SZ[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0};
-
- if (!type)
+ DWORD i;
+
+ if (!type_name)
return REG_SZ;
- if (lstrcmpiW(type,szREG_SZ)==0) return REG_SZ;
- if (lstrcmpiW(type,szREG_DWORD)==0) return REG_DWORD;
- if (lstrcmpiW(type,szREG_MULTI_SZ)==0) return REG_MULTI_SZ;
- if (lstrcmpiW(type,szREG_EXPAND_SZ)==0) return REG_EXPAND_SZ;
- if (lstrcmpiW(type,szREG_DWORD_BIG_ENDIAN)==0) return REG_DWORD_BIG_ENDIAN;
- if (lstrcmpiW(type,szREG_DWORD_LITTLE_ENDIAN)==0) return REG_DWORD_LITTLE_ENDIAN;
- if (lstrcmpiW(type,szREG_BINARY)==0) return REG_BINARY;
- if (lstrcmpiW(type,szREG_NONE)==0) return REG_NONE;
+ for (i = 0; i < ARRAY_SIZE(type_rels); i++)
+ {
+ if (!strcmpiW(type_rels[i].name, type_name))
+ return type_rels[i].type;
+ }
return -1;
}
@@ -278,11 +308,11 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
}
}
- reg_type = get_regtype(type);
+ reg_type = wchar_get_type(type);
if (reg_type == -1)
{
RegCloseKey(subkey);
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_INVALID_DATATYPE);
return 1;
}
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
index 1c2ae83..d49d3d8 100644
--- a/programs/reg/reg.h
+++ b/programs/reg/reg.h
@@ -31,3 +31,4 @@
#define STRING_NO_REMOTE 108
#define STRING_CANNOT_FIND 109
#define STRING_ERROR 110
+#define STRING_INVALID_TYPE 111
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 5fc5a76..1c19375 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -36,4 +36,5 @@ STRINGTABLE
STRING_NO_REMOTE, "Error: Unable to access remote machine\n"
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
STRING_ERROR, "Unexpected error: "
+ STRING_INVALID_TYPE, "Error: Invalid type\n"
}
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 15:17:40 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 22:17:40 +0100
Subject: [PATCH 6/8] reg: Add wchar/raw data conversion functions
In-Reply-To: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
References: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415308662-32675-6-git-send-email-jnvsor@gmail.com>
In the case of REG_SZ and the like, it may seem like the functions
perform an unncessary copy of the strings which should already be
in memory ripe for the taking.
However because these functions handle more than one type of data
the calling function needs to be able to free the data afterwards.
Simply returning the input string would result in a function
freeing one of it's own parameters, so we make sure to return
new memory by making a copy.
---
programs/reg/reg.c | 139 +++++++++++++++++++++++++++++++++++++++--------
programs/reg/reg.h | 2 +
programs/reg/reg.rc | 2 +
programs/reg/tests/reg.c | 55 +++++++++----------
4 files changed, 146 insertions(+), 52 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index facd241..0c51f8b 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -18,11 +18,15 @@
#include
#include
+#include
#include "reg.h"
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
#define ERROR_NO_REMOTE 20000
+#define ERROR_NOT_INT_OR_NEG 20001
+
+WINE_DEFAULT_DEBUG_CHANNEL(reg);
static const WCHAR short_hklm[] = {'H','K','L','M',0};
static const WCHAR short_hkcu[] = {'H','K','C','U',0};
@@ -151,6 +155,10 @@ static int reg_print_error(LSTATUS error_code)
return reg_message(STRING_CANNOT_FIND);
case ERROR_INVALID_DATATYPE:
return reg_message(STRING_INVALID_TYPE);
+ case ERROR_UNSUPPORTED_TYPE:
+ return reg_message(STRING_UNSUPPORTED_TYPE);
+ case ERROR_NOT_INT_OR_NEG:
+ return reg_message(STRING_NOT_INT_OR_NEG);
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -218,43 +226,118 @@ static DWORD wchar_get_type(const WCHAR *type_name)
return -1;
}
-static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *reg_count)
+static LSTATUS wchar_get_data( const WCHAR *input, const DWORD type,
+ const WCHAR separator, DWORD *size_out, BYTE **out)
{
- LPBYTE out_data = NULL;
- *reg_count = 0;
+ static const WCHAR empty = 0;
+ DWORD i;
- switch (reg_type)
+ if (!input)
+ input = ∅
+
+ switch (type)
{
case REG_SZ:
+ case REG_EXPAND_SZ:
{
- *reg_count = (lstrlenW(data) + 1) * sizeof(WCHAR);
- out_data = HeapAlloc(GetProcessHeap(),0,*reg_count);
- lstrcpyW((LPWSTR)out_data,data);
- break;
+ i = (strlenW(input) + 1) * sizeof(WCHAR);
+ *out = HeapAlloc(GetProcessHeap(), 0, i);
+ memcpy(*out, input, i);
+ *size_out = i;
+ return ERROR_SUCCESS;
}
case REG_DWORD:
+ case REG_DWORD_BIG_ENDIAN:
{
- LPWSTR rest;
- DWORD val;
- val = strtolW(data, &rest, 0);
- if (rest == data) {
- static const WCHAR nonnumber[] = {'E','r','r','o','r',':',' ','/','d',' ','r','e','q','u','i','r','e','s',' ','n','u','m','b','e','r','.','\n',0};
- reg_printfW(nonnumber);
- break;
+ WCHAR *temp;
+
+ if (input[0] == '0' && (input[1] == 'x' || input[1] == 'X'))
+ i = strtoulW(input, &temp, 16);
+ else
+ i = strtoulW(input, &temp, 10);
+
+ if (input[0] == '-' || temp[0] || temp == input)
+ return ERROR_NOT_INT_OR_NEG;
+
+ *out = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
+ ** (DWORD **) out = i;
+ *size_out = sizeof(DWORD);
+ return ERROR_SUCCESS;
+ }
+ case REG_MULTI_SZ:
+ {
+ WCHAR *temp = HeapAlloc(GetProcessHeap(), 0, (strlenW(input) + 1) * sizeof(WCHAR));
+ DWORD p;
+
+ for (i = 0, p = 0; i <= strlenW(input); i++, p++)
+ {
+ /* If this character is the separator, or no separator has been given and these
+ * characters are "\\0", then add a 0 indicating the end of this string */
+ if ( (separator && input[i] == separator) ||
+ (!separator && input[i] == '\\' && input[i + 1] == '0') )
+ {
+ /* If it's the first character or the previous one was a separator */
+ if (!p || temp[p - 1] == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, temp);
+ return ERROR_BAD_COMMAND;
+ }
+ temp[p] = 0;
+
+ if (!separator)
+ i++;
+ }
+ else
+ temp[p] = input[i];
}
- *reg_count = sizeof(DWORD);
- out_data = HeapAlloc(GetProcessHeap(),0,*reg_count);
- ((LPDWORD)out_data)[0] = val;
- break;
+
+ /* Add a 0 to the end if the string wasn't "", and it wasn't
+ * double-0-terminated already (In the case of a trailing separator) */
+ if(p > 1 && temp[p - 2])
+ temp[p++] = 0;
+
+ *size_out = p * sizeof(WCHAR);
+ *out = HeapReAlloc(GetProcessHeap(), 0, temp, p * sizeof(WCHAR));
+ return ERROR_SUCCESS;
+ }
+ case REG_BINARY:
+ {
+ BYTE * temp = HeapAlloc(GetProcessHeap(), 0, strlenW(input));
+ DWORD p, odd;
+
+ for (i = 0, p = 0; i < strlenW(input); i++, p++)
+ {
+ if (input[i] >= '0' && input[i] <= '9')
+ temp[p] = input[i] - '0';
+ else if (input[i] >= 'a' && input[i] <= 'f')
+ temp[p] = input[i] - 'a' + 10;
+ else if (input[i] >= 'A' && input[i] <= 'F')
+ temp[p] = input[i] - 'A' + 10;
+ else
+ {
+ HeapFree(GetProcessHeap(), 0, temp);
+ return ERROR_BAD_COMMAND;
+ }
+ }
+
+ odd = p & 1;
+ temp += odd;
+ p >>= 1;
+
+ for (i = 0; i < p; i++)
+ temp[i] = (temp[i * 2] << 4) | temp[i * 2 + 1];
+
+ p += odd;
+ *size_out = p;
+ *out = HeapReAlloc(GetProcessHeap(), 0, temp-odd, p);
+ return ERROR_SUCCESS;
}
default:
{
- static const WCHAR unhandled[] = {'U','n','h','a','n','d','l','e','d',' ','T','y','p','e',' ','0','x','%','x',' ',' ','d','a','t','a',' ','%','s','\n',0};
- reg_printfW(unhandled, reg_type,data);
+ FIXME("Add support for registry type: %u\n", type);
+ return ERROR_UNSUPPORTED_TYPE;
}
}
-
- return out_data;
}
static LSTATUS sane_path(const WCHAR *key)
@@ -317,7 +400,15 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
}
if (data)
- reg_data = get_regdata(data,reg_type,separator,®_count);
+ {
+ err = wchar_get_data(data, reg_type, separator, ®_count, ®_data);
+ if (err != ERROR_SUCCESS)
+ {
+ RegCloseKey(subkey);
+ reg_print_error(err);
+ return 1;
+ }
+ }
RegSetValueExW(subkey,value_name,0,reg_type,reg_data,reg_count);
HeapFree(GetProcessHeap(),0,reg_data);
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
index d49d3d8..f1b398b 100644
--- a/programs/reg/reg.h
+++ b/programs/reg/reg.h
@@ -32,3 +32,5 @@
#define STRING_CANNOT_FIND 109
#define STRING_ERROR 110
#define STRING_INVALID_TYPE 111
+#define STRING_UNSUPPORTED_TYPE 112
+#define STRING_NOT_INT_OR_NEG 113
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 1c19375..47986ab 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -37,4 +37,6 @@ STRINGTABLE
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
STRING_ERROR, "Unexpected error: "
STRING_INVALID_TYPE, "Error: Invalid type\n"
+ STRING_UNSUPPORTED_TYPE, "Error: Unsupported type\n"
+ STRING_NOT_INT_OR_NEG, "Error: This type requires /d to be a positive number\n"
}
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 57e0108..b2894d6 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -183,11 +183,11 @@ static void test_add(void)
/* REG_EXPAND_SZ */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand0 /t REG_EXpand_sz /d \"dead%PATH%beef\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, TODO_REG_SIZE);
+ verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand1 /t REG_EXpand_sz /d \"dead^%PATH^%beef\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, TODO_REG_SIZE);
+ verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -195,11 +195,11 @@ static void test_add(void)
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, TODO_REG_SIZE);
+ verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand3 /f /d \"\"", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, 0);
/* REG_BINARY */
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin0 /f", &r);
@@ -209,14 +209,14 @@ static void test_add(void)
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_BINARY /d deadbeef /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
dword = 0xefbeadde;
- verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), TODO_REG_SIZE);
+ verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin1 /f /d 0xDeAdBeEf", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin2 /f /d x01", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin3 /f /d 01x", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin4 /f /d DeAdBeEf0DD", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -230,8 +230,8 @@ static void test_add(void)
err = RegQueryValueExA(hkey, "bin4", NULL, &type, (void *) (buffer+12), &size);
ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
ok(type == REG_BINARY, "got wrong type %u\n", type);
- todo_wine ok(size == 6, "got wrong size %u\n", size);
- todo_wine ok(memcmp(buffer, buffer+12, 6) == 0 ||
+ ok(size == 6, "got wrong size %u\n", size);
+ ok(memcmp(buffer, buffer+12, 6) == 0 ||
broken(memcmp(buffer+6, buffer+12, 6) == 0 /* WinXP */), "got wrong data\n");
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin5 /d \"\" /f", &r);
@@ -252,11 +252,11 @@ static void test_add(void)
todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %d, expected 0\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword3 /t REG_DWORD /d deadbeef /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword4 /t REG_DWORD /d 123xyz /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword5 /t reg_dword /d 12345678 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -270,22 +270,21 @@ static void test_add(void)
ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
ok(type == REG_DWORD, "got wrong type %d, expected %d\n", type, REG_DWORD);
ok(size == sizeof(DWORD), "got wrong size %d, expected %d\n", size, (int)sizeof(DWORD));
- todo_wine ok(dword == 123 || broken(dword == 0123 /* WinXP */),
+ ok(dword == 123 || broken(dword == 0123 /* WinXP */),
"got wrong data %d, expected %d\n", dword, 123);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword7 /t reg_dword /d 0xabcdefg /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0xdeadbeef /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
dword = 0xdeadbeef;
- verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword),
- (sizeof(long) > sizeof(DWORD)) ? 0 : TODO_REG_DATA);
+ verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword), 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword9 /f /d -1", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword10 /f /d -0x1", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
/* REG_DWORD_LITTLE_ENDIAN */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_LE /t REG_DWORD_LITTLE_ENDIAN /d 456 /f", &r);
@@ -297,7 +296,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE /t REG_DWORD_BIG_ENDIAN /d 456 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
dword = 456;
- verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), TODO_REG_SIZE);
+ verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), 0);
/* REG_DWORD_BIG_ENDIAN is broken in every version of windows. It behaves like
* an ordinary REG_DWORD - that is little endian. GG */
@@ -305,15 +304,15 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi0 /t REG_MULTI_SZ /d \"three\\0little\\0strings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
memcpy(buffer, "three\0little\0strings\0", 22);
- verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, TODO_REG_SIZE);
+ verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi1 /s \"#\" /d \"three#little#strings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, TODO_REG_SIZE);
+ verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi2 /d \"\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, TODO_REG_SIZE);
+ verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -321,7 +320,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, TODO_REG_SIZE);
+ verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
@@ -330,16 +329,16 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi10 /s \"#\" /d \"#a\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi11 /s \"#\" /d \"a#\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
buffer[0]='a'; buffer[1]=0; buffer[2]=0;
- verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, TODO_REG_SIZE);
+ verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, 0);
RegCloseKey(hkey);
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 15:17:41 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 22:17:41 +0100
Subject: [PATCH 7/8] reg: Clean up reg_add
In-Reply-To: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
References: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415308662-32675-7-git-send-email-jnvsor@gmail.com>
You'll notice that bad value input leaves a zombie key after this
call, but this is consistant with native.
---
programs/reg/reg.c | 92 ++++++++++++++++++++++++++----------------------
programs/reg/tests/reg.c | 22 ++++++------
2 files changed, 60 insertions(+), 54 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index 0c51f8b..2d46d21 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -353,71 +353,70 @@ static LSTATUS sane_path(const WCHAR *key)
return ERROR_SUCCESS;
}
-static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
- WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
+static int reg_add( const WCHAR *key_name, const WCHAR *value_name, const BOOL value_empty,
+ const WCHAR *type, const WCHAR separator, const WCHAR *data,
+ const BOOL force)
{
- static const WCHAR stubW[] = {'A','D','D',' ','-',' ','%','s',
- ' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
- HKEY subkey;
- LONG err;
-
- reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
-
- err = sane_path(key_name);
+ HKEY key = NULL;
+ LONG err = sane_path(key_name);
if (err != ERROR_SUCCESS)
+ goto error;
+
+ if (value_name && value_empty)
{
- reg_print_error(err);
- return 1;
+ err = ERROR_BAD_COMMAND;
+ goto error;
}
- err = path_open(key_name, &subkey, TRUE);
+ err = path_open(key_name, &key, TRUE);
if(err != ERROR_SUCCESS)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
+ goto error;
if (value_name || data)
{
- DWORD reg_type;
- DWORD reg_count = 0;
- BYTE* reg_data = NULL;
+ DWORD size, reg_type;
+ BYTE *data_out;
+
+ if (value_name && !value_name[0])
+ value_name = NULL;
- if (!force)
+ if (type && !type[0])
{
- if (RegQueryValueW(subkey,value_name,NULL,NULL)==ERROR_SUCCESS)
- {
- /* FIXME: Prompt for overwrite */
- }
+ data = NULL;
+ type = NULL;
}
- reg_type = wchar_get_type(type);
- if (reg_type == -1)
+ if (!force && RegQueryValueExW(key, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{
- RegCloseKey(subkey);
- reg_print_error(ERROR_INVALID_DATATYPE);
- return 1;
+ FIXME("Prompt for overwrite\n");
}
- if (data)
+ reg_type = wchar_get_type(type);
+ if (reg_type == -1)
{
- err = wchar_get_data(data, reg_type, separator, ®_count, ®_data);
- if (err != ERROR_SUCCESS)
- {
- RegCloseKey(subkey);
- reg_print_error(err);
- return 1;
- }
+ err = ERROR_INVALID_DATATYPE;
+ goto error;
}
- RegSetValueExW(subkey,value_name,0,reg_type,reg_data,reg_count);
- HeapFree(GetProcessHeap(),0,reg_data);
+ err = wchar_get_data(data, reg_type, separator, &size, &data_out);
+ if (err != ERROR_SUCCESS)
+ goto error;
+
+ err = RegSetValueExW(key, value_name, 0, reg_type, data_out, size);
+ HeapFree(GetProcessHeap(), 0, data_out);
+ if (err != ERROR_SUCCESS)
+ goto error;
}
- RegCloseKey(subkey);
+ RegCloseKey(key);
reg_message(STRING_SUCCESS);
-
return 0;
+
+error:
+ RegCloseKey(key);
+
+ reg_print_error(err);
+ return 1;
}
static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
@@ -597,7 +596,14 @@ int wmain(int argc, WCHAR *argvW[])
else if (!lstrcmpiW(argvW[i], slashTW))
type = argvW[++i];
else if (!lstrcmpiW(argvW[i], slashSW))
- separator = argvW[++i][0];
+ {
+ if (!argvW[++i][0] || argvW[i][1])
+ {
+ reg_print_error(ERROR_BAD_COMMAND);
+ return 1;
+ }
+ separator = argvW[i][0];
+ }
else if (!lstrcmpiW(argvW[i], slashDW))
data = argvW[++i];
else if (!lstrcmpiW(argvW[i], slashFW))
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index b2894d6..3e4454e 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -110,12 +110,12 @@ static void test_add(void)
/* Test empty type */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\" /d WineTest /f", &r);
- todo_wine ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
+ ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
"got exit code %u\n", r);
if (r == REG_EXIT_SUCCESS)
- todo_wine verify_reg(hkey, "emptyType", REG_SZ, "", 1, 0);
+ verify_reg(hkey, "emptyType", REG_SZ, "", 1, 0);
else
- todo_wine win_skip("broken reg.exe detected\n");
+ win_skip("broken reg.exe detected\n");
/* Test input key formats */
run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
@@ -166,7 +166,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /v test /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_reg(hkey, "test", REG_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "test", REG_SZ, "", 1, 0);
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /d WineTEST /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -174,7 +174,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test2 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_reg(hkey, "test2", REG_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "test2", REG_SZ, "", 1, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test3 /f /d \"\"", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -191,7 +191,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, 0);
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -249,7 +249,7 @@ static void test_add(void)
win_skip("broken reg.exe detected\n");
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword1 /t REG_DWORD /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %d, expected 0\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
@@ -316,18 +316,18 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, TODO_REG_SIZE);
+ verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi6 /s \"\\0\" /d \"three\\0little\\0strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
--
2.1.1
From jnvsor at gmail.com Thu Nov 6 15:17:42 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Thu, 6 Nov 2014 22:17:42 +0100
Subject: [PATCH 8/8] reg: Clean up reg_delete
In-Reply-To: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
References: <1415308662-32675-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415308662-32675-8-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 150 +++++++++++++++++++++++------------------------
programs/reg/tests/reg.c | 2 +-
2 files changed, 74 insertions(+), 78 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index 2d46d21..2bcdd48 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -419,120 +419,116 @@ error:
return 1;
}
-static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
- BOOL value_all, BOOL force)
+static int reg_delete(const WCHAR *key_name, const WCHAR *value_name, const BOOL value_empty,
+ const BOOL value_all, const BOOL force)
{
- HKEY subkey;
- LONG err;
-
- static const WCHAR stubW[] = {'D','E','L','E','T','E',
- ' ','-',' ','%','s',' ','%','s',' ','%','d',' ','%','d',' ','%','d','\n'
- ,0};
- reg_printfW(stubW, key_name, value_name, value_empty, value_all, force);
-
- err = sane_path(key_name);
+ HKEY key = NULL;
+ LONG err = sane_path(key_name);
if (err != ERROR_SUCCESS)
{
reg_print_error(err);
return 1;
}
- err = path_open(key_name, &subkey, FALSE);
+ err = path_open(key_name, &key, FALSE);
if (err != ERROR_SUCCESS)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
-
- if (value_name && value_empty)
- {
- reg_message(STRING_INVALID_CMDLINE);
- return 1;
- }
+ goto error;
- if (value_empty && value_all)
+ /* Mutually exclusive options */
+ if ((!!value_name + !!value_empty + !!value_all) > 1)
{
- reg_message(STRING_INVALID_CMDLINE);
- return 1;
+ err = ERROR_BAD_COMMAND;
+ goto error;
}
if (!force)
{
- /* FIXME: Prompt for delete */
+ FIXME("Prompt for delete\n");
}
- /* Delete subtree only if no /v* option is given */
- if (!value_name && !value_empty && !value_all)
+ if (value_empty || value_name)
{
- err = RegDeleteTreeA(subkey, NULL);
- if (err != ERROR_SUCCESS)
- {
- reg_print_error(err);
- return 1;
- }
+ if (value_name && value_name[0])
+ err = RegDeleteValueW(key, value_name);
+ else
+ err = RegDeleteValueW(key, NULL);
- err = RegDeleteKeyA(subkey, "");
if (err != ERROR_SUCCESS)
- {
- reg_print_error(err);
- return 1;
- }
- reg_message(STRING_SUCCESS);
- return 0;
+ goto error;
}
-
- if (value_all)
+ else if (value_all)
{
- LPWSTR szValue;
- DWORD maxValue;
- DWORD count;
- LONG rc;
-
- rc = RegQueryInfoKeyW(subkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- &maxValue, NULL, NULL, NULL);
- if (rc != ERROR_SUCCESS)
- {
- /* FIXME: failure */
- RegCloseKey(subkey);
- return 1;
- }
- maxValue++;
- szValue = HeapAlloc(GetProcessHeap(),0,maxValue*sizeof(WCHAR));
+ WCHAR *enum_v_name;
+ DWORD count, max_size, this_size, i = 0, errors = 0;
+
+ err = RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL, NULL, NULL,
+ &count, &max_size, NULL, NULL, NULL);
+ if (err != ERROR_SUCCESS)
+ goto error;
- while (1)
+ enum_v_name = HeapAlloc(GetProcessHeap(), 0, ++max_size * sizeof(WCHAR));
+
+ while (i < count)
{
- count = maxValue;
- rc = RegEnumValueW(subkey, 0, szValue, &count, NULL, NULL, NULL, NULL);
- if (rc == ERROR_SUCCESS)
+ this_size = max_size;
+
+ err = RegEnumValueW(key, i, enum_v_name, &this_size, NULL, NULL, NULL, NULL);
+ if (err != ERROR_SUCCESS)
{
- rc = RegDeleteValueW(subkey, szValue);
- if (rc != ERROR_SUCCESS)
- break;
+ i++;
+ errors++;
+ reg_print_error(err);
+ continue;
}
- else break;
+
+ err = RegDeleteValueW(key, enum_v_name);
+ if (err != ERROR_SUCCESS)
+ {
+ i++;
+ errors++;
+ reg_print_error(err);
+ continue;
+ }
+
+ count--;
}
- if (rc != ERROR_SUCCESS)
+
+ HeapFree(GetProcessHeap(), 0, enum_v_name);
+
+ if (errors)
{
- /* FIXME delete failed */
+ RegCloseKey(key);
+ return 1;
}
}
- else if (value_name)
+ /* Delete subtree only if no /v* option is given */
+ else
{
- if (RegDeleteValueW(subkey,value_name) != ERROR_SUCCESS)
+ if (key == path_get_rootkey(key_name))
{
- RegCloseKey(subkey);
- reg_message(STRING_CANNOT_FIND);
+ /* "This works well enough on native to make you regret you pressed enter" - stefand */
+ FIXME("Trying to delete a root key is a bad idea.\n");
+ RegCloseKey(key);
return 1;
}
- }
- else if (value_empty)
- {
- RegSetValueExW(subkey,NULL,0,REG_SZ,NULL,0);
+
+ err = RegDeleteTreeA(key, NULL);
+ if (err != ERROR_SUCCESS)
+ goto error;
+ err = RegDeleteKeyA(key, "");
+ if (err != ERROR_SUCCESS)
+ goto error;
}
- RegCloseKey(subkey);
+ RegCloseKey(key);
reg_message(STRING_SUCCESS);
return 0;
+
+error:
+ RegCloseKey(key);
+
+ reg_print_error(err);
+ return 1;
}
static int reg_query(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 3e4454e..d08a9c2 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -380,7 +380,7 @@ static void test_delete(void)
run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
err = RegQueryValueExA(hkey, "", NULL, NULL, NULL, NULL);
- todo_wine ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
+ ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
--
2.1.1
From stefan at codeweavers.com Thu Nov 6 16:47:19 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 6 Nov 2014 23:47:19 +0100
Subject: [PATCH 1/4] d3d9/tests: The device restores the mode settings from
the registry (v4).
Message-ID: <1415314042-10250-1-git-send-email-stefan@codeweavers.com>
v4: Test width and height in the same ok statement to prevent accidental
successes inside todo_wine when switching from e.g. 1920x1080 to
1920x1200.
Version 3: Simplify the mode selection code and hardcode
D3DFMT_X8R8G8B8. Retain the test for mode reset when the device was
originally created with the registry size.
Version 2: Make sure the mode set with ChangeDisplaySettings is bigger
than the device's mode. Otherwise Windows shrinks the window to the new
mode + 12 pixels. Testing this behavior is not the purpose of this test.
Implementing this behavior is complicated because ddraw destroys and
recreates swapchains in SetCooperativeLevel.
---
dlls/d3d9/tests/device.c | 152 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 116 insertions(+), 36 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 05585fd..d3618e2 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -3900,56 +3900,115 @@ done:
static void test_mode_change(void)
{
- RECT fullscreen_rect, focus_rect, r;
+ RECT d3d_rect, focus_rect, r;
struct device_desc device_desc;
IDirect3DSurface9 *backbuffer;
IDirect3DDevice9 *device;
D3DSURFACE_DESC desc;
IDirect3D9 *d3d9;
DEVMODEW devmode;
- UINT refcount;
+ ULONG refcount;
+ UINT adapter_mode_count, i;
HRESULT hr;
DWORD ret;
+ LONG change_ret;
+ D3DDISPLAYMODE d3ddm;
+ DWORD d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0;
- focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
- 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
- device_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
- 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d9, "Failed to create a D3D object.\n");
- SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+ adapter_mode_count = IDirect3D9_GetAdapterModeCount(d3d9, D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8);
+ for (i = 0; i < adapter_mode_count; ++i)
+ {
+ hr = IDirect3D9_EnumAdapterModes(d3d9, D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, i, &d3ddm);
+ ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+
+ if (d3ddm.Width == registry_mode.dmPelsWidth && d3ddm.Height == registry_mode.dmPelsHeight)
+ continue;
+ /* The r200 driver on Windows XP enumerates modes like 320x200 and 320x240 but
+ * refuses to create a device at these sizes. */
+ if (d3ddm.Width < 640 || d3ddm.Height < 480)
+ continue;
+
+ if (!user32_width)
+ {
+ user32_width = d3ddm.Width;
+ user32_height = d3ddm.Height;
+ continue;
+ }
+
+ /* Make sure the d3d mode is smaller in width or height and at most
+ * equal in the other dimension than the mode passed to
+ * ChangeDisplaySettings. Otherwise Windows shrinks the window to
+ * the ChangeDisplaySettings parameters + 12. */
+ if (d3ddm.Width == user32_width && d3ddm.Height == user32_height)
+ continue;
+ if (d3ddm.Width <= user32_width && d3ddm.Height <= user32_height)
+ {
+ d3d_width = d3ddm.Width;
+ d3d_height = d3ddm.Height;
+ break;
+ }
+ if (user32_width <= d3ddm.Width && user32_height <= d3ddm.Height)
+ {
+ d3d_width = user32_width;
+ d3d_height = user32_height;
+ user32_width = d3ddm.Width;
+ user32_height = d3ddm.Height;
+ break;
+ }
+ }
+
+ if (!d3d_width)
+ {
+ skip("Could not find adequate modes, skipping mode tests.\n");
+ IDirect3D9_Release(d3d9);
+ return;
+ }
+
+ memset(&devmode, 0, sizeof(devmode));
+ devmode.dmSize = sizeof(devmode);
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = user32_width;
+ devmode.dmPelsHeight = user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, user32_width / 2, user32_height / 2, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, user32_width / 2, user32_height / 2, 0, 0, 0, 0);
+
+ SetRect(&d3d_rect, 0, 0, d3d_width, d3d_height);
GetWindowRect(focus_window, &focus_rect);
device_desc.device_window = device_window;
- device_desc.width = registry_mode.dmPelsWidth;
- device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.width = d3d_width;
+ device_desc.height = d3d_height;
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
if (!(device = create_device(d3d9, focus_window, &device_desc)))
{
skip("Failed to create a D3D device, skipping tests.\n");
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
goto done;
}
- memset(&devmode, 0, sizeof(devmode));
- devmode.dmSize = sizeof(devmode);
- devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
- devmode.dmPelsWidth = 640;
- devmode.dmPelsHeight = 480;
-
- ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
- ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
+ devmode.dmPelsWidth = user32_width;
+ devmode.dmPelsHeight = user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- memset(&devmode, 0, sizeof(devmode));
- devmode.dmSize = sizeof(devmode);
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
ok(ret, "Failed to get display mode.\n");
- ok(devmode.dmPelsWidth == 640, "Got unexpect width %u.\n", devmode.dmPelsWidth);
- ok(devmode.dmPelsHeight == 480, "Got unexpect height %u.\n", devmode.dmPelsHeight);
+ ok(devmode.dmPelsWidth == user32_width && devmode.dmPelsHeight == user32_height,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ user32_width, user32_height, devmode.dmPelsWidth, devmode.dmPelsHeight);
GetWindowRect(device_window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, &d3d_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ d3d_rect.left, d3d_rect.top, d3d_rect.right, d3d_rect.bottom,
r.left, r.top, r.right, r.bottom);
GetWindowRect(focus_window, &r);
ok(EqualRect(&r, &focus_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
@@ -3960,31 +4019,52 @@ static void test_mode_change(void)
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
hr = IDirect3DSurface9_GetDesc(backbuffer, &desc);
ok(SUCCEEDED(hr), "Failed to get backbuffer desc, hr %#x.\n", hr);
- ok(desc.Width == registry_mode.dmPelsWidth, "Got unexpected backbuffer width %u.\n", desc.Width);
- ok(desc.Height == registry_mode.dmPelsHeight, "Got unexpected backbuffer height %u.\n", desc.Height);
+ ok(desc.Width == d3d_width, "Got unexpected backbuffer width %u, expected %u.\n",
+ desc.Width, d3d_width);
+ ok(desc.Height == d3d_height, "Got unexpected backbuffer height %u, expected %u.\n",
+ desc.Height, d3d_height);
IDirect3DSurface9_Release(backbuffer);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
- memset(&devmode, 0, sizeof(devmode));
- devmode.dmSize = sizeof(devmode);
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
ok(ret, "Failed to get display mode.\n");
- ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpect width %u.\n", devmode.dmPelsWidth);
- ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect height %u.\n", devmode.dmPelsHeight);
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, devmode.dmPelsWidth, devmode.dmPelsHeight);
+
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ /* The mode restore also happens when the device was created at the original screen size. */
+
+ device_desc.device_window = device_window;
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ ok(!!(device = create_device(d3d9, focus_window, &device_desc)), "Failed to create a D3D device.\n");
+
+ devmode.dmPelsWidth = user32_width;
+ devmode.dmPelsHeight = user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ refcount = IDirect3DDevice9_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, devmode.dmPelsWidth, devmode.dmPelsHeight);
done:
DestroyWindow(device_window);
DestroyWindow(focus_window);
IDirect3D9_Release(d3d9);
-
- memset(&devmode, 0, sizeof(devmode));
- devmode.dmSize = sizeof(devmode);
- ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
- ok(ret, "Failed to get display mode.\n");
- ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpect width %u.\n", devmode.dmPelsWidth);
- ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect height %u.\n", devmode.dmPelsHeight);
}
static void test_device_window_reset(void)
--
2.0.4
From stefan at codeweavers.com Thu Nov 6 16:47:20 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 6 Nov 2014 23:47:20 +0100
Subject: [PATCH 2/4] d3d8/tests: The device restores the mode settings from
the registry (v5).
Message-ID: <1415314042-10250-2-git-send-email-stefan@codeweavers.com>
v5: Test width and height in the same ok statement to prevent accidental
successes inside todo_wine when switching from e.g. 1920x1080 to
1920x1200.
v4: Simplify the mode selection code and (via previous patch) use
EnumDisplaySettingsW(ENUM_REGISTRY_SETTINGS) instead of
GetSystemMetrics(SM_C?SCREEN). Retain the test for mode reset when the
device was originally created with the registry size.
v3: Make the window visible. This works around the failure of 107263 on
the W8 testbot.
The testbot failure (device::release does not restore the mode) happens
on Vista too. This problem only happens if the application is not in
foreground *and* the windows are hidden. If the application is in
foreground, the device properly restores the mode even with (manually)
hidden windows.
This is a preexisting condition, see the failure in line 3051 here:
http://test.winehq.org/data/4bb80afedcca6bdc510574488258ef1a16e4167f/win8_newtb-w8/d3d8:device.html
This patch changes the previous resolution, thus the testbot did not
filter it out.
---
dlls/d3d8/tests/device.c | 158 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 121 insertions(+), 37 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 46918e8..9153139 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -2982,56 +2982,119 @@ static void test_unsupported_shaders(void)
static void test_mode_change(void)
{
- RECT fullscreen_rect, focus_rect, r;
+ RECT d3d_rect, focus_rect, r;
struct device_desc device_desc;
IDirect3DSurface8 *backbuffer;
IDirect3DDevice8 *device;
D3DSURFACE_DESC desc;
IDirect3D8 *d3d8;
DEVMODEW devmode;
- UINT refcount;
+ ULONG refcount;
+ UINT adapter_mode_count, i;
HRESULT hr;
- DWORD ret;
+ BOOL ret;
+ LONG change_ret;
+ D3DDISPLAYMODE d3ddm;
+ DWORD d3d_width = 0, d3d_height = 0, user32_width = 0, user32_height = 0;
- focus_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
- 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
- device_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
- 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
ok(!!d3d8, "Failed to create a D3D object.\n");
- SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+ adapter_mode_count = IDirect3D8_GetAdapterModeCount(d3d8, D3DADAPTER_DEFAULT);
+ for (i = 0; i < adapter_mode_count; ++i)
+ {
+ hr = IDirect3D8_EnumAdapterModes(d3d8, D3DADAPTER_DEFAULT, i, &d3ddm);
+ ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+
+ if (d3ddm.Format != D3DFMT_X8R8G8B8)
+ continue;
+ if (d3ddm.Width == registry_mode.dmPelsWidth && d3ddm.Height == registry_mode.dmPelsHeight)
+ continue;
+ /* The r200 driver on Windows XP enumerates modes like 320x200 and 320x240 but
+ * refuses to create a device at these sizes. */
+ if (d3ddm.Width < 640 || d3ddm.Height < 480)
+ continue;
+
+ if (!user32_width)
+ {
+ user32_width = d3ddm.Width;
+ user32_height = d3ddm.Height;
+ continue;
+ }
+
+ /* Make sure the d3d mode is smaller in width or height and at most
+ * equal in the other dimension than the mode passed to
+ * ChangeDisplaySettings. Otherwise Windows shrinks the window to
+ * the ChangeDisplaySettings parameters + 12. */
+ if (d3ddm.Width == user32_width && d3ddm.Height == user32_height)
+ continue;
+ if (d3ddm.Width <= user32_width && d3ddm.Height <= user32_height)
+ {
+ d3d_width = d3ddm.Width;
+ d3d_height = d3ddm.Height;
+ break;
+ }
+ if (user32_width <= d3ddm.Width && user32_height <= d3ddm.Height)
+ {
+ d3d_width = user32_width;
+ d3d_height = user32_height;
+ user32_width = d3ddm.Width;
+ user32_height = d3ddm.Height;
+ break;
+ }
+ }
+
+ if (!d3d_width)
+ {
+ skip("Could not find adequate modes, skipping mode tests.\n");
+ IDirect3D8_Release(d3d8);
+ return;
+ }
+
+ memset(&devmode, 0, sizeof(devmode));
+ devmode.dmSize = sizeof(devmode);
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = user32_width;
+ devmode.dmPelsHeight = user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ /* Make the windows visible, otherwise device::release does not restore the mode if
+ * the application is not in foreground like on the testbot. */
+ focus_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, user32_width / 2, user32_height / 2, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, user32_width / 2, user32_height / 2, 0, 0, 0, 0);
+
+ SetRect(&d3d_rect, 0, 0, d3d_width, d3d_height);
GetWindowRect(focus_window, &focus_rect);
device_desc.device_window = device_window;
- device_desc.width = registry_mode.dmPelsWidth;
- device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.width = d3d_width;
+ device_desc.height = d3d_height;
device_desc.flags = CREATE_DEVICE_FULLSCREEN;
if (!(device = create_device(d3d8, focus_window, &device_desc)))
{
skip("Failed to create a D3D device, skipping tests.\n");
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
goto done;
}
- memset(&devmode, 0, sizeof(devmode));
- devmode.dmSize = sizeof(devmode);
- devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
- devmode.dmPelsWidth = 640;
- devmode.dmPelsHeight = 480;
-
- ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
- ok(ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", ret);
+ devmode.dmPelsWidth = user32_width;
+ devmode.dmPelsHeight = user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- memset(&devmode, 0, sizeof(devmode));
- devmode.dmSize = sizeof(devmode);
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
ok(ret, "Failed to get display mode.\n");
- ok(devmode.dmPelsWidth == 640, "Got unexpect width %u.\n", devmode.dmPelsWidth);
- ok(devmode.dmPelsHeight == 480, "Got unexpect height %u.\n", devmode.dmPelsHeight);
+ ok(devmode.dmPelsWidth == user32_width && devmode.dmPelsHeight == user32_height,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ user32_width, user32_height, devmode.dmPelsWidth, devmode.dmPelsHeight);
GetWindowRect(device_window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, &d3d_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ d3d_rect.left, d3d_rect.top, d3d_rect.right, d3d_rect.bottom,
r.left, r.top, r.right, r.bottom);
GetWindowRect(focus_window, &r);
ok(EqualRect(&r, &focus_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
@@ -3042,31 +3105,52 @@ static void test_mode_change(void)
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
hr = IDirect3DSurface8_GetDesc(backbuffer, &desc);
ok(SUCCEEDED(hr), "Failed to get backbuffer desc, hr %#x.\n", hr);
- ok(desc.Width == registry_mode.dmPelsWidth, "Got unexpected backbuffer width %u.\n", desc.Width);
- ok(desc.Height == registry_mode.dmPelsHeight, "Got unexpected backbuffer height %u.\n", desc.Height);
+ ok(desc.Width == d3d_width, "Got unexpected backbuffer width %u, expected %u.\n",
+ desc.Width, d3d_width);
+ ok(desc.Height == d3d_height, "Got unexpected backbuffer height %u, expected %u.\n",
+ desc.Height, d3d_height);
IDirect3DSurface8_Release(backbuffer);
refcount = IDirect3DDevice8_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
- memset(&devmode, 0, sizeof(devmode));
- devmode.dmSize = sizeof(devmode);
ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
ok(ret, "Failed to get display mode.\n");
- ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpect width %u.\n", devmode.dmPelsWidth);
- ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect height %u.\n", devmode.dmPelsHeight);
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, devmode.dmPelsWidth, devmode.dmPelsHeight);
+
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ /* The mode restore also happens when the device was created at the original screen size. */
+
+ device_desc.device_window = device_window;
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ ok(!!(device = create_device(d3d8, focus_window, &device_desc)), "Failed to create a D3D device.\n");
+
+ devmode.dmPelsWidth = user32_width;
+ devmode.dmPelsHeight = user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ refcount = IDirect3DDevice8_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, devmode.dmPelsWidth, devmode.dmPelsHeight);
done:
DestroyWindow(device_window);
DestroyWindow(focus_window);
IDirect3D8_Release(d3d8);
-
- memset(&devmode, 0, sizeof(devmode));
- devmode.dmSize = sizeof(devmode);
- ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
- ok(ret, "Failed to get display mode.\n");
- ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth, "Got unexpect width %u.\n", devmode.dmPelsWidth);
- ok(devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpect height %u.\n", devmode.dmPelsHeight);
}
static void test_device_window_reset(void)
--
2.0.4
From stefan at codeweavers.com Thu Nov 6 16:47:21 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 6 Nov 2014 23:47:21 +0100
Subject: [PATCH 3/4] ddraw/tests: Check if the current display settings match
the registry settings.
Message-ID: <1415314042-10250-3-git-send-email-stefan@codeweavers.com>
---
dlls/ddraw/tests/ddraw1.c | 68 ++++++++++++++++++++++++++++-------------------
dlls/ddraw/tests/ddraw2.c | 68 ++++++++++++++++++++++++++++-------------------
dlls/ddraw/tests/ddraw4.c | 68 ++++++++++++++++++++++++++++-------------------
dlls/ddraw/tests/ddraw7.c | 67 +++++++++++++++++++++++++++-------------------
4 files changed, 159 insertions(+), 112 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 742d82c..fe8a36e 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -21,6 +21,8 @@
#include "wine/test.h"
#include "d3d.h"
+static DEVMODEW registry_mode;
+
struct create_window_thread_param
{
HWND window;
@@ -2007,7 +2009,7 @@ static void test_window_style(void)
style = GetWindowLongA(window, GWL_STYLE);
exstyle = GetWindowLongA(window, GWL_EXSTYLE);
- SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
+ SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2137,7 +2139,7 @@ static void test_coop_level_mode_set(void)
window = CreateWindowA("ddraw_test_wndproc_wc", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
+ SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&s, 0, 0, 640, 480);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
@@ -2559,7 +2561,7 @@ done:
static void test_coop_level_mode_set_multi(void)
{
IDirectDraw *ddraw1, *ddraw2;
- UINT orig_w, orig_h, w, h;
+ UINT w, h;
HWND window;
HRESULT hr;
ULONG ref;
@@ -2569,9 +2571,6 @@ static void test_coop_level_mode_set_multi(void)
ddraw1 = create_ddraw();
ok(!!ddraw1, "Failed to create a ddraw object.\n");
- orig_w = GetSystemMetrics(SM_CXSCREEN);
- orig_h = GetSystemMetrics(SM_CYSCREEN);
-
/* With just a single ddraw object, the display mode is restored on
* release. */
hr = set_display_mode(ddraw1, 800, 600);
@@ -2591,9 +2590,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* When there are multiple ddraw objects, the display mode is restored to
* the initial mode, before the first SetDisplayMode() call. */
@@ -2616,16 +2615,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Regardless of release ordering. */
ddraw1 = create_ddraw();
@@ -2647,16 +2646,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* But only for ddraw objects that called SetDisplayMode(). */
ddraw1 = create_ddraw();
@@ -2678,9 +2677,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* If there's a ddraw object that's currently in exclusive mode, it blocks
* restoring the display mode. */
@@ -2713,9 +2712,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Exclusive mode blocks mode setting on other ddraw objects in general. */
ddraw1 = create_ddraw();
@@ -2736,16 +2735,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
DestroyWindow(window);
}
@@ -4217,8 +4216,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
- surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
+ surface_desc.dwWidth = registry_mode.dmPelsWidth;
+ surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
@@ -4226,8 +4225,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
- surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
+ surface_desc.dwWidth = registry_mode.dmPelsWidth;
+ surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
@@ -5635,6 +5634,7 @@ static void test_surface_desc_lock(void)
START_TEST(ddraw1)
{
IDirectDraw *ddraw;
+ DEVMODEW current_mode;
if (!(ddraw = create_ddraw()))
{
@@ -5643,6 +5643,18 @@ START_TEST(ddraw1)
}
IDirectDraw_Release(ddraw);
+ memset(¤t_mode, 0, sizeof(current_mode));
+ current_mode.dmSize = sizeof(current_mode);
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, ¤t_mode), "Failed to get display mode.\n");
+ registry_mode.dmSize = sizeof(registry_mode);
+ ok(EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, ®istry_mode), "Failed to get display mode.\n");
+ if (registry_mode.dmPelsWidth != current_mode.dmPelsWidth
+ || registry_mode.dmPelsHeight != current_mode.dmPelsHeight)
+ {
+ skip("Current mode does not match registry mode, skipping test.\n");
+ return;
+ }
+
test_coop_level_create_device_window();
test_clipper_blt();
test_coop_level_d3d_state();
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index c5a8393..607f14c 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -21,6 +21,8 @@
#include "wine/test.h"
#include "d3d.h"
+static DEVMODEW registry_mode;
+
struct create_window_thread_param
{
HWND window;
@@ -2195,7 +2197,7 @@ static void test_window_style(void)
style = GetWindowLongA(window, GWL_STYLE);
exstyle = GetWindowLongA(window, GWL_EXSTYLE);
- SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
+ SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2341,7 +2343,7 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
+ SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&s, 0, 0, 640, 480);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
@@ -2854,7 +2856,7 @@ done:
static void test_coop_level_mode_set_multi(void)
{
IDirectDraw2 *ddraw1, *ddraw2;
- UINT orig_w, orig_h, w, h;
+ UINT w, h;
HWND window;
HRESULT hr;
ULONG ref;
@@ -2864,9 +2866,6 @@ static void test_coop_level_mode_set_multi(void)
ddraw1 = create_ddraw();
ok(!!ddraw1, "Failed to create a ddraw object.\n");
- orig_w = GetSystemMetrics(SM_CXSCREEN);
- orig_h = GetSystemMetrics(SM_CYSCREEN);
-
/* With just a single ddraw object, the display mode is restored on
* release. */
hr = set_display_mode(ddraw1, 800, 600);
@@ -2886,9 +2885,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* When there are multiple ddraw objects, the display mode is restored to
* the initial mode, before the first SetDisplayMode() call. */
@@ -2911,16 +2910,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw2_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Regardless of release ordering. */
ddraw1 = create_ddraw();
@@ -2942,16 +2941,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw2_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* But only for ddraw objects that called SetDisplayMode(). */
ddraw1 = create_ddraw();
@@ -2973,9 +2972,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* If there's a ddraw object that's currently in exclusive mode, it blocks
* restoring the display mode. */
@@ -3008,9 +3007,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Exclusive mode blocks mode setting on other ddraw objects in general. */
ddraw1 = create_ddraw();
@@ -3031,16 +3030,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw2_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw2_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
DestroyWindow(window);
}
@@ -5293,8 +5292,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
- surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
+ surface_desc.dwWidth = registry_mode.dmPelsWidth;
+ surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
@@ -5302,8 +5301,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
- surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
+ surface_desc.dwWidth = registry_mode.dmPelsWidth;
+ surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
@@ -6711,6 +6710,7 @@ static void test_surface_desc_lock(void)
START_TEST(ddraw2)
{
IDirectDraw2 *ddraw;
+ DEVMODEW current_mode;
if (!(ddraw = create_ddraw()))
{
@@ -6719,6 +6719,18 @@ START_TEST(ddraw2)
}
IDirectDraw2_Release(ddraw);
+ memset(¤t_mode, 0, sizeof(current_mode));
+ current_mode.dmSize = sizeof(current_mode);
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, ¤t_mode), "Failed to get display mode.\n");
+ registry_mode.dmSize = sizeof(registry_mode);
+ ok(EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, ®istry_mode), "Failed to get display mode.\n");
+ if (registry_mode.dmPelsWidth != current_mode.dmPelsWidth
+ || registry_mode.dmPelsHeight != current_mode.dmPelsHeight)
+ {
+ skip("Current mode does not match registry mode, skipping test.\n");
+ return;
+ }
+
test_coop_level_create_device_window();
test_clipper_blt();
test_coop_level_d3d_state();
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 009ac6f..1224698 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -22,6 +22,8 @@
#include
#include "d3d.h"
+static DEVMODEW registry_mode;
+
struct vec2
{
float x, y;
@@ -2382,7 +2384,7 @@ static void test_window_style(void)
style = GetWindowLongA(window, GWL_STYLE);
exstyle = GetWindowLongA(window, GWL_EXSTYLE);
- SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
+ SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2528,7 +2530,7 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
+ SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&s, 0, 0, 640, 480);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
@@ -3033,7 +3035,7 @@ static void test_coop_level_mode_set(void)
static void test_coop_level_mode_set_multi(void)
{
IDirectDraw4 *ddraw1, *ddraw2;
- UINT orig_w, orig_h, w, h;
+ UINT w, h;
HWND window;
HRESULT hr;
ULONG ref;
@@ -3043,9 +3045,6 @@ static void test_coop_level_mode_set_multi(void)
ddraw1 = create_ddraw();
ok(!!ddraw1, "Failed to create a ddraw object.\n");
- orig_w = GetSystemMetrics(SM_CXSCREEN);
- orig_h = GetSystemMetrics(SM_CYSCREEN);
-
/* With just a single ddraw object, the display mode is restored on
* release. */
hr = set_display_mode(ddraw1, 800, 600);
@@ -3058,9 +3057,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* When there are multiple ddraw objects, the display mode is restored to
* the initial mode, before the first SetDisplayMode() call. */
@@ -3083,16 +3082,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw4_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Regardless of release ordering. */
ddraw1 = create_ddraw();
@@ -3114,16 +3113,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw4_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* But only for ddraw objects that called SetDisplayMode(). */
ddraw1 = create_ddraw();
@@ -3145,9 +3144,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* If there's a ddraw object that's currently in exclusive mode, it blocks
* restoring the display mode. */
@@ -3180,9 +3179,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Exclusive mode blocks mode setting on other ddraw objects in general. */
ddraw1 = create_ddraw();
@@ -3203,16 +3202,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw4_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw4_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
DestroyWindow(window);
}
@@ -6075,8 +6074,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
- surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
+ surface_desc.dwWidth = registry_mode.dmPelsWidth;
+ surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
@@ -6084,8 +6083,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
- surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
+ surface_desc.dwWidth = registry_mode.dmPelsWidth;
+ surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
@@ -7786,6 +7785,7 @@ static void test_surface_desc_lock(void)
START_TEST(ddraw4)
{
IDirectDraw4 *ddraw;
+ DEVMODEW current_mode;
if (!(ddraw = create_ddraw()))
{
@@ -7794,6 +7794,18 @@ START_TEST(ddraw4)
}
IDirectDraw4_Release(ddraw);
+ memset(¤t_mode, 0, sizeof(current_mode));
+ current_mode.dmSize = sizeof(current_mode);
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, ¤t_mode), "Failed to get display mode.\n");
+ registry_mode.dmSize = sizeof(registry_mode);
+ ok(EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, ®istry_mode), "Failed to get display mode.\n");
+ if (registry_mode.dmPelsWidth != current_mode.dmPelsWidth
+ || registry_mode.dmPelsHeight != current_mode.dmPelsHeight)
+ {
+ skip("Current mode does not match registry mode, skipping test.\n");
+ return;
+ }
+
test_process_vertices();
test_coop_level_create_device_window();
test_clipper_blt();
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index ec50fb8..282432f 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -23,6 +23,7 @@
#include "d3d.h"
static HRESULT (WINAPI *pDirectDrawCreateEx)(GUID *guid, void **ddraw, REFIID iid, IUnknown *outer_unknown);
+static DEVMODEW registry_mode;
struct vec2
{
@@ -2061,7 +2062,7 @@ static void test_window_style(void)
style = GetWindowLongA(window, GWL_STYLE);
exstyle = GetWindowLongA(window, GWL_EXSTYLE);
- SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
+ SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2206,7 +2207,7 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
+ SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&s, 0, 0, 640, 480);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
@@ -2711,7 +2712,7 @@ static void test_coop_level_mode_set(void)
static void test_coop_level_mode_set_multi(void)
{
IDirectDraw7 *ddraw1, *ddraw2;
- UINT orig_w, orig_h, w, h;
+ UINT w, h;
HWND window;
HRESULT hr;
ULONG ref;
@@ -2721,9 +2722,6 @@ static void test_coop_level_mode_set_multi(void)
ddraw1 = create_ddraw();
ok(!!ddraw1, "Failed to create a ddraw object.\n");
- orig_w = GetSystemMetrics(SM_CXSCREEN);
- orig_h = GetSystemMetrics(SM_CYSCREEN);
-
/* With just a single ddraw object, the display mode is restored on
* release. */
hr = set_display_mode(ddraw1, 800, 600);
@@ -2736,9 +2734,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* When there are multiple ddraw objects, the display mode is restored to
* the initial mode, before the first SetDisplayMode() call. */
@@ -2761,16 +2759,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw7_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Regardless of release ordering. */
ddraw1 = create_ddraw();
@@ -2792,16 +2790,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw7_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* But only for ddraw objects that called SetDisplayMode(). */
ddraw1 = create_ddraw();
@@ -2823,9 +2821,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* If there's a ddraw object that's currently in exclusive mode, it blocks
* restoring the display mode. */
@@ -2858,9 +2856,9 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
/* Exclusive mode blocks mode setting on other ddraw objects in general. */
ddraw1 = create_ddraw();
@@ -2881,16 +2879,16 @@ static void test_coop_level_mode_set_multi(void)
ref = IDirectDraw7_Release(ddraw1);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
ref = IDirectDraw7_Release(ddraw2);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
w = GetSystemMetrics(SM_CXSCREEN);
- ok(w == orig_w, "Got unexpected screen width %u.\n", w);
+ ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
h = GetSystemMetrics(SM_CYSCREEN);
- ok(h == orig_h, "Got unexpected screen height %u.\n", h);
+ ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
DestroyWindow(window);
}
@@ -5913,8 +5911,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
- surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
+ surface_desc.dwWidth = registry_mode.dmPelsWidth;
+ surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
@@ -5922,8 +5920,8 @@ static void test_surface_attachment(void)
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- surface_desc.dwWidth = GetSystemMetrics(SM_CXSCREEN);
- surface_desc.dwHeight = GetSystemMetrics(SM_CYSCREEN);
+ surface_desc.dwWidth = registry_mode.dmPelsWidth;
+ surface_desc.dwHeight = registry_mode.dmPelsHeight;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
@@ -7630,6 +7628,7 @@ START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
IDirectDraw7 *ddraw;
+ DEVMODEW current_mode;
if (!(pDirectDrawCreateEx = (void *)GetProcAddress(module, "DirectDrawCreateEx")))
{
@@ -7644,6 +7643,18 @@ START_TEST(ddraw7)
}
IDirectDraw7_Release(ddraw);
+ memset(¤t_mode, 0, sizeof(current_mode));
+ current_mode.dmSize = sizeof(current_mode);
+ ok(EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, ¤t_mode), "Failed to get display mode.\n");
+ registry_mode.dmSize = sizeof(registry_mode);
+ ok(EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, ®istry_mode), "Failed to get display mode.\n");
+ if (registry_mode.dmPelsWidth != current_mode.dmPelsWidth
+ || registry_mode.dmPelsHeight != current_mode.dmPelsHeight)
+ {
+ skip("Current mode does not match registry mode, skipping test.\n");
+ return;
+ }
+
test_process_vertices();
test_coop_level_create_device_window();
test_clipper_blt();
--
2.0.4
From stefan at codeweavers.com Thu Nov 6 16:47:22 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 6 Nov 2014 23:47:22 +0100
Subject: [PATCH 4/4] ddraw/tests: Fix some COM macro versions in
test_coop_level_mode_set.
Message-ID: <1415314042-10250-4-git-send-email-stefan@codeweavers.com>
---
dlls/ddraw/tests/ddraw2.c | 6 +++---
dlls/ddraw/tests/ddraw4.c | 20 ++++++++++----------
dlls/ddraw/tests/ddraw7.c | 6 +++---
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 607f14c..ad0d040 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -2424,7 +2424,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = IDirectDraw_RestoreDisplayMode(ddraw);
+ hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2682,7 +2682,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = IDirectDraw_RestoreDisplayMode(ddraw);
+ hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2786,7 +2786,7 @@ static void test_coop_level_mode_set(void)
s.bottom - s.top, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
- hr = IDirectDraw_RestoreDisplayMode(ddraw);
+ hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
/* If the window is changed at the same time, messages are sent to the new window. */
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 1224698..69f3ac7 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -2611,7 +2611,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = IDirectDraw_RestoreDisplayMode(ddraw);
+ hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2736,7 +2736,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = IDirectDraw_RestoreDisplayMode(ddraw);
+ hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2862,7 +2862,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = IDirectDraw_RestoreDisplayMode(ddraw);
+ hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2934,13 +2934,13 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
- hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
+ hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
- IDirectDrawSurface_Release(primary);
+ IDirectDrawSurface4_Release(primary);
/* The screen restore is a property of DDSCL_EXCLUSIVE */
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
@@ -2958,15 +2958,15 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
- hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
+ hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
s.right - s.left, ddsd.dwWidth);
ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
s.bottom - s.top, ddsd.dwHeight);
- IDirectDrawSurface_Release(primary);
+ IDirectDrawSurface4_Release(primary);
- hr = IDirectDraw_RestoreDisplayMode(ddraw);
+ hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
/* If the window is changed at the same time, messages are sent to the new window. */
@@ -3009,13 +3009,13 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
- hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
+ hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
- IDirectDrawSurface_Release(primary);
+ IDirectDrawSurface4_Release(primary);
ref = IDirectDraw4_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 282432f..3aebfa7 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -2288,7 +2288,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = IDirectDraw_RestoreDisplayMode(ddraw);
+ hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2539,7 +2539,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = IDirectDraw_RestoreDisplayMode(ddraw);
+ hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2643,7 +2643,7 @@ static void test_coop_level_mode_set(void)
s.bottom - s.top, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
- hr = IDirectDraw_RestoreDisplayMode(ddraw);
+ hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
/* If the window is changed at the same time, messages are sent to the new window. */
--
2.0.4
From mengshuaicalendr at gmail.com Thu Nov 6 21:36:58 2014
From: mengshuaicalendr at gmail.com (Shuai Meng)
Date: Fri, 07 Nov 2014 11:36:58 +0800
Subject: [PATCH] vbscript: Implemented String(try 3)
Message-ID: <545C3E5A.1050601@gmail.com>
testbot:
https://newtestbot.winehq.org/JobDetails.pl?Key=10093
Change log:
used mod other than division when the second argument(length of
string) is grater than 256;
removed the judgment of string length when error number is 14(i.e.
VBSE_OUT_OF_STRING_SPACE)
removed some related tests.
---
dlls/vbscript/global.c | 63
+++++++++++++++++++++++++++++++++++++++++++--
dlls/vbscript/tests/api.vbs | 53 ++++++++++++++++++++++++++++++++++++++
dlls/vbscript/vbscript.h | 1 +
3 files changed, 115 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-vbscript-Implemented-String.txt
Type: text/x-patch
Size: 6334 bytes
Desc: not available
URL:
From hellas at burntcomma.com Thu Nov 6 22:06:55 2014
From: hellas at burntcomma.com (Mark Harmstone)
Date: Fri, 07 Nov 2014 04:06:55 +0000
Subject: [PATCH] winealsa: fix input sound distortion and heap corruption
Message-ID: <545C455F.1050201@burntcomma.com>
At present, winealsa attempts to call map_channels when a capture device
is opened. If a microphone can be opened in either stereo or mono mode,
and mono is requested, Wine will still return stereo data. Not only does
this result in distorted in audio, it also very frequently results in
heap corruption when snd_pcm_readi overruns the buffer allocated by the
program.
I don't have a copy of World of Warcraft to test this on, but this may
also fix bug 31684. It's the same symptoms, at least.
---
dlls/winealsa.drv/mmdevdrv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c
index a4c02bf..91fba2f 100644
--- a/dlls/winealsa.drv/mmdevdrv.c
+++ b/dlls/winealsa.drv/mmdevdrv.c
@@ -1164,7 +1164,7 @@ static DWORD get_channel_mask(unsigned int channels)
static HRESULT map_channels(ACImpl *This, const WAVEFORMATEX *fmt)
{
- if(fmt->wFormatTag == WAVE_FORMAT_EXTENSIBLE || fmt->nChannels > 2){
+ if( (This->dataflow != eCapture && fmt->wFormatTag ==
WAVE_FORMAT_EXTENSIBLE) || fmt->nChannels > 2){
WAVEFORMATEXTENSIBLE *fmtex = (void*)fmt;
DWORD mask, flag = SPEAKER_FRONT_LEFT;
UINT i = 0;
--
2.0.4
From sebastian at fds-team.de Thu Nov 6 22:44:13 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Fri, 07 Nov 2014 05:44:13 +0100
Subject: ntoskrnl.exe: Fix incorrect interpretation of SIB byte when parsing
x86 opcode.
Message-ID: <545C4E1D.6070503@fds-team.de>
I hope this issue is obvious enough without writing tests for that. ;)
Layout of the SIB byte should be:
* bits 0-2 base
* bits 3-5 index
* bits 6-7 scale
The current incorrect implementation has the effect, that when the scale bits are set, the index is not recognized anymore.
---
dlls/ntoskrnl.exe/instr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ntoskrnl.exe-Fix-incorrect-interpretation-of-SIB-byt.patch
Type: text/x-patch
Size: 864 bytes
Desc: not available
URL:
From sebastian at fds-team.de Thu Nov 6 22:44:17 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Fri, 07 Nov 2014 05:44:17 +0100
Subject: krnl386.exe16: Fix incorrect interpretation of SIB byte when parsing
x86 opcode.
Message-ID: <545C4E21.8060505@fds-team.de>
Same issue as in ntoskrnl.exe.
---
dlls/krnl386.exe16/instr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-krnl386.exe16-Fix-incorrect-interpretation-of-SIB-by.patch
Type: text/x-patch
Size: 870 bytes
Desc: not available
URL:
From alexhenrie24 at gmail.com Fri Nov 7 00:32:01 2014
From: alexhenrie24 at gmail.com (Alex Henrie)
Date: Thu, 6 Nov 2014 23:32:01 -0700
Subject: [PATCH 1/2] kernel32/tests: Add UTF-7 stray + sign removal tests.
Message-ID: <1415341922-1495-1-git-send-email-alexhenrie24@gmail.com>
---
dlls/kernel32/tests/codepage.c | 68 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 147989b..401df3c 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -527,6 +527,73 @@ static void test_utf7_encoding(void)
}
}
+static void test_utf7_decoding(void)
+{
+ char input[32];
+ WCHAR output[32], expected[32];
+ int i, len, expected_len;
+
+ static const char base64_decoding_table[] =
+ {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x00-0x0F */
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10-0x1F */
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20-0x2F */
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, /* 0x30-0x3F */
+ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40-0x4F */
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50-0x5F */
+ -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60-0x6F */
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* 0x70-0x7F */
+ };
+
+ if (MultiByteToWideChar(CP_UTF7, 0, "foobar", -1, NULL, 0) == 0 &&
+ GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+ {
+ skip("UTF-7 decoding not implemented\n");
+ return;
+ }
+
+ /* test which one-byte characters remove stray + signs */
+ for (i = 0; i < 256; i++)
+ {
+ sprintf(input, "+%c+AAA", i);
+
+ memset(output, 0x23, sizeof(output) - sizeof(WCHAR));
+ output[sizeof(output) / sizeof(WCHAR) - 1] = 0;
+
+ len = MultiByteToWideChar(CP_UTF7, 0, input, 7, output, sizeof(output) / sizeof(WCHAR) - 1);
+
+ if (i == '-')
+ {
+ /* removes the - sign */
+ expected_len = 3;
+ expected[0] = 0x002B;
+ expected[1] = 0;
+ expected[2] = 0;
+ }
+ else if (i <= 0x7F && base64_decoding_table[i] != -1)
+ {
+ /* absorbs the character into the base64 sequence */
+ expected_len = 2;
+ expected[0] = (base64_decoding_table[i] << 10) | 0x03E0;
+ expected[1] = 0;
+ }
+ else
+ {
+ /* removes the + sign */
+ expected_len = 3;
+ expected[0] = i;
+ expected[1] = 0;
+ expected[2] = 0;
+ }
+ expected[expected_len] = 0x2323;
+
+ ok(len == expected_len, "i=0x%02x: expected len=%i, got len=%i\n", i, expected_len, len);
+ ok(memcmp(output, expected, (expected_len + 1) * sizeof(WCHAR)) == 0,
+ "i=0x%02x: expected output=%s, got output=%s\n",
+ i, wine_dbgstr_wn(expected, expected_len + 1), wine_dbgstr_wn(output, expected_len + 1));
+ }
+}
+
static void test_undefined_byte_char(void)
{
static const struct tag_testset {
@@ -734,6 +801,7 @@ START_TEST(codepage)
test_string_conversion(&bUsedDefaultChar);
test_utf7_encoding();
+ test_utf7_decoding();
test_undefined_byte_char();
test_threadcp();
--
2.1.3
From alexhenrie24 at gmail.com Fri Nov 7 00:32:02 2014
From: alexhenrie24 at gmail.com (Alex Henrie)
Date: Thu, 6 Nov 2014 23:32:02 -0700
Subject: [PATCH 2/2] kernel32/tests: Add UTF-7 implicit termination tests.
In-Reply-To: <1415341922-1495-1-git-send-email-alexhenrie24@gmail.com>
References: <1415341922-1495-1-git-send-email-alexhenrie24@gmail.com>
Message-ID: <1415341922-1495-2-git-send-email-alexhenrie24@gmail.com>
---
dlls/kernel32/tests/codepage.c | 53 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 401df3c..71d2ced 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -592,6 +592,59 @@ static void test_utf7_decoding(void)
"i=0x%02x: expected output=%s, got output=%s\n",
i, wine_dbgstr_wn(expected, expected_len + 1), wine_dbgstr_wn(output, expected_len + 1));
}
+
+ /* test which one-byte characters terminate a sequence
+ * also test whether the unfinished byte pair is discarded or not */
+ for (i = 0; i < 256; i++)
+ {
+ sprintf(input, "+B%c+AAA", i);
+
+ memset(output, 0x23, sizeof(output) - sizeof(WCHAR));
+ output[sizeof(output) / sizeof(WCHAR) - 1] = 0;
+
+ len = MultiByteToWideChar(CP_UTF7, 0, input, 8, output, sizeof(output) / sizeof(WCHAR) - 1);
+
+ if (i == '-')
+ {
+ /* explicitly terminates */
+ expected_len = 2;
+ expected[0] = 0;
+ expected[1] = 0;
+ }
+ else if (i <= 0x7F)
+ {
+ if (base64_decoding_table[i] != -1)
+ {
+ /* absorbs the character into the base64 sequence */
+ expected_len = 3;
+ expected[0] = 0x0400 | (base64_decoding_table[i] << 4) | 0x000F;
+ expected[1] = 0x8000;
+ expected[2] = 0;
+ }
+ else
+ {
+ /* implicitly terminates and discards the unfinished byte pair */
+ expected_len = 3;
+ expected[0] = i;
+ expected[1] = 0;
+ expected[2] = 0;
+ }
+ }
+ else
+ {
+ /* implicitly terminates but does not the discard unfinished byte pair */
+ expected_len = 3;
+ expected[0] = i;
+ expected[1] = 0x0400;
+ expected[2] = 0;
+ }
+ expected[expected_len] = 0x2323;
+
+ ok(len == expected_len, "i=0x%02x: expected len=%i, got len=%i\n", i, expected_len, len);
+ ok(memcmp(output, expected, (expected_len + 1) * sizeof(WCHAR)) == 0,
+ "i=0x%02x: expected output=%s, got output=%s\n",
+ i, wine_dbgstr_wn(expected, expected_len + 1), wine_dbgstr_wn(output, expected_len + 1));
+ }
}
static void test_undefined_byte_char(void)
--
2.1.3
From mstefani at redhat.de Fri Nov 7 03:22:01 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Fri, 7 Nov 2014 10:22:01 +0100
Subject: shell32: Simplify check for empty string (PVS-Studio)
Message-ID: <20141107092201.GA22906@redhat.com>
---
dlls/shell32/shellord.c | 2 +-
dlls/shell32/tests/ebrowser.c | 2 +-
dlls/shell32/tests/shlfolder.c | 14 +++++++-------
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c
index 56c9fe9..914dc5a 100644
--- a/dlls/shell32/shellord.c
+++ b/dlls/shell32/shellord.c
@@ -947,7 +947,7 @@ void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
/* buffer size looks good */
ptr += 12; /* get to string */
len = bufused - (ptr-buffer); /* get length of buf remaining */
- if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) {
+ if (ptr[0] && (lstrlenA(ptr) <= len-1)) {
/* appears to be good string */
lstrcpyA(old_lnk_name, link_dir);
PathAppendA(old_lnk_name, ptr);
diff --git a/dlls/shell32/tests/ebrowser.c b/dlls/shell32/tests/ebrowser.c
index 1936cf9..4c255a1 100644
--- a/dlls/shell32/tests/ebrowser.c
+++ b/dlls/shell32/tests/ebrowser.c
@@ -1381,7 +1381,7 @@ static void test_navigation(void)
ok(pSHCreateShellItem != NULL, "pSHCreateShellItem unexpectedly missing.\n");
GetCurrentDirectoryW(MAX_PATH, current_path);
- if(!lstrlenW(current_path))
+ if(!current_path[0])
{
skip("Failed to create test-directory.\n");
return;
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index fc37443..1b457bb 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -81,7 +81,7 @@ static WCHAR *make_wstr(const char *str)
WCHAR *ret;
int len;
- if(!str || strlen(str) == 0)
+ if (!str || !str[0])
return NULL;
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
@@ -2203,7 +2203,7 @@ static void test_SHCreateShellItem(void)
return;
}
- if (!lstrlenA(curdirA))
+ if (!curdirA[0])
{
win_skip("GetCurrentDirectoryA returned empty string, skipping test_SHCreateShellItem\n");
return;
@@ -2780,7 +2780,7 @@ static void test_ShellItemCompare(void)
}
GetCurrentDirectoryW(MAX_PATH, curdirW);
- if(!lstrlenW(curdirW))
+ if (!curdirW[0])
{
skip("Failed to get current directory, skipping.\n");
return;
@@ -4387,7 +4387,7 @@ static void test_GetUIObject(void)
}
GetCurrentDirectoryW(MAX_PATH, path);
- if(!lstrlenW(path))
+ if (!path[0])
{
skip("GetCurrentDirectoryW returned an empty string.\n");
return;
@@ -4989,8 +4989,8 @@ static void test_SHChangeNotify(BOOL test_new_delivery)
exp_data->missing_events = exp_data->notify_count;
SHChangeNotify(exp_data->signal, SHCNF_PATHA | SHCNF_FLUSH,
- strlen(exp_data->path_1) > 0 ? exp_data->path_1 : NULL,
- strlen(exp_data->path_2) > 0 ? exp_data->path_2 : NULL);
+ exp_data->path_1[0] ? exp_data->path_1 : NULL,
+ exp_data->path_2[0] ? exp_data->path_2 : NULL);
do_events();
ok(exp_data->missing_events == 0, "%s: Expected wndproc to be called\n", exp_data->id);
@@ -5045,7 +5045,7 @@ static void test_SHCreateDefaultContextMenu(void)
}
GetCurrentDirectoryW(MAX_PATH, path);
- if(!lstrlenW(path))
+ if (!path[0])
{
skip("GetCurrentDirectoryW returned an empty string.\n");
return;
--
1.9.3
From nsivov at codeweavers.com Fri Nov 7 04:20:39 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Fri, 07 Nov 2014 13:20:39 +0300
Subject: [PATCH 1/4] dwrite: Implement GetMetrics() for DWRITE_FONT_METRICS1
Message-ID: <545C9CF7.9020803@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-dwrite-Implement-GetMetrics-for-DWRITE_FONT_METRICS1.patch
Type: text/x-patch
Size: 13134 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Fri Nov 7 04:21:16 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Fri, 07 Nov 2014 13:21:16 +0300
Subject: [PATCH 2/4] dwrite: Added a basic test for TryGetFontTable()
Message-ID: <545C9D1C.7060407@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-dwrite-Added-a-basic-test-for-TryGetFontTable.patch
Type: text/x-patch
Size: 5727 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Fri Nov 7 04:21:32 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Fri, 07 Nov 2014 13:21:32 +0300
Subject: [PATCH 3/4] dwrite: Respond to IID_IDWriteTextLayout1 too
Message-ID: <545C9D2C.6090605@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-dwrite-Respond-to-IID_IDWriteTextLayout1-too.patch
Type: text/x-patch
Size: 3475 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Fri Nov 7 04:21:53 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Fri, 07 Nov 2014 13:21:53 +0300
Subject: [PATCH 4/4] dwrite: Implement ConvertFontToLOGFONT()
Message-ID: <545C9D41.6000103@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-dwrite-Implement-ConvertFontToLOGFONT.patch
Type: text/x-patch
Size: 10217 bytes
Desc: not available
URL:
From piotr at codeweavers.com Fri Nov 7 06:20:50 2014
From: piotr at codeweavers.com (Piotr Caban)
Date: Fri, 07 Nov 2014 13:20:50 +0100
Subject: msvcp110: Add codecvt::length export
Message-ID: <545CB922.70404@codeweavers.com>
---
dlls/msvcp110/msvcp110.spec | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-msvcp110-Add-codecvt-length-export.txt
Type: text/x-patch
Size: 4414 bytes
Desc: not available
URL:
From hellas at burntcomma.com Fri Nov 7 08:57:45 2014
From: hellas at burntcomma.com (Mark Harmstone)
Date: Fri, 07 Nov 2014 14:57:45 +0000
Subject: [PATCH 1/5] mmdevapi: use struct for endpoint info in GetEndpointIDs
Message-ID: <545CDDE9.9030903@burntcomma.com>
At present, the only information returned by GetEndpointIDs in the audio drivers
is the GUID of each device, and its "id" (actually its name). This patch creates
a new DeviceProps struct, and uses that to communicate the device information
instead. The following patches allow drivers to additionally specify the form
factor and vendor and product IDs of the device, which are used to create a fake
device path.
These patches are needed for the guitar cable detection in the Rocksmith games.
---
dlls/mmdevapi/devenum.c | 21 +++++++++--------
dlls/mmdevapi/mmdevapi.h | 6 ++++-
dlls/winealsa.drv/mmdevdrv.c | 48 +++++++++++++++++++++------------------
dlls/winecoreaudio.drv/mmdevdrv.c | 32 ++++++++++++++------------
dlls/wineoss.drv/mmdevdrv.c | 22 ++++++++++--------
5 files changed, 73 insertions(+), 56 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mmdevapi-use-struct-for-endpoint-info-in-GetEndpoint.patch
Type: text/x-patch
Size: 17745 bytes
Desc: not available
URL:
From hellas at burntcomma.com Fri Nov 7 08:58:11 2014
From: hellas at burntcomma.com (Mark Harmstone)
Date: Fri, 07 Nov 2014 14:58:11 +0000
Subject: [PATCH 2/5] mmdevapi: add property for device form factor
Message-ID: <545CDE03.90504@burntcomma.com>
---
dlls/mmdevapi/devenum.c | 5 +++++
dlls/mmdevapi/mmdevapi.h | 1 +
dlls/winealsa.drv/mmdevdrv.c | 6 ++++++
dlls/winecoreaudio.drv/mmdevdrv.c | 3 +++
dlls/wineoss.drv/mmdevdrv.c | 3 +++
5 files changed, 18 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-mmdevapi-add-property-for-device-form-factor.patch
Type: text/x-patch
Size: 4533 bytes
Desc: not available
URL:
From hellas at burntcomma.com Fri Nov 7 08:58:22 2014
From: hellas at burntcomma.com (Mark Harmstone)
Date: Fri, 07 Nov 2014 14:58:22 +0000
Subject: [PATCH 4/5] mmdevapi: add property for device path
Message-ID: <545CDE0E.4000709@burntcomma.com>
---
dlls/mmdevapi/devenum.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-mmdevapi-add-property-for-device-path.patch
Type: text/x-patch
Size: 3849 bytes
Desc: not available
URL:
From hellas at burntcomma.com Fri Nov 7 08:58:17 2014
From: hellas at burntcomma.com (Mark Harmstone)
Date: Fri, 07 Nov 2014 14:58:17 +0000
Subject: [PATCH 3/5] mmdevapi: add device path variables to DeviceProps struct
Message-ID: <545CDE09.5000900@burntcomma.com>
---
dlls/mmdevapi/devenum.c | 2 ++
dlls/mmdevapi/mmdevapi.h | 8 ++++++++
dlls/winealsa.drv/mmdevdrv.c | 11 +++++++++++
dlls/winecoreaudio.drv/mmdevdrv.c | 9 +++++++++
dlls/wineoss.drv/mmdevdrv.c | 9 +++++++++
5 files changed, 39 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-mmdevapi-add-device-path-variables-to-DeviceProps-st.patch
Type: text/x-patch
Size: 5368 bytes
Desc: not available
URL:
From hellas at burntcomma.com Fri Nov 7 09:13:32 2014
From: hellas at burntcomma.com (Mark Harmstone)
Date: Fri, 07 Nov 2014 15:13:32 +0000
Subject: [PATCH] winealsa: disable channel remapping for capture devices
Message-ID: <545CE19C.1060203@burntcomma.com>
This replaces the malformed previous submission: https://www.winehq.org/pipermail/wine-patches/2014-November/135456.html.
---
dlls/winealsa.drv/mmdevdrv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-winealsa-disable-channel-remapping-for-capture-devic.patch
Type: text/x-patch
Size: 623 bytes
Desc: not available
URL:
From hellas at burntcomma.com Fri Nov 7 08:58:26 2014
From: hellas at burntcomma.com (Mark Harmstone)
Date: Fri, 07 Nov 2014 14:58:26 +0000
Subject: [PATCH 5/5] winealsa: return device path information
Message-ID: <545CDE12.8030507@burntcomma.com>
---
dlls/winealsa.drv/mmdevdrv.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-winealsa-return-device-path-information.patch
Type: text/x-patch
Size: 2276 bytes
Desc: not available
URL:
From jnvsor at gmail.com Fri Nov 7 10:29:13 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Fri, 7 Nov 2014 17:29:13 +0100
Subject: [PATCH v2 1/8] reg: Add system error printing function
Message-ID: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 32 ++++++++++++++++++++++++++++----
programs/reg/reg.h | 1 +
programs/reg/reg.rc | 1 +
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index d299cbf..1ae5746 100644
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -67,6 +67,30 @@ static int reg_message(int msg)
return reg_printfW(formatW, msg_buffer);
}
+static void reg_print_error(LSTATUS error_code)
+{
+ switch (error_code)
+ {
+ case ERROR_SUCCESS:
+ return;
+ case ERROR_BAD_COMMAND:
+ reg_message(STRING_INVALID_CMDLINE);
+ return;
+ default:
+ {
+ static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
+ WCHAR *message = NULL;
+ FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
+ error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *)&message, 0, NULL);
+
+ reg_message(STRING_ERROR);
+ reg_printfW(error_string, error_code, message);
+ LocalFree(message);
+ return;
+ }
+ }
+}
+
static HKEY get_rootkey(LPWSTR key)
{
static const WCHAR szHKLM[] = {'H','K','L','M',0};
@@ -397,7 +421,7 @@ int wmain(int argc, WCHAR *argvW[])
if (argc < 3)
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
@@ -433,7 +457,7 @@ int wmain(int argc, WCHAR *argvW[])
if (argc < 3)
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
@@ -464,7 +488,7 @@ int wmain(int argc, WCHAR *argvW[])
if (argc < 3)
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
@@ -488,7 +512,7 @@ int wmain(int argc, WCHAR *argvW[])
}
else
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
}
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
index 2221647..1c2ae83 100644
--- a/programs/reg/reg.h
+++ b/programs/reg/reg.h
@@ -30,3 +30,4 @@
#define STRING_INVALID_CMDLINE 107
#define STRING_NO_REMOTE 108
#define STRING_CANNOT_FIND 109
+#define STRING_ERROR 110
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 479912b..6183aaa 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -35,4 +35,5 @@ STRINGTABLE
STRING_INVALID_CMDLINE, "Error: Invalid command line parameters\n"
STRING_NO_REMOTE, "Error: Unable to add keys to remote machine\n"
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
+ STRING_ERROR, "Unexpected error: "
}
--
2.1.1
From jnvsor at gmail.com Fri Nov 7 10:29:14 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Fri, 7 Nov 2014 17:29:14 +0100
Subject: [PATCH v2 2/8] reg: Add sane_path function to do preliniary key
validation
In-Reply-To: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
References: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415377760-22769-2-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 25 +++++++++++++++++++++----
programs/reg/reg.rc | 2 +-
2 files changed, 22 insertions(+), 5 deletions(-)
mode change 100644 => 100755 programs/reg/reg.c
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
old mode 100644
new mode 100755
index 1ae5746..c146ce9
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -20,6 +20,8 @@
#include
#include "reg.h"
+#define ERROR_NO_REMOTE 20000
+
static int reg_printfW(const WCHAR *msg, ...)
{
va_list va_args;
@@ -76,6 +78,9 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_BAD_COMMAND:
reg_message(STRING_INVALID_CMDLINE);
return;
+ case ERROR_NO_REMOTE:
+ reg_message(STRING_NO_REMOTE);
+ return;
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -187,6 +192,14 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r
return out_data;
}
+static LSTATUS sane_path(const WCHAR *key)
+{
+ if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
+ return ERROR_NO_REMOTE;
+
+ return ERROR_SUCCESS;
+}
+
static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
{
@@ -194,12 +207,14 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
LPWSTR p;
HKEY root,subkey;
+ LONG err;
reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
- if (key_name[0]=='\\' && key_name[1]=='\\')
+ err = sane_path(key_name);
+ if (err != ERROR_SUCCESS)
{
- reg_message(STRING_NO_REMOTE);
+ reg_print_error(err);
return 1;
}
@@ -264,15 +279,17 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
{
LPWSTR p;
HKEY root,subkey;
+ LONG err;
static const WCHAR stubW[] = {'D','E','L','E','T','E',
' ','-',' ','%','s',' ','%','s',' ','%','d',' ','%','d',' ','%','d','\n'
,0};
reg_printfW(stubW, key_name, value_name, value_empty, value_all, force);
- if (key_name[0]=='\\' && key_name[1]=='\\')
+ err = sane_path(key_name);
+ if (err != ERROR_SUCCESS)
{
- reg_message(STRING_NO_REMOTE);
+ reg_print_error(err);
return 1;
}
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 6183aaa..5fc5a76 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -33,7 +33,7 @@ STRINGTABLE
STRING_SUCCESS, "The operation completed successfully\n"
STRING_INVALID_KEY, "Error: Invalid key name\n"
STRING_INVALID_CMDLINE, "Error: Invalid command line parameters\n"
- STRING_NO_REMOTE, "Error: Unable to add keys to remote machine\n"
+ STRING_NO_REMOTE, "Error: Unable to access remote machine\n"
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
STRING_ERROR, "Unexpected error: "
}
--
2.1.1
From jnvsor at gmail.com Fri Nov 7 10:29:15 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Fri, 7 Nov 2014 17:29:15 +0100
Subject: [PATCH v2 3/8] reg: Add check for multiple backslashes at the end of
the key
In-Reply-To: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
References: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415377760-22769-3-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 8 ++++++++
programs/reg/tests/reg.c | 4 ++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index c146ce9..ff12b3f 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -78,6 +78,9 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_BAD_COMMAND:
reg_message(STRING_INVALID_CMDLINE);
return;
+ case ERROR_INVALID_HANDLE:
+ reg_message(STRING_INVALID_KEY);
+ return;
case ERROR_NO_REMOTE:
reg_message(STRING_NO_REMOTE);
return;
@@ -194,6 +197,11 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r
static LSTATUS sane_path(const WCHAR *key)
{
+ int i = strlenW(key);
+
+ if (i < 3 || (key[i - 1] == '\\' && key[i - 2] == '\\'))
+ return ERROR_INVALID_HANDLE;
+
if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
return ERROR_NO_REMOTE;
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index f93df55..57e0108 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -129,10 +129,10 @@ static void test_add(void)
ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %u\n", r);
err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest2");
- todo_wine ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
+ ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
"got exit code %d\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);
--
2.1.1
From jnvsor at gmail.com Fri Nov 7 10:29:17 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Fri, 7 Nov 2014 17:29:17 +0100
Subject: [PATCH v2 5/8] reg: Add wchar/type conversion functions
In-Reply-To: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
References: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415377760-22769-5-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 77 +++++++++++++++++++++++++++++++++++++----------------
programs/reg/reg.h | 1 +
programs/reg/reg.rc | 1 +
3 files changed, 56 insertions(+), 23 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index 12bb495..72add9b 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -50,6 +50,44 @@ root_rels[] =
{HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
};
+static const WCHAR type_none[] = {'R','E','G','_','N','O','N','E',0};
+static const WCHAR type_sz[] = {'R','E','G','_','S','Z',0};
+static const WCHAR type_expand_sz[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0};
+static const WCHAR type_binary[] = {'R','E','G','_','B','I','N','A','R','Y',0};
+static const WCHAR type_dword[] = {'R','E','G','_','D','W','O','R','D',0};
+static const WCHAR type_dword_le[] = {'R','E','G','_','D','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
+static const WCHAR type_dword_be[] = {'R','E','G','_','D','W','O','R','D','_','B','I','G','_','E','N','D','I','A','N',0};
+static const WCHAR type_link[] = {'R','E','G','_','L','I','N','K',0};
+static const WCHAR type_multi_sz[] = {'R','E','G','_','M','U','L','T','I','_','S','Z',0};
+static const WCHAR type_resource_list[] = {'R','E','G','_','R','E','S','O','U','R','C','E','_','L','I','S','T',0};
+static const WCHAR type_full_resource_descriptor[] = {'R','E','G','_','F','U','L','L','_','R','E','S','O','U','R','C','E','_','D','E','S','C','R','I','P','T','O','R',0};
+static const WCHAR type_resource_requirements_list[] = {'R','E','G','_','R','E','S','O','U','R','C','E','_','R','E','Q','U','I','R','E','M','E','N','T','S','_','L','I','S','T',0};
+static const WCHAR type_qword[] = {'R','E','G','_','Q','W','O','R','D',0};
+static const WCHAR type_qword_le[] = {'R','E','G','_','Q','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
+
+static const struct
+{
+ DWORD type;
+ const WCHAR *name;
+}
+type_rels[] =
+{
+ {REG_NONE, type_none},
+ {REG_SZ, type_sz},
+ {REG_EXPAND_SZ, type_expand_sz},
+ {REG_BINARY, type_binary},
+ {REG_DWORD, type_dword},
+ {REG_DWORD_LITTLE_ENDIAN, type_dword_le},
+ {REG_DWORD_BIG_ENDIAN, type_dword_be},
+ {REG_LINK, type_link},
+ {REG_MULTI_SZ, type_multi_sz},
+ {REG_RESOURCE_LIST, type_resource_list},
+ {REG_FULL_RESOURCE_DESCRIPTOR, type_full_resource_descriptor},
+ {REG_RESOURCE_REQUIREMENTS_LIST, type_resource_requirements_list},
+ {REG_QWORD, type_qword},
+ {REG_QWORD_LITTLE_ENDIAN, type_qword_le},
+};
+
static int reg_printfW(const WCHAR *msg, ...)
{
va_list va_args;
@@ -115,6 +153,9 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_FILE_NOT_FOUND:
reg_message(STRING_CANNOT_FIND);
return;
+ case ERROR_INVALID_DATATYPE:
+ reg_message(STRING_INVALID_TYPE);
+ return;
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -166,30 +207,20 @@ static LSTATUS path_open(const WCHAR *path, HKEY *out, BOOL create)
return RegOpenKeyW(*out, path, out);
}
-static DWORD get_regtype(LPWSTR type)
+static DWORD wchar_get_type(const WCHAR *type_name)
{
- static const WCHAR szREG_SZ[] = {'R','E','G','_','S','Z',0};
- static const WCHAR szREG_MULTI_SZ[] = {'R','E','G','_','M','U','L','T','I','_','S','Z',0};
- static const WCHAR szREG_DWORD_BIG_ENDIAN[] = {'R','E','G','_','D','W','O','R','D','_','B','I','G','_','E','N','D','I','A','N',0};
- static const WCHAR szREG_DWORD[] = {'R','E','G','_','D','W','O','R','D',0};
- static const WCHAR szREG_BINARY[] = {'R','E','G','_','B','I','N','A','R','Y',0};
- static const WCHAR szREG_DWORD_LITTLE_ENDIAN[] = {'R','E','G','_','D','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
- static const WCHAR szREG_NONE[] = {'R','E','G','_','N','O','N','E',0};
- static const WCHAR szREG_EXPAND_SZ[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0};
-
- if (!type)
+ DWORD i;
+
+ if (!type_name)
return REG_SZ;
- if (lstrcmpiW(type,szREG_SZ)==0) return REG_SZ;
- if (lstrcmpiW(type,szREG_DWORD)==0) return REG_DWORD;
- if (lstrcmpiW(type,szREG_MULTI_SZ)==0) return REG_MULTI_SZ;
- if (lstrcmpiW(type,szREG_EXPAND_SZ)==0) return REG_EXPAND_SZ;
- if (lstrcmpiW(type,szREG_DWORD_BIG_ENDIAN)==0) return REG_DWORD_BIG_ENDIAN;
- if (lstrcmpiW(type,szREG_DWORD_LITTLE_ENDIAN)==0) return REG_DWORD_LITTLE_ENDIAN;
- if (lstrcmpiW(type,szREG_BINARY)==0) return REG_BINARY;
- if (lstrcmpiW(type,szREG_NONE)==0) return REG_NONE;
+ for (i = 0; i < ARRAY_SIZE(type_rels); i++)
+ {
+ if (!strcmpiW(type_rels[i].name, type_name))
+ return type_rels[i].type;
+ }
- return -1;
+ return ~0u;
}
static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *reg_count)
@@ -282,11 +313,11 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
}
}
- reg_type = get_regtype(type);
- if (reg_type == -1)
+ reg_type = wchar_get_type(type);
+ if (reg_type == ~0u)
{
RegCloseKey(subkey);
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_INVALID_DATATYPE);
return 1;
}
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
index 1c2ae83..d49d3d8 100644
--- a/programs/reg/reg.h
+++ b/programs/reg/reg.h
@@ -31,3 +31,4 @@
#define STRING_NO_REMOTE 108
#define STRING_CANNOT_FIND 109
#define STRING_ERROR 110
+#define STRING_INVALID_TYPE 111
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 5fc5a76..1c19375 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -36,4 +36,5 @@ STRINGTABLE
STRING_NO_REMOTE, "Error: Unable to access remote machine\n"
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
STRING_ERROR, "Unexpected error: "
+ STRING_INVALID_TYPE, "Error: Invalid type\n"
}
--
2.1.1
From jnvsor at gmail.com Fri Nov 7 10:29:18 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Fri, 7 Nov 2014 17:29:18 +0100
Subject: [PATCH v2 6/8] reg: Add wchar/raw data conversion functions
In-Reply-To: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
References: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415377760-22769-6-git-send-email-jnvsor@gmail.com>
In the case of REG_SZ and the like, it may seem like the functions
perform an unncessary copy of the strings which should already be
in memory ripe for the taking.
However because these functions handle more than one type of data
the calling function needs to be able to free the data afterwards.
Simply returning the input string would result in a function
freeing one of it's own parameters, so we make sure to return
new memory by making a copy.
---
programs/reg/reg.c | 140 +++++++++++++++++++++++++++++++++++++++--------
programs/reg/reg.h | 2 +
programs/reg/reg.rc | 2 +
programs/reg/tests/reg.c | 55 +++++++++----------
4 files changed, 147 insertions(+), 52 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index 72add9b..48ac438 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -18,11 +18,15 @@
#include
#include
+#include
#include "reg.h"
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
#define ERROR_NO_REMOTE 20000
+#define ERROR_NOT_INT_OR_NEG 20001
+
+WINE_DEFAULT_DEBUG_CHANNEL(reg);
static const WCHAR short_hklm[] = {'H','K','L','M',0};
static const WCHAR short_hkcu[] = {'H','K','C','U',0};
@@ -156,6 +160,12 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_INVALID_DATATYPE:
reg_message(STRING_INVALID_TYPE);
return;
+ case ERROR_UNSUPPORTED_TYPE:
+ reg_message(STRING_UNSUPPORTED_TYPE);
+ return;
+ case ERROR_NOT_INT_OR_NEG:
+ reg_message(STRING_NOT_INT_OR_NEG);
+ return;
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -223,43 +233,117 @@ static DWORD wchar_get_type(const WCHAR *type_name)
return ~0u;
}
-static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *reg_count)
+static LSTATUS wchar_get_data(const WCHAR *input, const DWORD type, const WCHAR separator,
+ DWORD *size_out, BYTE **out)
{
- LPBYTE out_data = NULL;
- *reg_count = 0;
+ static const WCHAR empty = 0;
+ DWORD i;
- switch (reg_type)
+ if (!input)
+ input = ∅
+
+ switch (type)
{
case REG_SZ:
+ case REG_EXPAND_SZ:
{
- *reg_count = (lstrlenW(data) + 1) * sizeof(WCHAR);
- out_data = HeapAlloc(GetProcessHeap(),0,*reg_count);
- lstrcpyW((LPWSTR)out_data,data);
- break;
+ i = (strlenW(input) + 1) * sizeof(WCHAR);
+ *out = HeapAlloc(GetProcessHeap(), 0, i);
+ memcpy(*out, input, i);
+ *size_out = i;
+ return ERROR_SUCCESS;
}
case REG_DWORD:
+ case REG_DWORD_BIG_ENDIAN:
+ {
+ WCHAR *temp;
+
+ if (input[0] == '0' && (input[1] == 'x' || input[1] == 'X'))
+ i = strtoulW(input, &temp, 16);
+ else
+ i = strtoulW(input, &temp, 10);
+
+ if (input[0] == '-' || temp[0] || temp == input)
+ return ERROR_NOT_INT_OR_NEG;
+
+ *out = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
+ **(DWORD **) out = i;
+ *size_out = sizeof(DWORD);
+ return ERROR_SUCCESS;
+ }
+ case REG_MULTI_SZ:
{
- LPWSTR rest;
- DWORD val;
- val = strtolW(data, &rest, 0);
- if (rest == data) {
- static const WCHAR nonnumber[] = {'E','r','r','o','r',':',' ','/','d',' ','r','e','q','u','i','r','e','s',' ','n','u','m','b','e','r','.','\n',0};
- reg_printfW(nonnumber);
- break;
+ WCHAR *temp = HeapAlloc(GetProcessHeap(), 0, (strlenW(input) + 1) * sizeof(WCHAR));
+ DWORD p;
+
+ for (i = 0, p = 0; i <= strlenW(input); i++, p++)
+ {
+ /* If this character is the separator, or no separator has been given and these
+ * characters are "\\0", then add a 0 indicating the end of this string */
+ if ( (separator && input[i] == separator) ||
+ (!separator && input[i] == '\\' && input[i + 1] == '0') )
+ {
+ /* If it's the first character or the previous one was a separator */
+ if (!p || temp[p - 1] == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, temp);
+ return ERROR_BAD_COMMAND;
+ }
+ temp[p] = 0;
+
+ if (!separator)
+ i++;
+ }
+ else
+ temp[p] = input[i];
}
- *reg_count = sizeof(DWORD);
- out_data = HeapAlloc(GetProcessHeap(),0,*reg_count);
- ((LPDWORD)out_data)[0] = val;
- break;
+
+ /* Add a 0 to the end if the string wasn't "", and it wasn't
+ * double-0-terminated already (In the case of a trailing separator) */
+ if(p > 1 && temp[p - 2])
+ temp[p++] = 0;
+
+ *size_out = p * sizeof(WCHAR);
+ *out = temp;
+ return ERROR_SUCCESS;
+ }
+ case REG_BINARY:
+ {
+ BYTE *temp = HeapAlloc(GetProcessHeap(), 0, strlenW(input));
+ DWORD p, odd;
+
+ for (i = 0, p = 0; i < strlenW(input); i++, p++)
+ {
+ if (input[i] >= '0' && input[i] <= '9')
+ temp[p] = input[i] - '0';
+ else if (input[i] >= 'a' && input[i] <= 'f')
+ temp[p] = input[i] - 'a' + 10;
+ else if (input[i] >= 'A' && input[i] <= 'F')
+ temp[p] = input[i] - 'A' + 10;
+ else
+ {
+ HeapFree(GetProcessHeap(), 0, temp);
+ return ERROR_BAD_COMMAND;
+ }
+ }
+
+ *out = temp;
+ odd = p & 1;
+ temp += odd;
+ p >>= 1;
+
+ for (i = 0; i < p; i++)
+ temp[i] = (temp[i * 2] << 4) | temp[i * 2 + 1];
+
+ *size_out = p + odd;
+ return ERROR_SUCCESS;
}
default:
{
- static const WCHAR unhandled[] = {'U','n','h','a','n','d','l','e','d',' ','T','y','p','e',' ','0','x','%','x',' ',' ','d','a','t','a',' ','%','s','\n',0};
- reg_printfW(unhandled, reg_type,data);
+ FIXME("Add support for registry type: %u\n", type);
+ return ERROR_UNSUPPORTED_TYPE;
}
}
-
- return out_data;
}
static LSTATUS sane_path(const WCHAR *key)
@@ -322,7 +406,15 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
}
if (data)
- reg_data = get_regdata(data,reg_type,separator,®_count);
+ {
+ err = wchar_get_data(data, reg_type, separator, ®_count, ®_data);
+ if (err != ERROR_SUCCESS)
+ {
+ RegCloseKey(subkey);
+ reg_print_error(err);
+ return 1;
+ }
+ }
RegSetValueExW(subkey,value_name,0,reg_type,reg_data,reg_count);
HeapFree(GetProcessHeap(),0,reg_data);
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
index d49d3d8..f1b398b 100644
--- a/programs/reg/reg.h
+++ b/programs/reg/reg.h
@@ -32,3 +32,5 @@
#define STRING_CANNOT_FIND 109
#define STRING_ERROR 110
#define STRING_INVALID_TYPE 111
+#define STRING_UNSUPPORTED_TYPE 112
+#define STRING_NOT_INT_OR_NEG 113
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 1c19375..47986ab 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -37,4 +37,6 @@ STRINGTABLE
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
STRING_ERROR, "Unexpected error: "
STRING_INVALID_TYPE, "Error: Invalid type\n"
+ STRING_UNSUPPORTED_TYPE, "Error: Unsupported type\n"
+ STRING_NOT_INT_OR_NEG, "Error: This type requires /d to be a positive number\n"
}
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 57e0108..b2894d6 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -183,11 +183,11 @@ static void test_add(void)
/* REG_EXPAND_SZ */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand0 /t REG_EXpand_sz /d \"dead%PATH%beef\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, TODO_REG_SIZE);
+ verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand1 /t REG_EXpand_sz /d \"dead^%PATH^%beef\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, TODO_REG_SIZE);
+ verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -195,11 +195,11 @@ static void test_add(void)
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, TODO_REG_SIZE);
+ verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand3 /f /d \"\"", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, 0);
/* REG_BINARY */
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin0 /f", &r);
@@ -209,14 +209,14 @@ static void test_add(void)
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_BINARY /d deadbeef /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
dword = 0xefbeadde;
- verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), TODO_REG_SIZE);
+ verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin1 /f /d 0xDeAdBeEf", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin2 /f /d x01", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin3 /f /d 01x", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin4 /f /d DeAdBeEf0DD", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -230,8 +230,8 @@ static void test_add(void)
err = RegQueryValueExA(hkey, "bin4", NULL, &type, (void *) (buffer+12), &size);
ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
ok(type == REG_BINARY, "got wrong type %u\n", type);
- todo_wine ok(size == 6, "got wrong size %u\n", size);
- todo_wine ok(memcmp(buffer, buffer+12, 6) == 0 ||
+ ok(size == 6, "got wrong size %u\n", size);
+ ok(memcmp(buffer, buffer+12, 6) == 0 ||
broken(memcmp(buffer+6, buffer+12, 6) == 0 /* WinXP */), "got wrong data\n");
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin5 /d \"\" /f", &r);
@@ -252,11 +252,11 @@ static void test_add(void)
todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %d, expected 0\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword3 /t REG_DWORD /d deadbeef /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword4 /t REG_DWORD /d 123xyz /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword5 /t reg_dword /d 12345678 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -270,22 +270,21 @@ static void test_add(void)
ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
ok(type == REG_DWORD, "got wrong type %d, expected %d\n", type, REG_DWORD);
ok(size == sizeof(DWORD), "got wrong size %d, expected %d\n", size, (int)sizeof(DWORD));
- todo_wine ok(dword == 123 || broken(dword == 0123 /* WinXP */),
+ ok(dword == 123 || broken(dword == 0123 /* WinXP */),
"got wrong data %d, expected %d\n", dword, 123);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword7 /t reg_dword /d 0xabcdefg /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0xdeadbeef /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
dword = 0xdeadbeef;
- verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword),
- (sizeof(long) > sizeof(DWORD)) ? 0 : TODO_REG_DATA);
+ verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword), 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword9 /f /d -1", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword10 /f /d -0x1", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
/* REG_DWORD_LITTLE_ENDIAN */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_LE /t REG_DWORD_LITTLE_ENDIAN /d 456 /f", &r);
@@ -297,7 +296,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE /t REG_DWORD_BIG_ENDIAN /d 456 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
dword = 456;
- verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), TODO_REG_SIZE);
+ verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), 0);
/* REG_DWORD_BIG_ENDIAN is broken in every version of windows. It behaves like
* an ordinary REG_DWORD - that is little endian. GG */
@@ -305,15 +304,15 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi0 /t REG_MULTI_SZ /d \"three\\0little\\0strings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
memcpy(buffer, "three\0little\0strings\0", 22);
- verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, TODO_REG_SIZE);
+ verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi1 /s \"#\" /d \"three#little#strings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, TODO_REG_SIZE);
+ verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi2 /d \"\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, TODO_REG_SIZE);
+ verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -321,7 +320,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, TODO_REG_SIZE);
+ verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
@@ -330,16 +329,16 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi10 /s \"#\" /d \"#a\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi11 /s \"#\" /d \"a#\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
buffer[0]='a'; buffer[1]=0; buffer[2]=0;
- verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, TODO_REG_SIZE);
+ verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, 0);
RegCloseKey(hkey);
--
2.1.1
From jnvsor at gmail.com Fri Nov 7 10:29:16 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Fri, 7 Nov 2014 17:29:16 +0100
Subject: [PATCH v2 4/8] reg: Add path/key conversion functions
In-Reply-To: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
References: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415377760-22769-4-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 146 +++++++++++++++++++++++++++++------------------------
1 file changed, 80 insertions(+), 66 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index ff12b3f..12bb495 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -20,8 +20,36 @@
#include
#include "reg.h"
+#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
+
#define ERROR_NO_REMOTE 20000
+static const WCHAR short_hklm[] = {'H','K','L','M',0};
+static const WCHAR short_hkcu[] = {'H','K','C','U',0};
+static const WCHAR short_hkcr[] = {'H','K','C','R',0};
+static const WCHAR short_hku[] = {'H','K','U',0};
+static const WCHAR short_hkcc[] = {'H','K','C','C',0};
+static const WCHAR long_hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
+static const WCHAR long_hkcu[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
+static const WCHAR long_hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
+static const WCHAR long_hku[] = {'H','K','E','Y','_','U','S','E','R','S',0};
+static const WCHAR long_hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
+
+static const struct
+{
+ HKEY key;
+ const WCHAR *short_name;
+ const WCHAR *long_name;
+}
+root_rels[] =
+{
+ {HKEY_LOCAL_MACHINE, short_hklm, long_hklm},
+ {HKEY_CURRENT_USER, short_hkcu, long_hkcu},
+ {HKEY_CLASSES_ROOT, short_hkcr, long_hkcr},
+ {HKEY_USERS, short_hku, long_hku},
+ {HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
+};
+
static int reg_printfW(const WCHAR *msg, ...)
{
va_list va_args;
@@ -84,6 +112,9 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_NO_REMOTE:
reg_message(STRING_NO_REMOTE);
return;
+ case ERROR_FILE_NOT_FOUND:
+ reg_message(STRING_CANNOT_FIND);
+ return;
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -99,35 +130,40 @@ static void reg_print_error(LSTATUS error_code)
}
}
-static HKEY get_rootkey(LPWSTR key)
+static inline BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name)
{
- static const WCHAR szHKLM[] = {'H','K','L','M',0};
- static const WCHAR szHKEY_LOCAL_MACHINE[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
- static const WCHAR szHKCU[] = {'H','K','C','U',0};
- static const WCHAR szHKEY_CURRENT_USER[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
- static const WCHAR szHKCR[] = {'H','K','C','R',0};
- static const WCHAR szHKEY_CLASSES_ROOT[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
- static const WCHAR szHKU[] = {'H','K','U',0};
- static const WCHAR szHKEY_USERS[] = {'H','K','E','Y','_','U','S','E','R','S',0};
- static const WCHAR szHKCC[] = {'H','K','C','C',0};
- static const WCHAR szHKEY_CURRENT_CONFIG[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
-
- if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKLM,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,18,szHKEY_LOCAL_MACHINE,18)==CSTR_EQUAL)
- return HKEY_LOCAL_MACHINE;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKCU,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,17,szHKEY_CURRENT_USER,17)==CSTR_EQUAL)
- return HKEY_CURRENT_USER;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKCR,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,17,szHKEY_CLASSES_ROOT,17)==CSTR_EQUAL)
- return HKEY_CLASSES_ROOT;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,3,szHKU,3)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,10,szHKEY_USERS,10)==CSTR_EQUAL)
- return HKEY_USERS;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKCC,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,19,szHKEY_CURRENT_CONFIG,19)==CSTR_EQUAL)
- return HKEY_CURRENT_CONFIG;
- else return NULL;
+ DWORD length = strlenW(rootkey_name);
+
+ return (!strncmpiW(input_path, rootkey_name, length) &&
+ (input_path[length] == 0 || input_path[length] == '\\'));
+}
+
+static HKEY path_get_rootkey(const WCHAR *path)
+{
+ DWORD i;
+
+ for (i = 0; i < ARRAY_SIZE(root_rels); i++)
+ {
+ if (path_rootname_cmp(path, root_rels[i].short_name) ||
+ path_rootname_cmp(path, root_rels[i].long_name))
+ return root_rels[i].key;
+ }
+
+ return NULL;
+}
+
+static LSTATUS path_open(const WCHAR *path, HKEY *out, BOOL create)
+{
+ *out = path_get_rootkey(path);
+
+ path = strchrW(path, '\\');
+ if (path)
+ path++;
+
+ if (create)
+ return RegCreateKeyW(*out, path, out);
+ else
+ return RegOpenKeyW(*out, path, out);
}
static DWORD get_regtype(LPWSTR type)
@@ -213,8 +249,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
{
static const WCHAR stubW[] = {'A','D','D',' ','-',' ','%','s',
' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
- LPWSTR p;
- HKEY root,subkey;
+ HKEY subkey;
LONG err;
reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
@@ -226,22 +261,8 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
return 1;
}
- p = strchrW(key_name,'\\');
- if (!p)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
- p++;
-
- root = get_rootkey(key_name);
- if (!root)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
-
- if(RegCreateKeyW(root,p,&subkey)!=ERROR_SUCCESS)
+ err = path_open(key_name, &subkey, TRUE);
+ if(err != ERROR_SUCCESS)
{
reg_message(STRING_INVALID_KEY);
return 1;
@@ -285,8 +306,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
BOOL value_all, BOOL force)
{
- LPWSTR p;
- HKEY root,subkey;
+ HKEY subkey;
LONG err;
static const WCHAR stubW[] = {'D','E','L','E','T','E',
@@ -301,16 +321,8 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
return 1;
}
- p = strchrW(key_name,'\\');
- if (!p)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
- p++;
-
- root = get_rootkey(key_name);
- if (!root)
+ err = path_open(key_name, &subkey, FALSE);
+ if (err != ERROR_SUCCESS)
{
reg_message(STRING_INVALID_KEY);
return 1;
@@ -336,21 +348,23 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
/* Delete subtree only if no /v* option is given */
if (!value_name && !value_empty && !value_all)
{
- if (RegDeleteTreeW(root,p)!=ERROR_SUCCESS)
+ err = RegDeleteTreeA(subkey, NULL);
+ if (err != ERROR_SUCCESS)
{
- reg_message(STRING_CANNOT_FIND);
+ reg_print_error(err);
+ return 1;
+ }
+
+ err = RegDeleteKeyA(subkey, "");
+ if (err != ERROR_SUCCESS)
+ {
+ reg_print_error(err);
return 1;
}
reg_message(STRING_SUCCESS);
return 0;
}
- if(RegOpenKeyW(root,p,&subkey)!=ERROR_SUCCESS)
- {
- reg_message(STRING_CANNOT_FIND);
- return 1;
- }
-
if (value_all)
{
LPWSTR szValue;
--
2.1.1
From jnvsor at gmail.com Fri Nov 7 10:29:20 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Fri, 7 Nov 2014 17:29:20 +0100
Subject: [PATCH v2 8/8] reg: Clean up reg_delete
In-Reply-To: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
References: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415377760-22769-8-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 150 +++++++++++++++++++++++------------------------
programs/reg/tests/reg.c | 2 +-
2 files changed, 74 insertions(+), 78 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index eb62a61..fbc7969 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -425,120 +425,116 @@ error:
return 1;
}
-static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
- BOOL value_all, BOOL force)
+static int reg_delete(const WCHAR *key_name, const WCHAR *value_name, const BOOL value_empty,
+ const BOOL value_all, const BOOL force)
{
- HKEY subkey;
- LONG err;
-
- static const WCHAR stubW[] = {'D','E','L','E','T','E',
- ' ','-',' ','%','s',' ','%','s',' ','%','d',' ','%','d',' ','%','d','\n'
- ,0};
- reg_printfW(stubW, key_name, value_name, value_empty, value_all, force);
-
- err = sane_path(key_name);
+ HKEY key = NULL;
+ LONG err = sane_path(key_name);
if (err != ERROR_SUCCESS)
{
reg_print_error(err);
return 1;
}
- err = path_open(key_name, &subkey, FALSE);
+ err = path_open(key_name, &key, FALSE);
if (err != ERROR_SUCCESS)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
-
- if (value_name && value_empty)
- {
- reg_message(STRING_INVALID_CMDLINE);
- return 1;
- }
+ goto error;
- if (value_empty && value_all)
+ /* Mutually exclusive options */
+ if ((!!value_name + !!value_empty + !!value_all) > 1)
{
- reg_message(STRING_INVALID_CMDLINE);
- return 1;
+ err = ERROR_BAD_COMMAND;
+ goto error;
}
if (!force)
{
- /* FIXME: Prompt for delete */
+ FIXME("Prompt for delete\n");
}
- /* Delete subtree only if no /v* option is given */
- if (!value_name && !value_empty && !value_all)
+ if (value_empty || value_name)
{
- err = RegDeleteTreeA(subkey, NULL);
- if (err != ERROR_SUCCESS)
- {
- reg_print_error(err);
- return 1;
- }
+ if (value_name && value_name[0])
+ err = RegDeleteValueW(key, value_name);
+ else
+ err = RegDeleteValueW(key, NULL);
- err = RegDeleteKeyA(subkey, "");
if (err != ERROR_SUCCESS)
- {
- reg_print_error(err);
- return 1;
- }
- reg_message(STRING_SUCCESS);
- return 0;
+ goto error;
}
-
- if (value_all)
+ else if (value_all)
{
- LPWSTR szValue;
- DWORD maxValue;
- DWORD count;
- LONG rc;
-
- rc = RegQueryInfoKeyW(subkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- &maxValue, NULL, NULL, NULL);
- if (rc != ERROR_SUCCESS)
- {
- /* FIXME: failure */
- RegCloseKey(subkey);
- return 1;
- }
- maxValue++;
- szValue = HeapAlloc(GetProcessHeap(),0,maxValue*sizeof(WCHAR));
+ WCHAR *enum_v_name;
+ DWORD count, max_size, this_size, i = 0, errors = 0;
- while (1)
+ err = RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL, NULL, NULL,
+ &count, &max_size, NULL, NULL, NULL);
+ if (err != ERROR_SUCCESS)
+ goto error;
+
+ enum_v_name = HeapAlloc(GetProcessHeap(), 0, ++max_size * sizeof(WCHAR));
+
+ while (i < count)
{
- count = maxValue;
- rc = RegEnumValueW(subkey, 0, szValue, &count, NULL, NULL, NULL, NULL);
- if (rc == ERROR_SUCCESS)
+ this_size = max_size;
+
+ err = RegEnumValueW(key, i, enum_v_name, &this_size, NULL, NULL, NULL, NULL);
+ if (err != ERROR_SUCCESS)
+ {
+ i++;
+ errors++;
+ reg_print_error(err);
+ continue;
+ }
+
+ err = RegDeleteValueW(key, enum_v_name);
+ if (err != ERROR_SUCCESS)
{
- rc = RegDeleteValueW(subkey, szValue);
- if (rc != ERROR_SUCCESS)
- break;
+ i++;
+ errors++;
+ reg_print_error(err);
+ continue;
}
- else break;
+
+ count--;
}
- if (rc != ERROR_SUCCESS)
+
+ HeapFree(GetProcessHeap(), 0, enum_v_name);
+
+ if (errors)
{
- /* FIXME delete failed */
+ RegCloseKey(key);
+ return 1;
}
}
- else if (value_name)
+ /* Delete subtree only if no /v* option is given */
+ else
{
- if (RegDeleteValueW(subkey,value_name) != ERROR_SUCCESS)
+ if (key == path_get_rootkey(key_name))
{
- RegCloseKey(subkey);
- reg_message(STRING_CANNOT_FIND);
+ /* "This works well enough on native to make you regret you pressed enter" - stefand */
+ FIXME("Deleting a root key is not implemented.\n");
+ RegCloseKey(key);
return 1;
}
- }
- else if (value_empty)
- {
- RegSetValueExW(subkey,NULL,0,REG_SZ,NULL,0);
+
+ err = RegDeleteTreeA(key, NULL);
+ if (err != ERROR_SUCCESS)
+ goto error;
+ err = RegDeleteKeyA(key, "");
+ if (err != ERROR_SUCCESS)
+ goto error;
}
- RegCloseKey(subkey);
+ RegCloseKey(key);
reg_message(STRING_SUCCESS);
return 0;
+
+error:
+ RegCloseKey(key);
+
+ reg_print_error(err);
+ return 1;
}
static int reg_query(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 3e4454e..d08a9c2 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -380,7 +380,7 @@ static void test_delete(void)
run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
err = RegQueryValueExA(hkey, "", NULL, NULL, NULL, NULL);
- todo_wine ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
+ ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
--
2.1.1
From huw at codeweavers.com Fri Nov 7 10:48:49 2014
From: huw at codeweavers.com (Huw Davies)
Date: Fri, 7 Nov 2014 16:48:49 +0000
Subject: user32: Make the combo's listbox a topmost window.
Message-ID: <1415378929-2857-1-git-send-email-huw@codeweavers.com>
---
dlls/user32/combo.c | 2 +-
dlls/user32/tests/combo.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c
index 2aa4424..e891c58 100644
--- a/dlls/user32/combo.c
+++ b/dlls/user32/combo.c
@@ -1059,7 +1059,7 @@ static void CBDropDown( LPHEADCOMBO lphc )
r.bottom = min( r.top + nDroppedHeight, mon_info.rcWork.bottom );
}
- SetWindowPos( lphc->hWndLBox, HWND_TOP, r.left, r.top, r.right - r.left, r.bottom - r.top,
+ SetWindowPos( lphc->hWndLBox, HWND_TOPMOST, r.left, r.top, r.right - r.left, r.bottom - r.top,
SWP_NOACTIVATE | SWP_SHOWWINDOW );
diff --git a/dlls/user32/tests/combo.c b/dlls/user32/tests/combo.c
index d9875ea..b6d5ef6 100644
--- a/dlls/user32/tests/combo.c
+++ b/dlls/user32/tests/combo.c
@@ -537,6 +537,61 @@ static void test_editselection(void)
DestroyWindow(hCombo);
}
+static void test_listbox_styles(DWORD cb_style)
+{
+ BOOL (WINAPI *pGetComboBoxInfo)(HWND, PCOMBOBOXINFO);
+ HWND combo;
+ COMBOBOXINFO info;
+ DWORD style, exstyle, expect_style, expect_exstyle;
+ BOOL ret;
+
+ pGetComboBoxInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo");
+ if (!pGetComboBoxInfo){
+ win_skip("GetComboBoxInfo is not available\n");
+ return;
+ }
+
+ expect_style = WS_CHILD|WS_CLIPSIBLINGS|LBS_COMBOBOX|LBS_HASSTRINGS|LBS_NOTIFY;
+ if (cb_style == CBS_SIMPLE)
+ {
+ expect_style |= WS_VISIBLE;
+ expect_exstyle = WS_EX_CLIENTEDGE;
+ }
+ else
+ {
+ expect_style |= WS_BORDER;
+ expect_exstyle = WS_EX_TOOLWINDOW;
+ }
+
+ combo = build_combo(cb_style);
+ info.cbSize = sizeof(COMBOBOXINFO);
+ SetLastError(0xdeadbeef);
+ ret = pGetComboBoxInfo(combo, &info);
+ ok(ret, "Failed to get combobox info structure.\n");
+
+ style = GetWindowLongW( info.hwndList, GWL_STYLE );
+ exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
+ ok(style == expect_style, "%08x: got %08x\n", cb_style, style);
+ ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
+
+ if (cb_style != CBS_SIMPLE)
+ expect_exstyle |= WS_EX_TOPMOST;
+
+ SendMessageW(combo, CB_SHOWDROPDOWN, TRUE, 0 );
+ style = GetWindowLongW( info.hwndList, GWL_STYLE );
+ exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
+ ok(style == (expect_style | WS_VISIBLE), "%08x: got %08x\n", cb_style, style);
+ ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
+
+ SendMessageW(combo, CB_SHOWDROPDOWN, FALSE, 0 );
+ style = GetWindowLongW( info.hwndList, GWL_STYLE );
+ exstyle = GetWindowLongW( info.hwndList, GWL_EXSTYLE );
+ ok(style == expect_style, "%08x: got %08x\n", cb_style, style);
+ ok(exstyle == expect_exstyle, "%08x: got %08x\n", cb_style, exstyle);
+
+ DestroyWindow(combo);
+}
+
START_TEST(combo)
{
hMainWnd = CreateWindowA("static", "Test", WS_OVERLAPPEDWINDOW, 10, 10, 300, 300, NULL, NULL, NULL, 0);
@@ -551,6 +606,9 @@ START_TEST(combo)
test_changesize(CBS_DROPDOWN);
test_changesize(CBS_DROPDOWNLIST);
test_editselection();
+ test_listbox_styles(CBS_SIMPLE);
+ test_listbox_styles(CBS_DROPDOWN);
+ test_listbox_styles(CBS_DROPDOWNLIST);
DestroyWindow(hMainWnd);
}
--
1.8.0
From jnvsor at gmail.com Fri Nov 7 10:29:19 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Fri, 7 Nov 2014 17:29:19 +0100
Subject: [PATCH v2 7/8] reg: Clean up reg_add
In-Reply-To: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
References: <1415377760-22769-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415377760-22769-7-git-send-email-jnvsor@gmail.com>
You'll notice that bad value input leaves a zombie key after this
call, but this is consistant with native.
---
programs/reg/reg.c | 92 ++++++++++++++++++++++++++----------------------
programs/reg/tests/reg.c | 22 ++++++------
2 files changed, 60 insertions(+), 54 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index 48ac438..eb62a61 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -359,71 +359,70 @@ static LSTATUS sane_path(const WCHAR *key)
return ERROR_SUCCESS;
}
-static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
- WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
+static int reg_add( const WCHAR *key_name, const WCHAR *value_name, const BOOL value_empty,
+ const WCHAR *type, const WCHAR separator, const WCHAR *data,
+ const BOOL force)
{
- static const WCHAR stubW[] = {'A','D','D',' ','-',' ','%','s',
- ' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
- HKEY subkey;
- LONG err;
-
- reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
-
- err = sane_path(key_name);
+ HKEY key = NULL;
+ LONG err = sane_path(key_name);
if (err != ERROR_SUCCESS)
+ goto error;
+
+ if (value_name && value_empty)
{
- reg_print_error(err);
- return 1;
+ err = ERROR_BAD_COMMAND;
+ goto error;
}
- err = path_open(key_name, &subkey, TRUE);
+ err = path_open(key_name, &key, TRUE);
if(err != ERROR_SUCCESS)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
+ goto error;
if (value_name || data)
{
- DWORD reg_type;
- DWORD reg_count = 0;
- BYTE* reg_data = NULL;
+ DWORD size, reg_type;
+ BYTE *data_out;
+
+ if (value_name && !value_name[0])
+ value_name = NULL;
- if (!force)
+ if (type && !type[0])
{
- if (RegQueryValueW(subkey,value_name,NULL,NULL)==ERROR_SUCCESS)
- {
- /* FIXME: Prompt for overwrite */
- }
+ data = NULL;
+ type = NULL;
}
- reg_type = wchar_get_type(type);
- if (reg_type == ~0u)
+ if (!force && RegQueryValueExW(key, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{
- RegCloseKey(subkey);
- reg_print_error(ERROR_INVALID_DATATYPE);
- return 1;
+ FIXME("Prompt for overwrite\n");
}
- if (data)
+ reg_type = wchar_get_type(type);
+ if (reg_type == ~0u)
{
- err = wchar_get_data(data, reg_type, separator, ®_count, ®_data);
- if (err != ERROR_SUCCESS)
- {
- RegCloseKey(subkey);
- reg_print_error(err);
- return 1;
- }
+ err = ERROR_INVALID_DATATYPE;
+ goto error;
}
- RegSetValueExW(subkey,value_name,0,reg_type,reg_data,reg_count);
- HeapFree(GetProcessHeap(),0,reg_data);
+ err = wchar_get_data(data, reg_type, separator, &size, &data_out);
+ if (err != ERROR_SUCCESS)
+ goto error;
+
+ err = RegSetValueExW(key, value_name, 0, reg_type, data_out, size);
+ HeapFree(GetProcessHeap(), 0, data_out);
+ if (err != ERROR_SUCCESS)
+ goto error;
}
- RegCloseKey(subkey);
+ RegCloseKey(key);
reg_message(STRING_SUCCESS);
-
return 0;
+
+error:
+ RegCloseKey(key);
+
+ reg_print_error(err);
+ return 1;
}
static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
@@ -603,7 +602,14 @@ int wmain(int argc, WCHAR *argvW[])
else if (!lstrcmpiW(argvW[i], slashTW))
type = argvW[++i];
else if (!lstrcmpiW(argvW[i], slashSW))
- separator = argvW[++i][0];
+ {
+ if (!argvW[++i][0] || argvW[i][1])
+ {
+ reg_print_error(ERROR_BAD_COMMAND);
+ return 1;
+ }
+ separator = argvW[i][0];
+ }
else if (!lstrcmpiW(argvW[i], slashDW))
data = argvW[++i];
else if (!lstrcmpiW(argvW[i], slashFW))
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index b2894d6..3e4454e 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -110,12 +110,12 @@ static void test_add(void)
/* Test empty type */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\" /d WineTest /f", &r);
- todo_wine ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
+ ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
"got exit code %u\n", r);
if (r == REG_EXIT_SUCCESS)
- todo_wine verify_reg(hkey, "emptyType", REG_SZ, "", 1, 0);
+ verify_reg(hkey, "emptyType", REG_SZ, "", 1, 0);
else
- todo_wine win_skip("broken reg.exe detected\n");
+ win_skip("broken reg.exe detected\n");
/* Test input key formats */
run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
@@ -166,7 +166,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /v test /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_reg(hkey, "test", REG_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "test", REG_SZ, "", 1, 0);
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /d WineTEST /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -174,7 +174,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test2 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_reg(hkey, "test2", REG_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "test2", REG_SZ, "", 1, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test3 /f /d \"\"", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -191,7 +191,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, 0);
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -249,7 +249,7 @@ static void test_add(void)
win_skip("broken reg.exe detected\n");
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword1 /t REG_DWORD /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %d, expected 0\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
@@ -316,18 +316,18 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, TODO_REG_SIZE);
+ verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi6 /s \"\\0\" /d \"three\\0little\\0strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
--
2.1.1
From joachim.priesner at web.de Fri Nov 7 15:39:19 2014
From: joachim.priesner at web.de (Joachim Priesner)
Date: Fri, 7 Nov 2014 22:39:19 +0100
Subject: [1/2] wined3d: Set D3DPMISCCAPS_FOGVERTEXCLAMPED flag in
get_device_caps (resend)
Message-ID: <201411072239.20998.joachim.priesner@web.de>
Wine clamps the oFog output of vertex shaders. Tests for the flag follow
in the second part of this patch.
---
dlls/wined3d/directx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index d428d94..41bad21 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -4148,12 +4148,12 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
WINED3DPMISCCAPS_MASKZ |
WINED3DPMISCCAPS_BLENDOP |
+ WINED3DPMISCCAPS_FOGVERTEXCLAMPED |
WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
/* TODO:
WINED3DPMISCCAPS_NULLREFERENCE
WINED3DPMISCCAPS_FOGANDSPECULARALPHA
- WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
- WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
+ WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS */
if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
--
1.8.4.5
From joachim.priesner at web.de Fri Nov 7 15:39:22 2014
From: joachim.priesner at web.de (Joachim Priesner)
Date: Fri, 7 Nov 2014 22:39:22 +0100
Subject: [2/2] wined3d: Take abs() of vertex z coordinate as FFP fog
coordinate (try 6)
Message-ID: <201411072239.24023.joachim.priesner@web.de>
Take the absolute value of vertex.z as fog coordinate instead of just
the z coordinate. This fixes e.g. fog for applications that use
right-handed projection matrices.
Also test the clamp behavior of the oFog vertex shader output.
Tested on openSuse 13.1 and Windows 8.1 (VMware Player).
Try 6: Move the vertex declaration before the vertex shader code in
the d3d8 test.
---
dlls/d3d8/tests/visual.c | 297 +++++++++++++++++++++++++++++++++++++
dlls/d3d9/tests/visual.c | 360 +++++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 161 ++++++++++++++++++++
dlls/wined3d/glsl_shader.c | 2 +-
4 files changed, 819 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index 163110c..7b9ee5f 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -696,6 +696,302 @@ done:
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void fog_negative_z_test(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000,
+ C_CLAMPED_FOG = 0xdeadbeef /* triggers special codepath when used as middle_color */
+ };
+
+ /* Fill the null-shader entry with the FVF (SetVertexShader is "overloaded" on d3d8). */
+ DWORD vertex_shader[3] = {D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, 0, 0};
+ DWORD pixel_shader[2] = {0, 0};
+ IDirect3D8 *d3d;
+ IDirect3DDevice8 *device;
+ BOOL has_vs_support, has_ps_support, has_table_fog_support;
+ unsigned int i, ps, y;
+ D3DCOLOR color, expected_middle_color;
+ ULONG refcount;
+ D3DCAPS8 caps;
+ HWND window;
+ HRESULT hr;
+
+ static const DWORD vertex_decl[] =
+ {
+ D3DVSD_STREAM(0),
+ D3DVSD_REG(0, D3DVSDT_FLOAT3), /* position, v0 */
+ D3DVSD_REG(1, D3DVSDT_D3DCOLOR), /* diffuse color, v1 */
+ D3DVSD_REG(2, D3DVSDT_D3DCOLOR), /* specular color, v2 */
+ D3DVSD_CONST(0, 1), 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ D3DVSD_END()
+ };
+
+ /* Basic vertex shader without fog computation ("non foggy") */
+ static const DWORD vertex_shader_code1[] =
+ {
+ 0xfffe0100, /* vs_1_0 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"). Outputs the z coordinate of the vertex
+ * as its fog intensity value. */
+ static const DWORD vertex_shader_code2[] =
+ {
+ 0xfffe0100, /* vs_1_0 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x00000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic pixel shader */
+ static const DWORD pixel_shader_code[] =
+ {
+ 0xffff0101, /* ps_1_1 */
+ 0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
+ 0x0000ffff
+ };
+
+ static const struct
+ {
+ struct vec3 position;
+ DWORD diffuse;
+ DWORD specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+ static const struct
+ {
+ int vshader;
+ D3DFOGMODE vfog;
+ D3DFOGMODE tfog;
+ DWORD color_left;
+ DWORD color_middle_top;
+ DWORD color_middle_bottom;
+ DWORD color_right;
+ }
+ test_data[] =
+ {
+ /* Using z-based fog, the bottom quad should have a gradient UNFOGGED->FOGGED
+ * for table fog, and be completely fogged for vertex fog.
+ * When the fog coordinate returned by the vertex shader is used instead,
+ * the result is a gradient FOGGED->UNFOGGED. */
+
+ /* No vertex shader */
+ {0, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {0, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader without vertex fog computation */
+ {1, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader with vertex fog computation.
+ * As drivers inconsistently clamp or don't clamp the oFog output of vertex shaders,
+ * the special value C_CLAMPED_FOG allows both C_HALF_FOGGED (clamped) and C_FOGGED. */
+ {2, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {2, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1.
+ * Note that for the tests with vertex shaders, this matrix is hard-coded in the shaders. */
+ static const D3DMATRIX proj_mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f
+ }}};
+
+ window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate8(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps (%#x)\n", hr);
+
+ has_table_fog_support = caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests\n");
+
+ has_ps_support = caps.PixelShaderVersion >= D3DPS_VERSION(1, 1);
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice8_CreatePixelShader(device, pixel_shader_code, &pixel_shader[1]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No ps_1_1 support, skipping some fog tests\n");
+ }
+
+ has_vs_support = caps.VertexShaderVersion >= D3DVS_VERSION(1, 0);
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice8_CreateVertexShader(device, vertex_decl, vertex_shader_code1, &vertex_shader[1], 0);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_CreateVertexShader(device, vertex_decl, vertex_shader_code2, &vertex_shader[2], 0);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No vs_1_0 support, skipping some fog tests\n");
+ }
+
+ /* Setup initial states: No depth test, no lighting, fog on, fog color */
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Turning off depth test failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Turning off lighting failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Turning on fog calculations failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Setting fog color failed (%#x)\n", hr);
+
+ hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform (%#x)\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].vshader != 0 && !vertex_shader[test_data[i].vshader])
+ continue;
+ if (test_data[i].tfog != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ hr = IDirect3DDevice8_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
+ ok(SUCCEEDED(hr), "SetVertexShader failed (%#x)\n", hr);
+
+ for (ps = 0; ps < sizeof(pixel_shader)/sizeof(pixel_shader[0]); ps++)
+ {
+ if (ps != 0 && !pixel_shader[ps])
+ continue;
+
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice8_SetPixelShader(device, pixel_shader[ps]);
+ ok(SUCCEEDED(hr), "SetPixelShader failed (%#x)\n", hr);
+ }
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, test_data[i].vfog);
+ ok(SUCCEEDED(hr), "Setting fog vertex mode to %d failed (%#x)\n", test_data[i].vfog, hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, test_data[i].tfog);
+ ok(SUCCEEDED(hr), "Setting fog table mode to %d failed (%#x)\n", test_data[i].tfog, hr);
+
+ hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Clear failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_BeginScene(device);
+ ok(SUCCEEDED(hr), "BeginScene failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &top_quad[0], sizeof(top_quad[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_1[0], sizeof(bottom_quad_1[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_2[0], sizeof(bottom_quad_2[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_EndScene(device);
+ ok(SUCCEEDED(hr), "EndScene failed (%#x)\n", hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = getPixelColor(device, 2, y);
+ ok(color_match(color, test_data[i].color_left, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got left color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_left);
+ color = getPixelColor(device, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ if (expected_middle_color == C_CLAMPED_FOG)
+ {
+ ok(color_match(color, C_HALF_FOGGED, 13) || color_match(color, C_FOGGED, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got middle color %08x, "
+ "expected %08x+-5%% or %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, C_HALF_FOGGED, C_FOGGED);
+ }
+ else
+ {
+ ok(color_match(color, expected_middle_color, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got middle color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, expected_middle_color);
+ }
+ color = getPixelColor(device, 638, y);
+ ok(color_match(color, test_data[i].color_right, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got right color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_right);
+ }
+
+ hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Present failed (%#x)\n", hr);
+ }
+ }
+ for (i = 0; i < sizeof(vertex_shader)/sizeof(vertex_shader[0]); i++)
+ if (vertex_shader[i])
+ IDirect3DDevice8_DeleteVertexShader(device, vertex_shader[i]);
+ for (i = 0; i < sizeof(pixel_shader)/sizeof(pixel_shader[0]); i++)
+ if (pixel_shader[i])
+ IDirect3DDevice8_DeletePixelShader(device, pixel_shader[i]);
+ refcount = IDirect3DDevice8_Release(device);
+ ok(!refcount, "Device has %u references left\n", refcount);
+done:
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+}
+
/* This tests fog in combination with shaders.
* What's tested: linear fog (vertex and table) with pixel shader
* linear table fog with non foggy vertex shader
@@ -5092,6 +5388,7 @@ START_TEST(visual)
offscreen_test();
alpha_test();
test_scalar_instructions();
+ fog_negative_z_test();
fog_with_shader_test();
cnd_test();
p8_texture_test();
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 117c8eb..f8ac3a6 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -1825,6 +1825,365 @@ done:
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void fog_negative_z_test(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000,
+ C_CLAMPED_FOG = 0xdeadbeef /* triggers special codepath when used as middle_color */
+ };
+
+ IDirect3DVertexShader9 *vertex_shader[4] = {NULL, NULL, NULL, NULL};
+ IDirect3DPixelShader9 *pixel_shader[3] = {NULL, NULL, NULL};
+ IDirect3DVertexDeclaration9 *vertex_declaration = NULL;
+ IDirect3DDevice9 *device;
+ BOOL has_vs_support, has_ps_support, has_table_fog_support, is_fog_vertex_clamped;
+ unsigned int i, ps, y;
+ IDirect3D9 *d3d;
+ ULONG refcount;
+ D3DCAPS9 caps;
+ DWORD color, expected_middle_color;
+ HWND window;
+ HRESULT hr;
+
+ /* Basic vertex shader without fog computation ("non foggy") */
+ static const DWORD vertex_shader_code1[] =
+ {
+ 0xfffe0101, /* vs_1_1 */
+ 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0000001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"). Outputs the z coordinate of the vertex
+ * as its fog intensity value. */
+ static const DWORD vertex_shader_code2[] =
+ {
+ 0xfffe0101, /* vs_1_1 */
+ 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0000001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x00000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"), vs_2_0 */
+ static const DWORD vertex_shader_code3[] =
+ {
+ 0xfffe0200, /* vs_2_0 */
+ 0x05000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0200001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x03000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x03000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x02000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x02000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x02000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic pixel shader */
+ static const DWORD pixel_shader_code[] =
+ {
+ 0xffff0101, /* ps_1_1 */
+ 0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
+ 0x0000ffff
+ };
+ static const DWORD pixel_shader_code2[] =
+ {
+ 0xffff0200, /* ps_2_0 */
+ 0x0200001f, 0x80000000, 0x900f0000, /* dcl v0 */
+ 0x02000001, 0x800f0800, 0x90e40000, /* mov oC0, v0 */
+ 0x0000ffff
+ };
+ static const struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+
+ static const D3DVERTEXELEMENT9 decl_elements[] =
+ {
+ {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
+ {0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, /* diffuse */
+ {0, 16, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, /* specular */
+ D3DDECL_END()
+ };
+ static const struct
+ {
+ int vshader;
+ D3DFOGMODE vfog;
+ D3DFOGMODE tfog;
+ DWORD color_left;
+ DWORD color_middle_top;
+ DWORD color_middle_bottom;
+ DWORD color_right;
+ }
+ test_data[] =
+ {
+ /* Using z-based fog, the bottom quad should have a gradient UNFOGGED->FOGGED
+ * for table fog, and be completely fogged for vertex fog.
+ * When the fog coordinate returned by the vertex shader is used instead,
+ * the result is a gradient FOGGED->UNFOGGED in the right half of the screen.
+ *
+ * C_CLAMPED_FOG will be replaced by the correct expected value based on
+ * the value of D3DPMISCCAPS_FOGVERTEXCLAMPED. If the driver clamps the oFog
+ * output of vertex shaders, it should be C_HALF_FOGGED, else C_FOGGED. */
+
+ /* No vertex shader */
+ {0, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {0, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader without vertex fog computation */
+ {1, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader vs_1_1 with vertex fog computation */
+ {2, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {2, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+
+ /* Vertex shader vs_2_0 with vertex fog computation */
+ {3, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {3, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {3, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {3, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1.
+ * Note that for the tests with vertex shaders, this matrix is hard-coded in the shaders. */
+ static const D3DMATRIX proj_mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f,
+ }}};
+
+ window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate9(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps (%#x)\n", hr);
+
+ has_table_fog_support = caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests\n");
+
+ has_vs_support = caps.VertexShaderVersion >= D3DVS_VERSION(1, 1);
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code1, &vertex_shader[1]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code2, &vertex_shader[2]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+
+ if (caps.VertexShaderVersion >= D3DVS_VERSION(2, 0))
+ {
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code3, &vertex_shader[3]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No vs_2_0 support, skipping some fog tests\n");
+ }
+ }
+ else
+ {
+ skip("No vs_1_1 support, skipping some fog tests\n");
+ }
+
+ has_ps_support = caps.PixelShaderVersion >= D3DPS_VERSION(1, 1);
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code, &pixel_shader[1]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+
+ if (caps.PixelShaderVersion >= D3DPS_VERSION(2, 0))
+ {
+ hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code2, &pixel_shader[2]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No ps_2_0 support, skipping some fog tests\n");
+ }
+ }
+ else
+ {
+ skip("No ps_1_1 support, skipping some fog tests\n");
+ }
+
+ is_fog_vertex_clamped = caps.PrimitiveMiscCaps & D3DPMISCCAPS_FOGVERTEXCLAMPED;
+
+ hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
+ ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%#x)\n", hr);
+
+ /* Setup initial states: No depth test, no lighting, fog on, fog color */
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Turning off depth test failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Turning off lighting failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Turning on fog calculations failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Setting fog color failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
+ ok(SUCCEEDED(hr), "SetVertexDeclaration failed (%#x)\n", hr);
+
+ hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform (%#x)\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].vshader != 0 && !vertex_shader[test_data[i].vshader])
+ continue;
+ if (test_data[i].tfog != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice9_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
+ ok(SUCCEEDED(hr), "SetVertexShader failed (%#x)\n", hr);
+ }
+
+ for (ps = 0; ps < sizeof(pixel_shader)/sizeof(pixel_shader[0]); ps++)
+ {
+ if (ps != 0 && !pixel_shader[ps])
+ continue;
+
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice9_SetPixelShader(device, pixel_shader[ps]);
+ ok(SUCCEEDED(hr), "SetPixelShader failed (%#x)\n", hr);
+ }
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, test_data[i].vfog);
+ ok(SUCCEEDED(hr), "Setting fog vertex mode to %d failed (%#x)\n", test_data[i].vfog, hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, test_data[i].tfog);
+ ok(SUCCEEDED(hr), "Setting fog table mode to %d failed (%#x)\n", test_data[i].tfog, hr);
+
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Clear failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_BeginScene(device);
+ ok(SUCCEEDED(hr), "BeginScene failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &top_quad[0], sizeof(top_quad[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_1[0], sizeof(bottom_quad_1[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_2[0], sizeof(bottom_quad_2[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_EndScene(device);
+ ok(SUCCEEDED(hr), "EndScene failed (%#x)\n", hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = getPixelColor(device, 2, y);
+ ok(color_match(color, test_data[i].color_left, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got left color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_left);
+ color = getPixelColor(device, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ if (expected_middle_color == C_CLAMPED_FOG)
+ {
+ expected_middle_color = is_fog_vertex_clamped ? C_HALF_FOGGED : C_FOGGED;
+ }
+ ok(color_match(color, expected_middle_color, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got middle color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, expected_middle_color);
+ color = getPixelColor(device, 638, y);
+ ok(color_match(color, test_data[i].color_right, 13),
+ "fog vs%i ps%i fvm%i ftm%i, y=%i: got right color %08x, expected %08x+-5%%\n",
+ test_data[i].vshader, ps, test_data[i].vfog, test_data[i].tfog, y,
+ color, test_data[i].color_right);
+
+ }
+
+ hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Present failed (%#x)\n", hr);
+ }
+ }
+
+ for (i = 0; i < sizeof(vertex_shader)/sizeof(vertex_shader[0]); i++)
+ if (vertex_shader[i])
+ IDirect3DVertexShader9_Release(vertex_shader[i]);
+ for (i = 0; i < sizeof(pixel_shader)/sizeof(pixel_shader[0]); i++)
+ if (pixel_shader[i])
+ IDirect3DPixelShader9_Release(pixel_shader[i]);
+ IDirect3DVertexDeclaration9_Release(vertex_declaration);
+ refcount = IDirect3DDevice9_Release(device);
+ ok(!refcount, "Device has %u references left\n", refcount);
+done:
+ IDirect3D9_Release(d3d);
+ DestroyWindow(window);
+}
+
/* This test tests fog in combination with shaders.
* What's tested: linear fog (vertex and table) with pixel shader
* linear table fog with non foggy vertex shader
@@ -16729,6 +17088,7 @@ START_TEST(visual)
test_vshader_input();
test_vshader_float16();
stream_test();
+ fog_negative_z_test();
fog_with_shader_test();
texbem_test();
texdepth_test();
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index ec50fb8..4e999f7 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -3384,6 +3384,166 @@ static void test_fog_special(void)
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void test_fog_negative_z(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000
+ };
+
+ D3DCOLOR color, expected_middle_color;
+ HRESULT hr;
+ ULONG refcount;
+ BOOL has_table_fog_support;
+ unsigned int i, y;
+ HWND window;
+ IDirect3DDevice7 *device;
+ IDirectDrawSurface7 *rt;
+ D3DDEVICEDESC7 caps;
+
+ static struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+ static const struct
+ {
+ DWORD vertexmode, tablemode;
+ D3DCOLOR color_left, color_middle_top, color_middle_bottom, color_right;
+ }
+ test_data[] =
+ {
+ {D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1. */
+ static D3DMATRIX proj_mat =
+ {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f
+ };
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+
+ if (!(device = create_device(window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create a 3D device, skipping test.\n");
+ DestroyWindow(window);
+ return;
+ }
+
+ memset(&caps, 0, sizeof(caps));
+ hr = IDirect3DDevice7_GetCaps(device, &caps);
+ ok(SUCCEEDED(hr), "IDirect3DDevice7_GetCaps failed, hr %#x.\n", hr);
+
+ has_table_fog_support = caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests.\n");
+
+ hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
+ ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Failed to enable fog, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Failed to set fog color, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].tablemode != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Failed to clear render target, i=%d, hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, test_data[i].vertexmode);
+ ok(SUCCEEDED(hr), "Failed to set fog vertex mode, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, test_data[i].tablemode);
+ ok(SUCCEEDED(hr), "Failed to set fog table mode, i=%d, hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice7_BeginScene(device);
+ ok(SUCCEEDED(hr), "Failed to begin scene, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, top_quad, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, bottom_quad_1, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, bottom_quad_2, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_EndScene(device);
+ ok(SUCCEEDED(hr), "Failed to end scene, i=%d, hr %#x.\n", i, hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = get_surface_color(rt, 2, y);
+ ok(compare_color(color, test_data[i].color_left, 13),
+ "fog fvm%i ftm%i y=%i: got left color %08x, expected %08x+-5%%.\n",
+ test_data[i].vertexmode, test_data[i].tablemode, color, y,
+ test_data[i].color_left);
+ color = get_surface_color(rt, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ ok(compare_color(color, expected_middle_color, 13),
+ "fog fvm%i ftm%i y=%i: got middle color %08x, expected %08x+-5%%.\n",
+ test_data[i].vertexmode, test_data[i].tablemode, y,
+ color, expected_middle_color);
+ color = get_surface_color(rt, 638, y);
+ ok(compare_color(color, test_data[i].color_right, 13),
+ "fog fvm%i ftm%i y=%i: got right color %08x, expected %08x+-5%%.\n",
+ test_data[i].vertexmode, test_data[i].tablemode, y,
+ color, test_data[i].color_right);
+ }
+ }
+
+ IDirectDrawSurface7_Release(rt);
+ refcount = IDirect3DDevice7_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
static void test_lighting_interface_versions(void)
{
IDirect3DDevice7 *device;
@@ -7671,6 +7831,7 @@ START_TEST(ddraw7)
test_clear_rect_count();
test_coop_level_versions();
test_fog_special();
+ test_fog_negative_z();
test_lighting_interface_versions();
test_coop_level_activateapp();
test_texturemanage();
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 7379ba2..907e895 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -5005,7 +5005,7 @@ static GLhandleARB shader_glsl_generate_ffp_vertex_shader(struct wined3d_shader_
/* Need to undo the [0.0 - 1.0] -> [-1.0 - 1.0] transformation from D3D to GL coordinates. */
shader_addline(buffer, "gl_FogFragCoord = gl_Position.z * 0.5 + 0.5;\n");
else
- shader_addline(buffer, "gl_FogFragCoord = ec_pos.z;\n");
+ shader_addline(buffer, "gl_FogFragCoord = abs(ec_pos.z);\n");
break;
default:
--
1.8.4.5
From mengshuaicalendr at gmail.com Fri Nov 7 23:00:51 2014
From: mengshuaicalendr at gmail.com (Shuai Meng)
Date: Sat, 08 Nov 2014 13:00:51 +0800
Subject: [PATCH] vbscript: Implemented String(try 4)
Message-ID: <545DA383.8030802@gmail.com>
Change log:
removed codes that handled VT_ARRAY|VT_BYREF|VT_VARIANT case
separately.
---
dlls/vbscript/global.c | 61
+++++++++++++++++++++++++++++++++++++++++++--
dlls/vbscript/tests/api.vbs | 53 +++++++++++++++++++++++++++++++++++++++
dlls/vbscript/vbscript.h | 1 +
3 files changed, 113 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-vbscript-Implemented-String.txt
Type: text/x-patch
Size: 6256 bytes
Desc: not available
URL:
From jnvsor at gmail.com Sat Nov 8 04:26:42 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Sat, 8 Nov 2014 11:26:42 +0100
Subject: [PATCH v3 01/10] reg/tests: Test for integer overflow
Message-ID: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
---
programs/reg/tests/reg.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index f93df55..9b1881e 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -287,6 +287,9 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword10 /f /d -0x1", &r);
todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0x01ffffffff /f", &r);
+ todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %d\n", r);
+
/* REG_DWORD_LITTLE_ENDIAN */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_LE /t REG_DWORD_LITTLE_ENDIAN /d 456 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
--
2.1.3
From jnvsor at gmail.com Sat Nov 8 04:26:44 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Sat, 8 Nov 2014 11:26:44 +0100
Subject: [PATCH v3 03/10] reg: Add system error printing function
In-Reply-To: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
References: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415442411-14059-3-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 32 ++++++++++++++++++++++++++++----
programs/reg/reg.h | 1 +
programs/reg/reg.rc | 1 +
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index d299cbf..1ae5746 100644
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -67,6 +67,30 @@ static int reg_message(int msg)
return reg_printfW(formatW, msg_buffer);
}
+static void reg_print_error(LSTATUS error_code)
+{
+ switch (error_code)
+ {
+ case ERROR_SUCCESS:
+ return;
+ case ERROR_BAD_COMMAND:
+ reg_message(STRING_INVALID_CMDLINE);
+ return;
+ default:
+ {
+ static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
+ WCHAR *message = NULL;
+ FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
+ error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *)&message, 0, NULL);
+
+ reg_message(STRING_ERROR);
+ reg_printfW(error_string, error_code, message);
+ LocalFree(message);
+ return;
+ }
+ }
+}
+
static HKEY get_rootkey(LPWSTR key)
{
static const WCHAR szHKLM[] = {'H','K','L','M',0};
@@ -397,7 +421,7 @@ int wmain(int argc, WCHAR *argvW[])
if (argc < 3)
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
@@ -433,7 +457,7 @@ int wmain(int argc, WCHAR *argvW[])
if (argc < 3)
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
@@ -464,7 +488,7 @@ int wmain(int argc, WCHAR *argvW[])
if (argc < 3)
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
@@ -488,7 +512,7 @@ int wmain(int argc, WCHAR *argvW[])
}
else
{
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_BAD_COMMAND);
return 1;
}
}
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
index 2221647..1c2ae83 100644
--- a/programs/reg/reg.h
+++ b/programs/reg/reg.h
@@ -30,3 +30,4 @@
#define STRING_INVALID_CMDLINE 107
#define STRING_NO_REMOTE 108
#define STRING_CANNOT_FIND 109
+#define STRING_ERROR 110
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 479912b..6183aaa 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -35,4 +35,5 @@ STRINGTABLE
STRING_INVALID_CMDLINE, "Error: Invalid command line parameters\n"
STRING_NO_REMOTE, "Error: Unable to add keys to remote machine\n"
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
+ STRING_ERROR, "Unexpected error: "
}
--
2.1.3
From jnvsor at gmail.com Sat Nov 8 04:26:45 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Sat, 8 Nov 2014 11:26:45 +0100
Subject: [PATCH v3 04/10] reg: Add sane_path function to do preliniary key
validation
In-Reply-To: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
References: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415442411-14059-4-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 25 +++++++++++++++++++++----
programs/reg/reg.rc | 2 +-
2 files changed, 22 insertions(+), 5 deletions(-)
mode change 100644 => 100755 programs/reg/reg.c
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
old mode 100644
new mode 100755
index 1ae5746..c146ce9
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -20,6 +20,8 @@
#include
#include "reg.h"
+#define ERROR_NO_REMOTE 20000
+
static int reg_printfW(const WCHAR *msg, ...)
{
va_list va_args;
@@ -76,6 +78,9 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_BAD_COMMAND:
reg_message(STRING_INVALID_CMDLINE);
return;
+ case ERROR_NO_REMOTE:
+ reg_message(STRING_NO_REMOTE);
+ return;
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -187,6 +192,14 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r
return out_data;
}
+static LSTATUS sane_path(const WCHAR *key)
+{
+ if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
+ return ERROR_NO_REMOTE;
+
+ return ERROR_SUCCESS;
+}
+
static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
{
@@ -194,12 +207,14 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
LPWSTR p;
HKEY root,subkey;
+ LONG err;
reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
- if (key_name[0]=='\\' && key_name[1]=='\\')
+ err = sane_path(key_name);
+ if (err != ERROR_SUCCESS)
{
- reg_message(STRING_NO_REMOTE);
+ reg_print_error(err);
return 1;
}
@@ -264,15 +279,17 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
{
LPWSTR p;
HKEY root,subkey;
+ LONG err;
static const WCHAR stubW[] = {'D','E','L','E','T','E',
' ','-',' ','%','s',' ','%','s',' ','%','d',' ','%','d',' ','%','d','\n'
,0};
reg_printfW(stubW, key_name, value_name, value_empty, value_all, force);
- if (key_name[0]=='\\' && key_name[1]=='\\')
+ err = sane_path(key_name);
+ if (err != ERROR_SUCCESS)
{
- reg_message(STRING_NO_REMOTE);
+ reg_print_error(err);
return 1;
}
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 6183aaa..5fc5a76 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -33,7 +33,7 @@ STRINGTABLE
STRING_SUCCESS, "The operation completed successfully\n"
STRING_INVALID_KEY, "Error: Invalid key name\n"
STRING_INVALID_CMDLINE, "Error: Invalid command line parameters\n"
- STRING_NO_REMOTE, "Error: Unable to add keys to remote machine\n"
+ STRING_NO_REMOTE, "Error: Unable to access remote machine\n"
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
STRING_ERROR, "Unexpected error: "
}
--
2.1.3
From jnvsor at gmail.com Sat Nov 8 04:26:46 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Sat, 8 Nov 2014 11:26:46 +0100
Subject: [PATCH v3 05/10] reg: Add check for multiple backslashes at the end
of the key
In-Reply-To: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
References: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415442411-14059-5-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 8 ++++++++
programs/reg/tests/reg.c | 4 ++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index c146ce9..ff12b3f 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -78,6 +78,9 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_BAD_COMMAND:
reg_message(STRING_INVALID_CMDLINE);
return;
+ case ERROR_INVALID_HANDLE:
+ reg_message(STRING_INVALID_KEY);
+ return;
case ERROR_NO_REMOTE:
reg_message(STRING_NO_REMOTE);
return;
@@ -194,6 +197,11 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r
static LSTATUS sane_path(const WCHAR *key)
{
+ int i = strlenW(key);
+
+ if (i < 3 || (key[i - 1] == '\\' && key[i - 2] == '\\'))
+ return ERROR_INVALID_HANDLE;
+
if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
return ERROR_NO_REMOTE;
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 2d86d83..9420b5c 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -129,10 +129,10 @@ static void test_add(void)
ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %u\n", r);
err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest2");
- todo_wine ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
+ ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
"got exit code %d\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);
--
2.1.3
From jnvsor at gmail.com Sat Nov 8 04:26:49 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Sat, 8 Nov 2014 11:26:49 +0100
Subject: [PATCH v3 08/10] reg: Add wchar/raw data conversion functions
In-Reply-To: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
References: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415442411-14059-8-git-send-email-jnvsor@gmail.com>
In the case of REG_SZ and the like, it may seem like the functions
perform an unncessary copy of the strings which should already be
in memory ripe for the taking.
However because these functions handle more than one type of data
the calling function needs to be able to free the data afterwards.
Simply returning the input string would result in a function
freeing one of it's own parameters, so we make sure to return
new memory by making a copy.
---
programs/reg/reg.c | 151 +++++++++++++++++++++++++++++++++++++++--------
programs/reg/reg.h | 2 +
programs/reg/reg.rc | 2 +
programs/reg/tests/reg.c | 59 +++++++++---------
4 files changed, 160 insertions(+), 54 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index a5a619e..bcbcdaa 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -18,11 +18,16 @@
#include
#include
+#include
#include "reg.h"
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
#define ERROR_NO_REMOTE 20000
+#define ERROR_NEGATIVE 20001
+#define ERROR_NOT_NUMBER 20002
+
+WINE_DEFAULT_DEBUG_CHANNEL(reg);
static const WCHAR short_hklm[] = {'H','K','L','M',0};
static const WCHAR short_hkcu[] = {'H','K','C','U',0};
@@ -144,6 +149,13 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_UNSUPPORTED_TYPE:
reg_message(STRING_UNSUPPORTED_TYPE);
return;
+ case ERROR_NEGATIVE:
+ case ERROR_NOT_NUMBER:
+ reg_message(STRING_NOT_INT_OR_NEG);
+ return;
+ case ERROR_ARITHMETIC_OVERFLOW:
+ reg_message(STRING_ERANGE);
+ return;
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -211,43 +223,126 @@ static DWORD wchar_get_type(const WCHAR *type_name)
return ~0u;
}
-static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *reg_count)
+static LSTATUS wchar_get_data(const WCHAR *input, const DWORD type, const WCHAR separator,
+ DWORD *size_out, BYTE **out)
{
- LPBYTE out_data = NULL;
- *reg_count = 0;
+ static const WCHAR empty = 0;
+ DWORD i;
- switch (reg_type)
+ if (!input)
+ input = ∅
+
+ switch (type)
{
+ case REG_NONE:
case REG_SZ:
+ case REG_EXPAND_SZ:
{
- *reg_count = (lstrlenW(data) + 1) * sizeof(WCHAR);
- out_data = HeapAlloc(GetProcessHeap(),0,*reg_count);
- lstrcpyW((LPWSTR)out_data,data);
- break;
+ i = (strlenW(input) + 1) * sizeof(WCHAR);
+ *out = HeapAlloc(GetProcessHeap(), 0, i);
+ memcpy(*out, input, i);
+ *size_out = i;
+ return ERROR_SUCCESS;
}
case REG_DWORD:
+ case REG_DWORD_BIG_ENDIAN:
+ {
+ WCHAR *temp;
+
+ if (input[0] == '0' && (input[1] == 'x' || input[1] == 'X'))
+ i = strtoulW(input, &temp, 16);
+ else
+ i = strtoulW(input, &temp, 10);
+
+ if (input[0] == '-')
+ return ERROR_NEGATIVE;
+
+ if (temp[0] || temp == input)
+ return ERROR_NOT_NUMBER;
+
+ FIXME("Check for integer overflow.\n");
+ if (0)
+ return ERROR_ARITHMETIC_OVERFLOW;
+
+
+ *out = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
+ **(DWORD **) out = i;
+ *size_out = sizeof(DWORD);
+ return ERROR_SUCCESS;
+ }
+ case REG_MULTI_SZ:
+ {
+ WCHAR *temp = HeapAlloc(GetProcessHeap(), 0, (strlenW(input) + 1) * sizeof(WCHAR));
+ DWORD p;
+
+ for (i = 0, p = 0; i <= strlenW(input); i++, p++)
+ {
+ /* If this character is the separator, or no separator has been given and these
+ * characters are "\\0", then add a 0 indicating the end of this string */
+ if ( (separator && input[i] == separator) ||
+ (!separator && input[i] == '\\' && input[i + 1] == '0') )
+ {
+ /* If it's the first character or the previous one was a separator */
+ if (!p || temp[p - 1] == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, temp);
+ return ERROR_BAD_COMMAND;
+ }
+ temp[p] = 0;
+
+ if (!separator)
+ i++;
+ }
+ else
+ temp[p] = input[i];
+ }
+
+ /* Add a 0 to the end if the string wasn't "", and it wasn't
+ * double-0-terminated already (In the case of a trailing separator) */
+ if (p > 1 && temp[p - 2])
+ temp[p++] = 0;
+
+ *size_out = p * sizeof(WCHAR);
+ *out = (BYTE *) temp;
+ return ERROR_SUCCESS;
+ }
+ case REG_BINARY:
{
- LPWSTR rest;
- DWORD val;
- val = strtolW(data, &rest, 0);
- if (rest == data) {
- static const WCHAR nonnumber[] = {'E','r','r','o','r',':',' ','/','d',' ','r','e','q','u','i','r','e','s',' ','n','u','m','b','e','r','.','\n',0};
- reg_printfW(nonnumber);
- break;
+ BYTE *temp = HeapAlloc(GetProcessHeap(), 0, strlenW(input));
+ DWORD p, odd;
+
+ for (i = 0, p = 0; i < strlenW(input); i++, p++)
+ {
+ if (input[i] >= '0' && input[i] <= '9')
+ temp[p] = input[i] - '0';
+ else if (input[i] >= 'a' && input[i] <= 'f')
+ temp[p] = input[i] - 'a' + 10;
+ else if (input[i] >= 'A' && input[i] <= 'F')
+ temp[p] = input[i] - 'A' + 10;
+ else
+ {
+ HeapFree(GetProcessHeap(), 0, temp);
+ return ERROR_BAD_COMMAND;
+ }
}
- *reg_count = sizeof(DWORD);
- out_data = HeapAlloc(GetProcessHeap(),0,*reg_count);
- ((LPDWORD)out_data)[0] = val;
- break;
+
+ *out = temp;
+ odd = p & 1;
+ temp += odd;
+ p >>= 1;
+
+ for (i = 0; i < p; i++)
+ temp[i] = (temp[i * 2] << 4) | temp[i * 2 + 1];
+
+ *size_out = p + odd;
+ return ERROR_SUCCESS;
}
default:
{
- static const WCHAR unhandled[] = {'U','n','h','a','n','d','l','e','d',' ','T','y','p','e',' ','0','x','%','x',' ',' ','d','a','t','a',' ','%','s','\n',0};
- reg_printfW(unhandled, reg_type,data);
+ FIXME("Add support for registry type: %u\n", type);
+ return ERROR_UNSUPPORTED_TYPE;
}
}
-
- return out_data;
}
static LSTATUS sane_path(const WCHAR *key)
@@ -310,7 +405,15 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
}
if (data)
- reg_data = get_regdata(data,reg_type,separator,®_count);
+ {
+ err = wchar_get_data(data, reg_type, separator, ®_count, ®_data);
+ if (err != ERROR_SUCCESS)
+ {
+ RegCloseKey(subkey);
+ reg_print_error(err);
+ return 1;
+ }
+ }
RegSetValueExW(subkey,value_name,0,reg_type,reg_data,reg_count);
HeapFree(GetProcessHeap(),0,reg_data);
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
index 42de422..e407256 100644
--- a/programs/reg/reg.h
+++ b/programs/reg/reg.h
@@ -32,3 +32,5 @@
#define STRING_CANNOT_FIND 109
#define STRING_ERROR 110
#define STRING_UNSUPPORTED_TYPE 111
+#define STRING_NOT_INT_OR_NEG 112
+#define STRING_ERANGE 113
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index beafd4f..3fc4e89 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -37,4 +37,6 @@ STRINGTABLE
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
STRING_ERROR, "Unexpected error: "
STRING_UNSUPPORTED_TYPE, "Error: Unsupported type\n"
+ STRING_NOT_INT_OR_NEG, "Error: This type requires /d to be a positive number\n"
+ STRING_ERANGE, "Error: Value out of range\n"
}
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 9420b5c..99b4813 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -153,8 +153,8 @@ static void test_add(void)
/* REG_NONE */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v none0 /d deadbeef /t REG_NONE /f", &r);
- todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d\n", r);
- todo_wine verify_reg(hkey, "none0", REG_NONE, "d\0e\0a\0d\0b\0e\0e\0f\0\0", 18, 0);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d\n", r);
+ verify_reg(hkey, "none0", REG_NONE, "d\0e\0a\0d\0b\0e\0e\0f\0\0", 18, 0);
/* REG_SZ */
run_reg_exe("reg add HKCU\\" KEY_BASE " /d WineTest /f", &r);
@@ -188,11 +188,11 @@ static void test_add(void)
/* REG_EXPAND_SZ */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand0 /t REG_EXpand_sz /d \"dead%PATH%beef\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, TODO_REG_SIZE);
+ verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand1 /t REG_EXpand_sz /d \"dead^%PATH^%beef\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, TODO_REG_SIZE);
+ verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -200,11 +200,11 @@ static void test_add(void)
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, TODO_REG_SIZE);
+ verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand3 /f /d \"\"", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, 0);
/* REG_BINARY */
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin0 /f", &r);
@@ -214,14 +214,14 @@ static void test_add(void)
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_BINARY /d deadbeef /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
dword = 0xefbeadde;
- verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), TODO_REG_SIZE);
+ verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin1 /f /d 0xDeAdBeEf", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin2 /f /d x01", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin3 /f /d 01x", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin4 /f /d DeAdBeEf0DD", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -235,8 +235,8 @@ static void test_add(void)
err = RegQueryValueExA(hkey, "bin4", NULL, &type, (void *) (buffer+12), &size);
ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
ok(type == REG_BINARY, "got wrong type %u\n", type);
- todo_wine ok(size == 6, "got wrong size %u\n", size);
- todo_wine ok(memcmp(buffer, buffer+12, 6) == 0 ||
+ ok(size == 6, "got wrong size %u\n", size);
+ ok(memcmp(buffer, buffer+12, 6) == 0 ||
broken(memcmp(buffer+6, buffer+12, 6) == 0 /* WinXP */), "got wrong data\n");
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin5 /d \"\" /f", &r);
@@ -257,11 +257,11 @@ static void test_add(void)
todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %d, expected 0\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword3 /t REG_DWORD /d deadbeef /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword4 /t REG_DWORD /d 123xyz /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword5 /t reg_dword /d 12345678 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -275,22 +275,21 @@ static void test_add(void)
ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
ok(type == REG_DWORD, "got wrong type %d, expected %d\n", type, REG_DWORD);
ok(size == sizeof(DWORD), "got wrong size %d, expected %d\n", size, (int)sizeof(DWORD));
- todo_wine ok(dword == 123 || broken(dword == 0123 /* WinXP */),
+ ok(dword == 123 || broken(dword == 0123 /* WinXP */),
"got wrong data %d, expected %d\n", dword, 123);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword7 /t reg_dword /d 0xabcdefg /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0xdeadbeef /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
dword = 0xdeadbeef;
- verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword),
- (sizeof(long) > sizeof(DWORD)) ? 0 : TODO_REG_DATA);
+ verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword), 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword9 /f /d -1", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword10 /f /d -0x1", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0x01ffffffff /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %d\n", r);
@@ -305,7 +304,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE /t REG_DWORD_BIG_ENDIAN /d 456 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
dword = 456;
- verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), TODO_REG_SIZE);
+ verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), 0);
/* REG_DWORD_BIG_ENDIAN is broken in every version of windows. It behaves like
* an ordinary REG_DWORD - that is little endian. GG */
@@ -313,15 +312,15 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi0 /t REG_MULTI_SZ /d \"three\\0little\\0strings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
memcpy(buffer, "three\0little\0strings\0", 22);
- verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, TODO_REG_SIZE);
+ verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi1 /s \"#\" /d \"three#little#strings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, TODO_REG_SIZE);
+ verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi2 /d \"\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, TODO_REG_SIZE);
+ verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -329,7 +328,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, TODO_REG_SIZE);
+ verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
@@ -338,16 +337,16 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi10 /s \"#\" /d \"#a\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi11 /s \"#\" /d \"a#\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
buffer[0]='a'; buffer[1]=0; buffer[2]=0;
- verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, TODO_REG_SIZE);
+ verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, 0);
RegCloseKey(hkey);
--
2.1.3
From jnvsor at gmail.com Sat Nov 8 04:26:50 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Sat, 8 Nov 2014 11:26:50 +0100
Subject: [PATCH v3 09/10] reg: Clean up reg_add
In-Reply-To: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
References: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415442411-14059-9-git-send-email-jnvsor@gmail.com>
You'll notice that bad value input leaves a zombie key after this
call, but this is consistant with native.
---
programs/reg/reg.c | 92 ++++++++++++++++++++++++++----------------------
programs/reg/tests/reg.c | 22 ++++++------
2 files changed, 60 insertions(+), 54 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index bcbcdaa..b76fd3c 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -358,71 +358,70 @@ static LSTATUS sane_path(const WCHAR *key)
return ERROR_SUCCESS;
}
-static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
- WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
+static int reg_add( const WCHAR *key_name, const WCHAR *value_name, const BOOL value_empty,
+ const WCHAR *type, const WCHAR separator, const WCHAR *data,
+ const BOOL force)
{
- static const WCHAR stubW[] = {'A','D','D',' ','-',' ','%','s',
- ' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
- HKEY subkey;
- LONG err;
-
- reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
-
- err = sane_path(key_name);
+ HKEY key = NULL;
+ LONG err = sane_path(key_name);
if (err != ERROR_SUCCESS)
+ goto error;
+
+ if (value_name && value_empty)
{
- reg_print_error(err);
- return 1;
+ err = ERROR_BAD_COMMAND;
+ goto error;
}
- err = path_open(key_name, &subkey, TRUE);
+ err = path_open(key_name, &key, TRUE);
if (err != ERROR_SUCCESS)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
+ goto error;
if (value_name || data)
{
- DWORD reg_type;
- DWORD reg_count = 0;
- BYTE* reg_data = NULL;
+ DWORD size, reg_type;
+ BYTE *data_out;
+
+ if (value_name && !value_name[0])
+ value_name = NULL;
- if (!force)
+ if (type && !type[0])
{
- if (RegQueryValueW(subkey,value_name,NULL,NULL)==ERROR_SUCCESS)
- {
- /* FIXME: Prompt for overwrite */
- }
+ data = NULL;
+ type = NULL;
}
- reg_type = wchar_get_type(type);
- if (reg_type == ~0u)
+ if (!force && RegQueryValueExW(key, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{
- RegCloseKey(subkey);
- reg_print_error(ERROR_UNSUPPORTED_TYPE);
- return 1;
+ FIXME("Prompt for overwrite\n");
}
- if (data)
+ reg_type = wchar_get_type(type);
+ if (reg_type == ~0u)
{
- err = wchar_get_data(data, reg_type, separator, ®_count, ®_data);
- if (err != ERROR_SUCCESS)
- {
- RegCloseKey(subkey);
- reg_print_error(err);
- return 1;
- }
+ err = ERROR_INVALID_DATATYPE;
+ goto error;
}
- RegSetValueExW(subkey,value_name,0,reg_type,reg_data,reg_count);
- HeapFree(GetProcessHeap(),0,reg_data);
+ err = wchar_get_data(data, reg_type, separator, &size, &data_out);
+ if (err != ERROR_SUCCESS)
+ goto error;
+
+ err = RegSetValueExW(key, value_name, 0, reg_type, data_out, size);
+ HeapFree(GetProcessHeap(), 0, data_out);
+ if (err != ERROR_SUCCESS)
+ goto error;
}
- RegCloseKey(subkey);
+ RegCloseKey(key);
reg_message(STRING_SUCCESS);
-
return 0;
+
+error:
+ RegCloseKey(key);
+
+ reg_print_error(err);
+ return 1;
}
static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
@@ -602,7 +601,14 @@ int wmain(int argc, WCHAR *argvW[])
else if (!lstrcmpiW(argvW[i], slashTW))
type = argvW[++i];
else if (!lstrcmpiW(argvW[i], slashSW))
- separator = argvW[++i][0];
+ {
+ if (!argvW[++i][0] || argvW[i][1])
+ {
+ reg_print_error(ERROR_BAD_COMMAND);
+ return 1;
+ }
+ separator = argvW[i][0];
+ }
else if (!lstrcmpiW(argvW[i], slashDW))
data = argvW[++i];
else if (!lstrcmpiW(argvW[i], slashFW))
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 99b4813..a3ecdfb 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -110,12 +110,12 @@ static void test_add(void)
/* Test empty type */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\" /d WineTest /f", &r);
- todo_wine ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
+ ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
"got exit code %u\n", r);
if (r == REG_EXIT_SUCCESS)
- todo_wine verify_reg(hkey, "emptyType", REG_SZ, "", 1, 0);
+ verify_reg(hkey, "emptyType", REG_SZ, "", 1, 0);
else
- todo_wine win_skip("broken reg.exe detected\n");
+ win_skip("broken reg.exe detected\n");
/* Test input key formats */
run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
@@ -171,7 +171,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /v test /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_reg(hkey, "test", REG_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "test", REG_SZ, "", 1, 0);
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /d WineTEST /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -179,7 +179,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test2 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_reg(hkey, "test2", REG_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "test2", REG_SZ, "", 1, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test3 /f /d \"\"", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -196,7 +196,7 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, TODO_REG_SIZE);
+ verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, 0);
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
@@ -254,7 +254,7 @@ static void test_add(void)
win_skip("broken reg.exe detected\n");
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword1 /t REG_DWORD /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %d, expected 0\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
@@ -324,18 +324,18 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
- verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, TODO_REG_SIZE);
+ verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi6 /s \"\\0\" /d \"three\\0little\\0strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
--
2.1.3
From jnvsor at gmail.com Sat Nov 8 04:26:48 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Sat, 8 Nov 2014 11:26:48 +0100
Subject: [PATCH v3 07/10] reg: Add wchar/type conversion functions
In-Reply-To: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
References: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415442411-14059-7-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 65 ++++++++++++++++++++++++++++++++++-------------------
programs/reg/reg.h | 1 +
programs/reg/reg.rc | 1 +
3 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index e4a3860..a5a619e 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -50,6 +50,32 @@ root_rels[] =
{HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
};
+static const WCHAR type_none[] = {'R','E','G','_','N','O','N','E',0};
+static const WCHAR type_sz[] = {'R','E','G','_','S','Z',0};
+static const WCHAR type_expand_sz[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0};
+static const WCHAR type_binary[] = {'R','E','G','_','B','I','N','A','R','Y',0};
+static const WCHAR type_dword[] = {'R','E','G','_','D','W','O','R','D',0};
+static const WCHAR type_dword_le[] = {'R','E','G','_','D','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
+static const WCHAR type_dword_be[] = {'R','E','G','_','D','W','O','R','D','_','B','I','G','_','E','N','D','I','A','N',0};
+static const WCHAR type_multi_sz[] = {'R','E','G','_','M','U','L','T','I','_','S','Z',0};
+
+static const struct
+{
+ DWORD type;
+ const WCHAR *name;
+}
+type_rels[] =
+{
+ {REG_NONE, type_none},
+ {REG_SZ, type_sz},
+ {REG_EXPAND_SZ, type_expand_sz},
+ {REG_BINARY, type_binary},
+ {REG_DWORD, type_dword},
+ {REG_DWORD_LITTLE_ENDIAN, type_dword_le},
+ {REG_DWORD_BIG_ENDIAN, type_dword_be},
+ {REG_MULTI_SZ, type_multi_sz},
+};
+
static int reg_printfW(const WCHAR *msg, ...)
{
va_list va_args;
@@ -115,6 +141,9 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_FILE_NOT_FOUND:
reg_message(STRING_CANNOT_FIND);
return;
+ case ERROR_UNSUPPORTED_TYPE:
+ reg_message(STRING_UNSUPPORTED_TYPE);
+ return;
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -166,30 +195,20 @@ static LSTATUS path_open(const WCHAR *path, HKEY *out, BOOL create)
return RegOpenKeyW(*out, path, out);
}
-static DWORD get_regtype(LPWSTR type)
+static DWORD wchar_get_type(const WCHAR *type_name)
{
- static const WCHAR szREG_SZ[] = {'R','E','G','_','S','Z',0};
- static const WCHAR szREG_MULTI_SZ[] = {'R','E','G','_','M','U','L','T','I','_','S','Z',0};
- static const WCHAR szREG_DWORD_BIG_ENDIAN[] = {'R','E','G','_','D','W','O','R','D','_','B','I','G','_','E','N','D','I','A','N',0};
- static const WCHAR szREG_DWORD[] = {'R','E','G','_','D','W','O','R','D',0};
- static const WCHAR szREG_BINARY[] = {'R','E','G','_','B','I','N','A','R','Y',0};
- static const WCHAR szREG_DWORD_LITTLE_ENDIAN[] = {'R','E','G','_','D','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
- static const WCHAR szREG_NONE[] = {'R','E','G','_','N','O','N','E',0};
- static const WCHAR szREG_EXPAND_SZ[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0};
-
- if (!type)
+ DWORD i;
+
+ if (!type_name)
return REG_SZ;
- if (lstrcmpiW(type,szREG_SZ)==0) return REG_SZ;
- if (lstrcmpiW(type,szREG_DWORD)==0) return REG_DWORD;
- if (lstrcmpiW(type,szREG_MULTI_SZ)==0) return REG_MULTI_SZ;
- if (lstrcmpiW(type,szREG_EXPAND_SZ)==0) return REG_EXPAND_SZ;
- if (lstrcmpiW(type,szREG_DWORD_BIG_ENDIAN)==0) return REG_DWORD_BIG_ENDIAN;
- if (lstrcmpiW(type,szREG_DWORD_LITTLE_ENDIAN)==0) return REG_DWORD_LITTLE_ENDIAN;
- if (lstrcmpiW(type,szREG_BINARY)==0) return REG_BINARY;
- if (lstrcmpiW(type,szREG_NONE)==0) return REG_NONE;
+ for (i = 0; i < ARRAY_SIZE(type_rels); i++)
+ {
+ if (!strcmpiW(type_rels[i].name, type_name))
+ return type_rels[i].type;
+ }
- return -1;
+ return ~0u;
}
static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *reg_count)
@@ -282,11 +301,11 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
}
}
- reg_type = get_regtype(type);
- if (reg_type == -1)
+ reg_type = wchar_get_type(type);
+ if (reg_type == ~0u)
{
RegCloseKey(subkey);
- reg_message(STRING_INVALID_CMDLINE);
+ reg_print_error(ERROR_UNSUPPORTED_TYPE);
return 1;
}
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
index 1c2ae83..42de422 100644
--- a/programs/reg/reg.h
+++ b/programs/reg/reg.h
@@ -31,3 +31,4 @@
#define STRING_NO_REMOTE 108
#define STRING_CANNOT_FIND 109
#define STRING_ERROR 110
+#define STRING_UNSUPPORTED_TYPE 111
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index 5fc5a76..beafd4f 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -36,4 +36,5 @@ STRINGTABLE
STRING_NO_REMOTE, "Error: Unable to access remote machine\n"
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
STRING_ERROR, "Unexpected error: "
+ STRING_UNSUPPORTED_TYPE, "Error: Unsupported type\n"
}
--
2.1.3
From jnvsor at gmail.com Sat Nov 8 04:26:51 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Sat, 8 Nov 2014 11:26:51 +0100
Subject: [PATCH v3 10/10] reg: Clean up reg_delete
In-Reply-To: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
References: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415442411-14059-10-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 150 +++++++++++++++++++++++------------------------
programs/reg/tests/reg.c | 2 +-
2 files changed, 74 insertions(+), 78 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index b76fd3c..d5a74a7 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -424,120 +424,116 @@ error:
return 1;
}
-static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
- BOOL value_all, BOOL force)
+static int reg_delete(const WCHAR *key_name, const WCHAR *value_name, const BOOL value_empty,
+ const BOOL value_all, const BOOL force)
{
- HKEY subkey;
- LONG err;
-
- static const WCHAR stubW[] = {'D','E','L','E','T','E',
- ' ','-',' ','%','s',' ','%','s',' ','%','d',' ','%','d',' ','%','d','\n'
- ,0};
- reg_printfW(stubW, key_name, value_name, value_empty, value_all, force);
-
- err = sane_path(key_name);
+ HKEY key = NULL;
+ LONG err = sane_path(key_name);
if (err != ERROR_SUCCESS)
{
reg_print_error(err);
return 1;
}
- err = path_open(key_name, &subkey, FALSE);
+ err = path_open(key_name, &key, FALSE);
if (err != ERROR_SUCCESS)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
-
- if (value_name && value_empty)
- {
- reg_message(STRING_INVALID_CMDLINE);
- return 1;
- }
+ goto error;
- if (value_empty && value_all)
+ /* Mutually exclusive options */
+ if ((!!value_name + !!value_empty + !!value_all) > 1)
{
- reg_message(STRING_INVALID_CMDLINE);
- return 1;
+ err = ERROR_BAD_COMMAND;
+ goto error;
}
if (!force)
{
- /* FIXME: Prompt for delete */
+ FIXME("Prompt for delete\n");
}
- /* Delete subtree only if no /v* option is given */
- if (!value_name && !value_empty && !value_all)
+ if (value_empty || value_name)
{
- err = RegDeleteTreeA(subkey, NULL);
- if (err != ERROR_SUCCESS)
- {
- reg_print_error(err);
- return 1;
- }
+ if (value_name && value_name[0])
+ err = RegDeleteValueW(key, value_name);
+ else
+ err = RegDeleteValueW(key, NULL);
- err = RegDeleteKeyA(subkey, "");
if (err != ERROR_SUCCESS)
- {
- reg_print_error(err);
- return 1;
- }
- reg_message(STRING_SUCCESS);
- return 0;
+ goto error;
}
-
- if (value_all)
+ else if (value_all)
{
- LPWSTR szValue;
- DWORD maxValue;
- DWORD count;
- LONG rc;
-
- rc = RegQueryInfoKeyW(subkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- &maxValue, NULL, NULL, NULL);
- if (rc != ERROR_SUCCESS)
- {
- /* FIXME: failure */
- RegCloseKey(subkey);
- return 1;
- }
- maxValue++;
- szValue = HeapAlloc(GetProcessHeap(),0,maxValue*sizeof(WCHAR));
+ WCHAR *enum_v_name;
+ DWORD count, max_size, this_size, i = 0, errors = 0;
- while (1)
+ err = RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL, NULL, NULL,
+ &count, &max_size, NULL, NULL, NULL);
+ if (err != ERROR_SUCCESS)
+ goto error;
+
+ enum_v_name = HeapAlloc(GetProcessHeap(), 0, ++max_size * sizeof(WCHAR));
+
+ while (i < count)
{
- count = maxValue;
- rc = RegEnumValueW(subkey, 0, szValue, &count, NULL, NULL, NULL, NULL);
- if (rc == ERROR_SUCCESS)
+ this_size = max_size;
+
+ err = RegEnumValueW(key, i, enum_v_name, &this_size, NULL, NULL, NULL, NULL);
+ if (err != ERROR_SUCCESS)
+ {
+ i++;
+ errors++;
+ reg_print_error(err);
+ continue;
+ }
+
+ err = RegDeleteValueW(key, enum_v_name);
+ if (err != ERROR_SUCCESS)
{
- rc = RegDeleteValueW(subkey, szValue);
- if (rc != ERROR_SUCCESS)
- break;
+ i++;
+ errors++;
+ reg_print_error(err);
+ continue;
}
- else break;
+
+ count--;
}
- if (rc != ERROR_SUCCESS)
+
+ HeapFree(GetProcessHeap(), 0, enum_v_name);
+
+ if (errors)
{
- /* FIXME delete failed */
+ RegCloseKey(key);
+ return 1;
}
}
- else if (value_name)
+ /* Delete subtree only if no /v* option is given */
+ else
{
- if (RegDeleteValueW(subkey,value_name) != ERROR_SUCCESS)
+ if (key == path_get_rootkey(key_name))
{
- RegCloseKey(subkey);
- reg_message(STRING_CANNOT_FIND);
+ /* "This works well enough on native to make you regret you pressed enter" - stefand */
+ FIXME("Deleting a root key is not implemented.\n");
+ RegCloseKey(key);
return 1;
}
- }
- else if (value_empty)
- {
- RegSetValueExW(subkey,NULL,0,REG_SZ,NULL,0);
+
+ err = RegDeleteTreeA(key, NULL);
+ if (err != ERROR_SUCCESS)
+ goto error;
+ err = RegDeleteKeyA(key, "");
+ if (err != ERROR_SUCCESS)
+ goto error;
}
- RegCloseKey(subkey);
+ RegCloseKey(key);
reg_message(STRING_SUCCESS);
return 0;
+
+error:
+ RegCloseKey(key);
+
+ reg_print_error(err);
+ return 1;
}
static int reg_query(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index a3ecdfb..20ef7af 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -388,7 +388,7 @@ static void test_delete(void)
run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
err = RegQueryValueExA(hkey, "", NULL, NULL, NULL, NULL);
- todo_wine ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
+ ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
--
2.1.3
From jnvsor at gmail.com Sat Nov 8 04:26:43 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Sat, 8 Nov 2014 11:26:43 +0100
Subject: [PATCH v3 02/10] reg/tests: Test REG_NONE
In-Reply-To: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
References: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415442411-14059-2-git-send-email-jnvsor@gmail.com>
---
programs/reg/tests/reg.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index 9b1881e..2d86d83 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -151,6 +151,11 @@ static void test_add(void)
err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest4");
ok(err == ERROR_SUCCESS, "got exit code %d\n", r);
+ /* REG_NONE */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v none0 /d deadbeef /t REG_NONE /f", &r);
+ todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d\n", r);
+ todo_wine verify_reg(hkey, "none0", REG_NONE, "d\0e\0a\0d\0b\0e\0e\0f\0\0", 18, 0);
+
/* REG_SZ */
run_reg_exe("reg add HKCU\\" KEY_BASE " /d WineTest /f", &r);
ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
--
2.1.3
From jnvsor at gmail.com Sat Nov 8 04:26:47 2014
From: jnvsor at gmail.com (Jonathan Vollebregt)
Date: Sat, 8 Nov 2014 11:26:47 +0100
Subject: [PATCH v3 06/10] reg: Add path/key conversion functions
In-Reply-To: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
References: <1415442411-14059-1-git-send-email-jnvsor@gmail.com>
Message-ID: <1415442411-14059-6-git-send-email-jnvsor@gmail.com>
---
programs/reg/reg.c | 146 +++++++++++++++++++++++++++++------------------------
1 file changed, 80 insertions(+), 66 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index ff12b3f..e4a3860 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -20,8 +20,36 @@
#include
#include "reg.h"
+#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
+
#define ERROR_NO_REMOTE 20000
+static const WCHAR short_hklm[] = {'H','K','L','M',0};
+static const WCHAR short_hkcu[] = {'H','K','C','U',0};
+static const WCHAR short_hkcr[] = {'H','K','C','R',0};
+static const WCHAR short_hku[] = {'H','K','U',0};
+static const WCHAR short_hkcc[] = {'H','K','C','C',0};
+static const WCHAR long_hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
+static const WCHAR long_hkcu[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
+static const WCHAR long_hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
+static const WCHAR long_hku[] = {'H','K','E','Y','_','U','S','E','R','S',0};
+static const WCHAR long_hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
+
+static const struct
+{
+ HKEY key;
+ const WCHAR *short_name;
+ const WCHAR *long_name;
+}
+root_rels[] =
+{
+ {HKEY_LOCAL_MACHINE, short_hklm, long_hklm},
+ {HKEY_CURRENT_USER, short_hkcu, long_hkcu},
+ {HKEY_CLASSES_ROOT, short_hkcr, long_hkcr},
+ {HKEY_USERS, short_hku, long_hku},
+ {HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
+};
+
static int reg_printfW(const WCHAR *msg, ...)
{
va_list va_args;
@@ -84,6 +112,9 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_NO_REMOTE:
reg_message(STRING_NO_REMOTE);
return;
+ case ERROR_FILE_NOT_FOUND:
+ reg_message(STRING_CANNOT_FIND);
+ return;
default:
{
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
@@ -99,35 +130,40 @@ static void reg_print_error(LSTATUS error_code)
}
}
-static HKEY get_rootkey(LPWSTR key)
+static inline BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name)
+{
+ DWORD length = strlenW(rootkey_name);
+
+ return (!strncmpiW(input_path, rootkey_name, length) &&
+ (input_path[length] == 0 || input_path[length] == '\\'));
+}
+
+static HKEY path_get_rootkey(const WCHAR *path)
+{
+ DWORD i;
+
+ for (i = 0; i < ARRAY_SIZE(root_rels); i++)
+ {
+ if (path_rootname_cmp(path, root_rels[i].short_name) ||
+ path_rootname_cmp(path, root_rels[i].long_name))
+ return root_rels[i].key;
+ }
+
+ return NULL;
+}
+
+static LSTATUS path_open(const WCHAR *path, HKEY *out, BOOL create)
{
- static const WCHAR szHKLM[] = {'H','K','L','M',0};
- static const WCHAR szHKEY_LOCAL_MACHINE[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
- static const WCHAR szHKCU[] = {'H','K','C','U',0};
- static const WCHAR szHKEY_CURRENT_USER[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
- static const WCHAR szHKCR[] = {'H','K','C','R',0};
- static const WCHAR szHKEY_CLASSES_ROOT[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
- static const WCHAR szHKU[] = {'H','K','U',0};
- static const WCHAR szHKEY_USERS[] = {'H','K','E','Y','_','U','S','E','R','S',0};
- static const WCHAR szHKCC[] = {'H','K','C','C',0};
- static const WCHAR szHKEY_CURRENT_CONFIG[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
-
- if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKLM,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,18,szHKEY_LOCAL_MACHINE,18)==CSTR_EQUAL)
- return HKEY_LOCAL_MACHINE;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKCU,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,17,szHKEY_CURRENT_USER,17)==CSTR_EQUAL)
- return HKEY_CURRENT_USER;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKCR,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,17,szHKEY_CLASSES_ROOT,17)==CSTR_EQUAL)
- return HKEY_CLASSES_ROOT;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,3,szHKU,3)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,10,szHKEY_USERS,10)==CSTR_EQUAL)
- return HKEY_USERS;
- else if (CompareStringW(CP_ACP,NORM_IGNORECASE,key,4,szHKCC,4)==CSTR_EQUAL ||
- CompareStringW(CP_ACP,NORM_IGNORECASE,key,19,szHKEY_CURRENT_CONFIG,19)==CSTR_EQUAL)
- return HKEY_CURRENT_CONFIG;
- else return NULL;
+ *out = path_get_rootkey(path);
+
+ path = strchrW(path, '\\');
+ if (path)
+ path++;
+
+ if (create)
+ return RegCreateKeyW(*out, path, out);
+ else
+ return RegOpenKeyW(*out, path, out);
}
static DWORD get_regtype(LPWSTR type)
@@ -213,8 +249,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
{
static const WCHAR stubW[] = {'A','D','D',' ','-',' ','%','s',
' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
- LPWSTR p;
- HKEY root,subkey;
+ HKEY subkey;
LONG err;
reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
@@ -226,22 +261,8 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
return 1;
}
- p = strchrW(key_name,'\\');
- if (!p)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
- p++;
-
- root = get_rootkey(key_name);
- if (!root)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
-
- if(RegCreateKeyW(root,p,&subkey)!=ERROR_SUCCESS)
+ err = path_open(key_name, &subkey, TRUE);
+ if (err != ERROR_SUCCESS)
{
reg_message(STRING_INVALID_KEY);
return 1;
@@ -285,8 +306,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
BOOL value_all, BOOL force)
{
- LPWSTR p;
- HKEY root,subkey;
+ HKEY subkey;
LONG err;
static const WCHAR stubW[] = {'D','E','L','E','T','E',
@@ -301,16 +321,8 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
return 1;
}
- p = strchrW(key_name,'\\');
- if (!p)
- {
- reg_message(STRING_INVALID_KEY);
- return 1;
- }
- p++;
-
- root = get_rootkey(key_name);
- if (!root)
+ err = path_open(key_name, &subkey, FALSE);
+ if (err != ERROR_SUCCESS)
{
reg_message(STRING_INVALID_KEY);
return 1;
@@ -336,21 +348,23 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
/* Delete subtree only if no /v* option is given */
if (!value_name && !value_empty && !value_all)
{
- if (RegDeleteTreeW(root,p)!=ERROR_SUCCESS)
+ err = RegDeleteTreeA(subkey, NULL);
+ if (err != ERROR_SUCCESS)
{
- reg_message(STRING_CANNOT_FIND);
+ reg_print_error(err);
+ return 1;
+ }
+
+ err = RegDeleteKeyA(subkey, "");
+ if (err != ERROR_SUCCESS)
+ {
+ reg_print_error(err);
return 1;
}
reg_message(STRING_SUCCESS);
return 0;
}
- if(RegOpenKeyW(root,p,&subkey)!=ERROR_SUCCESS)
- {
- reg_message(STRING_CANNOT_FIND);
- return 1;
- }
-
if (value_all)
{
LPWSTR szValue;
--
2.1.3
From nsivov at codeweavers.com Sat Nov 8 10:02:55 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Sat, 08 Nov 2014 19:02:55 +0300
Subject: [PATCH] include: Add a couple more defines for D3DPRESENT_* flags
Message-ID: <545E3EAF.3040300@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-include-Add-a-couple-more-defines-for-D3DPRESENT_-fl.patch
Type: text/x-patch
Size: 957 bytes
Desc: not available
URL:
From mengshuaicalendr at gmail.com Sat Nov 8 20:46:11 2014
From: mengshuaicalendr at gmail.com (Shuai Meng)
Date: Sun, 9 Nov 2014 10:46:11 +0800
Subject: [PATCH] vbscript: Implemented String(try 4)
In-Reply-To: <545DA383.8030802@gmail.com>
References: <545DA383.8030802@gmail.com>
Message-ID:
Sorry, I was in such a hurry that I ignored the first advice of Piotr, I
will resend this patch later.
2014-11-08 13:00 GMT+08:00 Shuai Meng :
> Change log:
> removed codes that handled VT_ARRAY|VT_BYREF|VT_VARIANT case
> separately.
> ---
> dlls/vbscript/global.c | 61 ++++++++++++++++++++++++++++++
> +++++++++++++--
> dlls/vbscript/tests/api.vbs | 53 +++++++++++++++++++++++++++++++++++++++
> dlls/vbscript/vbscript.h | 1 +
> 3 files changed, 113 insertions(+), 2 deletions(-)
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From matellanesivan at gmail.com Sun Nov 9 13:17:31 2014
From: matellanesivan at gmail.com (=?UTF-8?B?SXbDoW4gTWF0ZWxsYW5lcw==?=)
Date: Sun, 09 Nov 2014 20:17:31 +0100
Subject: msvcrt: Add missing declarations in wchar.h
Message-ID: <545FBDCB.9020205@gmail.com>
---
include/msvcrt/wchar.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/msvcrt/wchar.h b/include/msvcrt/wchar.h
index d936dc3..702fa67 100644
--- a/include/msvcrt/wchar.h
+++ b/include/msvcrt/wchar.h
@@ -313,12 +313,18 @@ int __cdecl _wstat64(const wchar_t*,struct _stat64*);
#ifndef _WSTDIO_DEFINED
#define _WSTDIO_DEFINED
+wint_t __cdecl _fgetwc_nolock(FILE*);
wint_t __cdecl _fgetwchar(void);
+wint_t __cdecl _fputwc_nolock(wint_t,FILE*);
wint_t __cdecl _fputwchar(wint_t);
+wint_t __cdecl _getwc_nolock(FILE*);
wchar_t* __cdecl _getws(wchar_t*);
+wint_t __cdecl _putwc_nolock(wint_t,FILE*);
int __cdecl _putws(const wchar_t*);
int __cdecl _snwprintf(wchar_t*,size_t,const wchar_t*,...);
int __cdecl _snwprintf_s(wchar_t*,size_t,size_t,const wchar_t*,...);
+int __cdecl _scwprintf(const wchar_t*,...);
+wint_t __cdecl _ungetwc_nolock(wint_t,FILE*);
int __cdecl _vscwprintf(const wchar_t*,__ms_va_list);
int __cdecl _vscwprintf_p_l(const wchar_t*,_locale_t,__ms_va_list);
int __cdecl _vsnwprintf(wchar_t*,size_t,const wchar_t*,__ms_va_list);
--
1.9.1
From matellanesivan at gmail.com Sun Nov 9 13:17:45 2014
From: matellanesivan at gmail.com (=?UTF-8?B?SXbDoW4gTWF0ZWxsYW5lcw==?=)
Date: Sun, 09 Nov 2014 20:17:45 +0100
Subject: msvcrt: Added _fread_nolock_s implementation (try 2)
Message-ID: <545FBDD9.3080808@gmail.com>
Hi,
I've checked when the file gets locked after calling fread_s.
It turns out that the locking is done after validating the stream, the element size and
the element count. This potentially leads to calling the invalid parameter handler with
the file locked if, for example, destBuffer == NULL (at least that's what happens on my
Windows 7 x64 machine).
This implementation tries to reproduce this behaviour.
Cheers!
---
dlls/msvcr100/msvcr100.spec | 2 +-
dlls/msvcr100/tests/msvcr100.c | 35 +++++++++++++++++++++++++++++++++++
dlls/msvcr110/msvcr110.spec | 2 +-
dlls/msvcr120/msvcr120.spec | 2 +-
dlls/msvcr80/msvcr80.spec | 2 +-
dlls/msvcr90/msvcr90.spec | 2 +-
dlls/msvcrt/file.c | 26 ++++++++++++++++++++++++--
dlls/msvcrt/msvcrt.h | 1 +
include/msvcrt/stdio.h | 2 ++
9 files changed, 67 insertions(+), 7 deletions(-)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index cb45506..a6e7771 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -835,7 +835,7 @@
@ cdecl _fputwc_nolock(long ptr) MSVCRT__fputwc_nolock
@ cdecl _fputwchar(long) MSVCRT__fputwchar
@ cdecl _fread_nolock(ptr long long ptr) MSVCRT__fread_nolock
-@ stub _fread_nolock_s
+@ cdecl _fread_nolock_s(ptr long long long ptr) MSVCRT__fread_nolock_s
@ cdecl _free_locale(ptr) MSVCRT__free_locale
@ stub _freea
@ stub _freea_s
diff --git a/dlls/msvcr100/tests/msvcr100.c b/dlls/msvcr100/tests/msvcr100.c
index a998fb5..4c66ed5 100644
--- a/dlls/msvcr100/tests/msvcr100.c
+++ b/dlls/msvcr100/tests/msvcr100.c
@@ -140,6 +140,8 @@ static int (__cdecl *p_wmemmove_s)(wchar_t *dest, size_t numberOfElements, const
static FILE* (__cdecl *p_fopen)(const char*,const char*);
static int (__cdecl *p_fclose)(FILE*);
static size_t (__cdecl *p_fread_s)(void*,size_t,size_t,size_t,FILE*);
+static void (__cdecl *p_lock_file)(FILE*);
+static void (__cdecl *p_unlock_file)(FILE*);
static void* (__cdecl *p__aligned_offset_malloc)(size_t, size_t, size_t);
static void (__cdecl *p__aligned_free)(void*);
static size_t (__cdecl *p__aligned_msize)(void*, size_t, size_t);
@@ -178,6 +180,8 @@ static BOOL init(void)
SET(p_fopen, "fopen");
SET(p_fclose, "fclose");
SET(p_fread_s, "fread_s");
+ SET(p_lock_file, "_lock_file");
+ SET(p_unlock_file, "_unlock_file");
SET(p__aligned_offset_malloc, "_aligned_offset_malloc");
SET(p__aligned_free, "_aligned_free");
SET(p__aligned_msize, "_aligned_msize");
@@ -357,11 +361,30 @@ static void test_wmemmove_s(void)
"Cannot reset invalid parameter handler\n");
}
+struct block_file_arg
+{
+ FILE *test_file;
+ HANDLE init;
+ HANDLE finish;
+};
+
+static DWORD WINAPI block_file(void *arg)
+{
+ struct block_file_arg *files = arg;
+ p_lock_file(files->test_file);
+ SetEvent(files->init);
+ WaitForSingleObject(files->finish, INFINITE);
+ p_unlock_file(files->test_file);
+ return 0;
+}
+
static void test_fread_s(void)
{
static const char test_file[] = "fread_s.tst";
int ret;
char buf[10];
+ HANDLE thread;
+ struct block_file_arg arg;
FILE *f = fopen(test_file, "w");
if(!f) {
@@ -382,6 +405,12 @@ static void test_fread_s(void)
CHECK_CALLED(invalid_parameter_handler);
f = p_fopen(test_file, "r");
+ arg.test_file = f;
+ arg.init = CreateEventW(NULL, FALSE, FALSE, NULL);
+ arg.finish = CreateEventW(NULL, FALSE, FALSE, NULL);
+ thread = CreateThread(NULL, 0, block_file, (void*)&arg, 0, NULL);
+ WaitForSingleObject(arg.init, INFINITE);
+
errno = 0xdeadbeef;
ret = p_fread_s(NULL, sizeof(buf), 0, 1, f);
ok(ret == 0, "fread_s returned %d, expected 0\n", ret);
@@ -390,6 +419,9 @@ static void test_fread_s(void)
ok(ret == 0, "fread_s returned %d, expected 0\n", ret);
ok(errno == 0xdeadbeef, "errno = %d, expected 0xdeadbeef\n", errno);
+ SetEvent(arg.finish);
+ WaitForSingleObject(thread, INFINITE);
+
SET_EXPECT(invalid_parameter_handler);
errno = 0xdeadbeef;
ret = p_fread_s(NULL, sizeof(buf), 1, 1, f);
@@ -426,6 +458,9 @@ static void test_fread_s(void)
ok(p_set_invalid_parameter_handler(NULL) == test_invalid_parameter_handler,
"Cannot reset invalid parameter handler\n");
+ CloseHandle(arg.init);
+ CloseHandle(arg.finish);
+ CloseHandle(thread);
unlink(test_file);
}
diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec
index d41699d..141697c 100644
--- a/dlls/msvcr110/msvcr110.spec
+++ b/dlls/msvcr110/msvcr110.spec
@@ -1183,7 +1183,7 @@
@ cdecl _fputwc_nolock(long ptr) MSVCRT__fputwc_nolock
@ cdecl _fputwchar(long) MSVCRT__fputwchar
@ cdecl _fread_nolock(ptr long long ptr) MSVCRT__fread_nolock
-@ stub _fread_nolock_s
+@ cdecl _fread_nolock_s(ptr long long long ptr) MSVCRT__fread_nolock_s
@ cdecl _free_locale(ptr) MSVCRT__free_locale
@ stub _freea
@ stub _freea_s
diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index fbf688e..1b8dc28 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -1181,7 +1181,7 @@
@ cdecl _fputwc_nolock(long ptr) MSVCRT__fputwc_nolock
@ cdecl _fputwchar(long) MSVCRT__fputwchar
@ cdecl _fread_nolock(ptr long long ptr) MSVCRT__fread_nolock
-@ stub _fread_nolock_s
+@ cdecl _fread_nolock_s(ptr long long long ptr) MSVCRT__fread_nolock_s
@ cdecl _free_locale(ptr) MSVCRT__free_locale
@ stub _freea
@ stub _freea_s
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index efb4539..fcad7cd 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -502,7 +502,7 @@
@ cdecl _fputwc_nolock(long ptr) MSVCRT__fputwc_nolock
@ cdecl _fputwchar(long) MSVCRT__fputwchar
@ cdecl _fread_nolock(ptr long long ptr) MSVCRT__fread_nolock
-@ stub _fread_nolock_s
+@ cdecl _fread_nolock_s(ptr long long long ptr) MSVCRT__fread_nolock_s
@ cdecl _free_locale(ptr) MSVCRT__free_locale
@ stub _freea
@ stub _freea_s
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index fa62366..7328b46 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -484,7 +484,7 @@
@ cdecl _fputwc_nolock(long ptr) MSVCRT__fputwc_nolock
@ cdecl _fputwchar(long) MSVCRT__fputwchar
@ cdecl _fread_nolock(ptr long long ptr) MSVCRT__fread_nolock
-@ stub _fread_nolock_s
+@ cdecl _fread_nolock_s(ptr long long long ptr) MSVCRT__fread_nolock_s
@ cdecl _free_locale(ptr) MSVCRT__free_locale
@ stub _freea
@ stub _freea_s
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 491942d..5049605 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -4130,9 +4130,31 @@ MSVCRT_size_t CDECL MSVCRT__fread_nolock(void *ptr, MSVCRT_size_t size, MSVCRT_s
MSVCRT_size_t CDECL MSVCRT_fread_s(void *buf, MSVCRT_size_t buf_size, MSVCRT_size_t elem_size,
MSVCRT_size_t count, MSVCRT_FILE *stream)
{
+ MSVCRT_size_t ret;
+
+ if(!MSVCRT_CHECK_PMT(stream != NULL)) {
+ if(buf && buf_size)
+ memset(buf, 0, buf_size);
+ return 0;
+ }
+ if(!elem_size || !count) return 0;
+
+ MSVCRT__lock_file(stream);
+ ret = MSVCRT__fread_nolock_s(buf, buf_size, elem_size, count, stream);
+ MSVCRT__unlock_file(stream);
+
+ return ret;
+}
+
+/*********************************************************************
+ * _fread_nolock_s (MSVCR80.@)
+ */
+MSVCRT_size_t CDECL MSVCRT__fread_nolock_s(void *buf, MSVCRT_size_t buf_size, MSVCRT_size_t elem_size,
+ MSVCRT_size_t count, MSVCRT_FILE *stream)
+{
size_t bytes_left, buf_pos;
- TRACE("(%p %lu %lu %lu %p\n", buf, buf_size, elem_size, count, stream);
+ TRACE("(%p %lu %lu %lu %p)\n", buf, buf_size, elem_size, count, stream);
if(!MSVCRT_CHECK_PMT(stream != NULL)) {
if(buf && buf_size)
@@ -4154,7 +4176,7 @@ MSVCRT_size_t CDECL MSVCRT_fread_s(void *buf, MSVCRT_size_t buf_size, MSVCRT_siz
return 0;
}
- MSVCRT_fread((char*)buf+buf_pos, 1, size, stream);
+ MSVCRT__fread_nolock((char*)buf+buf_pos, 1, size, stream);
buf_pos += size;
bytes_left -= size;
}else {
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index 70ac68b..72d529d 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -934,6 +934,7 @@ MSVCRT_ulong* __cdecl MSVCRT___doserrno(void);
int* __cdecl MSVCRT__errno(void);
char* __cdecl MSVCRT_getenv(const char*);
MSVCRT_size_t __cdecl MSVCRT__fread_nolock(void*,MSVCRT_size_t,MSVCRT_size_t,MSVCRT_FILE*);
+MSVCRT_size_t __cdecl MSVCRT__fread_nolock_s(void*,MSVCRT_size_t,MSVCRT_size_t,MSVCRT_size_t,MSVCRT_FILE*);
MSVCRT_size_t __cdecl MSVCRT__fwrite_nolock(const void*,MSVCRT_size_t,MSVCRT_size_t,MSVCRT_FILE*);
int __cdecl MSVCRT_fclose(MSVCRT_FILE*);
int __cdecl MSVCRT__fclose_nolock(MSVCRT_FILE*);
diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h
index eda89e6..0606d07 100644
--- a/include/msvcrt/stdio.h
+++ b/include/msvcrt/stdio.h
@@ -128,6 +128,7 @@ int __cdecl _vsnprintf_s(char*,size_t,size_t,const char*,__ms_va_list);
int __cdecl _vsprintf_p_l(char*,size_t,const char*,_locale_t,__ms_va_list);
size_t __cdecl _fread_nolock(void*,size_t,size_t,FILE*);
+size_t __cdecl _fread_nolock_s(void*,size_t,size_t,size_t,FILE*);
size_t __cdecl _fwrite_nolock(const void*,size_t,size_t,FILE*);
int __cdecl _fclose_nolock(FILE*);
int __cdecl _fflush_nolock(FILE*);
@@ -156,6 +157,7 @@ int __cdecl fprintf_s(FILE*,const char*,...);
int __cdecl fputc(int,FILE*);
int __cdecl fputs(const char*,FILE*);
size_t __cdecl fread(void*,size_t,size_t,FILE*);
+size_t __cdecl fread_s(void*,size_t,size_t,size_t,FILE*);
FILE* __cdecl freopen(const char*,const char*,FILE*);
int __cdecl fscanf(FILE*,const char*,...);
int __cdecl fscanf_s(FILE*,const char*,...);
--
1.9.1
From austinenglish at gmail.com Sun Nov 9 23:45:36 2014
From: austinenglish at gmail.com (Austin English)
Date: Sun, 9 Nov 2014 23:45:36 -0600
Subject: kernel32: add TRUST_E_NOSIGNATURE resource definition
Message-ID:
Patch is from https://bugs.winehq.org/show_bug.cgi?id=29997. It seems the
author never submitted it, so doing so for him.
--
-Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-kernel32-add-TRUST_E_NOSIGNATURE-resource-definition.patch
Type: text/x-patch
Size: 1222 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Mon Nov 10 01:06:49 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Mon, 10 Nov 2014 10:06:49 +0300
Subject: [PATCH] dwrite: Remove OpenType language id from cache.
Message-ID: <54606409.7010701@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-dwrite-Remove-OpenType-language-id-from-cache.patch
Type: text/x-patch
Size: 8506 bytes
Desc: not available
URL:
From christopherwuy at gmail.com Fri Nov 7 20:15:21 2014
From: christopherwuy at gmail.com (YongHao Hu)
Date: Sat, 08 Nov 2014 10:15:21 +0800
Subject: msvcp90: Add std_Ctraits::Isnan implementation. (try 2)
Message-ID: <545D7CB9.9000302@gmail.com>
try2: Update msvcp70.spec, msvcp71.spec and msvcp80.spec.
Thanks for Nikolay Sivov's comment.
---
dlls/msvcp70/msvcp70.spec | 6 +++---
dlls/msvcp71/msvcp71.spec | 6 +++---
dlls/msvcp80/msvcp80.spec | 6 +++---
dlls/msvcp90/math.c | 9 +++++++++
dlls/msvcp90/msvcp90.spec | 6 +++---
dlls/msvcp90/tests/misc.c | 48
+++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 69 insertions(+), 12 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0058-msvcp90-Add-std_Ctraits-Isnan-implementation.txt
Type: text/x-patch
Size: 8502 bytes
Desc: not available
URL:
From drew_ronneberg at yahoo.com Sun Nov 9 17:18:34 2014
From: drew_ronneberg at yahoo.com (Drew Ronneberg)
Date: Sun, 9 Nov 2014 15:18:34 -0800
Subject: [PATCH] Do not call SendMessage() to hide a window that is already
hidden
Message-ID: <1415575114.24164.YahooMailNeo@web162801.mail.bf1.yahoo.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Do-not-call-SendMessage-to-hide-a-window-that-is-alrea.txt
URL:
From qhong at codeweavers.com Mon Nov 10 02:27:54 2014
From: qhong at codeweavers.com (Qian Hong)
Date: Mon, 10 Nov 2014 16:27:54 +0800
Subject: [PATCH 1/2] user32: Add more exception handlings for timer callbacks.
Message-ID: <5460770A.4030506@codeweavers.com>
- No code change from last try.
- Superseded patch 107362.
---
dlls/user32/message.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-user32-Add-more-exception-handlings-for-timer-callback.txt
Type: text/x-patch
Size: 920 bytes
Desc: not available
URL:
From qhong at codeweavers.com Mon Nov 10 02:28:23 2014
From: qhong at codeweavers.com (Qian Hong)
Date: Mon, 10 Nov 2014 16:28:23 +0800
Subject: [PATCH 2/2] user32/tests: Test exception handling for timer callbacks.
(try 2)
Message-ID: <54607727.7010606@codeweavers.com>
Try 2:
- Test timer callback without Sleep().
- Superseded patch 107363.
Thanks Alexandre for advice.
---
dlls/user32/tests/msg.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-user32-tests-Test-exception-handling-for-timer-callbac.txt
Type: text/x-patch
Size: 2238 bytes
Desc: not available
URL:
From hugh.mcmaster at outlook.com Mon Nov 10 05:00:59 2014
From: hugh.mcmaster at outlook.com (Hugh McMaster)
Date: Mon, 10 Nov 2014 22:00:59 +1100
Subject: [PATCH] reg.exe: Modernise print functions
Message-ID:
This patch modernises reg.exe so its printf-type functions conform to the other Wine programs. It will also mean other developers do not have to add this functionality in various places, e.g. printing error messages.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reg-print-functions.patch
Type: application/octet-stream
Size: 4021 bytes
Desc: not available
URL:
From jr98 at gmx.net Mon Nov 10 05:21:49 2014
From: jr98 at gmx.net (Julian =?ISO-8859-1?Q?R=FCger?=)
Date: Mon, 10 Nov 2014 12:21:49 +0100
Subject: [website] German translation for release 1.7.30
Message-ID: <1415618509.4984.1.camel@xpsubuntu>
Sorry for the delay, I was traveling last week.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-German-translation-for-release-1.7.30.patch
Type: text/x-patch
Size: 1298 bytes
Desc: not available
URL:
From hugh.mcmaster at outlook.com Mon Nov 10 06:21:56 2014
From: hugh.mcmaster at outlook.com (Hugh McMaster)
Date: Mon, 10 Nov 2014 23:21:56 +1100
Subject: [PATCH] reg: Modernise print functions (updated)
Message-ID:
This patch modernises reg.exe so its printf-type functions conform to the other Wine programs. It will also mean other developers do not have to add this functionality in various places, e.g. printing error messages.
Update: I forgot to use __ms_va_start and __ms_va_end when using __ms_va_list. Fixed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reg-print-functions.patch
Type: application/octet-stream
Size: 4051 bytes
Desc: not available
URL:
From piotr at codeweavers.com Mon Nov 10 06:46:18 2014
From: piotr at codeweavers.com (Piotr Caban)
Date: Mon, 10 Nov 2014 13:46:18 +0100
Subject: user32: Move IME Window Procedure to user32 (try2)
Message-ID: <5460B39A.4@codeweavers.com>
---
dlls/imm32/imm.c | 105 ++++++-----------------------------------
dlls/imm32/imm32.spec | 4 ++
dlls/user32/class.c | 1 +
dlls/user32/controls.h | 4 ++
dlls/user32/misc.c | 116
++++++++++++++++++++++++++++++++++++++++++++--
dlls/user32/tests/class.c | 11 ++---
dlls/user32/user_main.c | 6 +++
dlls/user32/winproc.c | 1 +
8 files changed, 146 insertions(+), 102 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-user32-Move-IME-Window-Procedure-to-user32.txt
Type: text/x-patch
Size: 15209 bytes
Desc: not available
URL:
From jacek at codeweavers.com Mon Nov 10 08:00:56 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Mon, 10 Nov 2014 15:00:56 +0100
Subject: [PATCH 2/3] mshtml: Delay onreadystateevent notification if script
elemenet is not added by parser.
Message-ID: <5460C518.5000406@codeweavers.com>
---
dlls/mshtml/htmlscript.h | 1 +
dlls/mshtml/script.c | 50
++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 49 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-mshtml-Delay-onreadystateevent-notification-if-script.diff
Type: text/x-patch
Size: 2832 bytes
Desc: not available
URL:
From jacek at codeweavers.com Mon Nov 10 08:01:15 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Mon, 10 Nov 2014 15:01:15 +0100
Subject: [PATCH 3/3] mshtml: Added script element readyState and
onreadystatechange tests.
Message-ID: <5460C52B.5000606@codeweavers.com>
---
dlls/mshtml/tests/events.html | 81
+++++++++++++++++++++++++++++++++++++++++-
dlls/mshtml/tests/externscr.js | 2 ++
dlls/mshtml/tests/script.c | 19 ++++++++++
3 files changed, 101 insertions(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-mshtml-Added-script-element-readyState-and-onreadysta.diff
Type: text/x-patch
Size: 6193 bytes
Desc: not available
URL:
From jacek at codeweavers.com Mon Nov 10 08:01:33 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Mon, 10 Nov 2014 15:01:33 +0100
Subject: [PATCH 1/3] mshtml: Ignore query and hash parts in res protocol
handler.
Message-ID: <5460C53D.3070303@codeweavers.com>
---
dlls/mshtml/protocol.c | 8 +++++++-
dlls/mshtml/tests/protocol.c | 2 ++
2 files changed, 9 insertions(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Ignore-query-and-hash-parts-in-res-protocol-ha.diff
Type: text/x-patch
Size: 1628 bytes
Desc: not available
URL:
From dimesio at earthlink.net Mon Nov 10 10:01:07 2014
From: dimesio at earthlink.net (Rosanne DiMesio)
Date: Mon, 10 Nov 2014 10:01:07 -0600
Subject: [website] Ubuntu download: Correct Ubuntu downloads instructions
Message-ID: <20141110100107.6e1d0cd0e94d0e8aae1d8cfe@earthlink.net>
Revises instructions to no longer identify the PPA as WineHQ's and to clarify the support status of Ubuntu derivatives. Fixes bugs 34299 and 33549.
---
templates/en/download/ubuntu.template | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Website-Correct-Ubuntu-downloads-instructions.txt
URL:
From mbruni at codeweavers.com Mon Nov 10 11:56:10 2014
From: mbruni at codeweavers.com (Matteo Bruni)
Date: Mon, 10 Nov 2014 18:56:10 +0100
Subject: [PATCH 1/5] winex11.drv: Actually report WGL_SWAP_EXCHANGE_ARB as the
swap method.
Message-ID: <1415642174-16277-1-git-send-email-mbruni@codeweavers.com>
I.e. do what it was probably intended to do from the start. It should
fix bug 16699.
---
dlls/winex11.drv/opengl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 71af3db..1481034 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -2742,7 +2742,7 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int
* point only ATI offers this.
*/
piValues[i] = WGL_SWAP_EXCHANGE_ARB;
- break;
+ continue;
case WGL_PBUFFER_LARGEST_ARB:
curGLXAttr = GLX_LARGEST_PBUFFER;
--
2.0.4
From mbruni at codeweavers.com Mon Nov 10 11:56:11 2014
From: mbruni at codeweavers.com (Matteo Bruni)
Date: Mon, 10 Nov 2014 18:56:11 +0100
Subject: [PATCH 2/5] winex11.drv: Add support for GLX_OML_swap_method.
In-Reply-To: <1415642174-16277-1-git-send-email-mbruni@codeweavers.com>
References: <1415642174-16277-1-git-send-email-mbruni@codeweavers.com>
Message-ID: <1415642174-16277-2-git-send-email-mbruni@codeweavers.com>
---
dlls/winex11.drv/opengl.c | 61 ++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 55 insertions(+), 6 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 1481034..cf5d440 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -145,6 +145,10 @@ typedef XID GLXPbuffer;
#define GLX_PBUFFER 0x8023
#define GLX_PBUFFER_HEIGHT 0x8040
#define GLX_PBUFFER_WIDTH 0x8041
+#define GLX_SWAP_METHOD_OML 0x8060
+#define GLX_SWAP_EXCHANGE_OML 0x8061
+#define GLX_SWAP_COPY_OML 0x8062
+#define GLX_SWAP_UNDEFINED_OML 0x8063
#define GLX_RGBA_BIT 0x00000001
#define GLX_COLOR_INDEX_BIT 0x00000002
#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
@@ -285,6 +289,7 @@ static BOOL use_render_texture_emulation = TRUE;
static enum glx_swap_control_method swap_control_method = GLX_SWAP_CONTROL_NONE;
/* Set when GLX_EXT_swap_control_tear is supported, requires GLX_SWAP_CONTROL_EXT */
static BOOL has_swap_control_tear = FALSE;
+static BOOL has_swap_method = FALSE;
static CRITICAL_SECTION context_section;
static CRITICAL_SECTION_DEBUG critsect_debug =
@@ -878,8 +883,30 @@ static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, struct wgl_
case WGL_SWAP_METHOD_ARB:
pop = iWGLAttr[++cur];
- /* For now we ignore this and just return SWAP_EXCHANGE */
TRACE("pAttr[%d] = WGL_SWAP_METHOD_ARB: %#x\n", cur, pop);
+ if (has_swap_method)
+ {
+ switch (pop)
+ {
+ case WGL_SWAP_EXCHANGE_ARB:
+ pop = GLX_SWAP_EXCHANGE_OML;
+ break;
+ case WGL_SWAP_COPY_ARB:
+ pop = GLX_SWAP_COPY_OML;
+ break;
+ case WGL_SWAP_UNDEFINED_ARB:
+ pop = GLX_SWAP_UNDEFINED_OML;
+ break;
+ default:
+ ERR("Unexpected swap method %#x.\n", pop);
+ pop = GLX_DONT_CARE;
+ }
+ PUSH2(oGLXAttr, GLX_SWAP_METHOD_OML, pop);
+ }
+ else
+ {
+ WARN("GLX_OML_swap_method not supported, ignoring attribute.\n");
+ }
break;
case WGL_PBUFFER_LARGEST_ARB:
@@ -2737,11 +2764,30 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int
continue;
case WGL_SWAP_METHOD_ARB:
- /* For now return SWAP_EXCHANGE_ARB which is the best type of buffer switch available.
- * Later on we can also use GLX_OML_swap_method on drivers which support this. At this
- * point only ATI offers this.
- */
- piValues[i] = WGL_SWAP_EXCHANGE_ARB;
+ if (has_swap_method)
+ {
+ hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &tmp);
+ if (hTest) goto get_error;
+ switch (tmp)
+ {
+ case GLX_SWAP_EXCHANGE_OML:
+ piValues[i] = WGL_SWAP_EXCHANGE_ARB;
+ break;
+ case GLX_SWAP_COPY_OML:
+ piValues[i] = WGL_SWAP_COPY_ARB;
+ break;
+ case GLX_SWAP_UNDEFINED_OML:
+ piValues[i] = WGL_SWAP_UNDEFINED_ARB;
+ break;
+ default:
+ ERR("Unexpected swap method %x.\n", tmp);
+ }
+ }
+ else
+ {
+ WARN("GLX_OML_swap_method not supported, returning WGL_SWAP_EXCHANGE_ARB.\n");
+ piValues[i] = WGL_SWAP_EXCHANGE_ARB;
+ }
continue;
case WGL_PBUFFER_LARGEST_ARB:
@@ -3167,6 +3213,9 @@ static void X11DRV_WineGL_LoadExtensions(void)
opengl_funcs.ext.p_wglFreeMemoryNV = pglXFreeMemoryNV;
}
+ if (has_extension(WineGLInfo.glxExtensions, "GLX_OML_swap_method"))
+ has_swap_method = TRUE;
+
/* WINE-specific WGL Extensions */
/* In WineD3D we need the ability to set the pixel format more than once (e.g. after a device reset).
--
2.0.4
From mbruni at codeweavers.com Mon Nov 10 11:56:12 2014
From: mbruni at codeweavers.com (Matteo Bruni)
Date: Mon, 10 Nov 2014 18:56:12 +0100
Subject: [PATCH 3/5] d3dx9: Handle GUID_WICPixelFormat8bppGray format.
In-Reply-To: <1415642174-16277-1-git-send-email-mbruni@codeweavers.com>
References: <1415642174-16277-1-git-send-email-mbruni@codeweavers.com>
Message-ID: <1415642174-16277-3-git-send-email-mbruni@codeweavers.com>
For bug 37074.
---
dlls/d3dx9_36/surface.c | 1 +
dlls/d3dx9_36/tests/surface.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index c91048b..f187031 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -40,6 +40,7 @@ static const struct
{ &GUID_WICPixelFormat8bppIndexed, D3DFMT_P8 },
{ &GUID_WICPixelFormat1bppIndexed, D3DFMT_P8 },
{ &GUID_WICPixelFormat4bppIndexed, D3DFMT_P8 },
+ { &GUID_WICPixelFormat8bppGray, D3DFMT_L8 },
{ &GUID_WICPixelFormat16bppBGR555, D3DFMT_X1R5G5B5 },
{ &GUID_WICPixelFormat16bppBGR565, D3DFMT_R5G6B5 },
{ &GUID_WICPixelFormat24bppBGR, D3DFMT_R8G8B8 },
diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c
index 2ddc704..4490dc3 100644
--- a/dlls/d3dx9_36/tests/surface.c
+++ b/dlls/d3dx9_36/tests/surface.c
@@ -80,6 +80,16 @@ static const unsigned char bmp_8bpp[] = {
0x00,0x00
};
+static const unsigned char png_grayscale[] =
+{
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49,
+ 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x3a, 0x7e, 0x9b, 0x55, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44,
+ 0x41, 0x54, 0x08, 0xd7, 0x63, 0xf8, 0x0f, 0x00, 0x01, 0x01, 0x01, 0x00, 0x1b,
+ 0xb6, 0xee, 0x56, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42,
+ 0x60, 0x82
+};
+
/* 2x2 A8R8G8B8 pixel data */
static const unsigned char pixdata[] = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
@@ -493,6 +503,12 @@ static void test_D3DXGetImageInfo(void)
ok(info.Depth == 1, "Got depth %u, expected 1\n", info.Depth);
ok(info.Format == D3DFMT_P8, "Got format %u, expected %u\n", info.Format, D3DFMT_P8);
+ /* Grayscale PNG */
+ hr = D3DXGetImageInfoFromFileInMemory(png_grayscale, sizeof(png_grayscale), &info);
+ ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
+ ok(info.Depth == 1, "Got depth %u, expected 1\n", info.Depth);
+ ok(info.Format == D3DFMT_L8, "Got format %u, expected %u\n", info.Format, D3DFMT_L8);
+
/* test DDS support */
hr = D3DXGetImageInfoFromFileInMemory(dds_24bit, sizeof(dds_24bit), &info);
ok(hr == D3D_OK, "D3DXGetImageInfoFromFileInMemory returned %#x, expected %#x\n", hr, D3D_OK);
--
2.0.4
From mbruni at codeweavers.com Mon Nov 10 11:56:13 2014
From: mbruni at codeweavers.com (Matteo Bruni)
Date: Mon, 10 Nov 2014 18:56:13 +0100
Subject: [PATCH 4/5] d3dx9: Use an alpha-capable format when creating textures
with a color key.
In-Reply-To: <1415642174-16277-1-git-send-email-mbruni@codeweavers.com>
References: <1415642174-16277-1-git-send-email-mbruni@codeweavers.com>
Message-ID: <1415642174-16277-4-git-send-email-mbruni@codeweavers.com>
Only if no format was explicitly specified.
Followup to the fix for bug 37074.
---
dlls/d3dx9_36/tests/texture.c | 113 ++++++++++++++++++++++++++++++++++++++++++
dlls/d3dx9_36/texture.c | 30 ++++++++++-
2 files changed, 142 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c
index 61132bb..c90e2d5 100644
--- a/dlls/d3dx9_36/tests/texture.c
+++ b/dlls/d3dx9_36/tests/texture.c
@@ -87,6 +87,16 @@ static const unsigned char dds_volume_map[] = {
0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x84,0xef,0x7b,0xaa,0xab,0xab,0xab
};
+static const unsigned char png_grayscale[] =
+{
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49,
+ 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x3a, 0x7e, 0x9b, 0x55, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44,
+ 0x41, 0x54, 0x08, 0xd7, 0x63, 0xf8, 0x0f, 0x00, 0x01, 0x01, 0x01, 0x00, 0x1b,
+ 0xb6, 0xee, 0x56, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42,
+ 0x60, 0x82
+};
+
#define ADMITTED_ERROR 0.0001f
static inline float relative_error(float expected, float got)
@@ -1582,6 +1592,109 @@ static void test_D3DXCreateTextureFromFileInMemoryEx(IDirect3DDevice9 *device)
D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &texture);
ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x\n", hr, D3D_OK);
if (SUCCEEDED(hr)) IDirect3DTexture9_Release(texture);
+
+ /* Checking for color key format overrides. */
+ hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_16bit, sizeof(dds_16bit),
+ D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT,
+ D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &texture);
+ ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
+ if (SUCCEEDED(hr))
+ {
+ IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+ IDirect3DSurface9_GetDesc(surface, &desc);
+ ok(desc.Format == D3DFMT_X1R5G5B5, "Returned format %u, expected %u\n", desc.Format, D3DFMT_X1R5G5B5);
+ IDirect3DTexture9_Release(texture);
+ }
+ hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_16bit, sizeof(dds_16bit),
+ D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT,
+ D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
+ ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
+ if (SUCCEEDED(hr))
+ {
+ IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+ IDirect3DSurface9_GetDesc(surface, &desc);
+ ok(desc.Format == D3DFMT_A1R5G5B5, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A1R5G5B5);
+ IDirect3DTexture9_Release(texture);
+ }
+ hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_16bit, sizeof(dds_16bit),
+ D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_X1R5G5B5, D3DPOOL_DEFAULT,
+ D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
+ ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
+ if (SUCCEEDED(hr))
+ {
+ IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+ IDirect3DSurface9_GetDesc(surface, &desc);
+ ok(desc.Format == D3DFMT_X1R5G5B5, "Returned format %u, expected %u\n", desc.Format, D3DFMT_X1R5G5B5);
+ IDirect3DTexture9_Release(texture);
+ }
+
+ hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_24bit, sizeof(dds_24bit),
+ D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT,
+ D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &texture);
+ ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
+ if (SUCCEEDED(hr))
+ {
+ IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+ IDirect3DSurface9_GetDesc(surface, &desc);
+ ok(desc.Format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_X8R8G8B8);
+ IDirect3DTexture9_Release(texture);
+ }
+ hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_24bit, sizeof(dds_24bit),
+ D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT,
+ D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
+ ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
+ if (SUCCEEDED(hr))
+ {
+ IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+ IDirect3DSurface9_GetDesc(surface, &desc);
+ ok(desc.Format == D3DFMT_A8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8R8G8B8);
+ IDirect3DTexture9_Release(texture);
+ }
+ hr = D3DXCreateTextureFromFileInMemoryEx(device, dds_24bit, sizeof(dds_24bit),
+ D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT,
+ D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
+ ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
+ if (SUCCEEDED(hr))
+ {
+ IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+ IDirect3DSurface9_GetDesc(surface, &desc);
+ ok(desc.Format == D3DFMT_X8R8G8B8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_X8R8G8B8);
+ IDirect3DTexture9_Release(texture);
+ }
+
+ hr = D3DXCreateTextureFromFileInMemoryEx(device, png_grayscale, sizeof(png_grayscale),
+ D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT,
+ D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &texture);
+ ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
+ if (SUCCEEDED(hr))
+ {
+ IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+ IDirect3DSurface9_GetDesc(surface, &desc);
+ ok(desc.Format == D3DFMT_L8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_L8);
+ IDirect3DTexture9_Release(texture);
+ }
+ hr = D3DXCreateTextureFromFileInMemoryEx(device, png_grayscale, sizeof(png_grayscale),
+ D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT,
+ D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
+ ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
+ if (SUCCEEDED(hr))
+ {
+ IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+ IDirect3DSurface9_GetDesc(surface, &desc);
+ ok(desc.Format == D3DFMT_A8L8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_A8L8);
+ IDirect3DTexture9_Release(texture);
+ }
+ hr = D3DXCreateTextureFromFileInMemoryEx(device, png_grayscale, sizeof(png_grayscale),
+ D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_L8, D3DPOOL_DEFAULT,
+ D3DX_DEFAULT, D3DX_DEFAULT, 0xff000000, NULL, NULL, &texture);
+ ok(hr == D3D_OK, "D3DXCreateTextureFromFileInMemoryEx returned %#x, expected %#x.\n", hr, D3D_OK);
+ if (SUCCEEDED(hr))
+ {
+ IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface);
+ IDirect3DSurface9_GetDesc(surface, &desc);
+ ok(desc.Format == D3DFMT_L8, "Returned format %u, expected %u\n", desc.Format, D3DFMT_L8);
+ IDirect3DTexture9_Release(texture);
+ }
}
static void test_D3DXCreateCubeTextureFromFileInMemory(IDirect3DDevice9 *device)
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c
index 7ebe264..e997aa2 100644
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -538,6 +538,29 @@ HRESULT WINAPI D3DXCreateTexture(struct IDirect3DDevice9 *device, UINT width, UI
return IDirect3DDevice9_CreateTexture(device, width, height, miplevels, usage, format, pool, texture, NULL);
}
+static D3DFORMAT get_alpha_replacement_format(D3DFORMAT format)
+{
+ static const struct
+ {
+ D3DFORMAT orig_format;
+ D3DFORMAT replacement_format;
+ }
+ replacement_formats[] =
+ {
+ {D3DFMT_X8R8G8B8, D3DFMT_A8R8G8B8},
+ {D3DFMT_X1R5G5B5, D3DFMT_A1R5G5B5},
+ {D3DFMT_X4R4G4B4, D3DFMT_A4R4G4B4},
+ {D3DFMT_X8B8G8R8, D3DFMT_A8B8G8R8},
+ {D3DFMT_L8, D3DFMT_A8L8},
+ };
+ unsigned int i;
+
+ for (i = 0; i < sizeof(replacement_formats) / sizeof(replacement_formats[0]); ++i)
+ if (replacement_formats[i].orig_format == format)
+ return replacement_formats[i].replacement_format;
+ return format;
+}
+
HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *device, const void *srcdata,
UINT srcdatasize, UINT width, UINT height, UINT miplevels, DWORD usage, D3DFORMAT format,
D3DPOOL pool, DWORD filter, DWORD mipfilter, D3DCOLOR colorkey, D3DXIMAGE_INFO *srcinfo,
@@ -546,7 +569,7 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi
IDirect3DTexture9 **texptr;
IDirect3DTexture9 *buftex;
IDirect3DSurface9 *surface;
- BOOL dynamic_texture;
+ BOOL dynamic_texture, format_specified = FALSE;
D3DXIMAGE_INFO imginfo;
UINT loaded_miplevels, skip_levels;
D3DCAPS9 caps;
@@ -585,6 +608,8 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi
if (format == D3DFMT_UNKNOWN || format == D3DX_DEFAULT)
format = imginfo.Format;
+ else
+ format_specified = TRUE;
if (width == D3DX_FROM_FILE)
{
@@ -630,6 +655,9 @@ HRESULT WINAPI D3DXCreateTextureFromFileInMemoryEx(struct IDirect3DDevice9 *devi
return hr;
}
+ if (colorkey && !format_specified)
+ format = get_alpha_replacement_format(format);
+
if (imginfo.MipLevels < miplevels && (D3DFMT_DXT1 <= imginfo.Format && imginfo.Format <= D3DFMT_DXT5))
{
FIXME("Generation of mipmaps for compressed pixel formats is not implemented yet\n");
--
2.0.4
From mbruni at codeweavers.com Mon Nov 10 11:56:14 2014
From: mbruni at codeweavers.com (Matteo Bruni)
Date: Mon, 10 Nov 2014 18:56:14 +0100
Subject: [PATCH 5/5] d3dx9: Improve the scoring for fallback formats.
In-Reply-To: <1415642174-16277-1-git-send-email-mbruni@codeweavers.com>
References: <1415642174-16277-1-git-send-email-mbruni@codeweavers.com>
Message-ID: <1415642174-16277-5-git-send-email-mbruni@codeweavers.com>
Those were found empirically by disabling some texture formats in wined3d.
---
dlls/d3dx9_36/texture.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c
index e997aa2..de42307 100644
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -302,12 +302,13 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN
/* This format can be used, let's evaluate it.
Weights chosen quite arbitrarily... */
- score = 16 - 4 * (curchannels - channels);
+ score = 512 * (curfmt->type == fmt->type);
+ score -= 32 * (curchannels - channels);
for (j = 0; j < 4; j++)
{
int diff = curfmt->bits[j] - fmt->bits[j];
- score += 16 - (diff < 0 ? -diff * 4 : diff);
+ score -= (diff < 0 ? -diff * 8 : diff) * (j == 0 ? 1 : 2);
}
if (score > bestscore)
--
2.0.4
From nerv at dawncrow.de Mon Nov 10 14:06:15 2014
From: nerv at dawncrow.de (=?ISO-8859-15?Q?Andr=E9_Hentschel?=)
Date: Mon, 10 Nov 2014 21:06:15 +0100
Subject: ntdll/tests: Clarify ok() conditions (PVS-Studio)
Message-ID: <54611AB7.2050802@dawncrow.de>
remaining from https://bugs.winehq.org/show_bug.cgi?id=37127
---
dlls/ntdll/tests/string.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-ntdll-tests-Clarify-ok-conditions.txt
Type: text/x-patch
Size: 1720 bytes
Desc: not available
URL:
From nerv at dawncrow.de Mon Nov 10 14:06:21 2014
From: nerv at dawncrow.de (=?ISO-8859-15?Q?Andr=E9_Hentschel?=)
Date: Mon, 10 Nov 2014 21:06:21 +0100
Subject: urlmon/tests: Clarify ok() condition (PVS-Studio)
Message-ID: <54611ABD.9090909@dawncrow.de>
remaining from https://bugs.winehq.org/show_bug.cgi?id=37127
---
dlls/urlmon/tests/protocol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-urlmon-tests-Clarify-ok-condition.txt
Type: text/x-patch
Size: 646 bytes
Desc: not available
URL:
From nerv at dawncrow.de Mon Nov 10 14:06:26 2014
From: nerv at dawncrow.de (=?ISO-8859-15?Q?Andr=E9_Hentschel?=)
Date: Mon, 10 Nov 2014 21:06:26 +0100
Subject: user32/tests: Clarify ok() condition (PVS-Studio)
Message-ID: <54611AC2.6090105@dawncrow.de>
remaining from https://bugs.winehq.org/show_bug.cgi?id=37127
---
dlls/user32/tests/dde.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-user32-tests-Clarify-ok-condition.txt
Type: text/x-patch
Size: 754 bytes
Desc: not available
URL:
From nerv at dawncrow.de Mon Nov 10 14:06:31 2014
From: nerv at dawncrow.de (=?ISO-8859-15?Q?Andr=E9_Hentschel?=)
Date: Mon, 10 Nov 2014 21:06:31 +0100
Subject: xmllite/tests: Clarify ok() condition (PVS-Studio)
Message-ID: <54611AC7.9060003@dawncrow.de>
remaining from https://bugs.winehq.org/show_bug.cgi?id=37127
---
dlls/xmllite/tests/reader.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-xmllite-tests-Clarify-ok-condition.txt
Type: text/x-patch
Size: 612 bytes
Desc: not available
URL:
From nerv at dawncrow.de Mon Nov 10 14:07:03 2014
From: nerv at dawncrow.de (=?ISO-8859-15?Q?Andr=E9_Hentschel?=)
Date: Mon, 10 Nov 2014 21:07:03 +0100
Subject: avifil32: Simplify comparing two unsigned ints (PVS-Studio)
Message-ID: <54611AE7.8070307@dawncrow.de>
remaining from https://bugs.winehq.org/show_bug.cgi?id=37124
---
dlls/avifil32/avifile.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-avifil32-Simplify-comparing-two-unsigned-ints-PVS-Stud.txt
Type: text/x-patch
Size: 811 bytes
Desc: not available
URL:
From stefan at codeweavers.com Mon Nov 10 16:08:22 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 10 Nov 2014 23:08:22 +0100
Subject: [PATCH 2/5] ddraw/tests: Ddraw restores the mode settings from the
registry (v2).
Message-ID: <1415657305-20856-2-git-send-email-stefan@codeweavers.com>
v2: Merge with test_coop_level_mode_set. This has the positive side
effect that the messages on external mode changes are explicitly tested.
This behavior is already hinted by test_coop_level_mode_set_multi,
although mode_set_multi tests multiple ddraw interfaces and not external
mode changes.
---
dlls/ddraw/tests/ddraw1.c | 143 +++++++++++++++++++++++++++++++++++++++-------
dlls/ddraw/tests/ddraw2.c | 143 +++++++++++++++++++++++++++++++++++++++-------
dlls/ddraw/tests/ddraw4.c | 143 +++++++++++++++++++++++++++++++++++++++-------
dlls/ddraw/tests/ddraw7.c | 143 +++++++++++++++++++++++++++++++++++++++-------
4 files changed, 488 insertions(+), 84 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 455c52a..0ae204c 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -2104,7 +2104,7 @@ static LRESULT CALLBACK mode_set_proc(HWND hwnd, UINT message, WPARAM wparam, LP
struct test_coop_level_mode_set_enum_param
{
- DWORD ddraw_width, ddraw_height;
+ DWORD ddraw_width, ddraw_height, user32_width, user32_height;
};
static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_desc, void *context)
@@ -2117,15 +2117,24 @@ static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_
&& surface_desc->dwHeight == registry_mode.dmPelsHeight)
return DDENUMRET_OK;
- param->ddraw_width = surface_desc->dwWidth;
- param->ddraw_height = surface_desc->dwHeight;
+ if (!param->ddraw_width)
+ {
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_OK;
+ }
+ if (surface_desc->dwWidth == param->ddraw_width && surface_desc->dwHeight == param->ddraw_height)
+ return DDENUMRET_OK;
+
+ param->user32_width = surface_desc->dwWidth;
+ param->user32_height = surface_desc->dwHeight;
return DDENUMRET_CANCEL;
}
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface *primary;
- RECT registry_rect, ddraw_rect, r;
+ RECT registry_rect, ddraw_rect, user32_rect, r;
IDirectDraw *ddraw;
DDSURFACEDESC ddsd;
WNDCLASSA wc = {0};
@@ -2134,6 +2143,9 @@ static void test_coop_level_mode_set(void)
ULONG ref;
MSG msg;
struct test_coop_level_mode_set_enum_param param;
+ DEVMODEW devmode;
+ BOOL ret;
+ LONG change_ret;
static const UINT exclusive_messages[] =
{
@@ -2159,14 +2171,23 @@ static void test_coop_level_mode_set(void)
ref = IDirectDraw_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
- if (!param.ddraw_width)
+ if (!param.user32_height)
{
- skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ skip("Fewer than 3 different modes supported, skipping mode restore test.\n");
return;
}
SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+ SetRect(&user32_rect, 0, 0, param.user32_width, param.user32_height);
+
+ memset(&devmode, 0, sizeof(devmode));
+ devmode.dmSize = sizeof(devmode);
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
@@ -2182,8 +2203,8 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2195,14 +2216,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2226,10 +2247,10 @@ static void test_coop_level_mode_set(void)
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2256,18 +2277,37 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
+ "Expected screen size %ux%u, got %ux%u.\n",
+ param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = exclusive_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == registry_mode.dmPelsWidth
+ todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ todo_wine ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
@@ -2279,6 +2319,10 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ /* For Wine. */
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2338,6 +2382,23 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
{
@@ -2409,6 +2470,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2471,6 +2542,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2535,6 +2626,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index da343c7..334d89e 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -2303,7 +2303,7 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
struct test_coop_level_mode_set_enum_param
{
- DWORD ddraw_width, ddraw_height;
+ DWORD ddraw_width, ddraw_height, user32_width, user32_height;
};
static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_desc, void *context)
@@ -2316,15 +2316,24 @@ static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_
&& surface_desc->dwHeight == registry_mode.dmPelsHeight)
return DDENUMRET_OK;
- param->ddraw_width = surface_desc->dwWidth;
- param->ddraw_height = surface_desc->dwHeight;
+ if (!param->ddraw_width)
+ {
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_OK;
+ }
+ if (surface_desc->dwWidth == param->ddraw_width && surface_desc->dwHeight == param->ddraw_height)
+ return DDENUMRET_OK;
+
+ param->user32_width = surface_desc->dwWidth;
+ param->user32_height = surface_desc->dwHeight;
return DDENUMRET_CANCEL;
}
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface *primary;
- RECT registry_rect, ddraw_rect, r;
+ RECT registry_rect, ddraw_rect, user32_rect, r;
IDirectDraw2 *ddraw;
DDSURFACEDESC ddsd;
WNDCLASSA wc = {0};
@@ -2333,6 +2342,9 @@ static void test_coop_level_mode_set(void)
ULONG ref;
MSG msg;
struct test_coop_level_mode_set_enum_param param;
+ DEVMODEW devmode;
+ BOOL ret;
+ LONG change_ret;
static const UINT exclusive_messages[] =
{
@@ -2358,14 +2370,23 @@ static void test_coop_level_mode_set(void)
ref = IDirectDraw2_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
- if (!param.ddraw_width)
+ if (!param.user32_height)
{
- skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ skip("Fewer than 3 different modes supported, skipping mode restore test.\n");
return;
}
SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+ SetRect(&user32_rect, 0, 0, param.user32_width, param.user32_height);
+
+ memset(&devmode, 0, sizeof(devmode));
+ devmode.dmSize = sizeof(devmode);
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
@@ -2386,8 +2407,8 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2399,14 +2420,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2430,10 +2451,10 @@ static void test_coop_level_mode_set(void)
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2460,18 +2481,37 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
+ "Expected screen size %ux%u, got %ux%u.\n",
+ param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = exclusive_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == registry_mode.dmPelsWidth
+ todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ todo_wine ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
@@ -2483,6 +2523,10 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ /* For Wine. */
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2542,6 +2586,23 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
{
@@ -2613,6 +2674,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2675,6 +2746,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2739,6 +2830,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 056b45e..ab03f39 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -2490,7 +2490,7 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
struct test_coop_level_mode_set_enum_param
{
- DWORD ddraw_width, ddraw_height;
+ DWORD ddraw_width, ddraw_height, user32_width, user32_height;
};
static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface_desc, void *context)
@@ -2503,15 +2503,24 @@ static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface
&& surface_desc->dwHeight == registry_mode.dmPelsHeight)
return DDENUMRET_OK;
- param->ddraw_width = surface_desc->dwWidth;
- param->ddraw_height = surface_desc->dwHeight;
+ if (!param->ddraw_width)
+ {
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_OK;
+ }
+ if (surface_desc->dwWidth == param->ddraw_width && surface_desc->dwHeight == param->ddraw_height)
+ return DDENUMRET_OK;
+
+ param->user32_width = surface_desc->dwWidth;
+ param->user32_height = surface_desc->dwHeight;
return DDENUMRET_CANCEL;
}
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface4 *primary;
- RECT registry_rect, ddraw_rect, r;
+ RECT registry_rect, ddraw_rect, user32_rect, r;
IDirectDraw4 *ddraw;
DDSURFACEDESC2 ddsd;
WNDCLASSA wc = {0};
@@ -2520,6 +2529,9 @@ static void test_coop_level_mode_set(void)
ULONG ref;
MSG msg;
struct test_coop_level_mode_set_enum_param param;
+ DEVMODEW devmode;
+ BOOL ret;
+ LONG change_ret;
static const UINT exclusive_messages[] =
{
@@ -2545,14 +2557,23 @@ static void test_coop_level_mode_set(void)
ref = IDirectDraw4_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
- if (!param.ddraw_width)
+ if (!param.user32_height)
{
- skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ skip("Fewer than 3 different modes supported, skipping mode restore test.\n");
return;
}
SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+ SetRect(&user32_rect, 0, 0, param.user32_width, param.user32_height);
+
+ memset(&devmode, 0, sizeof(devmode));
+ devmode.dmSize = sizeof(devmode);
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
@@ -2573,8 +2594,8 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2586,14 +2607,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2617,10 +2638,10 @@ static void test_coop_level_mode_set(void)
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2647,18 +2668,37 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
+ "Expected screen size %ux%u, got %ux%u.\n",
+ param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = exclusive_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == registry_mode.dmPelsWidth
+ todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ todo_wine ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
@@ -2670,6 +2710,10 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
+ /* For Wine. */
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2729,6 +2773,23 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2793,6 +2854,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2855,6 +2926,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2919,6 +3010,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index aece0fe..cbf6112 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -2167,7 +2167,7 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
struct test_coop_level_mode_set_enum_param
{
- DWORD ddraw_width, ddraw_height;
+ DWORD ddraw_width, ddraw_height, user32_width, user32_height;
};
static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface_desc, void *context)
@@ -2180,15 +2180,24 @@ static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface
&& surface_desc->dwHeight == registry_mode.dmPelsHeight)
return DDENUMRET_OK;
- param->ddraw_width = surface_desc->dwWidth;
- param->ddraw_height = surface_desc->dwHeight;
+ if (!param->ddraw_width)
+ {
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_OK;
+ }
+ if (surface_desc->dwWidth == param->ddraw_width && surface_desc->dwHeight == param->ddraw_height)
+ return DDENUMRET_OK;
+
+ param->user32_width = surface_desc->dwWidth;
+ param->user32_height = surface_desc->dwHeight;
return DDENUMRET_CANCEL;
}
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface7 *primary;
- RECT registry_rect, ddraw_rect, r;
+ RECT registry_rect, ddraw_rect, user32_rect, r;
IDirectDraw7 *ddraw;
DDSURFACEDESC2 ddsd;
WNDCLASSA wc = {0};
@@ -2197,6 +2206,9 @@ static void test_coop_level_mode_set(void)
ULONG ref;
MSG msg;
struct test_coop_level_mode_set_enum_param param;
+ DEVMODEW devmode;
+ BOOL ret;
+ LONG change_ret;
static const UINT exclusive_messages[] =
{
@@ -2222,14 +2234,23 @@ static void test_coop_level_mode_set(void)
ref = IDirectDraw7_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
- if (!param.ddraw_width)
+ if (!param.user32_height)
{
- skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ skip("Fewer than 3 different modes supported, skipping mode restore test.\n");
return;
}
SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+ SetRect(&user32_rect, 0, 0, param.user32_width, param.user32_height);
+
+ memset(&devmode, 0, sizeof(devmode));
+ devmode.dmSize = sizeof(devmode);
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
@@ -2250,8 +2271,8 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2263,14 +2284,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2294,10 +2315,10 @@ static void test_coop_level_mode_set(void)
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2324,18 +2345,37 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
+ "Expected screen size %ux%u, got %ux%u.\n",
+ param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = exclusive_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == registry_mode.dmPelsWidth
+ todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ todo_wine ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
@@ -2347,6 +2387,10 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
+ /* For Wine. */
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2406,6 +2450,23 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2470,6 +2531,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2532,6 +2603,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2596,6 +2687,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
--
2.0.4
From stefan at codeweavers.com Mon Nov 10 16:08:21 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 10 Nov 2014 23:08:21 +0100
Subject: [PATCH 1/5] ddraw/tests: Rename modes and rectangles in
test_coop_level_mode_set.
Message-ID: <1415657305-20856-1-git-send-email-stefan@codeweavers.com>
I split this out of the next patch to make it easier to review. It
introduces the mode selection from test_mode_change in d3d8/9 but does
not introduce the additional tests yet. Other than selecting a variable
mode this is a no-op.
---
dlls/ddraw/tests/ddraw1.c | 281 +++++++++++++++++++++++-----------------
dlls/ddraw/tests/ddraw2.c | 323 ++++++++++++++++++++++++++--------------------
dlls/ddraw/tests/ddraw4.c | 323 ++++++++++++++++++++++++++--------------------
dlls/ddraw/tests/ddraw7.c | 323 ++++++++++++++++++++++++++--------------------
4 files changed, 702 insertions(+), 548 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index fe8a36e..455c52a 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -2102,10 +2102,30 @@ static LRESULT CALLBACK mode_set_proc(HWND hwnd, UINT message, WPARAM wparam, LP
return test_proc(hwnd, message, wparam, lparam);
}
+struct test_coop_level_mode_set_enum_param
+{
+ DWORD ddraw_width, ddraw_height;
+};
+
+static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_desc, void *context)
+{
+ struct test_coop_level_mode_set_enum_param *param = context;
+
+ if (U1(surface_desc->ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
+ return DDENUMRET_OK;
+ if (surface_desc->dwWidth == registry_mode.dmPelsWidth
+ && surface_desc->dwHeight == registry_mode.dmPelsHeight)
+ return DDENUMRET_OK;
+
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_CANCEL;
+}
+
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface *primary;
- RECT fullscreen_rect, r, s;
+ RECT registry_rect, ddraw_rect, r;
IDirectDraw *ddraw;
DDSURFACEDESC ddsd;
WNDCLASSA wc = {0};
@@ -2113,6 +2133,7 @@ static void test_coop_level_mode_set(void)
HRESULT hr;
ULONG ref;
MSG msg;
+ struct test_coop_level_mode_set_enum_param param;
static const UINT exclusive_messages[] =
{
@@ -2132,6 +2153,24 @@ static void test_coop_level_mode_set(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
+ memset(¶m, 0, sizeof(param));
+ hr = IDirectDraw_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
+ ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+ ref = IDirectDraw_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+
+ if (!param.ddraw_width)
+ {
+ skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ return;
+ }
+
+ SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+ SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
@@ -2139,15 +2178,12 @@ static void test_coop_level_mode_set(void)
window = CreateWindowA("ddraw_test_wndproc_wc", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
- SetRect(&s, 0, 0, 640, 480);
-
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2159,14 +2195,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2174,26 +2210,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == s.right && screen_size.cy == s.bottom,
+ ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
- s.right, s.bottom, screen_size.cx, screen_size.cy);
+ param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2205,14 +2241,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2225,21 +2261,22 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2251,30 +2288,30 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2286,14 +2323,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2301,7 +2338,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
{
win_skip("Broken SetDisplayMode(), skipping remaining tests.\n");
@@ -2316,16 +2353,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2337,14 +2374,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2360,16 +2397,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2381,14 +2418,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* DDSCL_NORMAL | DDSCL_FULLSCREEN behaves the same as just DDSCL_NORMAL.
@@ -2398,16 +2435,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2419,14 +2456,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2434,7 +2471,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2442,16 +2479,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2463,14 +2500,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2486,16 +2523,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2507,21 +2544,21 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* Unlike ddraw2-7, changing from EXCLUSIVE to NORMAL does not restore the resolution */
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
@@ -2536,10 +2573,10 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
@@ -2548,8 +2585,8 @@ static void test_coop_level_mode_set(void)
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
done:
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index ad0d040..da343c7 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -2301,10 +2301,30 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
return test_proc(hwnd, message, wparam, lparam);
}
+struct test_coop_level_mode_set_enum_param
+{
+ DWORD ddraw_width, ddraw_height;
+};
+
+static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_desc, void *context)
+{
+ struct test_coop_level_mode_set_enum_param *param = context;
+
+ if (U1(surface_desc->ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
+ return DDENUMRET_OK;
+ if (surface_desc->dwWidth == registry_mode.dmPelsWidth
+ && surface_desc->dwHeight == registry_mode.dmPelsHeight)
+ return DDENUMRET_OK;
+
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_CANCEL;
+}
+
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface *primary;
- RECT fullscreen_rect, r, s;
+ RECT registry_rect, ddraw_rect, r;
IDirectDraw2 *ddraw;
DDSURFACEDESC ddsd;
WNDCLASSA wc = {0};
@@ -2312,6 +2332,7 @@ static void test_coop_level_mode_set(void)
HRESULT hr;
ULONG ref;
MSG msg;
+ struct test_coop_level_mode_set_enum_param param;
static const UINT exclusive_messages[] =
{
@@ -2331,6 +2352,24 @@ static void test_coop_level_mode_set(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
+ memset(¶m, 0, sizeof(param));
+ hr = IDirectDraw2_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
+ ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+ ref = IDirectDraw2_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+
+ if (!param.ddraw_width)
+ {
+ skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ return;
+ }
+
+ SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+ SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
@@ -2343,15 +2382,12 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
- SetRect(&s, 0, 0, 640, 480);
-
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2363,14 +2399,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2378,26 +2414,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == s.right && screen_size.cy == s.bottom,
+ ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
- s.right, s.bottom, screen_size.cx, screen_size.cy);
+ param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2409,14 +2445,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2429,21 +2465,22 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2455,30 +2492,30 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2490,14 +2527,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2505,7 +2542,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
{
win_skip("Broken SetDisplayMode(), skipping remaining tests.\n");
@@ -2520,16 +2557,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2541,14 +2578,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2564,16 +2601,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2585,14 +2622,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* DDSCL_NORMAL | DDSCL_FULLSCREEN behaves the same as just DDSCL_NORMAL.
@@ -2602,16 +2639,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2623,14 +2660,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2638,7 +2675,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2646,16 +2683,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2667,14 +2704,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2690,16 +2727,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2711,21 +2748,21 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* Changing the coop level from EXCLUSIVE to NORMAL restores the screen resolution */
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2738,13 +2775,15 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2756,16 +2795,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
/* The screen restore is a property of DDSCL_EXCLUSIVE */
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
@@ -2780,10 +2819,10 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
@@ -2792,7 +2831,7 @@ static void test_coop_level_mode_set(void)
/* If the window is changed at the same time, messages are sent to the new window. */
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2809,17 +2848,17 @@ static void test_coop_level_mode_set(void)
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
- ok(screen_size2.cx == fullscreen_rect.right && screen_size2.cy == fullscreen_rect.bottom,
+ ok(screen_size2.cx == registry_mode.dmPelsWidth && screen_size2.cy == registry_mode.dmPelsHeight,
"Expected screen size 2 %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size2.cx, screen_size2.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size2.cx, screen_size2.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
GetWindowRect(window2, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2831,18 +2870,18 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
ref = IDirectDraw2_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
done:
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 69f3ac7..056b45e 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -2488,10 +2488,30 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
return test_proc(hwnd, message, wparam, lparam);
}
+struct test_coop_level_mode_set_enum_param
+{
+ DWORD ddraw_width, ddraw_height;
+};
+
+static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface_desc, void *context)
+{
+ struct test_coop_level_mode_set_enum_param *param = context;
+
+ if (U1(U4(surface_desc)->ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
+ return DDENUMRET_OK;
+ if (surface_desc->dwWidth == registry_mode.dmPelsWidth
+ && surface_desc->dwHeight == registry_mode.dmPelsHeight)
+ return DDENUMRET_OK;
+
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_CANCEL;
+}
+
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface4 *primary;
- RECT fullscreen_rect, r, s;
+ RECT registry_rect, ddraw_rect, r;
IDirectDraw4 *ddraw;
DDSURFACEDESC2 ddsd;
WNDCLASSA wc = {0};
@@ -2499,6 +2519,7 @@ static void test_coop_level_mode_set(void)
HRESULT hr;
ULONG ref;
MSG msg;
+ struct test_coop_level_mode_set_enum_param param;
static const UINT exclusive_messages[] =
{
@@ -2518,6 +2539,24 @@ static void test_coop_level_mode_set(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
+ memset(¶m, 0, sizeof(param));
+ hr = IDirectDraw4_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
+ ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+ ref = IDirectDraw4_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+
+ if (!param.ddraw_width)
+ {
+ skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ return;
+ }
+
+ SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+ SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
@@ -2530,15 +2569,12 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
- SetRect(&s, 0, 0, 640, 480);
-
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2550,14 +2586,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2565,26 +2601,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == s.right && screen_size.cy == s.bottom,
+ ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
- s.right, s.bottom, screen_size.cx, screen_size.cy);
+ param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2596,14 +2632,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2616,21 +2652,22 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2642,30 +2679,30 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2677,14 +2714,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2692,7 +2729,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2700,16 +2737,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2721,14 +2758,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2744,16 +2781,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2765,14 +2802,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* DDSCL_NORMAL | DDSCL_FULLSCREEN behaves the same as just DDSCL_NORMAL.
@@ -2782,16 +2819,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2803,14 +2840,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2818,7 +2855,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2826,16 +2863,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2847,14 +2884,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2870,16 +2907,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2891,21 +2928,21 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* Changing the coop level from EXCLUSIVE to NORMAL restores the screen resolution */
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2918,13 +2955,15 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2936,16 +2975,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
/* The screen restore is a property of DDSCL_EXCLUSIVE */
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
@@ -2960,10 +2999,10 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
@@ -2972,7 +3011,7 @@ static void test_coop_level_mode_set(void)
/* If the window is changed at the same time, messages are sent to the new window. */
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2989,17 +3028,17 @@ static void test_coop_level_mode_set(void)
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
- ok(screen_size2.cx == fullscreen_rect.right && screen_size2.cy == fullscreen_rect.bottom,
+ ok(screen_size2.cx == registry_mode.dmPelsWidth && screen_size2.cy == registry_mode.dmPelsHeight,
"Expected screen size 2 %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size2.cx, screen_size2.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size2.cx, screen_size2.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
GetWindowRect(window2, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -3011,18 +3050,18 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
ref = IDirectDraw4_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
expect_messages = NULL;
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 3aebfa7..aece0fe 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -2165,10 +2165,30 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
return test_proc(hwnd, message, wparam, lparam);
}
+struct test_coop_level_mode_set_enum_param
+{
+ DWORD ddraw_width, ddraw_height;
+};
+
+static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface_desc, void *context)
+{
+ struct test_coop_level_mode_set_enum_param *param = context;
+
+ if (U1(U4(surface_desc)->ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
+ return DDENUMRET_OK;
+ if (surface_desc->dwWidth == registry_mode.dmPelsWidth
+ && surface_desc->dwHeight == registry_mode.dmPelsHeight)
+ return DDENUMRET_OK;
+
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_CANCEL;
+}
+
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface7 *primary;
- RECT fullscreen_rect, r, s;
+ RECT registry_rect, ddraw_rect, r;
IDirectDraw7 *ddraw;
DDSURFACEDESC2 ddsd;
WNDCLASSA wc = {0};
@@ -2176,6 +2196,7 @@ static void test_coop_level_mode_set(void)
HRESULT hr;
ULONG ref;
MSG msg;
+ struct test_coop_level_mode_set_enum_param param;
static const UINT exclusive_messages[] =
{
@@ -2195,6 +2216,24 @@ static void test_coop_level_mode_set(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
+ memset(¶m, 0, sizeof(param));
+ hr = IDirectDraw7_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
+ ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+ ref = IDirectDraw7_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+
+ if (!param.ddraw_width)
+ {
+ skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ return;
+ }
+
+ SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+ SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
+
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
@@ -2207,15 +2246,12 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
- SetRect(&s, 0, 0, 640, 480);
-
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2227,14 +2263,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2242,26 +2278,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == s.right && screen_size.cy == s.bottom,
+ ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
- s.right, s.bottom, screen_size.cx, screen_size.cy);
+ param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2273,14 +2309,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2293,21 +2329,22 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2319,30 +2356,30 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2354,14 +2391,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2369,7 +2406,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2377,16 +2414,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2398,14 +2435,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2421,16 +2458,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2442,14 +2479,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* DDSCL_NORMAL | DDSCL_FULLSCREEN behaves the same as just DDSCL_NORMAL.
@@ -2459,16 +2496,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2480,14 +2517,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2495,7 +2532,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2503,16 +2540,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2524,14 +2561,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2547,16 +2584,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2568,21 +2605,21 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* Changing the coop level from EXCLUSIVE to NORMAL restores the screen resolution */
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2595,13 +2632,15 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2613,16 +2652,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
/* The screen restore is a property of DDSCL_EXCLUSIVE */
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
@@ -2637,10 +2676,10 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
hr = IDirectDraw7_RestoreDisplayMode(ddraw);
@@ -2649,7 +2688,7 @@ static void test_coop_level_mode_set(void)
/* If the window is changed at the same time, messages are sent to the new window. */
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2666,17 +2705,17 @@ static void test_coop_level_mode_set(void)
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
- ok(screen_size2.cx == fullscreen_rect.right && screen_size2.cy == fullscreen_rect.bottom,
+ ok(screen_size2.cx == registry_mode.dmPelsWidth && screen_size2.cy == registry_mode.dmPelsHeight,
"Expected screen size 2 %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size2.cx, screen_size2.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size2.cx, screen_size2.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
GetWindowRect(window2, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2688,18 +2727,18 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
ref = IDirectDraw7_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
expect_messages = NULL;
--
2.0.4
From stefan at codeweavers.com Mon Nov 10 16:08:23 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 10 Nov 2014 23:08:23 +0100
Subject: [PATCH 3/5] d3d9/tests: Fix some wndproc comparison error messages.
Message-ID: <1415657305-20856-3-git-send-email-stefan@codeweavers.com>
---
dlls/d3d9/tests/d3d9ex.c | 15 +++++----------
dlls/d3d9/tests/device.c | 21 +++++++--------------
2 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index bc60fcc..d93e591 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -1869,8 +1869,7 @@ static void test_wndproc(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
ref = IDirect3DDevice9Ex_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
@@ -1897,8 +1896,7 @@ static void test_wndproc(void)
}
proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
ref = IDirect3DDevice9Ex_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
@@ -2012,8 +2010,7 @@ static void test_wndproc_windowed(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
@@ -2050,8 +2047,7 @@ static void test_wndproc_windowed(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, focus_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
@@ -2086,8 +2082,7 @@ static void test_wndproc_windowed(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index d3618e2..28dc52e 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -3260,8 +3260,7 @@ static void test_wndproc(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
ref = IDirect3DDevice9_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
@@ -3288,8 +3287,7 @@ static void test_wndproc(void)
}
proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
ref = IDirect3DDevice9_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
@@ -3408,8 +3406,7 @@ static void test_wndproc_windowed(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
@@ -3446,8 +3443,7 @@ static void test_wndproc_windowed(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, focus_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
@@ -3482,8 +3478,7 @@ static void test_wndproc_windowed(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
@@ -4122,8 +4117,7 @@ static void test_device_window_reset(void)
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, FALSE);
ok(SUCCEEDED(hr), "Failed to reset device.\n");
@@ -4141,8 +4135,7 @@ static void test_device_window_reset(void)
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
ref = IDirect3DDevice9_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Mon Nov 10 16:08:24 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 10 Nov 2014 23:08:24 +0100
Subject: [PATCH 4/5] d3d8/tests: Fix some wndproc comparison error messages.
Message-ID: <1415657305-20856-4-git-send-email-stefan@codeweavers.com>
---
dlls/d3d8/tests/device.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 9153139..7468d13 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -2311,8 +2311,7 @@ static void test_wndproc(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
ref = IDirect3DDevice8_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
@@ -2339,8 +2338,7 @@ static void test_wndproc(void)
}
proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
ref = IDirect3DDevice8_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
@@ -2459,8 +2457,7 @@ static void test_wndproc_windowed(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
@@ -2497,8 +2494,7 @@ static void test_wndproc_windowed(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, focus_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
@@ -2533,8 +2529,7 @@ static void test_wndproc_windowed(void)
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, TRUE);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
@@ -3208,8 +3203,7 @@ static void test_device_window_reset(void)
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
hr = reset_device(device, device_window, FALSE);
ok(SUCCEEDED(hr), "Failed to reset device.\n");
@@ -3227,8 +3221,7 @@ static void test_device_window_reset(void)
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
ref = IDirect3DDevice8_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Mon Nov 10 16:08:25 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 10 Nov 2014 23:08:25 +0100
Subject: [PATCH 5/5] d3d9/tests: Allow passing a resolution to reset_device.
Message-ID: <1415657305-20856-5-git-send-email-stefan@codeweavers.com>
I will need this for the resolution restore on focus loss tests. d3d9ex
and d3d8 patches will follow.
---
dlls/d3d9/tests/device.c | 83 ++++++++++++++++++++++++++++++++----------------
1 file changed, 56 insertions(+), 27 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 28dc52e..1a5008a 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -178,19 +178,27 @@ static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window, cons
return NULL;
}
-static HRESULT reset_device(IDirect3DDevice9 *device, HWND device_window, BOOL windowed)
+static HRESULT reset_device(IDirect3DDevice9 *device, const struct device_desc *desc)
{
D3DPRESENT_PARAMETERS present_parameters = {0};
- present_parameters.Windowed = windowed;
- present_parameters.hDeviceWindow = device_window;
- present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
- present_parameters.BackBufferWidth = registry_mode.dmPelsWidth;
- present_parameters.BackBufferHeight = registry_mode.dmPelsHeight;
+ present_parameters.BackBufferWidth = 640;
+ present_parameters.BackBufferHeight = 480;
present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
+ present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
+ present_parameters.hDeviceWindow = NULL;
+ present_parameters.Windowed = TRUE;
present_parameters.EnableAutoDepthStencil = TRUE;
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
+ if (desc)
+ {
+ present_parameters.BackBufferWidth = desc->width;
+ present_parameters.BackBufferHeight = desc->height;
+ present_parameters.hDeviceWindow = desc->device_window;
+ present_parameters.Windowed = !(desc->flags & CREATE_DEVICE_FULLSCREEN);
+ }
+
return IDirect3DDevice9_Reset(device, &present_parameters);
}
@@ -2960,12 +2968,12 @@ static void test_scissor_size(void)
IDirect3D9 *d3d9_ptr;
unsigned int i;
static struct {
- int winx; int winy; int backx; int backy; BOOL window;
+ int winx; int winy; int backx; int backy; DWORD flags;
} scts[] = { /* scissor tests */
- {800, 600, 640, 480, TRUE},
- {800, 600, 640, 480, FALSE},
- {640, 480, 800, 600, TRUE},
- {640, 480, 800, 600, FALSE},
+ {800, 600, 640, 480, 0},
+ {800, 600, 640, 480, CREATE_DEVICE_FULLSCREEN},
+ {640, 480, 800, 600, 0},
+ {640, 480, 800, 600, CREATE_DEVICE_FULLSCREEN},
};
d3d9_ptr = Direct3DCreate9(D3D_SDK_VERSION);
@@ -2980,7 +2988,7 @@ static void test_scissor_size(void)
hwnd = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION,
0, 0, scts[i].winx, scts[i].winy, 0, 0, 0, 0);
- if (!scts[i].window)
+ if (scts[i].flags & CREATE_DEVICE_FULLSCREEN)
{
scts[i].backx = registry_mode.dmPelsWidth;
scts[i].backy = registry_mode.dmPelsHeight;
@@ -2989,7 +2997,7 @@ static void test_scissor_size(void)
device_desc.device_window = hwnd;
device_desc.width = scts[i].backx;
device_desc.height = scts[i].backy;
- device_desc.flags = scts[i].window ? 0 : CREATE_DEVICE_FULLSCREEN;
+ device_desc.flags = scts[i].flags;
if (!(device_ptr = create_device(d3d9_ptr, hwnd, &device_desc)))
{
skip("Failed to create a 3D device, skipping test.\n");
@@ -3006,7 +3014,10 @@ static void test_scissor_size(void)
scts[i].backx, scts[i].backy);
/* check the scissorrect values after a reset */
- hr = reset_device(device_ptr, hwnd, scts[i].window);
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.flags = scts[i].flags;
+ hr = reset_device(device_ptr, &device_desc);
ok(hr == D3D_OK, "IDirect3DDevice9_Reset failed with %08x\n", hr);
hr = IDirect3DDevice9_TestCooperativeLevel(device_ptr);
ok(hr == D3D_OK, "IDirect3DDevice9_TestCooperativeLevel after a successful reset returned %#x\n", hr);
@@ -3398,7 +3409,10 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
- hr = reset_device(device, device_window, FALSE);
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -3408,7 +3422,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, device_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -3435,7 +3450,8 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
- hr = reset_device(device, focus_window, FALSE);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -3445,7 +3461,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, focus_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -3470,7 +3487,9 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
- hr = reset_device(device, device_window, FALSE);
+ device_desc.device_window = device_window;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -3480,7 +3499,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, device_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -3517,6 +3537,7 @@ static void test_reset_fullscreen(void)
IDirect3DDevice9 *device = NULL;
IDirect3D9 *d3d;
ATOM atom;
+ struct device_desc device_desc;
static const struct message messages[] =
{
{WM_ACTIVATEAPP, FOCUS_WINDOW},
@@ -3555,7 +3576,11 @@ static void test_reset_fullscreen(void)
* This will force the window to be shown and will cause the WM_ACTIVATEAPP
* message to be sent.
*/
- ok(SUCCEEDED(reset_device(device, device_window, FALSE)), "Failed to reset device.\n");
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.device_window = device_window;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ ok(SUCCEEDED(reset_device(device, &device_desc)), "Failed to reset device.\n");
flush_events();
ok(expect_messages->message == 0, "Expected to receive message %#x.\n", expect_messages->message);
@@ -3740,7 +3765,8 @@ static void test_window_style(void)
focus_rect.left, focus_rect.top, focus_rect.right, focus_rect.bottom,
r.left, r.top, r.right, r.bottom, i);
- hr = reset_device(device, device_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
style = GetWindowLongA(device_window, GWL_STYLE);
@@ -4119,7 +4145,8 @@ static void test_device_window_reset(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, device_window, FALSE);
+ device_desc.device_window = device_window;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device.\n");
GetWindowRect(focus_window, &r);
@@ -4193,7 +4220,7 @@ static void test_reset_resources(void)
IDirect3DSurface9_Release(surface);
}
- hr = reset_device(device, device_window, TRUE);
+ hr = reset_device(device, NULL);
ok(SUCCEEDED(hr), "Failed to reset device.\n");
hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &rt);
@@ -9342,14 +9369,15 @@ static void test_lost_device(void)
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
- hr = reset_device(device, window, FALSE);
+ hr = reset_device(device, &device_desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = reset_device(device, window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -9372,7 +9400,8 @@ static void test_lost_device(void)
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = reset_device(device, window, FALSE);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
--
2.0.4
From mstefani at redhat.de Mon Nov 10 16:41:51 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Mon, 10 Nov 2014 23:41:51 +0100
Subject: wininet: Simplify the check for an empty string (PVS-Studio)
Message-ID: <20141110224151.GA31114@redhat.com>
---
dlls/wininet/ftp.c | 2 +-
dlls/wininet/tests/internet.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index 855aee0..f45e495 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -2496,7 +2496,7 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
if(hIC->proxyBypass)
FIXME("Proxy bypass is ignored.\n");
}
- if (!lpszUserName || !strlenW(lpszUserName)) {
+ if (!lpszUserName || !lpszUserName[0]) {
HKEY key;
WCHAR szPassword[MAX_PATH];
DWORD len = sizeof(szPassword);
diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c
index 1548615..5e09525 100644
--- a/dlls/wininet/tests/internet.c
+++ b/dlls/wininet/tests/internet.c
@@ -1578,7 +1578,7 @@ static void test_InternetGetConnectedStateExA(void)
res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
ok(res == TRUE, "Expected TRUE, got %d\n", res);
ok(flags, "Expected at least one flag set\n");
- ok(strlen(buffer) == 0, "Expected 0 bytes, got %u\n", lstrlenA(buffer));
+ ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer));
buffer[0] = 0;
flags = 0;
@@ -1592,7 +1592,7 @@ static void test_InternetGetConnectedStateExA(void)
res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
ok(res == TRUE, "Expected TRUE, got %d\n", res);
ok(flags, "Expected at least one flag set\n");
- ok(strlen(buffer) == 0, "Expected 0 bytes, got %u\n", lstrlenA(buffer));
+ ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer));
}
static void test_InternetGetConnectedStateExW(void)
@@ -1667,7 +1667,7 @@ static void test_InternetGetConnectedStateExW(void)
res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
ok(res == TRUE, "Expected TRUE, got %d\n", res);
ok(flags, "Expected at least one flag set\n");
- ok(lstrlenW(buffer) == 0, "Expected 0 bytes, got %u\n", lstrlenW(buffer));
+ ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
buffer[0] = 0;
flags = 0;
@@ -1681,7 +1681,7 @@ static void test_InternetGetConnectedStateExW(void)
res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
ok(res == TRUE, "Expected TRUE, got %d\n", res);
ok(flags, "Expected at least one flag set\n");
- ok(lstrlenW(buffer) == 0, "Expected 0 bytes, got %u\n", lstrlenW(buffer));
+ ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
}
/* ############################### */
--
1.8.3.1
From mstefani at redhat.de Mon Nov 10 16:44:08 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Mon, 10 Nov 2014 23:44:08 +0100
Subject: riched20/tests: Simplify the check for an empty string (PVS-Studio)
Message-ID: <20141110224408.GB31114@redhat.com>
---
dlls/riched20/tests/editor.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 5ad063e..244f065 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -3736,9 +3736,8 @@ static void test_EM_SETTEXTEX(void)
ok (result == 1,
"EM_SETTEXTEX returned %d, instead of 1\n",result);
- ok(lstrlenW(buf) == 0,
- "EM_SETTEXTEX with NULL lParam should clear rich edit.\n");
-
+ ok(!buf[0], "EM_SETTEXTEX with NULL lParam should clear rich edit.\n");
+
/* put some text back: !ST_SELECTION && Unicode && !\rtf */
setText.flags = 0;
SendMessageA(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM)TestItem1);
@@ -5225,8 +5224,7 @@ static void test_EM_STREAMIN(void)
result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
ok (result == 0,
"EM_STREAMIN: Test 2 returned %ld, expected 0\n", result);
- ok (strlen(buffer) == 0,
- "EM_STREAMIN: Test 2 set wrong text: Result: %s\n",buffer);
+ ok(!buffer[0], "EM_STREAMIN: Test 2 set wrong text: Result: %s\n",buffer);
ok(es.dwError == -16, "EM_STREAMIN: Test 2 set error %d, expected %d\n", es.dwError, -16);
es.dwCookie = (DWORD_PTR)&streamText3;
@@ -5237,8 +5235,7 @@ static void test_EM_STREAMIN(void)
result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
ok (result == 0,
"EM_STREAMIN: Test 3 returned %ld, expected 0\n", result);
- ok (strlen(buffer) == 0,
- "EM_STREAMIN: Test 3 set wrong text: Result: %s\n",buffer);
+ ok(!buffer[0], "EM_STREAMIN: Test 3 set wrong text: Result: %s\n",buffer);
ok(es.dwError == -16, "EM_STREAMIN: Test 3 set error %d, expected %d\n", es.dwError, -16);
es.dwCookie = (DWORD_PTR)&streamTextUTF8BOM;
--
1.8.3.1
From nerv at dawncrow.de Mon Nov 10 16:56:37 2014
From: nerv at dawncrow.de (=?ISO-8859-15?Q?Andr=E9_Hentschel?=)
Date: Mon, 10 Nov 2014 23:56:37 +0100
Subject: avifil32: Simplify comparing two unsigned ints (PVS-Studio) (try
2)
Message-ID: <546142A5.1010302@dawncrow.de>
try 2: added the missing +1 thanks to a hint by ken on irc
---
dlls/avifil32/avifile.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-avifil32-Simplify-comparing-two-unsigned-ints-PVS-Stud.txt
Type: text/x-patch
Size: 815 bytes
Desc: not available
URL:
From alexhenrie24 at gmail.com Tue Nov 11 00:34:26 2014
From: alexhenrie24 at gmail.com (Alex Henrie)
Date: Mon, 10 Nov 2014 23:34:26 -0700
Subject: [PATCH] kernel32/tests: Add tabular UTF-7 encoding tests.
Message-ID: <1415687666-2756-1-git-send-email-alexhenrie24@gmail.com>
---
dlls/kernel32/tests/codepage.c | 141 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 141 insertions(+)
diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 6e89533..9f5fad7 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -433,6 +433,119 @@ static void test_utf7_encoding(void)
static const char base64_encoding_table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ const struct
+ {
+ /* inputs */
+ WCHAR src[16];
+ int srclen;
+ char *dst;
+ int dstlen;
+ /* expected outputs */
+ char expected_dst[16];
+ int chars_written;
+ int len;
+ }
+ tests[] =
+ {
+ /* tests string conversion with srclen=-1 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, sizeof(output) - 1,
+ "+T2BZfVQX-", 11, 11
+ },
+ /* tests string conversion with srclen=-2 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -2, output, sizeof(output) - 1,
+ "+T2BZfVQX-", 11, 11
+ },
+ /* tests string conversion with dstlen=strlen(expected_dst) */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, 10,
+ "+T2BZfVQX-", 10, 0
+ },
+ /* tests string conversion with dstlen=strlen(expected_dst)+1 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, 11,
+ "+T2BZfVQX-", 11, 11
+ },
+ /* tests string conversion with dstlen=strlen(expected_dst)+2 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, 12,
+ "+T2BZfVQX-", 11, 11
+ },
+ /* tests dry run with dst=NULL and dstlen=0 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, NULL, 0,
+ {}, 0, 11
+ },
+ /* tests dry run with dst!=NULL and dstlen=0 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, 0,
+ {}, 0, 11
+ },
+ /* tests srclen > strlenW(src) */
+ {
+ {'a',0,'b',0}, 4, output, sizeof(output) - 1,
+ "a\0b", 4, 4
+ },
+ /* tests srclen < strlenW(src) with directly encodable chars */
+ {
+ {'h','e','l','l','o',0}, 2, output, sizeof(output) - 1,
+ "he", 2, 2
+ },
+ /* tests srclen < strlenW(src) with non-directly encodable chars */
+ {
+ {0x4F60,0x597D,0x5417,0}, 2, output, sizeof(output) - 1,
+ "+T2BZfQ-", 8, 8
+ },
+ /* tests a single null char */
+ {
+ {0}, -1, output, sizeof(output) - 1,
+ "", 1, 1
+ },
+ /* tests a buffer that runs out while not encoding a UTF-7 sequence */
+ {
+ {'h','e','l','l','o',0}, -1, output, 2,
+ "he", 2, 0
+ },
+ /* tests a buffer that runs out after writing 1 base64 character */
+ {
+ {0x4F60,0x0001,0}, -1, output, 2,
+ "+T", 2, 0
+ },
+ /* tests a buffer that runs out after writing 2 base64 characters */
+ {
+ {0x4F60,0x0001,0}, -1, output, 3,
+ "+T2", 3, 0
+ },
+ /* tests a buffer that runs out after writing 3 base64 characters */
+ {
+ {0x4F60,0x0001,0}, -1, output, 4,
+ "+T2A", 4, 0
+ },
+ /* tests a buffer that runs out just after writing the + sign */
+ {
+ {0x4F60,0}, -1, output, 1,
+ "+", 1, 0
+ },
+ /* tests a buffer that runs out just before writing the - sign
+ * the number of bits to encode here is evenly divisible by 6 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, 9,
+ "+T2BZfVQX", 9, 0
+ },
+ /* tests a buffer that runs out just before writing the - sign
+ * the number of bits to encode here is NOT evenly divisible by 6 */
+ {
+ {0x4F60,0}, -1, output, 4,
+ "+T2", 3, 0
+ },
+ /* tests a buffer that runs out in the middle of escaping a + sign */
+ {
+ {'+',0}, -1, output, 1,
+ "+", 1, 0
+ }
+ };
+
if (WideCharToMultiByte(CP_UTF7, 0, foobarW, -1, NULL, 0, NULL, NULL) == 0 &&
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
@@ -525,6 +638,34 @@ static void test_utf7_encoding(void)
ok(output[expected_len] == '#', "i=0x%04x: expected output[%i]='#', got output[%i]=%i\n",
i, expected_len, expected_len, output[expected_len]);
}
+
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ {
+ memset(output, '#', sizeof(output) - 1);
+ output[sizeof(output) - 1] = 0;
+ SetLastError(0xdeadbeef);
+
+ len = WideCharToMultiByte(CP_UTF7, 0, tests[i].src, tests[i].srclen,
+ tests[i].dst, tests[i].dstlen, NULL, NULL);
+
+ if (!tests[i].len)
+ {
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
+ "tests[%i]: expected error=0x%x, got error=0x%x\n",
+ i, ERROR_INSUFFICIENT_BUFFER, GetLastError());
+ }
+ ok(len == tests[i].len, "tests[%i]: expected len=%i, got len=%i\n", i, tests[i].len, len);
+
+ if (tests[i].dst)
+ {
+ ok(memcmp(tests[i].dst, tests[i].expected_dst, tests[i].chars_written) == 0,
+ "tests[%i]: expected dst='%s', got dst='%s'\n",
+ i, tests[i].expected_dst, tests[i].dst);
+ ok(tests[i].dst[tests[i].chars_written] == '#',
+ "tests[%i]: expected dst[%i]='#', got dst[%i]=%i\n",
+ i, tests[i].chars_written, tests[i].chars_written, tests[i].dst[tests[i].chars_written]);
+ }
+ }
}
static void test_utf7_decoding(void)
--
2.1.3
From jacek at codeweavers.com Tue Nov 11 03:55:34 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Tue, 11 Nov 2014 10:55:34 +0100
Subject: [PATCH 1/2] mshtml: Added IDispatchEx support to HTMLTxtRange object.
Message-ID: <5461DD16.4000809@codeweavers.com>
---
dlls/mshtml/mshtml_private.h | 1 +
dlls/mshtml/tests/dom.c | 2 ++
dlls/mshtml/txtrange.c | 58
++++++++++++++++++++++++++------------------
3 files changed, 37 insertions(+), 24 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Added-IDispatchEx-support-to-HTMLTxtRange-obje.diff
Type: text/x-patch
Size: 6029 bytes
Desc: not available
URL:
From jacek at codeweavers.com Tue Nov 11 03:55:53 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Tue, 11 Nov 2014 10:55:53 +0100
Subject: [PATCH 2/2] mshtml: Added support for IDispatchEx to
HTMLSelectionObject object.
Message-ID: <5461DD29.5020607@codeweavers.com>
---
dlls/mshtml/mshtml_private.h | 1 +
dlls/mshtml/selection.c | 56
+++++++++++++++++++++++++++-----------------
dlls/mshtml/tests/dom.c | 2 ++
3 files changed, 38 insertions(+), 21 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-mshtml-Added-support-for-IDispatchEx-to-HTMLSelection.diff
Type: text/x-patch
Size: 6305 bytes
Desc: not available
URL:
From hugh.mcmaster at outlook.com Tue Nov 11 04:24:51 2014
From: hugh.mcmaster at outlook.com (Hugh McMaster)
Date: Tue, 11 Nov 2014 21:24:51 +1100
Subject: [PATCH v2] cmd/tests: Add tests for 'del' (Fixes bug 35970)
Message-ID:
Wine currently returns an errorlevel of 1 when trying to delete a non-existent file.
Testing reveals 0 is the correct return value for all versions of Windows, except Windows 2000 (which does actually return 1).
Note that the DWORD errorlevel is set to 0 before this change.
-??????? if (!found) {
-??????????? errorlevel = 1;
+??????? if (!found)
This patch fixes bug 35970.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmd-del-test.patch
Type: application/octet-stream
Size: 2381 bytes
Desc: not available
URL:
From jacek at codeweavers.com Tue Nov 11 04:37:22 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Tue, 11 Nov 2014 11:37:22 +0100
Subject: mshtml: Ignore query and hash parts in res protocol handler.
Message-ID: <5461E6E2.2060904@codeweavers.com>
try2: Skipping tests on too old IEs.
---
dlls/mshtml/protocol.c | 8 +++++++-
dlls/mshtml/tests/protocol.c | 7 +++++++
2 files changed, 14 insertions(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Ignore-query-and-hash-parts-in-res-protocol-ha.diff
Type: text/x-patch
Size: 1769 bytes
Desc: not available
URL:
From jacek at codeweavers.com Tue Nov 11 05:34:09 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Tue, 11 Nov 2014 12:34:09 +0100
Subject: [PATCH 2/2] mshtml: Added script element readyState and
onreadystatechange tests.
Message-ID: <5461F431.2070708@codeweavers.com>
---
dlls/mshtml/tests/events.html | 76
++++++++++++++++++++++++++++++++++++++++--
dlls/mshtml/tests/externscr.js | 2 ++
dlls/mshtml/tests/script.c | 19 +++++++++++
3 files changed, 95 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-mshtml-Added-script-element-readyState-and-onreadysta.diff
Type: text/x-patch
Size: 6043 bytes
Desc: not available
URL:
From jacek at codeweavers.com Tue Nov 11 05:33:56 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Tue, 11 Nov 2014 12:33:56 +0100
Subject: [PATCH 1/2] mshtml: Delay onreadystateevent notification if script
elemenet is not added by parser.
Message-ID: <5461F424.3070202@codeweavers.com>
Resend with tests fixed.
---
dlls/mshtml/htmlscript.h | 1 +
dlls/mshtml/script.c | 50
++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 49 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Delay-onreadystateevent-notification-if-script.diff
Type: text/x-patch
Size: 2832 bytes
Desc: not available
URL:
From piotr at codeweavers.com Tue Nov 11 08:58:03 2014
From: piotr at codeweavers.com (Piotr Caban)
Date: Tue, 11 Nov 2014 15:58:03 +0100
Subject: [PATCH 1/4] msvcrt: Initialize file descriptor critical section
Message-ID: <546223FB.6030404@codeweavers.com>
---
dlls/msvcrt/file.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-msvcrt-Initialize-file-descriptor-critical-section.txt
Type: text/x-patch
Size: 1054 bytes
Desc: not available
URL:
From piotr at codeweavers.com Tue Nov 11 08:58:08 2014
From: piotr at codeweavers.com (Piotr Caban)
Date: Tue, 11 Nov 2014 15:58:08 +0100
Subject: [PATCH 2/4] msvcrt: Rename msvcrt_get_ioinfo function
Message-ID: <54622400.5070400@codeweavers.com>
---
dlls/msvcrt/file.c | 98
+++++++++++++++++++++++++++---------------------------
1 file changed, 49 insertions(+), 49 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-msvcrt-Rename-msvcrt_get_ioinfo-function.txt
Type: text/x-patch
Size: 14209 bytes
Desc: not available
URL:
From piotr at codeweavers.com Tue Nov 11 08:58:13 2014
From: piotr at codeweavers.com (Piotr Caban)
Date: Tue, 11 Nov 2014 15:58:13 +0100
Subject: [PATCH 3/4] msvcrt: Use fd critical section in _commit
Message-ID: <54622405.9050301@codeweavers.com>
---
dlls/msvcrt/file.c | 46 +++++++++++++++++++++++++++++++++++-----------
1 file changed, 35 insertions(+), 11 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-msvcrt-Use-fd-critical-section-in-_commit.txt
Type: text/x-patch
Size: 1944 bytes
Desc: not available
URL:
From piotr at codeweavers.com Tue Nov 11 08:58:18 2014
From: piotr at codeweavers.com (Piotr Caban)
Date: Tue, 11 Nov 2014 15:58:18 +0100
Subject: [PATCH 4/4] msvcrt: Use fd critical section in _close
Message-ID: <5462240A.4070707@codeweavers.com>
---
dlls/msvcrt/file.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-msvcrt-Use-fd-critical-section-in-_close.txt
Type: text/x-patch
Size: 872 bytes
Desc: not available
URL:
From nerv at dawncrow.de Tue Nov 11 14:20:46 2014
From: nerv at dawncrow.de (=?ISO-8859-15?Q?Andr=E9_Hentschel?=)
Date: Tue, 11 Nov 2014 21:20:46 +0100
Subject: avifil32: Simplify comparing two unsigned ints (PVS-Studio) (try
3)
Message-ID: <54626F9E.6030004@dawncrow.de>
now also addressing problems with the original logic
---
dlls/avifil32/avifile.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-avifil32-Simplify-comparing-two-unsigned-ints-PVS-Stud.txt
Type: text/x-patch
Size: 981 bytes
Desc: not available
URL:
From yifuwang2012 at gmail.com Tue Nov 11 16:02:51 2014
From: yifuwang2012 at gmail.com (Yifu Wang)
Date: Tue, 11 Nov 2014 14:02:51 -0800
Subject: [PATCH] msvcp120: Added VS2013 CPP runtime dll
Message-ID:
---
configure.ac | 1 +
dlls/msvcp120/Makefile.in | 14 +
dlls/msvcp120/msvcp120.spec | 3846 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 3861 insertions(+), 0 deletions(-)
create mode 100644 dlls/msvcp120/Makefile.in
create mode 100644 dlls/msvcp120/msvcp120.spec
From stefan at codeweavers.com Tue Nov 11 17:18:04 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 00:18:04 +0100
Subject: [PATCH 2/5] ddraw/tests: Ddraw restores the mode settings from the
registry (v2).
Message-ID: <1415747887-32375-2-git-send-email-stefan@codeweavers.com>
v2: Merge with test_coop_level_mode_set. This has the positive side
effect that the messages on external mode changes are explicitly tested.
This behavior is already hinted by test_coop_level_mode_set_multi,
although mode_set_multi tests multiple ddraw interfaces and not external
mode changes.
---
dlls/ddraw/tests/ddraw1.c | 150 +++++++++++++++++++++++++++++++++++++++-------
dlls/ddraw/tests/ddraw2.c | 150 +++++++++++++++++++++++++++++++++++++++-------
dlls/ddraw/tests/ddraw4.c | 150 +++++++++++++++++++++++++++++++++++++++-------
dlls/ddraw/tests/ddraw7.c | 150 +++++++++++++++++++++++++++++++++++++++-------
4 files changed, 508 insertions(+), 92 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index ed18b47..0ae204c 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -2104,7 +2104,7 @@ static LRESULT CALLBACK mode_set_proc(HWND hwnd, UINT message, WPARAM wparam, LP
struct test_coop_level_mode_set_enum_param
{
- DWORD ddraw_width, ddraw_height;
+ DWORD ddraw_width, ddraw_height, user32_width, user32_height;
};
static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_desc, void *context)
@@ -2117,15 +2117,24 @@ static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_
&& surface_desc->dwHeight == registry_mode.dmPelsHeight)
return DDENUMRET_OK;
- param->ddraw_width = surface_desc->dwWidth;
- param->ddraw_height = surface_desc->dwHeight;
+ if (!param->ddraw_width)
+ {
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_OK;
+ }
+ if (surface_desc->dwWidth == param->ddraw_width && surface_desc->dwHeight == param->ddraw_height)
+ return DDENUMRET_OK;
+
+ param->user32_width = surface_desc->dwWidth;
+ param->user32_height = surface_desc->dwHeight;
return DDENUMRET_CANCEL;
}
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface *primary;
- RECT registry_rect, ddraw_rect, r;
+ RECT registry_rect, ddraw_rect, user32_rect, r;
IDirectDraw *ddraw;
DDSURFACEDESC ddsd;
WNDCLASSA wc = {0};
@@ -2134,6 +2143,9 @@ static void test_coop_level_mode_set(void)
ULONG ref;
MSG msg;
struct test_coop_level_mode_set_enum_param param;
+ DEVMODEW devmode;
+ BOOL ret;
+ LONG change_ret;
static const UINT exclusive_messages[] =
{
@@ -2156,17 +2168,29 @@ static void test_coop_level_mode_set(void)
memset(¶m, 0, sizeof(param));
hr = IDirectDraw_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+ ref = IDirectDraw_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
- if (!param.ddraw_width)
+ if (!param.user32_height)
{
- skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
- ref = IDirectDraw_Release(ddraw);
- ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+ skip("Fewer than 3 different modes supported, skipping mode restore test.\n");
return;
}
SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+ SetRect(&user32_rect, 0, 0, param.user32_width, param.user32_height);
+
+ memset(&devmode, 0, sizeof(devmode));
+ devmode.dmSize = sizeof(devmode);
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
@@ -2179,8 +2203,8 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2192,14 +2216,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2223,10 +2247,10 @@ static void test_coop_level_mode_set(void)
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2253,18 +2277,37 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
+ "Expected screen size %ux%u, got %ux%u.\n",
+ param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = exclusive_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == registry_mode.dmPelsWidth
+ todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ todo_wine ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
@@ -2276,6 +2319,10 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ /* For Wine. */
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2335,6 +2382,23 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
{
@@ -2406,6 +2470,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2468,6 +2542,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2532,6 +2626,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 4e10d26..334d89e 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -2303,7 +2303,7 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
struct test_coop_level_mode_set_enum_param
{
- DWORD ddraw_width, ddraw_height;
+ DWORD ddraw_width, ddraw_height, user32_width, user32_height;
};
static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_desc, void *context)
@@ -2316,15 +2316,24 @@ static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_
&& surface_desc->dwHeight == registry_mode.dmPelsHeight)
return DDENUMRET_OK;
- param->ddraw_width = surface_desc->dwWidth;
- param->ddraw_height = surface_desc->dwHeight;
+ if (!param->ddraw_width)
+ {
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_OK;
+ }
+ if (surface_desc->dwWidth == param->ddraw_width && surface_desc->dwHeight == param->ddraw_height)
+ return DDENUMRET_OK;
+
+ param->user32_width = surface_desc->dwWidth;
+ param->user32_height = surface_desc->dwHeight;
return DDENUMRET_CANCEL;
}
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface *primary;
- RECT registry_rect, ddraw_rect, r;
+ RECT registry_rect, ddraw_rect, user32_rect, r;
IDirectDraw2 *ddraw;
DDSURFACEDESC ddsd;
WNDCLASSA wc = {0};
@@ -2333,6 +2342,9 @@ static void test_coop_level_mode_set(void)
ULONG ref;
MSG msg;
struct test_coop_level_mode_set_enum_param param;
+ DEVMODEW devmode;
+ BOOL ret;
+ LONG change_ret;
static const UINT exclusive_messages[] =
{
@@ -2355,17 +2367,29 @@ static void test_coop_level_mode_set(void)
memset(¶m, 0, sizeof(param));
hr = IDirectDraw2_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+ ref = IDirectDraw2_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
- if (!param.ddraw_width)
+ if (!param.user32_height)
{
- skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
- ref = IDirectDraw2_Release(ddraw);
- ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+ skip("Fewer than 3 different modes supported, skipping mode restore test.\n");
return;
}
SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+ SetRect(&user32_rect, 0, 0, param.user32_width, param.user32_height);
+
+ memset(&devmode, 0, sizeof(devmode));
+ devmode.dmSize = sizeof(devmode);
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
@@ -2383,8 +2407,8 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2396,14 +2420,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2427,10 +2451,10 @@ static void test_coop_level_mode_set(void)
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2457,18 +2481,37 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
+ "Expected screen size %ux%u, got %ux%u.\n",
+ param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = exclusive_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == registry_mode.dmPelsWidth
+ todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ todo_wine ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
@@ -2480,6 +2523,10 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ /* For Wine. */
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2539,6 +2586,23 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
{
@@ -2610,6 +2674,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2672,6 +2746,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2736,6 +2830,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 5ebbc11..ab03f39 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -2490,7 +2490,7 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
struct test_coop_level_mode_set_enum_param
{
- DWORD ddraw_width, ddraw_height;
+ DWORD ddraw_width, ddraw_height, user32_width, user32_height;
};
static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface_desc, void *context)
@@ -2503,15 +2503,24 @@ static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface
&& surface_desc->dwHeight == registry_mode.dmPelsHeight)
return DDENUMRET_OK;
- param->ddraw_width = surface_desc->dwWidth;
- param->ddraw_height = surface_desc->dwHeight;
+ if (!param->ddraw_width)
+ {
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_OK;
+ }
+ if (surface_desc->dwWidth == param->ddraw_width && surface_desc->dwHeight == param->ddraw_height)
+ return DDENUMRET_OK;
+
+ param->user32_width = surface_desc->dwWidth;
+ param->user32_height = surface_desc->dwHeight;
return DDENUMRET_CANCEL;
}
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface4 *primary;
- RECT registry_rect, ddraw_rect, r;
+ RECT registry_rect, ddraw_rect, user32_rect, r;
IDirectDraw4 *ddraw;
DDSURFACEDESC2 ddsd;
WNDCLASSA wc = {0};
@@ -2520,6 +2529,9 @@ static void test_coop_level_mode_set(void)
ULONG ref;
MSG msg;
struct test_coop_level_mode_set_enum_param param;
+ DEVMODEW devmode;
+ BOOL ret;
+ LONG change_ret;
static const UINT exclusive_messages[] =
{
@@ -2542,17 +2554,29 @@ static void test_coop_level_mode_set(void)
memset(¶m, 0, sizeof(param));
hr = IDirectDraw4_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+ ref = IDirectDraw4_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
- if (!param.ddraw_width)
+ if (!param.user32_height)
{
- skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
- ref = IDirectDraw4_Release(ddraw);
- ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+ skip("Fewer than 3 different modes supported, skipping mode restore test.\n");
return;
}
SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+ SetRect(&user32_rect, 0, 0, param.user32_width, param.user32_height);
+
+ memset(&devmode, 0, sizeof(devmode));
+ devmode.dmSize = sizeof(devmode);
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
@@ -2570,8 +2594,8 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2583,14 +2607,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2614,10 +2638,10 @@ static void test_coop_level_mode_set(void)
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2644,18 +2668,37 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
+ "Expected screen size %ux%u, got %ux%u.\n",
+ param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = exclusive_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == registry_mode.dmPelsWidth
+ todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ todo_wine ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
@@ -2667,6 +2710,10 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
+ /* For Wine. */
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2726,6 +2773,23 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2790,6 +2854,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2852,6 +2926,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2916,6 +3010,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 7850fb5..cbf6112 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -2167,7 +2167,7 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
struct test_coop_level_mode_set_enum_param
{
- DWORD ddraw_width, ddraw_height;
+ DWORD ddraw_width, ddraw_height, user32_width, user32_height;
};
static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface_desc, void *context)
@@ -2180,15 +2180,24 @@ static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface
&& surface_desc->dwHeight == registry_mode.dmPelsHeight)
return DDENUMRET_OK;
- param->ddraw_width = surface_desc->dwWidth;
- param->ddraw_height = surface_desc->dwHeight;
+ if (!param->ddraw_width)
+ {
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_OK;
+ }
+ if (surface_desc->dwWidth == param->ddraw_width && surface_desc->dwHeight == param->ddraw_height)
+ return DDENUMRET_OK;
+
+ param->user32_width = surface_desc->dwWidth;
+ param->user32_height = surface_desc->dwHeight;
return DDENUMRET_CANCEL;
}
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface7 *primary;
- RECT registry_rect, ddraw_rect, r;
+ RECT registry_rect, ddraw_rect, user32_rect, r;
IDirectDraw7 *ddraw;
DDSURFACEDESC2 ddsd;
WNDCLASSA wc = {0};
@@ -2197,6 +2206,9 @@ static void test_coop_level_mode_set(void)
ULONG ref;
MSG msg;
struct test_coop_level_mode_set_enum_param param;
+ DEVMODEW devmode;
+ BOOL ret;
+ LONG change_ret;
static const UINT exclusive_messages[] =
{
@@ -2219,17 +2231,29 @@ static void test_coop_level_mode_set(void)
memset(¶m, 0, sizeof(param));
hr = IDirectDraw7_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+ ref = IDirectDraw7_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
- if (!param.ddraw_width)
+ if (!param.user32_height)
{
- skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
- ref = IDirectDraw7_Release(ddraw);
- ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+ skip("Fewer than 3 different modes supported, skipping mode restore test.\n");
return;
}
SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+ SetRect(&user32_rect, 0, 0, param.user32_width, param.user32_height);
+
+ memset(&devmode, 0, sizeof(devmode));
+ devmode.dmSize = sizeof(devmode);
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ddraw = create_ddraw();
+ ok(!!ddraw, "Failed to create a ddraw object.\n");
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
@@ -2247,8 +2271,8 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2260,14 +2284,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2291,10 +2315,10 @@ static void test_coop_level_mode_set(void)
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
- registry_mode.dmPelsWidth, ddsd.dwWidth);
- ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
- registry_mode.dmPelsHeight, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+ param.user32_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+ param.user32_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2321,18 +2345,37 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
+ "Expected screen size %ux%u, got %ux%u.\n",
+ param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, &user32_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = exclusive_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == registry_mode.dmPelsWidth
+ todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ todo_wine ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
@@ -2344,6 +2387,10 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
+ /* For Wine. */
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2403,6 +2450,23 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2467,6 +2531,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
@@ -2529,6 +2603,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
+ devmode.dmPelsWidth = param.user32_width;
+ devmode.dmPelsHeight = param.user32_height;
+ change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
+ ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ expect_messages = NULL;
+ ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+
+ GetWindowRect(window, &r);
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
+ r.left, r.top, r.right, r.bottom);
+
+ PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
+ expect_messages = normal_messages;
+ screen_size.cx = 0;
+ screen_size.cy = 0;
+
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
@@ -2593,6 +2687,16 @@ static void test_coop_level_mode_set(void)
param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
+ ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+ ok(ret, "Failed to get display mode.\n");
+ todo_wine ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
+ && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
+ "Expected resolution %ux%u, got %ux%u.\n",
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ devmode.dmPelsWidth, devmode.dmPelsHeight);
+ change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
+ ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
--
2.0.4
From stefan at codeweavers.com Tue Nov 11 17:18:03 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 00:18:03 +0100
Subject: [PATCH 1/5] ddraw/tests: Rename modes and rectangles in
test_coop_level_mode_set (v2).
Message-ID: <1415747887-32375-1-git-send-email-stefan@codeweavers.com>
Version 2: Move the recreation of the ddraw object into patch 2.
I split this out of the next patch to make it easier to review. It
introduces the mode selection from test_mode_change in d3d8/9 but does
not introduce the additional tests yet. Other than selecting a variable
mode this is a no-op.
---
dlls/ddraw/tests/ddraw1.c | 278 ++++++++++++++++++++++------------------
dlls/ddraw/tests/ddraw2.c | 320 ++++++++++++++++++++++++++--------------------
dlls/ddraw/tests/ddraw4.c | 320 ++++++++++++++++++++++++++--------------------
dlls/ddraw/tests/ddraw7.c | 320 ++++++++++++++++++++++++++--------------------
4 files changed, 690 insertions(+), 548 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index fe8a36e..ed18b47 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -2102,10 +2102,30 @@ static LRESULT CALLBACK mode_set_proc(HWND hwnd, UINT message, WPARAM wparam, LP
return test_proc(hwnd, message, wparam, lparam);
}
+struct test_coop_level_mode_set_enum_param
+{
+ DWORD ddraw_width, ddraw_height;
+};
+
+static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_desc, void *context)
+{
+ struct test_coop_level_mode_set_enum_param *param = context;
+
+ if (U1(surface_desc->ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
+ return DDENUMRET_OK;
+ if (surface_desc->dwWidth == registry_mode.dmPelsWidth
+ && surface_desc->dwHeight == registry_mode.dmPelsHeight)
+ return DDENUMRET_OK;
+
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_CANCEL;
+}
+
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface *primary;
- RECT fullscreen_rect, r, s;
+ RECT registry_rect, ddraw_rect, r;
IDirectDraw *ddraw;
DDSURFACEDESC ddsd;
WNDCLASSA wc = {0};
@@ -2113,6 +2133,7 @@ static void test_coop_level_mode_set(void)
HRESULT hr;
ULONG ref;
MSG msg;
+ struct test_coop_level_mode_set_enum_param param;
static const UINT exclusive_messages[] =
{
@@ -2132,6 +2153,21 @@ static void test_coop_level_mode_set(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
+ memset(¶m, 0, sizeof(param));
+ hr = IDirectDraw_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
+ ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+
+ if (!param.ddraw_width)
+ {
+ skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ ref = IDirectDraw_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+ return;
+ }
+
+ SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+ SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
@@ -2139,15 +2175,12 @@ static void test_coop_level_mode_set(void)
window = CreateWindowA("ddraw_test_wndproc_wc", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
- SetRect(&s, 0, 0, 640, 480);
-
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2159,14 +2192,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2174,26 +2207,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == s.right && screen_size.cy == s.bottom,
+ ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
- s.right, s.bottom, screen_size.cx, screen_size.cy);
+ param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2205,14 +2238,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2225,21 +2258,22 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2251,30 +2285,30 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2286,14 +2320,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2301,7 +2335,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
{
win_skip("Broken SetDisplayMode(), skipping remaining tests.\n");
@@ -2316,16 +2350,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2337,14 +2371,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2360,16 +2394,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2381,14 +2415,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* DDSCL_NORMAL | DDSCL_FULLSCREEN behaves the same as just DDSCL_NORMAL.
@@ -2398,16 +2432,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2419,14 +2453,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2434,7 +2468,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2442,16 +2476,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2463,14 +2497,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2486,16 +2520,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2507,21 +2541,21 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* Unlike ddraw2-7, changing from EXCLUSIVE to NORMAL does not restore the resolution */
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
@@ -2536,10 +2570,10 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
@@ -2548,8 +2582,8 @@ static void test_coop_level_mode_set(void)
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
done:
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index ad0d040..4e10d26 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -2301,10 +2301,30 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
return test_proc(hwnd, message, wparam, lparam);
}
+struct test_coop_level_mode_set_enum_param
+{
+ DWORD ddraw_width, ddraw_height;
+};
+
+static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC *surface_desc, void *context)
+{
+ struct test_coop_level_mode_set_enum_param *param = context;
+
+ if (U1(surface_desc->ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
+ return DDENUMRET_OK;
+ if (surface_desc->dwWidth == registry_mode.dmPelsWidth
+ && surface_desc->dwHeight == registry_mode.dmPelsHeight)
+ return DDENUMRET_OK;
+
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_CANCEL;
+}
+
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface *primary;
- RECT fullscreen_rect, r, s;
+ RECT registry_rect, ddraw_rect, r;
IDirectDraw2 *ddraw;
DDSURFACEDESC ddsd;
WNDCLASSA wc = {0};
@@ -2312,6 +2332,7 @@ static void test_coop_level_mode_set(void)
HRESULT hr;
ULONG ref;
MSG msg;
+ struct test_coop_level_mode_set_enum_param param;
static const UINT exclusive_messages[] =
{
@@ -2331,6 +2352,21 @@ static void test_coop_level_mode_set(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
+ memset(¶m, 0, sizeof(param));
+ hr = IDirectDraw2_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
+ ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+
+ if (!param.ddraw_width)
+ {
+ skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ ref = IDirectDraw2_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+ return;
+ }
+
+ SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+ SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
@@ -2343,15 +2379,12 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
- SetRect(&s, 0, 0, 640, 480);
-
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2363,14 +2396,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2378,26 +2411,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == s.right && screen_size.cy == s.bottom,
+ ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
- s.right, s.bottom, screen_size.cx, screen_size.cy);
+ param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2409,14 +2442,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2429,21 +2462,22 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2455,30 +2489,30 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2490,14 +2524,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2505,7 +2539,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
{
win_skip("Broken SetDisplayMode(), skipping remaining tests.\n");
@@ -2520,16 +2554,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2541,14 +2575,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2564,16 +2598,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2585,14 +2619,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* DDSCL_NORMAL | DDSCL_FULLSCREEN behaves the same as just DDSCL_NORMAL.
@@ -2602,16 +2636,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2623,14 +2657,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2638,7 +2672,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2646,16 +2680,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2667,14 +2701,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2690,16 +2724,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2711,21 +2745,21 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* Changing the coop level from EXCLUSIVE to NORMAL restores the screen resolution */
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2738,13 +2772,15 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2756,16 +2792,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
/* The screen restore is a property of DDSCL_EXCLUSIVE */
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
@@ -2780,10 +2816,10 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
@@ -2792,7 +2828,7 @@ static void test_coop_level_mode_set(void)
/* If the window is changed at the same time, messages are sent to the new window. */
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2809,17 +2845,17 @@ static void test_coop_level_mode_set(void)
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
- ok(screen_size2.cx == fullscreen_rect.right && screen_size2.cy == fullscreen_rect.bottom,
+ ok(screen_size2.cx == registry_mode.dmPelsWidth && screen_size2.cy == registry_mode.dmPelsHeight,
"Expected screen size 2 %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size2.cx, screen_size2.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size2.cx, screen_size2.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
GetWindowRect(window2, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2831,18 +2867,18 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface_Release(primary);
ref = IDirectDraw2_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
done:
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 69f3ac7..5ebbc11 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -2488,10 +2488,30 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
return test_proc(hwnd, message, wparam, lparam);
}
+struct test_coop_level_mode_set_enum_param
+{
+ DWORD ddraw_width, ddraw_height;
+};
+
+static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface_desc, void *context)
+{
+ struct test_coop_level_mode_set_enum_param *param = context;
+
+ if (U1(U4(surface_desc)->ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
+ return DDENUMRET_OK;
+ if (surface_desc->dwWidth == registry_mode.dmPelsWidth
+ && surface_desc->dwHeight == registry_mode.dmPelsHeight)
+ return DDENUMRET_OK;
+
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_CANCEL;
+}
+
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface4 *primary;
- RECT fullscreen_rect, r, s;
+ RECT registry_rect, ddraw_rect, r;
IDirectDraw4 *ddraw;
DDSURFACEDESC2 ddsd;
WNDCLASSA wc = {0};
@@ -2499,6 +2519,7 @@ static void test_coop_level_mode_set(void)
HRESULT hr;
ULONG ref;
MSG msg;
+ struct test_coop_level_mode_set_enum_param param;
static const UINT exclusive_messages[] =
{
@@ -2518,6 +2539,21 @@ static void test_coop_level_mode_set(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
+ memset(¶m, 0, sizeof(param));
+ hr = IDirectDraw4_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
+ ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+
+ if (!param.ddraw_width)
+ {
+ skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ ref = IDirectDraw4_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+ return;
+ }
+
+ SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+ SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
@@ -2530,15 +2566,12 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
- SetRect(&s, 0, 0, 640, 480);
-
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2550,14 +2583,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2565,26 +2598,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == s.right && screen_size.cy == s.bottom,
+ ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
- s.right, s.bottom, screen_size.cx, screen_size.cy);
+ param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2596,14 +2629,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2616,21 +2649,22 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2642,30 +2676,30 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2677,14 +2711,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2692,7 +2726,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2700,16 +2734,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2721,14 +2755,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2744,16 +2778,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2765,14 +2799,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* DDSCL_NORMAL | DDSCL_FULLSCREEN behaves the same as just DDSCL_NORMAL.
@@ -2782,16 +2816,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2803,14 +2837,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2818,7 +2852,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2826,16 +2860,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2847,14 +2881,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2870,16 +2904,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2891,21 +2925,21 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* Changing the coop level from EXCLUSIVE to NORMAL restores the screen resolution */
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2918,13 +2952,15 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2936,16 +2972,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
/* The screen restore is a property of DDSCL_EXCLUSIVE */
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
@@ -2960,10 +2996,10 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
@@ -2972,7 +3008,7 @@ static void test_coop_level_mode_set(void)
/* If the window is changed at the same time, messages are sent to the new window. */
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2989,17 +3025,17 @@ static void test_coop_level_mode_set(void)
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
- ok(screen_size2.cx == fullscreen_rect.right && screen_size2.cy == fullscreen_rect.bottom,
+ ok(screen_size2.cx == registry_mode.dmPelsWidth && screen_size2.cy == registry_mode.dmPelsHeight,
"Expected screen size 2 %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size2.cx, screen_size2.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size2.cx, screen_size2.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
GetWindowRect(window2, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -3011,18 +3047,18 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface4_Release(primary);
ref = IDirectDraw4_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
expect_messages = NULL;
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 3aebfa7..7850fb5 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -2165,10 +2165,30 @@ static LRESULT CALLBACK mode_set_proc2(HWND hwnd, UINT message, WPARAM wparam, L
return test_proc(hwnd, message, wparam, lparam);
}
+struct test_coop_level_mode_set_enum_param
+{
+ DWORD ddraw_width, ddraw_height;
+};
+
+static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface_desc, void *context)
+{
+ struct test_coop_level_mode_set_enum_param *param = context;
+
+ if (U1(U4(surface_desc)->ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
+ return DDENUMRET_OK;
+ if (surface_desc->dwWidth == registry_mode.dmPelsWidth
+ && surface_desc->dwHeight == registry_mode.dmPelsHeight)
+ return DDENUMRET_OK;
+
+ param->ddraw_width = surface_desc->dwWidth;
+ param->ddraw_height = surface_desc->dwHeight;
+ return DDENUMRET_CANCEL;
+}
+
static void test_coop_level_mode_set(void)
{
IDirectDrawSurface7 *primary;
- RECT fullscreen_rect, r, s;
+ RECT registry_rect, ddraw_rect, r;
IDirectDraw7 *ddraw;
DDSURFACEDESC2 ddsd;
WNDCLASSA wc = {0};
@@ -2176,6 +2196,7 @@ static void test_coop_level_mode_set(void)
HRESULT hr;
ULONG ref;
MSG msg;
+ struct test_coop_level_mode_set_enum_param param;
static const UINT exclusive_messages[] =
{
@@ -2195,6 +2216,21 @@ static void test_coop_level_mode_set(void)
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
+ memset(¶m, 0, sizeof(param));
+ hr = IDirectDraw7_EnumDisplayModes(ddraw, 0, NULL, ¶m, test_coop_level_mode_set_enum_cb);
+ ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+
+ if (!param.ddraw_width)
+ {
+ skip("Fewer than 2 different modes supported, skipping mode restore test.\n");
+ ref = IDirectDraw7_Release(ddraw);
+ ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+ return;
+ }
+
+ SetRect(®istry_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
+ SetRect(&ddraw_rect, 0, 0, param.ddraw_width, param.ddraw_height);
+
wc.lpfnWndProc = mode_set_proc;
wc.lpszClassName = "ddraw_test_wndproc_wc";
ok(RegisterClassA(&wc), "Failed to register window class.\n");
@@ -2207,15 +2243,12 @@ static void test_coop_level_mode_set(void)
window2 = CreateWindowA("ddraw_test_wndproc_wc2", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
- SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
- SetRect(&s, 0, 0, 640, 480);
-
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2227,14 +2260,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2242,26 +2275,26 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == s.right && screen_size.cy == s.bottom,
+ ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
- s.right, s.bottom, screen_size.cx, screen_size.cy);
+ param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2273,14 +2306,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2293,21 +2326,22 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2319,30 +2353,30 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2354,14 +2388,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2369,7 +2403,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2377,16 +2411,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2398,14 +2432,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2421,16 +2455,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2442,14 +2476,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* DDSCL_NORMAL | DDSCL_FULLSCREEN behaves the same as just DDSCL_NORMAL.
@@ -2459,16 +2493,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2480,14 +2514,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2495,7 +2529,7 @@ static void test_coop_level_mode_set(void)
screen_size.cx = 0;
screen_size.cy = 0;
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
@@ -2503,16 +2537,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2524,14 +2558,14 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2547,16 +2581,16 @@ static void test_coop_level_mode_set(void)
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2568,21 +2602,21 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
/* Changing the coop level from EXCLUSIVE to NORMAL restores the screen resolution */
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2595,13 +2629,15 @@ static void test_coop_level_mode_set(void)
ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
expect_messages = NULL;
- ok(screen_size.cx == fullscreen_rect.right && screen_size.cy == fullscreen_rect.bottom,
+ ok(screen_size.cx == registry_mode.dmPelsWidth
+ && screen_size.cy == registry_mode.dmPelsHeight,
"Expected screen size %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size.cx, screen_size.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
+ screen_size.cx, screen_size.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2613,16 +2649,16 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
/* The screen restore is a property of DDSCL_EXCLUSIVE */
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
@@ -2637,10 +2673,10 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == s.right - s.left, "Expected surface width %u, got %u.\n",
- s.right - s.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == s.bottom - s.top, "Expected surface height %u, got %u.\n",
- s.bottom - s.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+ param.ddraw_width, ddsd.dwWidth);
+ ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+ param.ddraw_height, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
hr = IDirectDraw7_RestoreDisplayMode(ddraw);
@@ -2649,7 +2685,7 @@ static void test_coop_level_mode_set(void)
/* If the window is changed at the same time, messages are sent to the new window. */
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- hr = set_display_mode(ddraw, 640, 480);
+ hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
@@ -2666,17 +2702,17 @@ static void test_coop_level_mode_set(void)
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
- ok(screen_size2.cx == fullscreen_rect.right && screen_size2.cy == fullscreen_rect.bottom,
+ ok(screen_size2.cx == registry_mode.dmPelsWidth && screen_size2.cy == registry_mode.dmPelsHeight,
"Expected screen size 2 %ux%u, got %ux%u.\n",
- fullscreen_rect.right, fullscreen_rect.bottom, screen_size2.cx, screen_size2.cy);
+ registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size2.cx, screen_size2.cy);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
GetWindowRect(window2, &r);
- ok(EqualRect(&r, &fullscreen_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- fullscreen_rect.left, fullscreen_rect.top, fullscreen_rect.right, fullscreen_rect.bottom,
+ ok(EqualRect(&r, ®istry_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ registry_rect.left, registry_rect.top, registry_rect.right, registry_rect.bottom,
r.left, r.top, r.right, r.bottom);
memset(&ddsd, 0, sizeof(ddsd));
@@ -2688,18 +2724,18 @@ static void test_coop_level_mode_set(void)
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
- ok(ddsd.dwWidth == fullscreen_rect.right - fullscreen_rect.left, "Expected surface width %u, got %u.\n",
- fullscreen_rect.right - fullscreen_rect.left, ddsd.dwWidth);
- ok(ddsd.dwHeight == fullscreen_rect.bottom - fullscreen_rect.top, "Expected surface height %u, got %u.\n",
- fullscreen_rect.bottom - fullscreen_rect.top, ddsd.dwHeight);
+ ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+ registry_mode.dmPelsWidth, ddsd.dwWidth);
+ ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+ registry_mode.dmPelsHeight, ddsd.dwHeight);
IDirectDrawSurface7_Release(primary);
ref = IDirectDraw7_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
GetWindowRect(window, &r);
- ok(EqualRect(&r, &s), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
- s.left, s.top, s.right, s.bottom,
+ ok(EqualRect(&r, &ddraw_rect), "Expected {%d, %d, %d, %d}, got {%d, %d, %d, %d}.\n",
+ ddraw_rect.left, ddraw_rect.top, ddraw_rect.right, ddraw_rect.bottom,
r.left, r.top, r.right, r.bottom);
expect_messages = NULL;
--
2.0.4
From stefan at codeweavers.com Tue Nov 11 17:18:05 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 00:18:05 +0100
Subject: [PATCH 3/5] d3d/tests: Test fog interpolation.
Message-ID: <1415747887-32375-3-git-send-email-stefan@codeweavers.com>
---
dlls/d3d8/tests/visual.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++
dlls/d3d9/tests/visual.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 125 +++++++++++++++++++++++++++++++++++++++
3 files changed, 415 insertions(+)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index 9895a73..b21c9f0 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -5217,6 +5217,150 @@ done:
DestroyWindow(window);
}
+static void fog_interpolation_test(void)
+{
+ HRESULT hr;
+ IDirect3DDevice8 *device;
+ IDirect3D8 *d3d;
+ ULONG refcount;
+ HWND window;
+ D3DCOLOR color;
+ static const struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ quad[] =
+ {
+ {{-1.0f, -1.0f, 0.0f}, 0xffff0000, 0xff000000},
+ {{-1.0f, 1.0f, 0.0f}, 0xffff0000, 0xff000000},
+ {{ 1.0f, -1.0f, 1.0f}, 0xffff0000, 0x00000000},
+ {{ 1.0f, 1.0f, 1.0f}, 0xffff0000, 0x00000000},
+ };
+ union
+ {
+ DWORD d;
+ float f;
+ } conv;
+ unsigned int i;
+ static const struct
+ {
+ D3DFOGMODE vfog, tfog;
+ D3DSHADEMODE shade;
+ D3DCOLOR middle_color;
+ BOOL todo;
+ }
+ tests[] =
+ {
+ {D3DFOG_NONE, D3DFOG_NONE, D3DSHADE_FLAT, 0x00007f80, FALSE},
+ {D3DFOG_NONE, D3DFOG_NONE, D3DSHADE_GOURAUD, 0x00007f80, FALSE},
+ {D3DFOG_EXP, D3DFOG_NONE, D3DSHADE_FLAT, 0x00007f80, TRUE},
+ {D3DFOG_EXP, D3DFOG_NONE, D3DSHADE_GOURAUD, 0x00007f80, TRUE},
+ {D3DFOG_NONE, D3DFOG_EXP, D3DSHADE_FLAT, 0x0000ea15, FALSE},
+ {D3DFOG_NONE, D3DFOG_EXP, D3DSHADE_GOURAUD, 0x0000ea15, FALSE},
+ {D3DFOG_EXP, D3DFOG_EXP, D3DSHADE_FLAT, 0x0000ea15, FALSE},
+ {D3DFOG_EXP, D3DFOG_EXP, D3DSHADE_GOURAUD, 0x0000ea15, FALSE},
+ };
+ static const D3DMATRIX ident_mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
+ }}};
+ D3DCAPS8 caps;
+
+ window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate8(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object.\n");
+
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+ if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE))
+ skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping some fog tests\n");
+
+ hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
+ ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGCOLOR, 0x0000ff00);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ conv.f = 5.0;
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGDENSITY, conv.d);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
+ ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x000000ff);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+
+ /* Some of the tests seem to depend on the projection matrix explicitly
+ * being set to an identity matrix, even though that's the default.
+ * (AMD Radeon X1600, AMD Radeon HD 6310, Windows 7). Without this,
+ * the drivers seem to use a static z = 1.0 input for the fog equation.
+ * The input value is independent of the actual z and w component of
+ * the vertex position. */
+ hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &ident_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
+ {
+ if(!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog)
+ continue;
+
+ hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00808080, 0.0f, 0);
+ ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_SHADEMODE, tests[i].shade);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, tests[i].vfog);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, tests[i].tfog);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_BeginScene(device);
+ ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
+ ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_EndScene(device);
+ ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+
+ color = getPixelColor(device, 0, 240);
+ ok(color_match(color, 0x000000ff, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
+ color = getPixelColor(device, 320, 240);
+ if (tests[i].todo)
+ todo_wine ok(color_match(color, tests[i].middle_color, 2),
+ "Got unexpected color 0x%08x, case %u.\n", color, i);
+ else
+ ok(color_match(color, tests[i].middle_color, 2),
+ "Got unexpected color 0x%08x, case %u.\n", color, i);
+ color = getPixelColor(device, 639, 240);
+ ok(color_match(color, 0x0000fd02, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
+ hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+ }
+
+ refcount = IDirect3DDevice8_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+}
+
START_TEST(visual)
{
D3DADAPTER_IDENTIFIER8 identifier;
@@ -5267,4 +5411,5 @@ START_TEST(visual)
volume_v16u16_test();
add_dirty_rect_test();
test_3dc_formats();
+ fog_interpolation_test();
}
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index d1d7447..8cc4157 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -16820,6 +16820,150 @@ done:
DestroyWindow(window);
}
+static void fog_interpolation_test(void)
+{
+ HRESULT hr;
+ IDirect3DDevice9 *device;
+ IDirect3D9 *d3d;
+ ULONG refcount;
+ HWND window;
+ D3DCOLOR color;
+ static const struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ quad[] =
+ {
+ {{-1.0f, -1.0f, 0.0f}, 0xffff0000, 0xff000000},
+ {{-1.0f, 1.0f, 0.0f}, 0xffff0000, 0xff000000},
+ {{ 1.0f, -1.0f, 1.0f}, 0xffff0000, 0x00000000},
+ {{ 1.0f, 1.0f, 1.0f}, 0xffff0000, 0x00000000},
+ };
+ union
+ {
+ DWORD d;
+ float f;
+ } conv;
+ unsigned int i;
+ static const struct
+ {
+ D3DFOGMODE vfog, tfog;
+ D3DSHADEMODE shade;
+ D3DCOLOR middle_color;
+ BOOL todo;
+ }
+ tests[] =
+ {
+ {D3DFOG_NONE, D3DFOG_NONE, D3DSHADE_FLAT, 0x00007f80, FALSE},
+ {D3DFOG_NONE, D3DFOG_NONE, D3DSHADE_GOURAUD, 0x00007f80, FALSE},
+ {D3DFOG_EXP, D3DFOG_NONE, D3DSHADE_FLAT, 0x00007f80, TRUE},
+ {D3DFOG_EXP, D3DFOG_NONE, D3DSHADE_GOURAUD, 0x00007f80, TRUE},
+ {D3DFOG_NONE, D3DFOG_EXP, D3DSHADE_FLAT, 0x0000ea15, FALSE},
+ {D3DFOG_NONE, D3DFOG_EXP, D3DSHADE_GOURAUD, 0x0000ea15, FALSE},
+ {D3DFOG_EXP, D3DFOG_EXP, D3DSHADE_FLAT, 0x0000ea15, FALSE},
+ {D3DFOG_EXP, D3DFOG_EXP, D3DSHADE_GOURAUD, 0x0000ea15, FALSE},
+ };
+ static const D3DMATRIX ident_mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
+ }}};
+ D3DCAPS9 caps;
+
+ window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate9(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object.\n");
+
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ IDirect3D9_Release(d3d);
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+ if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE))
+ skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping some fog tests\n");
+
+ hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR);
+ ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, 0x0000ff00);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ conv.f = 5.0;
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGDENSITY, conv.d);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
+ ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x000000ff);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+
+ /* Some of the tests seem to depend on the projection matrix explicitly
+ * being set to an identity matrix, even though that's the default.
+ * (AMD Radeon X1600, AMD Radeon HD 6310, Windows 7). Without this,
+ * the drivers seem to use a static z = 1.0 input for the fog equation.
+ * The input value is independent of the actual z and w component of
+ * the vertex position. */
+ hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &ident_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
+ {
+ if(!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog)
+ continue;
+
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00808080, 0.0f, 0);
+ ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SHADEMODE, tests[i].shade);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, tests[i].vfog);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, tests[i].tfog);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_BeginScene(device);
+ ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
+ ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_EndScene(device);
+ ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+
+ color = getPixelColor(device, 0, 240);
+ ok(color_match(color, 0x000000ff, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
+ color = getPixelColor(device, 320, 240);
+ if (tests[i].todo)
+ todo_wine ok(color_match(color, tests[i].middle_color, 2),
+ "Got unexpected color 0x%08x, case %u.\n", color, i);
+ else
+ ok(color_match(color, tests[i].middle_color, 2),
+ "Got unexpected color 0x%08x, case %u.\n", color, i);
+ color = getPixelColor(device, 639, 240);
+ ok(color_match(color, 0x0000fd02, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
+ hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+ }
+
+ refcount = IDirect3DDevice9_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ IDirect3D9_Release(d3d);
+ DestroyWindow(window);
+}
+
START_TEST(visual)
{
D3DADAPTER_IDENTIFIER9 identifier;
@@ -16928,4 +17072,5 @@ START_TEST(visual)
stencil_cull_test();
test_per_stage_constant();
test_3dc_formats();
+ fog_interpolation_test();
}
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index cbf6112..f505c65 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -7764,6 +7764,130 @@ static void test_surface_desc_lock(void)
DestroyWindow(window);
}
+static void fog_interpolation_test(void)
+{
+ HRESULT hr;
+ IDirect3DDevice7 *device;
+ IDirectDrawSurface7 *rt;
+ ULONG refcount;
+ HWND window;
+ D3DCOLOR color;
+ static struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ quad[] =
+ {
+ {{-1.0f, -1.0f, 0.0f}, 0xffff0000, 0xff000000},
+ {{-1.0f, 1.0f, 0.0f}, 0xffff0000, 0xff000000},
+ {{ 1.0f, -1.0f, 1.0f}, 0xffff0000, 0x00000000},
+ {{ 1.0f, 1.0f, 1.0f}, 0xffff0000, 0x00000000},
+ };
+ union
+ {
+ DWORD d;
+ float f;
+ } conv;
+ unsigned int i;
+ static const struct
+ {
+ D3DFOGMODE vfog, tfog;
+ D3DSHADEMODE shade;
+ D3DCOLOR middle_color;
+ BOOL todo;
+ }
+ tests[] =
+ {
+ {D3DFOG_NONE, D3DFOG_NONE, D3DSHADE_FLAT, 0x00007f80, FALSE},
+ {D3DFOG_NONE, D3DFOG_NONE, D3DSHADE_GOURAUD, 0x00007f80, FALSE},
+ {D3DFOG_EXP, D3DFOG_NONE, D3DSHADE_FLAT, 0x00007f80, TRUE},
+ {D3DFOG_EXP, D3DFOG_NONE, D3DSHADE_GOURAUD, 0x00007f80, TRUE},
+ {D3DFOG_NONE, D3DFOG_EXP, D3DSHADE_FLAT, 0x0000ea15, FALSE},
+ {D3DFOG_NONE, D3DFOG_EXP, D3DSHADE_GOURAUD, 0x0000ea15, FALSE},
+ {D3DFOG_EXP, D3DFOG_EXP, D3DSHADE_FLAT, 0x0000ea15, FALSE},
+ {D3DFOG_EXP, D3DFOG_EXP, D3DSHADE_GOURAUD, 0x0000ea15, FALSE},
+ };
+ D3DDEVICEDESC7 caps;
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+
+ if (!(device = create_device(window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create a 3D device, skipping test.\n");
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
+ ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_GetCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+ if (!(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE))
+ skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping some fog tests\n");
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, 0x0000ff00);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ conv.f = 5.0;
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGDENSITY, conv.d);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
+ ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREFACTOR, 0x000000ff);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
+ {
+ if(!(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog)
+ continue;
+
+ hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00808080, 0.0f, 0);
+ ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SHADEMODE, tests[i].shade);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, tests[i].vfog);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, tests[i].tfog);
+ ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_BeginScene(device);
+ ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, quad, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_EndScene(device);
+ ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+
+ color = get_surface_color(rt, 0, 240);
+ ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
+ color = get_surface_color(rt, 320, 240);
+ if (tests[i].todo)
+ todo_wine ok(compare_color(color, tests[i].middle_color, 2),
+ "Got unexpected color 0x%08x, case %u.\n", color, i);
+ else
+ ok(compare_color(color, tests[i].middle_color, 2),
+ "Got unexpected color 0x%08x, case %u.\n", color, i);
+ color = get_surface_color(rt, 639, 240);
+ ok(compare_color(color, 0x0000fd02, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
+ }
+
+ IDirectDrawSurface7_Release(rt);
+ refcount = IDirect3DDevice7_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
@@ -7850,4 +7974,5 @@ START_TEST(ddraw7)
test_lost_device();
test_resource_priority();
test_surface_desc_lock();
+ fog_interpolation_test();
}
--
2.0.4
From stefan at codeweavers.com Tue Nov 11 17:18:06 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 00:18:06 +0100
Subject: [PATCH 4/5] d3d9/tests: Allow passing a resolution to reset_device in
d3d9ex.
Message-ID: <1415747887-32375-4-git-send-email-stefan@codeweavers.com>
The resolution change in test_wndproc_windowed is intentional.
---
dlls/d3d9/tests/d3d9ex.c | 59 ++++++++++++++++++++++++++++++++----------------
1 file changed, 39 insertions(+), 20 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index d93e591..bbb95b0 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -132,19 +132,27 @@ done:
return device;
}
-static HRESULT reset_device(IDirect3DDevice9Ex *device, HWND device_window, BOOL windowed)
+static HRESULT reset_device(IDirect3DDevice9Ex *device, const struct device_desc *desc)
{
D3DPRESENT_PARAMETERS present_parameters = {0};
- present_parameters.Windowed = windowed;
- present_parameters.hDeviceWindow = device_window;
- present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
- present_parameters.BackBufferWidth = 1024;
- present_parameters.BackBufferHeight = 768;
+ present_parameters.BackBufferWidth = 640;
+ present_parameters.BackBufferHeight = 480;
present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
+ present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
+ present_parameters.hDeviceWindow = NULL;
+ present_parameters.Windowed = TRUE;
present_parameters.EnableAutoDepthStencil = TRUE;
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
+ if (desc)
+ {
+ present_parameters.BackBufferWidth = desc->width;
+ present_parameters.BackBufferHeight = desc->height;
+ present_parameters.hDeviceWindow = desc->device_window;
+ present_parameters.Windowed = !(desc->flags & CREATE_DEVICE_FULLSCREEN);
+ }
+
return IDirect3DDevice9_Reset(device, &present_parameters);
}
@@ -1110,7 +1118,7 @@ static void test_reset_resources(void)
IDirect3DSurface9_Release(surface);
}
- hr = reset_device(device, window, TRUE);
+ hr = reset_device(device, NULL);
ok(SUCCEEDED(hr), "Failed to reset device.\n");
hr = IDirect3DDevice9_GetBackBuffer(device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &rt);
@@ -1284,7 +1292,9 @@ static void test_lost_device(void)
hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr);
- hr = reset_device(device, window, FALSE);
+ desc.width = 1024;
+ desc.height = 768;
+ hr = reset_device(device, &desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -1297,7 +1307,8 @@ static void test_lost_device(void)
hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x.\n", hr);
- hr = reset_device(device, window, TRUE);
+ desc.flags = 0;
+ hr = reset_device(device, &desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -1310,7 +1321,7 @@ static void test_lost_device(void)
hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
todo_wine ok(hr == S_PRESENT_MODE_CHANGED, "Got unexpected hr %#x.\n", hr);
- hr = reset_device(device, window, TRUE);
+ hr = reset_device(device, &desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -1349,7 +1360,8 @@ static void test_lost_device(void)
hr = IDirect3DDevice9Ex_CheckDeviceState(device, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = reset_device(device, window, FALSE);
+ desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9Ex_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -1977,8 +1989,8 @@ static void test_wndproc_windowed(void)
filter_messages = focus_window;
device_desc.device_window = device_window;
- device_desc.width = 640;
- device_desc.height = 480;
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
device_desc.flags = 0;
if (!(device = create_device(focus_window, &device_desc)))
{
@@ -2002,7 +2014,8 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
- hr = reset_device(device, device_window, FALSE);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2012,7 +2025,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, device_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2039,7 +2053,8 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
- hr = reset_device(device, focus_window, FALSE);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2049,7 +2064,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, focus_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2074,7 +2090,8 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
- hr = reset_device(device, device_window, FALSE);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2084,7 +2101,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, device_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2197,7 +2215,8 @@ static void test_window_style(void)
focus_rect.left, focus_rect.top, focus_rect.right, focus_rect.bottom,
r.left, r.top, r.right, r.bottom, i);
- hr = reset_device(device, device_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
style = GetWindowLongA(device_window, GWL_STYLE);
--
2.0.4
From stefan at codeweavers.com Tue Nov 11 17:18:07 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 00:18:07 +0100
Subject: [PATCH 5/5] d3d8/tests: Allow passing a resolution to reset_device.
Message-ID: <1415747887-32375-5-git-send-email-stefan@codeweavers.com>
---
dlls/d3d8/tests/device.c | 58 +++++++++++++++++++++++++++++++-----------------
1 file changed, 38 insertions(+), 20 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 7468d13..6e4cb46 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -136,19 +136,27 @@ static IDirect3DDevice8 *create_device(IDirect3D8 *d3d8, HWND focus_window, cons
return NULL;
}
-static HRESULT reset_device(IDirect3DDevice8 *device, HWND device_window, BOOL windowed)
+static HRESULT reset_device(IDirect3DDevice8 *device, const struct device_desc *desc)
{
D3DPRESENT_PARAMETERS present_parameters = {0};
- present_parameters.Windowed = windowed;
- present_parameters.hDeviceWindow = device_window;
- present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
- present_parameters.BackBufferWidth = registry_mode.dmPelsWidth;
- present_parameters.BackBufferHeight = registry_mode.dmPelsHeight;
+ present_parameters.BackBufferWidth = 640;
+ present_parameters.BackBufferHeight = 480;
present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
+ present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
+ present_parameters.hDeviceWindow = NULL;
+ present_parameters.Windowed = TRUE;
present_parameters.EnableAutoDepthStencil = TRUE;
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
+ if (desc)
+ {
+ present_parameters.BackBufferWidth = desc->width;
+ present_parameters.BackBufferHeight = desc->height;
+ present_parameters.hDeviceWindow = desc->device_window;
+ present_parameters.Windowed = !(desc->flags & CREATE_DEVICE_FULLSCREEN);
+ }
+
return IDirect3DDevice8_Reset(device, &present_parameters);
}
@@ -2424,8 +2432,8 @@ static void test_wndproc_windowed(void)
filter_messages = focus_window;
device_desc.device_window = device_window;
- device_desc.width = 640;
- device_desc.height = 480;
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
device_desc.flags = 0;
if (!(device = create_device(d3d8, focus_window, &device_desc)))
{
@@ -2449,7 +2457,8 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
- hr = reset_device(device, device_window, FALSE);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2459,7 +2468,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, device_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2486,7 +2496,8 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
- hr = reset_device(device, focus_window, FALSE);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2496,7 +2507,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, focus_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2521,7 +2533,8 @@ static void test_wndproc_windowed(void)
filter_messages = NULL;
- hr = reset_device(device, device_window, FALSE);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2531,7 +2544,8 @@ static void test_wndproc_windowed(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, device_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
@@ -2830,7 +2844,8 @@ static void test_window_style(void)
focus_rect.left, focus_rect.top, focus_rect.right, focus_rect.bottom,
r.left, r.top, r.right, r.bottom);
- hr = reset_device(device, device_window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
style = GetWindowLongA(device_window, GWL_STYLE);
@@ -3205,7 +3220,8 @@ static void test_device_window_reset(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
- hr = reset_device(device, device_window, FALSE);
+ device_desc.device_window = device_window;
+ hr = reset_device(device, &device_desc);
ok(SUCCEEDED(hr), "Failed to reset device.\n");
GetWindowRect(focus_window, &r);
@@ -3340,7 +3356,7 @@ static void test_reset_resources(void)
IDirect3DSurface8_Release(rt);
IDirect3DSurface8_Release(surface);
- hr = reset_device(device, device_window, TRUE);
+ hr = reset_device(device, NULL);
ok(SUCCEEDED(hr), "Failed to reset device.\n");
hr = IDirect3DDevice8_GetBackBuffer(device, 0, D3DBACKBUFFER_TYPE_MONO, &rt);
@@ -6506,14 +6522,15 @@ static void test_lost_device(void)
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
- hr = reset_device(device, window, FALSE);
+ hr = reset_device(device, &device_desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = reset_device(device, window, TRUE);
+ device_desc.flags = 0;
+ hr = reset_device(device, &device_desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_TestCooperativeLevel(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -6534,7 +6551,8 @@ static void test_lost_device(void)
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = reset_device(device, window, FALSE);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_TestCooperativeLevel(device);
todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
--
2.0.4
From 00cpxxx at gmail.com Tue Nov 11 19:06:18 2014
From: 00cpxxx at gmail.com (Bruno Jesus)
Date: Tue, 11 Nov 2014 23:06:18 -0200
Subject: dinput: Fix device type dump
Message-ID:
Related to bug https://bugs.winehq.org/show_bug.cgi?id=35954
-------------- next part --------------
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index 0d61f57..2931832 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -402,14 +402,30 @@ HRESULT WINAPI JoystickAGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface, REF
void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps)
{
+ int type = GET_DIDEVICE_TYPE(lpDIDevCaps->dwDevType);
TRACE("dwSize: %d\n", lpDIDevCaps->dwSize);
TRACE("dwFlags: %08x\n", lpDIDevCaps->dwFlags);
TRACE("dwDevType: %08x %s\n", lpDIDevCaps->dwDevType,
- lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
- lpDIDevCaps->dwDevType == DIDEVTYPE_MOUSE ? "DIDEVTYPE_MOUSE" :
- lpDIDevCaps->dwDevType == DIDEVTYPE_KEYBOARD ? "DIDEVTYPE_KEYBOARD" :
- lpDIDevCaps->dwDevType == DIDEVTYPE_JOYSTICK ? "DIDEVTYPE_JOYSTICK" :
- lpDIDevCaps->dwDevType == DIDEVTYPE_HID ? "DIDEVTYPE_HID" : "UNKNOWN");
+ /* Directx <= 7 definitions */
+ type == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
+ type == DIDEVTYPE_MOUSE ? "DIDEVTYPE_MOUSE" :
+ type == DIDEVTYPE_KEYBOARD ? "DIDEVTYPE_KEYBOARD" :
+ type == DIDEVTYPE_JOYSTICK ? "DIDEVTYPE_JOYSTICK" :
+ type == DIDEVTYPE_HID ? "DIDEVTYPE_HID" :
+ /* Directx >= 8 definitions */
+ type == DI8DEVTYPE_DEVICE ? "DI8DEVTYPE_DEVICE" :
+ type == DI8DEVTYPE_MOUSE ? "DI8DEVTYPE_MOUSE" :
+ type == DI8DEVTYPE_KEYBOARD ? "DI8DEVTYPE_KEYBOARD" :
+ type == DI8DEVTYPE_JOYSTICK ? "DI8DEVTYPE_JOYSTICK" :
+ type == DI8DEVTYPE_GAMEPAD ? "DI8DEVTYPE_GAMEPAD" :
+ type == DI8DEVTYPE_DRIVING ? "DI8DEVTYPE_DRIVING" :
+ type == DI8DEVTYPE_FLIGHT ? "DI8DEVTYPE_FLIGHT" :
+ type == DI8DEVTYPE_1STPERSON ? "DI8DEVTYPE_1STPERSON" :
+ type == DI8DEVTYPE_DEVICECTRL ? "DI8DEVTYPE_DEVICECTRL" :
+ type == DI8DEVTYPE_SCREENPOINTER ? "DI8DEVTYPE_SCREENPOINTER" :
+ type == DI8DEVTYPE_REMOTE ? "DI8DEVTYPE_REMOTE" :
+ type == DI8DEVTYPE_SUPPLEMENTAL ? "DI8DEVTYPE_SUPPLEMENTAL" :
+ "UNKNOWN");
TRACE("dwAxes: %d\n", lpDIDevCaps->dwAxes);
TRACE("dwButtons: %d\n", lpDIDevCaps->dwButtons);
TRACE("dwPOVs: %d\n", lpDIDevCaps->dwPOVs);
From austinenglish at gmail.com Tue Nov 11 19:41:03 2014
From: austinenglish at gmail.com (Austin English)
Date: Tue, 11 Nov 2014 19:41:03 -0600
Subject: shell32: add a stub for RegenerateUserEnvironment
Message-ID:
Fixes https://bugs.winehq.org/show_bug.cgi?id=37539
--
-Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
diff --git a/dlls/shell32/shell32.spec b/dlls/shell32/shell32.spec
index f219c8f..e6858c8 100644
--- a/dlls/shell32/shell32.spec
+++ b/dlls/shell32/shell32.spec
@@ -324,7 +324,7 @@
@ stub RealShellExecuteExA
@ stub RealShellExecuteExW
@ stub RealShellExecuteW
-@ stub RegenerateUserEnvironment
+@ stdcall RegenerateUserEnvironment(ptr long)
@ stdcall SetCurrentProcessExplicitAppUserModelID(wstr)
@ stdcall SHAddToRecentDocs (long ptr)
@ stdcall SHAppBarMessage(long ptr)
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c
index a6bc5c8..05b79e3 100644
--- a/dlls/shell32/shlexec.c
+++ b/dlls/shell32/shlexec.c
@@ -2097,3 +2097,12 @@ void WINAPI OpenAs_RunDLLW(HWND hwnd, HINSTANCE hinst, LPCWSTR cmdline, int cmds
{
FIXME("%p, %p, %s, %d\n", hwnd, hinst, debugstr_w(cmdline), cmdshow);
}
+
+/*************************************************************************
+ * RegenerateUserEnvironment [SHELL32.@]
+ */
+BOOL WINAPI RegenerateUserEnvironment(WCHAR *wunknown, BOOL bunknown)
+{
+ FIXME("stub: %p, %d\n", wunknown, bunknown);
+ return FALSE;
+}
From 00cpxxx at gmail.com Tue Nov 11 20:03:59 2014
From: 00cpxxx at gmail.com (Bruno Jesus)
Date: Wed, 12 Nov 2014 00:03:59 -0200
Subject: version: Handle NULL puLen parameter for VerQueryValueA/W
Message-ID:
Rebased version of patch from Jeff Zaroyko.
Tests were attempted but they crash in NT4 and 2000. It's possible to
add tests if a GetVersion() check is added to test for different
windows versions, I'm trying the simplified attempt first. Test
results:
https://testbot.winehq.org/JobDetails.pl?Key=10201
Fixes https://bugs.winehq.org/show_bug.cgi?id=16832
-------------- next part --------------
diff --git a/dlls/version/version.c b/dlls/version/version.c
index 9bc6ad1..58fd029 100644
--- a/dlls/version/version.c
+++ b/dlls/version/version.c
@@ -976,7 +976,7 @@ BOOL WINAPI VerQueryValueA( LPCVOID pBlock, LPCSTR lpSubBlock,
len = WideCharToMultiByte(CP_ACP, 0, *lplpBuffer, -1,
lpBufferA + pos, info->wLength - pos, NULL, NULL);
*lplpBuffer = lpBufferA + pos;
- *puLen = len;
+ if (puLen) *puLen = len;
}
return ret;
}
@@ -1036,7 +1036,7 @@ BOOL WINAPI VerQueryValueW( LPCVOID pBlock, LPCWSTR lpSubBlock,
len = MultiByteToWideChar(CP_ACP, 0, *lplpBuffer, -1,
lpBufferW + pos, max/sizeof(WCHAR) - pos );
*lplpBuffer = lpBufferW + pos;
- *puLen = len;
+ if (puLen) *puLen = len;
}
return ret;
}
From 00cpxxx at gmail.com Tue Nov 11 20:42:11 2014
From: 00cpxxx at gmail.com (Bruno Jesus)
Date: Wed, 12 Nov 2014 00:42:11 -0200
Subject: [1/2] server: Add a missing socket protocol attribution
Message-ID:
The new socket has to inherit the information just like family and type.
-------------- next part --------------
diff --git a/server/sock.c b/server/sock.c
index 4adad0f..e124ad6 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -773,6 +773,7 @@ static int accept_into_socket( struct sock *sock, struct sock *acceptsock )
acceptsock->hmask = 0;
acceptsock->pmask = 0;
acceptsock->polling = 0;
+ acceptsock->proto = sock->proto;
acceptsock->type = sock->type;
acceptsock->family = sock->family;
acceptsock->wparam = 0;
From 00cpxxx at gmail.com Tue Nov 11 20:42:14 2014
From: 00cpxxx at gmail.com (Bruno Jesus)
Date: Wed, 12 Nov 2014 00:42:14 -0200
Subject: [2/2] server: Store the time of the socket connection (try 2)
Message-ID:
Rebased version of a patch from Erich Hoover, all kudos to him.
-------------- next part --------------
diff --git a/server/sock.c b/server/sock.c
index e124ad6..7c0212e 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -107,6 +107,7 @@ struct sock
unsigned int message; /* message to send */
obj_handle_t wparam; /* message wparam (socket handle) */
int errors[FD_MAX_EVENTS]; /* event errors */
+ timeout_t connect_time;/* time the socket was connected */
struct sock *deferred; /* socket that waits for a deferred accept */
struct async_queue *read_q; /* queue for asynchronous reads */
struct async_queue *write_q; /* queue for asynchronous writes */
@@ -401,6 +402,7 @@ static void sock_poll_event( struct fd *fd, int event )
/* we got connected */
sock->state |= FD_WINE_CONNECTED|FD_READ|FD_WRITE;
sock->state &= ~FD_CONNECT;
+ sock->connect_time = current_time;
}
}
else if (sock->state & FD_WINE_LISTENING)
@@ -618,6 +620,7 @@ static void init_sock(struct sock *sock)
sock->window = 0;
sock->message = 0;
sock->wparam = 0;
+ sock->connect_time = 0;
sock->deferred = NULL;
sock->read_q = NULL;
sock->write_q = NULL;
@@ -725,6 +728,7 @@ static struct sock *accept_socket( obj_handle_t handle )
acceptsock->family = sock->family;
acceptsock->window = sock->window;
acceptsock->message = sock->message;
+ acceptsock->connect_time = current_time;
if (sock->event) acceptsock->event = (struct event *)grab_object( sock->event );
acceptsock->flags = sock->flags;
if (!(acceptsock->fd = create_anonymous_fd( &sock_fd_ops, acceptfd, &acceptsock->obj,
@@ -778,6 +782,7 @@ static int accept_into_socket( struct sock *sock, struct sock *acceptsock )
acceptsock->family = sock->family;
acceptsock->wparam = 0;
acceptsock->deferred = NULL;
+ acceptsock->connect_time = current_time;
release_object( acceptsock->fd );
acceptsock->fd = newfd;
From alexhenrie24 at gmail.com Tue Nov 11 21:39:59 2014
From: alexhenrie24 at gmail.com (Alex Henrie)
Date: Tue, 11 Nov 2014 20:39:59 -0700
Subject: [PATCH (try 2)] kernel32/tests: Add tabular UTF-7 encoding tests.
Message-ID: <1415763599-27630-1-git-send-email-alexhenrie24@gmail.com>
Try 2 does not test {'a',0,'b',0} because a near-identical test was
already included in the previously committed patches.
---
dlls/kernel32/tests/codepage.c | 136 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 136 insertions(+)
diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 6e89533..aa7977d 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -433,6 +433,114 @@ static void test_utf7_encoding(void)
static const char base64_encoding_table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ const struct
+ {
+ /* inputs */
+ WCHAR src[16];
+ int srclen;
+ char *dst;
+ int dstlen;
+ /* expected outputs */
+ char expected_dst[16];
+ int chars_written;
+ int len;
+ }
+ tests[] =
+ {
+ /* tests string conversion with srclen=-1 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, sizeof(output) - 1,
+ "+T2BZfVQX-", 11, 11
+ },
+ /* tests string conversion with srclen=-2 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -2, output, sizeof(output) - 1,
+ "+T2BZfVQX-", 11, 11
+ },
+ /* tests string conversion with dstlen=strlen(expected_dst) */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, 10,
+ "+T2BZfVQX-", 10, 0
+ },
+ /* tests string conversion with dstlen=strlen(expected_dst)+1 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, 11,
+ "+T2BZfVQX-", 11, 11
+ },
+ /* tests string conversion with dstlen=strlen(expected_dst)+2 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, 12,
+ "+T2BZfVQX-", 11, 11
+ },
+ /* tests dry run with dst=NULL and dstlen=0 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, NULL, 0,
+ {}, 0, 11
+ },
+ /* tests dry run with dst!=NULL and dstlen=0 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, 0,
+ {}, 0, 11
+ },
+ /* tests srclen < strlenW(src) with directly encodable chars */
+ {
+ {'h','e','l','l','o',0}, 2, output, sizeof(output) - 1,
+ "he", 2, 2
+ },
+ /* tests srclen < strlenW(src) with non-directly encodable chars */
+ {
+ {0x4F60,0x597D,0x5417,0}, 2, output, sizeof(output) - 1,
+ "+T2BZfQ-", 8, 8
+ },
+ /* tests a single null char */
+ {
+ {0}, -1, output, sizeof(output) - 1,
+ "", 1, 1
+ },
+ /* tests a buffer that runs out while not encoding a UTF-7 sequence */
+ {
+ {'h','e','l','l','o',0}, -1, output, 2,
+ "he", 2, 0
+ },
+ /* tests a buffer that runs out after writing 1 base64 character */
+ {
+ {0x4F60,0x0001,0}, -1, output, 2,
+ "+T", 2, 0
+ },
+ /* tests a buffer that runs out after writing 2 base64 characters */
+ {
+ {0x4F60,0x0001,0}, -1, output, 3,
+ "+T2", 3, 0
+ },
+ /* tests a buffer that runs out after writing 3 base64 characters */
+ {
+ {0x4F60,0x0001,0}, -1, output, 4,
+ "+T2A", 4, 0
+ },
+ /* tests a buffer that runs out just after writing the + sign */
+ {
+ {0x4F60,0}, -1, output, 1,
+ "+", 1, 0
+ },
+ /* tests a buffer that runs out just before writing the - sign
+ * the number of bits to encode here is evenly divisible by 6 */
+ {
+ {0x4F60,0x597D,0x5417,0}, -1, output, 9,
+ "+T2BZfVQX", 9, 0
+ },
+ /* tests a buffer that runs out just before writing the - sign
+ * the number of bits to encode here is NOT evenly divisible by 6 */
+ {
+ {0x4F60,0}, -1, output, 4,
+ "+T2", 3, 0
+ },
+ /* tests a buffer that runs out in the middle of escaping a + sign */
+ {
+ {'+',0}, -1, output, 1,
+ "+", 1, 0
+ }
+ };
+
if (WideCharToMultiByte(CP_UTF7, 0, foobarW, -1, NULL, 0, NULL, NULL) == 0 &&
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
@@ -525,6 +633,34 @@ static void test_utf7_encoding(void)
ok(output[expected_len] == '#', "i=0x%04x: expected output[%i]='#', got output[%i]=%i\n",
i, expected_len, expected_len, output[expected_len]);
}
+
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ {
+ memset(output, '#', sizeof(output) - 1);
+ output[sizeof(output) - 1] = 0;
+ SetLastError(0xdeadbeef);
+
+ len = WideCharToMultiByte(CP_UTF7, 0, tests[i].src, tests[i].srclen,
+ tests[i].dst, tests[i].dstlen, NULL, NULL);
+
+ if (!tests[i].len)
+ {
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
+ "tests[%i]: expected error=0x%x, got error=0x%x\n",
+ i, ERROR_INSUFFICIENT_BUFFER, GetLastError());
+ }
+ ok(len == tests[i].len, "tests[%i]: expected len=%i, got len=%i\n", i, tests[i].len, len);
+
+ if (tests[i].dst)
+ {
+ ok(memcmp(tests[i].dst, tests[i].expected_dst, tests[i].chars_written) == 0,
+ "tests[%i]: expected dst='%s', got dst='%s'\n",
+ i, tests[i].expected_dst, tests[i].dst);
+ ok(tests[i].dst[tests[i].chars_written] == '#',
+ "tests[%i]: expected dst[%i]='#', got dst[%i]=%i\n",
+ i, tests[i].chars_written, tests[i].chars_written, tests[i].dst[tests[i].chars_written]);
+ }
+ }
}
static void test_utf7_decoding(void)
--
2.1.3
From YWang at esri.com Tue Nov 11 15:39:59 2014
From: YWang at esri.com (Yifu Wang)
Date: Tue, 11 Nov 2014 21:39:59 +0000
Subject: [PATCH] msvcp120: Added VS2013 CPP runtime dll
Message-ID:
---
configure.ac | 1 +
dlls/msvcp120/Makefile.in | 14 +
dlls/msvcp120/msvcp120.spec | 3846 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 3861 insertions(+), 0 deletions(-)
create mode 100644 dlls/msvcp120/Makefile.in
create mode 100644 dlls/msvcp120/msvcp120.spec
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-msvcp120-Added-VS2013-CPP-runtime-dll.patch
Type: application/octet-stream
Size: 470290 bytes
Desc: 0001-msvcp120-Added-VS2013-CPP-runtime-dll.patch
URL:
From yifuwang2012 at gmail.com Tue Nov 11 16:12:09 2014
From: yifuwang2012 at gmail.com (Yifu Wang)
Date: Tue, 11 Nov 2014 14:12:09 -0800
Subject: [PATCH] msvcp120: Added VS2013 CPP runtime dll (resend)
Message-ID:
Forgot to attach the patch.
---
configure.ac | 1 +
dlls/msvcp120/Makefile.in | 14 +
dlls/msvcp120/msvcp120.spec | 3846 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 3861 insertions(+), 0 deletions(-)
create mode 100644 dlls/msvcp120/Makefile.in
create mode 100644 dlls/msvcp120/msvcp120.spec
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-msvcp120-Added-VS2013-CPP-runtime-dll.patch
Type: application/octet-stream
Size: 470290 bytes
Desc: not available
URL:
From hans at codeweavers.com Wed Nov 12 04:25:23 2014
From: hans at codeweavers.com (Hans Leidekker)
Date: Wed, 12 Nov 2014 11:25:23 +0100
Subject: server: Set the security descriptor of named pipe objects.
Message-ID: <1415787923.29176.1.camel@codeweavers.com>
---
dlls/ntdll/file.c | 19 +++++++++++++++----
server/named_pipe.c | 21 +++++++++++++++++----
server/protocol.def | 3 +--
3 files changed, 33 insertions(+), 10 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-server-Set-the-security-descriptor-of-named-pipe-objec.txt
Type: text/x-patch
Size: 5424 bytes
Desc: not available
URL:
From stefan at codeweavers.com Wed Nov 12 04:30:10 2014
From: stefan at codeweavers.com (=?UTF-8?B?U3RlZmFuIETDtnNpbmdlcg==?=)
Date: Wed, 12 Nov 2014 11:30:10 +0100
Subject: d3d8/tests: Allow passing a resolution to reset_device (v2).
Message-ID: <546336B2.4070705@codeweavers.com>
Version 2: Fix a whitespace error.
This supersedes 107621.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-d3d8-tests-Allow-passing-a-resolution-to-reset_devic.patch
Type: text/x-diff
Size: 7681 bytes
Desc: not available
URL:
From hans at codeweavers.com Wed Nov 12 04:31:36 2014
From: hans at codeweavers.com (Hans Leidekker)
Date: Wed, 12 Nov 2014 11:31:36 +0100
Subject: odbc32: Add a version resource.
Message-ID: <1415788296.29176.2.camel@codeweavers.com>
---
dlls/odbc32/Makefile.in | 2 ++
dlls/odbc32/rsrc.rc | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
create mode 100644 dlls/odbc32/rsrc.rc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-odbc32-Add-a-version-resource.txt
Type: text/x-patch
Size: 1515 bytes
Desc: not available
URL:
From mstefani at redhat.de Wed Nov 12 08:19:58 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Wed, 12 Nov 2014 15:19:58 +0100
Subject: gameux: Simplify the check for an empty string (PVS-Studio)
Message-ID: <20141112141958.GA26099@redhat.com>
---
dlls/gameux/gamestatistics.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/gameux/gamestatistics.c b/dlls/gameux/gamestatistics.c
index f49d73a..7c95065 100644
--- a/dlls/gameux/gamestatistics.c
+++ b/dlls/gameux/gamestatistics.c
@@ -180,7 +180,7 @@ static HRESULT GAMEUX_updateStatisticsFile(struct GAMEUX_STATS *stats)
{
IXMLDOMElement *categoryElement = NULL;
- if(lstrlenW(stats->categories[i].sName)==0)
+ if(!stats->categories[i].sName[0])
continue;
V_VT(&vValue) = VT_INT;
@@ -218,7 +218,7 @@ static HRESULT GAMEUX_updateStatisticsFile(struct GAMEUX_STATS *stats)
{
for(j=0; jcategories[i].stats[j].sName)==0)
+ if(!stats->categories[i].stats[j].sName[0])
continue;
V_VT(&vValue) = VT_INT;
--
1.9.3
From mstefani at redhat.de Wed Nov 12 08:22:05 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Wed, 12 Nov 2014 15:22:05 +0100
Subject: mciwave: Simplify the check for an empty string (PVS-Studio)
Message-ID: <20141112142205.GB26099@redhat.com>
---
dlls/mciwave/mciwave.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/mciwave/mciwave.c b/dlls/mciwave/mciwave.c
index 4f24169..c7992fb 100644
--- a/dlls/mciwave/mciwave.c
+++ b/dlls/mciwave/mciwave.c
@@ -444,7 +444,7 @@ static DWORD create_tmp_file(HMMIO* hFile, LPWSTR* pszTmpFileName)
TRACE("%s!\n", debugstr_w(*pszTmpFileName));
- if (*pszTmpFileName && (strlenW(*pszTmpFileName) > 0)) {
+ if (*pszTmpFileName && (*pszTmpFileName)[0]) {
*hFile = mmioOpenW(*pszTmpFileName, NULL,
MMIO_ALLOCBUF | MMIO_READWRITE | MMIO_CREATE);
@@ -470,7 +470,7 @@ static LRESULT WAVE_mciOpenFile(WINE_MCIWAVE* wmw, LPCWSTR filename)
HeapFree(GetProcessHeap(), 0, wmw->lpFileName);
wmw->lpFileName = fn;
- if (strlenW(filename) > 0) {
+ if (filename[0]) {
/* FIXME : what should be done if wmw->hFile is already != 0, or the driver is playin' */
TRACE("MCI_OPEN_ELEMENT %s!\n", debugstr_w(filename));
--
1.9.3
From mstefani at redhat.de Wed Nov 12 08:28:45 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Wed, 12 Nov 2014 15:28:45 +0100
Subject: crypt32/tests: Remove an unused assignment (PVS-Studio)
Message-ID: <20141112142845.GC26099@redhat.com>
---
The test before this uses
info.SubjectAlgorithm.pszObjId = oid2;
so assuming a copy and paste issue as all was added in one commit.
dlls/crypt32/tests/encode.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c
index 9e1853f..e9b49e9 100644
--- a/dlls/crypt32/tests/encode.c
+++ b/dlls/crypt32/tests/encode.c
@@ -5762,7 +5762,6 @@ static void test_decodeCTL(DWORD dwEncoding)
info.SubjectAlgorithm.Parameters.cbData = 0;
info.ThisUpdate.dwLowDateTime = info.ThisUpdate.dwHighDateTime = 0;
info.NextUpdate.dwLowDateTime = info.NextUpdate.dwHighDateTime = 0;
- info.SubjectAlgorithm.pszObjId = oid2;
info.SubjectAlgorithm.pszObjId = NULL;
value1.cbData = sizeof(emptySequence);
value1.pbData = (LPBYTE)emptySequence;
--
1.9.3
From jacek at codeweavers.com Wed Nov 12 09:25:13 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Wed, 12 Nov 2014 16:25:13 +0100
Subject: [PATCH 1/4] mshtml: Added IHTMLTxtRange::moveToElementText
implementation.
Message-ID: <54637BD9.90605@codeweavers.com>
---
dlls/mshtml/tests/dom.c | 11 +++++++++++
dlls/mshtml/txtrange.c | 18 ++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Added-IHTMLTxtRange-moveToElementText-implemen.diff
Type: text/x-patch
Size: 1893 bytes
Desc: not available
URL:
From jacek at codeweavers.com Wed Nov 12 09:25:20 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Wed, 12 Nov 2014 16:25:20 +0100
Subject: [PATCH 2/4] mshtml: Moved IHTMLElement2 implementation to htmlelem.c.
Message-ID: <54637BE0.5080603@codeweavers.com>
---
dlls/mshtml/Makefile.in | 1 -
dlls/mshtml/htmlelem.c | 1351
+++++++++++++++++++++++++++++++++++++++-
dlls/mshtml/htmlelem2.c | 1387
------------------------------------------
dlls/mshtml/mshtml_private.h | 1 -
4 files changed, 1349 insertions(+), 1391 deletions(-)
delete mode 100644 dlls/mshtml/htmlelem2.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-mshtml-Moved-IHTMLElement2-implementation-to-htmlelem.diff
Type: text/x-patch
Size: 84073 bytes
Desc: not available
URL:
From jacek at codeweavers.com Wed Nov 12 09:25:26 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Wed, 12 Nov 2014 16:25:26 +0100
Subject: [PATCH 3/4] mshtml: Added IHTMLElement2::put_dir implementation.
Message-ID: <54637BE6.40100@codeweavers.com>
---
dlls/mshtml/htmlelem.c | 21 +++++++++++++++++++--
dlls/mshtml/tests/dom.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-mshtml-Added-IHTMLElement2-put_dir-implementation.diff
Type: text/x-patch
Size: 2933 bytes
Desc: not available
URL:
From jacek at codeweavers.com Wed Nov 12 09:25:31 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Wed, 12 Nov 2014 16:25:31 +0100
Subject: [PATCH 4/4] mshtml: Added IHTMLTxtRange::pasteHTML implementation.
Message-ID: <54637BEB.1010809@codeweavers.com>
---
dlls/mshtml/tests/dom.c | 27 +++++++++++++++++++++++++++
dlls/mshtml/txtrange.c | 30 ++++++++++++++++++++++++++++--
2 files changed, 55 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-mshtml-Added-IHTMLTxtRange-pasteHTML-implementation.diff
Type: text/x-patch
Size: 3095 bytes
Desc: not available
URL:
From austinenglish at gmail.com Wed Nov 12 13:30:57 2014
From: austinenglish at gmail.com (Austin English)
Date: Wed, 12 Nov 2014 13:30:57 -0600
Subject: ntdll: Add stubs for vectored continue handler
Message-ID:
Fixes https://bugs.winehq.org/show_bug.cgi?id=30572
--
-Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ntdll-Add-stubs-for-vectored-continue-handler.patch
Type: text/x-patch
Size: 3152 bytes
Desc: not available
URL:
From stefan at codeweavers.com Wed Nov 12 15:15:34 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 22:15:34 +0100
Subject: [PATCH 1/6] wined3d: Add new D3DCREATE flags.
Message-ID: <1415826939-4478-1-git-send-email-stefan@codeweavers.com>
---
include/wine/wined3d.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 8f563bb..ef9850b 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -934,6 +934,12 @@ enum wined3d_display_rotation
#define WINED3DCREATE_MIXED_VERTEXPROCESSING 0x00000080
#define WINED3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100
#define WINED3DCREATE_ADAPTERGROUP_DEVICE 0x00000200
+#define WINED3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX 0x00000400
+#define WINED3DCREATE_NOWINDOWCHANGES 0x00000800
+#define WINED3DCREATE_DISABLE_PSGP_THREADING 0x00002000
+#define WINED3DCREATE_ENABLE_PRESENTSTATS 0x00004000
+#define WINED3DCREATE_DISABLE_PRINTSCREEN 0x00008000
+#define WINED3DCREATE_SCREENSAVER 0x10000000
/* VTF defines */
#define WINED3DDMAPSAMPLER 0x100
--
2.0.4
From stefan at codeweavers.com Wed Nov 12 15:15:35 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 22:15:35 +0100
Subject: [PATCH 2/6] wined3d: Minimize device windows on focus loss (v3).
Message-ID: <1415826939-4478-2-git-send-email-stefan@codeweavers.com>
Tests for d3d8 will follow after 107631 has been committed.
v3: Check for D3DCREATE_NOWINDOWCHANGES.
v2: Move to wined3d. The different behavior in d3d9ex was due to a
hidden window and not a difference how d3d9ex handles focus loss. See
patch 7.
Another patch will add an action (resize the window to match the
backbuffer size) on window activation. For this reason the swapchain
helper function is called on both activation and deactivation.
---
dlls/wined3d/device.c | 5 +++++
dlls/wined3d/swapchain.c | 6 ++++++
dlls/wined3d/wined3d_private.h | 1 +
3 files changed, 12 insertions(+)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index ee3636e..0de444b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4983,6 +4983,11 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
}
else if (message == WM_ACTIVATEAPP)
{
+ UINT i;
+
+ for (i = 0; i < device->swapchain_count; i++)
+ wined3d_swapchain_activate(device->swapchains[i], wparam);
+
device->device_parent->ops->activate(device->device_parent, wparam);
}
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 25e2107..4c0948f 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -1175,3 +1175,9 @@ void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain)
wined3d_resource_update_draw_binding(&swapchain->back_buffers[i]->resource);
}
}
+
+void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate)
+{
+ if (!activate && !(swapchain->device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES))
+ ShowWindow(swapchain->device_window, SW_MINIMIZE);
+}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0f302c4..5f90e9a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2701,6 +2701,7 @@ struct wined3d_swapchain
void x11_copy_to_screen(const struct wined3d_swapchain *swapchain, const RECT *rect) DECLSPEC_HIDDEN;
+void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate) DECLSPEC_HIDDEN;
struct wined3d_context *swapchain_get_context(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
void swapchain_destroy_contexts(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
HDC swapchain_get_backup_dc(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
--
2.0.4
From stefan at codeweavers.com Wed Nov 12 15:15:36 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 22:15:36 +0100
Subject: [PATCH 3/6] d3d9/tests: Test messages on focus loss.
Message-ID: <1415826939-4478-3-git-send-email-stefan@codeweavers.com>
Resolution changing behavior will be tested in a separate patch.
---
dlls/d3d9/tests/d3d9ex.c | 277 ++++++++++++++++++++++++++++----------------
dlls/d3d9/tests/device.c | 293 +++++++++++++++++++++++++++++++----------------
2 files changed, 375 insertions(+), 195 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index bbb95b0..424d2cc 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -1702,6 +1702,8 @@ struct message
{
UINT message;
enum message_window window;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
};
static const struct message *expect_messages;
@@ -1743,7 +1745,14 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
};
if (hwnd == w && expect_messages->message == message)
+ {
+ if (expect_messages->check_wparam)
+ ok(wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
}
return DefWindowProcA(hwnd, message, wparam, lparam);
@@ -1795,13 +1804,52 @@ static void test_wndproc(void)
ULONG ref;
DWORD res, tid;
HWND tmp;
+ unsigned int i;
+ HRESULT hr;
- static const struct message messages[] =
+ static const struct message create_messages[] =
+ {
+ {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0},
+ /* Do not test wparam here. If device creation succeeds,
+ * wparam is WA_ACTIVE. If device creation fails (testbot)
+ * wparam is set to WA_INACTIVE on some Windows versions. */
+ {WM_ACTIVATE, FOCUS_WINDOW, FALSE, 0},
+ {WM_SETFOCUS, FOCUS_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE},
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ /* Windows sends WM_ACTIVATE to the device window, indicating that
+ * SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
+ * the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
+ * leaves the device window active, breaking re-activation in the
+ * lost device test.
+ * {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
+ {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ /* WM_ACTIVATEAPP is sent to the device window too, but the order is
+ * not deterministic. It may be sent after the focus window handling
+ * or before. */
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages_nowc[] =
{
- {WM_WINDOWPOSCHANGING, FOCUS_WINDOW},
- {WM_ACTIVATE, FOCUS_WINDOW},
- {WM_SETFOCUS, FOCUS_WINDOW},
- {0, 0},
+ {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ {0, 0, FALSE, 0},
+ };
+ static const struct
+ {
+ DWORD create_flags;
+ const struct message *focus_loss_messages;
+ }
+ tests[] =
+ {
+ {0, focus_loss_messages},
+ {CREATE_DEVICE_NOWINDOWCHANGES, focus_loss_messages_nowc},
};
wc.lpfnWndProc = test_proc;
@@ -1813,121 +1861,156 @@ static void test_wndproc(void)
thread_params.test_finished = CreateEventA(NULL, FALSE, FALSE, NULL);
ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
- focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
- ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
-
- res = WaitForSingleObject(thread_params.window_created, INFINITE);
- ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
-
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
-
- trace("device_window %p, focus_window %p, dummy_window %p.\n",
- device_window, focus_window, thread_params.dummy_window);
-
- tmp = GetFocus();
- ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
- if (thread_params.running_in_foreground)
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
{
- tmp = GetForegroundWindow();
- ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
- thread_params.dummy_window, tmp);
- }
- else
- skip("Not running in foreground, skip foreground window test\n");
+ focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
+ ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
- flush_events();
+ res = WaitForSingleObject(thread_params.window_created, INFINITE);
+ ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
- expect_messages = messages;
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
- device_desc.device_window = device_window;
- device_desc.width = registry_mode.dmPelsWidth;
- device_desc.height = registry_mode.dmPelsHeight;
- device_desc.flags = CREATE_DEVICE_FULLSCREEN;
- if (!(device = create_device(focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ trace("device_window %p, focus_window %p, dummy_window %p.\n",
+ device_window, focus_window, thread_params.dummy_window);
- ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n",
- expect_messages->message, expect_messages->window);
- expect_messages = NULL;
-
- if (0) /* Disabled until we can make this work in a reliable way on Wine. */
- {
tmp = GetFocus();
- ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
- tmp = GetForegroundWindow();
- ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
- }
- SetForegroundWindow(focus_window);
- flush_events();
+ ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
+ if (thread_params.running_in_foreground)
+ {
+ tmp = GetForegroundWindow();
+ ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
+ thread_params.dummy_window, tmp);
+ }
+ else
+ skip("Not running in foreground, skip foreground window test\n");
- filter_messages = focus_window;
+ flush_events();
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ expect_messages = create_messages;
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ device_desc.device_window = device_window;
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN | tests[i].create_flags;
+ if (!(device = create_device(focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ref = IDirect3DDevice9Ex_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ if (0) /* Disabled until we can make this work in a reliable way on Wine. */
+ {
+ tmp = GetFocus();
+ ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
+ tmp = GetForegroundWindow();
+ ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
+ }
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n",
+ (LONG_PTR)test_proc);
+
+ expect_messages = tests[i].focus_loss_messages;
+ /* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
+ * manually changing the focus. It generates the same messages, but the task
+ * bar still shows the previous foreground window as active, and the window has
+ * an inactive titlebar if reactivated with SetForegroundWindow. Reactivating
+ * the device is difficult, see below. */
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
+ tmp = GetFocus();
+ ok(tmp != device_window, "The device window is active, i=%u.\n", i);
+ ok(tmp != focus_window, "The focus window is active, i=%u.\n", i);
+
+ hr = IDirect3DDevice9Ex_CheckDeviceState(device, device_window);
+ ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x, i=%u.\n", hr, i);
+
+ /* In d3d9ex the device and focus windows have to be minimized and restored,
+ * otherwise native does not notice that focus has been restored. This is
+ * independent of D3DCREATE_NOWINDOWCHANGES. */
+ ShowWindow(device_window, SW_MINIMIZE);
+ ShowWindow(device_window, SW_RESTORE);
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ /* Calling Reset is not necessary in d3d9ex. */
+ hr = IDirect3DDevice9Ex_CheckDeviceState(device, device_window);
+ ok(hr == S_OK, "Got unexpected hr %#x, i=%u.\n", hr, i);
+
+ filter_messages = focus_window;
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- device_desc.device_window = focus_window;
- if (!(device = create_device(focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, proc, i);
- ref = IDirect3DDevice9Ex_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ device_desc.device_window = focus_window;
+ if (!(device = create_device(focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- device_desc.device_window = device_window;
- if (!(device = create_device(focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ device_desc.device_window = device_window;
+ if (!(device = create_device(focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ref = IDirect3DDevice9Ex_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n",
+ (LONG_PTR)test_proc);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)DefWindowProcA, proc);
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)DefWindowProcA, proc);
done:
- filter_messages = NULL;
+ filter_messages = NULL;
+ DestroyWindow(device_window);
+ DestroyWindow(focus_window);
+ SetEvent(thread_params.test_finished);
+ WaitForSingleObject(thread, INFINITE);
+ CloseHandle(thread);
+ }
- SetEvent(thread_params.test_finished);
- WaitForSingleObject(thread, INFINITE);
CloseHandle(thread_params.test_finished);
CloseHandle(thread_params.window_created);
- CloseHandle(thread);
- DestroyWindow(device_window);
- DestroyWindow(focus_window);
UnregisterClassA("d3d9_test_wndproc_wc", GetModuleHandleA(NULL));
}
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 1a5008a..aeda123 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -3091,6 +3091,8 @@ struct message
{
UINT message;
enum message_window window;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
};
static const struct message *expect_messages;
@@ -3131,7 +3133,15 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
break;
};
- if (hwnd == w && expect_messages->message == message) ++expect_messages;
+ if (hwnd == w && expect_messages->message == message)
+ {
+ if (expect_messages->check_wparam)
+ ok(wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
+ ++expect_messages;
+ }
}
return DefWindowProcA(hwnd, message, wparam, lparam);
@@ -3182,13 +3192,52 @@ static void test_wndproc(void)
ULONG ref;
DWORD res, tid;
HWND tmp;
+ unsigned int i;
+ HRESULT hr;
- static const struct message messages[] =
+ static const struct message create_messages[] =
+ {
+ {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0},
+ /* Do not test wparam here. If device creation succeeds,
+ * wparam is WA_ACTIVE. If device creation fails (testbot)
+ * wparam is set to WA_INACTIVE on some Windows versions. */
+ {WM_ACTIVATE, FOCUS_WINDOW, FALSE, 0},
+ {WM_SETFOCUS, FOCUS_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE},
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ /* Windows sends WM_ACTIVATE to the device window, indicating that
+ * SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
+ * the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
+ * leaves the device window active, breaking re-activation in the
+ * lost device test.
+ * {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
+ {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ /* WM_ACTIVATEAPP is sent to the device window too, but the order is
+ * not deterministic. It may be sent after the focus window handling
+ * or before. */
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages_nowc[] =
{
- {WM_WINDOWPOSCHANGING, FOCUS_WINDOW},
- {WM_ACTIVATE, FOCUS_WINDOW},
- {WM_SETFOCUS, FOCUS_WINDOW},
- {0, 0},
+ {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ {0, 0, FALSE, 0},
+ };
+ static const struct
+ {
+ DWORD create_flags;
+ const struct message *focus_loss_messages;
+ }
+ tests[] =
+ {
+ {0, focus_loss_messages},
+ {CREATE_DEVICE_NOWINDOWCHANGES, focus_loss_messages_nowc},
};
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
@@ -3203,122 +3252,168 @@ static void test_wndproc(void)
thread_params.test_finished = CreateEventA(NULL, FALSE, FALSE, NULL);
ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
- focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
- ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ {
+ focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
+ ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
- res = WaitForSingleObject(thread_params.window_created, INFINITE);
- ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+ res = WaitForSingleObject(thread_params.window_created, INFINITE);
+ ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
- trace("device_window %p, focus_window %p, dummy_window %p.\n",
- device_window, focus_window, thread_params.dummy_window);
+ trace("device_window %p, focus_window %p, dummy_window %p.\n",
+ device_window, focus_window, thread_params.dummy_window);
- tmp = GetFocus();
- ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
- if (thread_params.running_in_foreground)
- {
- tmp = GetForegroundWindow();
- ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
- thread_params.dummy_window, tmp);
- }
- else
- skip("Not running in foreground, skip foreground window test\n");
+ tmp = GetFocus();
+ ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
+ if (thread_params.running_in_foreground)
+ {
+ tmp = GetForegroundWindow();
+ ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
+ thread_params.dummy_window, tmp);
+ }
+ else
+ skip("Not running in foreground, skip foreground window test\n");
- flush_events();
+ flush_events();
- expect_messages = messages;
+ expect_messages = create_messages;
- device_desc.device_window = device_window;
- device_desc.width = registry_mode.dmPelsWidth;
- device_desc.height = registry_mode.dmPelsHeight;
- device_desc.flags = CREATE_DEVICE_FULLSCREEN;
- if (!(device = create_device(d3d9, focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ device_desc.device_window = device_window;
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN | tests[i].create_flags;
+ if (!(device = create_device(d3d9, focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n",
- expect_messages->message, expect_messages->window);
- expect_messages = NULL;
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
- if (0) /* Disabled until we can make this work in a reliable way on Wine. */
- {
+ if (0) /* Disabled until we can make this work in a reliable way on Wine. */
+ {
+ tmp = GetFocus();
+ ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
+ tmp = GetForegroundWindow();
+ ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
+ }
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, proc, i);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, i);
+
+ expect_messages = tests[i].focus_loss_messages;
+ /* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
+ * manually changing the focus. It generates the same messages, but the task
+ * bar still shows the previous foreground window as active, and the window has
+ * an inactive titlebar if reactivated with SetForegroundWindow. Reactivating
+ * the device is difficult, see below. */
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
tmp = GetFocus();
- ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
- tmp = GetForegroundWindow();
- ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
- }
- SetForegroundWindow(focus_window);
- flush_events();
+ ok(tmp != device_window, "The device window is active, i=%u.\n", i);
+ ok(tmp != focus_window, "The focus window is active, i=%u.\n", i);
- filter_messages = focus_window;
+ hr = IDirect3DDevice9_TestCooperativeLevel(device);
+ ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ /* This is needed on native with D3DCREATE_NOWINDOWCHANGES, and it needs to be
+ * done before the focus window is restored. This makes sense to some extent
+ * because minimizing the window on focus loss is the application's job if this
+ * flag is set. */
+ if (tests[i].create_flags & CREATE_DEVICE_NOWINDOWCHANGES)
+ {
+ ShowWindow(device_window, SW_MINIMIZE);
+ ShowWindow(device_window, SW_RESTORE);
+ }
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ /* I have to minimize and restore the focus window, otherwise native d3d9 fails
+ * device::reset with D3DERR_DEVICELOST. This does not happen when the window
+ * restore is triggered by the user. */
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ SetForegroundWindow(focus_window);
+ flush_events();
- ref = IDirect3DDevice9_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ hr = IDirect3DDevice9_TestCooperativeLevel(device);
+ ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ /* Releasing a device in lost state breaks follow-up tests on native. */
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x, i=%u.\n", hr, i);
- device_desc.device_window = focus_window;
- if (!(device = create_device(d3d9, focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ filter_messages = focus_window;
- ref = IDirect3DDevice9_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ ref = IDirect3DDevice9_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- device_desc.device_window = device_window;
- if (!(device = create_device(d3d9, focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, proc, i);
- proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ device_desc.device_window = focus_window;
+ if (!(device = create_device(d3d9, focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ref = IDirect3DDevice9_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ ref = IDirect3DDevice9_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)DefWindowProcA, proc);
+ device_desc.device_window = device_window;
+ if (!(device = create_device(d3d9, focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
+
+ proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, i);
+
+ ref = IDirect3DDevice9_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)DefWindowProcA, proc, i);
done:
- filter_messages = NULL;
- IDirect3D9_Release(d3d9);
+ filter_messages = NULL;
+ DestroyWindow(device_window);
+ DestroyWindow(focus_window);
+ SetEvent(thread_params.test_finished);
+ WaitForSingleObject(thread, INFINITE);
+ CloseHandle(thread);
+ }
- SetEvent(thread_params.test_finished);
- WaitForSingleObject(thread, INFINITE);
+ IDirect3D9_Release(d3d9);
CloseHandle(thread_params.test_finished);
CloseHandle(thread_params.window_created);
- CloseHandle(thread);
-
- DestroyWindow(device_window);
- DestroyWindow(focus_window);
UnregisterClassA("d3d9_test_wndproc_wc", GetModuleHandleA(NULL));
}
@@ -3540,8 +3635,10 @@ static void test_reset_fullscreen(void)
struct device_desc device_desc;
static const struct message messages[] =
{
- {WM_ACTIVATEAPP, FOCUS_WINDOW},
- {0, 0},
+ /* Windows usually sends wparam = TRUE, except on the testbot,
+ * where it randomly sends FALSE. Ignore it. */
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
};
d3d = Direct3DCreate9(D3D_SDK_VERSION);
--
2.0.4
From stefan at codeweavers.com Wed Nov 12 15:15:37 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 22:15:37 +0100
Subject: [PATCH 4/6] d3d9/tests: Test style changes on focus loss.
Message-ID: <1415826939-4478-4-git-send-email-stefan@codeweavers.com>
I will add message tests for the hidden window behavior in a separate
test.
I don't particularly care about the behavior on the second d3d9ex device
creation. This part is in the test to explain why I am destroying
the device and the windows. d3d9ex does the same when calling reset to
switch to fullscreen mode a second time.
---
dlls/d3d9/tests/d3d9ex.c | 85 +++++++++++++++++++++++++++++++++++++++++++++---
dlls/d3d9/tests/device.c | 40 +++++++++++++++++++++--
2 files changed, 117 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index 424d2cc..0074261 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -2218,24 +2218,27 @@ done:
static void test_window_style(void)
{
RECT focus_rect, device_rect, fullscreen_rect, r, r2;
- LONG device_style, device_exstyle;
+ LONG device_style, device_exstyle, expected_style;
LONG focus_style, focus_exstyle;
struct device_desc device_desc;
LONG style;
IDirect3DDevice9Ex *device;
HRESULT hr;
ULONG ref;
+ BOOL ret;
static const struct
{
LONG style_flags;
DWORD device_flags;
+ LONG focus_loss_style;
+ LONG create2_style, create2_exstyle;
}
tests[] =
{
- {0, 0},
- {WS_VISIBLE, 0},
- {0, CREATE_DEVICE_NOWINDOWCHANGES},
- {WS_VISIBLE, CREATE_DEVICE_NOWINDOWCHANGES},
+ {0, 0, 0, WS_VISIBLE, WS_EX_TOPMOST},
+ {WS_VISIBLE, 0, WS_MINIMIZE, WS_VISIBLE, WS_EX_TOPMOST},
+ {0, CREATE_DEVICE_NOWINDOWCHANGES, 0, 0, 0},
+ {WS_VISIBLE, CREATE_DEVICE_NOWINDOWCHANGES, 0, 0, 0},
};
unsigned int i;
@@ -2323,6 +2326,78 @@ static void test_window_style(void)
ref = IDirect3DDevice9Ex_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ if (device_style & WS_VISIBLE)
+ ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ device_style, style, i);
+ else
+ todo_wine ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ device_style, style, i);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n",
+ device_exstyle, style, i);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+ focus_style, style, i);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+ focus_exstyle, style, i);
+
+ /* The second time a device is created on the window the window becomes visible and
+ * topmost if D3DCREATE_NOWINDOWCHANGES is not set. */
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ device = create_device(focus_window, &device_desc);
+ ok(!!device, "Failed to create a D3D device.\n");
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | tests[i].create2_style;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ expected_style, style, i);
+ expected_style = device_exstyle | tests[i].create2_exstyle;
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x, i=%u.\n",
+ expected_style, style, i);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+ focus_style, style, i);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+ focus_exstyle, style, i);
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+ DestroyWindow(device_window);
+ DestroyWindow(focus_window);
+ focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | tests[i].style_flags,
+ 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | tests[i].style_flags,
+ 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+
+ device_desc.device_window = device_window;
+ device = create_device(focus_window, &device_desc);
+ ok(!!device, "Failed to create a D3D device.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | tests[i].focus_loss_style;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ expected_style, style, i);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n",
+ device_exstyle, style, i);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+ focus_style, style, i);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+ focus_exstyle, style, i);
+
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
DestroyWindow(device_window);
DestroyWindow(focus_window);
}
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index aeda123..d98221a 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -3787,15 +3787,16 @@ static void test_window_style(void)
IDirect3D9 *d3d9;
HRESULT hr;
ULONG ref;
+ BOOL ret;
static const struct
{
DWORD device_flags;
- LONG style, exstyle;
+ LONG style, focus_loss_style, exstyle;
}
tests[] =
{
- {0, WS_VISIBLE, WS_EX_TOPMOST},
- {CREATE_DEVICE_NOWINDOWCHANGES, 0},
+ {0, WS_VISIBLE, WS_MINIMIZE, WS_EX_TOPMOST},
+ {CREATE_DEVICE_NOWINDOWCHANGES, 0, 0, 0},
};
unsigned int i;
@@ -3890,6 +3891,39 @@ static void test_window_style(void)
ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
focus_exstyle, style, i);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | tests[i].focus_loss_style | tests[i].style;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x.\n",
+ expected_style, style);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ expected_style = device_exstyle | tests[i].exstyle;
+ todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x.\n",
+ expected_style, style);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x.\n",
+ focus_style, style);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
+ focus_exstyle, style);
+
+ /* In d3d8 follow-up tests fail on native if the device is destroyed while
+ * lost. This doesn't happen in d3d9 on my test machine but it still seems
+ * like a good idea to reset it first. */
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ ret = SetForegroundWindow(focus_window);
+ ok(ret, "Failed to set foreground window.\n");
+ flush_events();
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
ref = IDirect3DDevice9_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Wed Nov 12 15:15:39 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 22:15:39 +0100
Subject: [PATCH 6/6] ddraw/tests: Test focus loss style changes.
Message-ID: <1415826939-4478-6-git-send-email-stefan@codeweavers.com>
---
dlls/ddraw/tests/ddraw1.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw2.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw4.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw7.c | 37 ++++++++++++++++++++++++++++++++++++-
4 files changed, 144 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index b31e25e..569aa94 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -2009,12 +2009,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2040,6 +2041,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2048,6 +2063,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 84dd17a..61cf668 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -2197,12 +2197,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw2 *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2228,6 +2229,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2236,6 +2251,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw2_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index fa8309d..eca99fa 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -2384,12 +2384,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw4 *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2415,6 +2416,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2423,6 +2438,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw4_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index adbecc2..9cf56a3 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -2062,12 +2062,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw7 *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2093,6 +2094,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2101,6 +2116,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw7_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Wed Nov 12 15:15:38 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Wed, 12 Nov 2014 22:15:38 +0100
Subject: [PATCH 5/6] ddraw/tests: Test messages on focus loss.
Message-ID: <1415826939-4478-5-git-send-email-stefan@codeweavers.com>
---
dlls/ddraw/tests/ddraw1.c | 97 +++++++++++++++++++++++++++++++-------------
dlls/ddraw/tests/ddraw2.c | 101 ++++++++++++++++++++++++++++++++--------------
dlls/ddraw/tests/ddraw4.c | 101 ++++++++++++++++++++++++++++++++--------------
dlls/ddraw/tests/ddraw7.c | 101 ++++++++++++++++++++++++++++++++--------------
4 files changed, 278 insertions(+), 122 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 0ae204c..b31e25e 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -428,12 +428,26 @@ static void destroy_material(IDirect3DMaterial *material)
IDirect3DMaterial_Release(material);
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -1878,15 +1892,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -1906,7 +1920,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2147,19 +2161,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2234,7 +2263,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2280,7 +2309,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2291,6 +2320,16 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ hr = IDirectDrawSurface_Restore(primary);
+ ok(SUCCEEDED(hr), "Surface Restore failed, hr %#x.\n", hr);
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2299,7 +2338,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2385,7 +2424,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2409,7 +2448,7 @@ static void test_coop_level_mode_set(void)
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2453,7 +2492,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2548,7 +2587,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2565,7 +2604,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2609,7 +2648,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 334d89e..84dd17a 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -361,12 +361,26 @@ static void destroy_material(IDirect3DMaterial2 *material)
IDirect3DMaterial2_Release(material);
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -2066,15 +2080,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -2094,7 +2108,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2346,19 +2360,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2438,7 +2467,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2484,7 +2513,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2495,6 +2524,16 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ hr = IDirectDrawSurface_Restore(primary);
+ ok(SUCCEEDED(hr), "Surface Restore failed, hr %#x.\n", hr);
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2503,7 +2542,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2589,7 +2628,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2613,7 +2652,7 @@ static void test_coop_level_mode_set(void)
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2657,7 +2696,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2752,7 +2791,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2769,7 +2808,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2813,7 +2852,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2874,7 +2913,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2945,7 +2984,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index ab03f39..fa8309d 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -391,12 +391,26 @@ static void destroy_material(IDirect3DMaterial3 *material)
IDirect3DMaterial3_Release(material);
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -2253,15 +2267,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -2281,7 +2295,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2533,19 +2547,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2625,7 +2654,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2671,7 +2700,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2682,6 +2711,16 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ hr = IDirectDrawSurface4_Restore(primary);
+ ok(SUCCEEDED(hr), "Surface Restore failed, hr %#x.\n", hr);
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2690,7 +2729,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2776,7 +2815,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2793,7 +2832,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2837,7 +2876,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2932,7 +2971,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2949,7 +2988,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2993,7 +3032,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -3054,7 +3093,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -3125,7 +3164,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index f505c65..adbecc2 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -324,12 +324,26 @@ static IDirect3DDevice7 *create_device(HWND window, DWORD coop_level)
return device;
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -1931,15 +1945,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -1959,7 +1973,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2210,19 +2224,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2302,7 +2331,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2348,7 +2377,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2359,6 +2388,16 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ hr = IDirectDrawSurface7_Restore(primary);
+ ok(SUCCEEDED(hr), "Surface Restore failed, hr %#x.\n", hr);
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2367,7 +2406,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2453,7 +2492,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2470,7 +2509,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2514,7 +2553,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2609,7 +2648,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2626,7 +2665,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2670,7 +2709,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2731,7 +2770,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2802,7 +2841,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
--
2.0.4
From madewokherd at gmail.com Wed Nov 12 16:06:42 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Wed, 12 Nov 2014 16:06:42 -0600
Subject: [1/5] windowscodecs: Treat missing GUID list keys as empty.
Message-ID:
-------------- next part --------------
From e9993ead9c995f22b24fb1702cbd54b4bf46108e Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Thu, 6 Nov 2014 16:07:17 -0600
Subject: [PATCH 1/7] windowscodecs: Treat missing GUID list keys as empty.
---
dlls/windowscodecs/info.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/info.c b/dlls/windowscodecs/info.c
index 5f42994..d42d726 100644
--- a/dlls/windowscodecs/info.c
+++ b/dlls/windowscodecs/info.c
@@ -151,7 +151,12 @@ static HRESULT ComponentInfo_GetGuidList(HKEY classkey, LPCWSTR subkeyname,
return E_INVALIDARG;
ret = RegOpenKeyExW(classkey, subkeyname, 0, KEY_READ, &subkey);
- if (ret != ERROR_SUCCESS) return HRESULT_FROM_WIN32(ret);
+ if (ret == ERROR_FILE_NOT_FOUND)
+ {
+ *actual_size = 0;
+ return S_OK;
+ }
+ else if (ret != ERROR_SUCCESS) return HRESULT_FROM_WIN32(ret);
if (buffer)
{
--
2.1.0
From madewokherd at gmail.com Wed Nov 12 16:07:46 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Wed, 12 Nov 2014 16:07:46 -0600
Subject: [2/5] windowscodecs: Implement MetadataReaderInfo_GetContainerFormats.
Message-ID:
-------------- next part --------------
From c058fb6c5ccea5304a8f2ad0bae0f355e9df1e56 Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Thu, 6 Nov 2014 16:07:54 -0600
Subject: [PATCH 2/7] windowscodecs: Implement
MetadataReaderInfo_GetContainerFormats.
---
dlls/windowscodecs/info.c | 8 +++++---
dlls/windowscodecs/tests/info.c | 2 --
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/windowscodecs/info.c b/dlls/windowscodecs/info.c
index d42d726..ea81dba 100644
--- a/dlls/windowscodecs/info.c
+++ b/dlls/windowscodecs/info.c
@@ -56,6 +56,7 @@ static const WCHAR supportstransparency_valuename[] = {'S','u','p','p','o','r','
static const WCHAR requiresfullstream_valuename[] = {'R','e','q','u','i','r','e','s','F','u','l','l','S','t','r','e','a','m',0};
static const WCHAR supportspadding_valuename[] = {'S','u','p','p','o','r','t','s','P','a','d','d','i','n','g',0};
static const WCHAR fileextensions_valuename[] = {'F','i','l','e','E','x','t','e','n','s','i','o','n','s',0};
+static const WCHAR containers_keyname[] = {'C','o','n','t','a','i','n','e','r','s',0};
static HRESULT ComponentInfo_GetStringValue(HKEY classkey, LPCWSTR value,
UINT buffer_size, WCHAR *buffer, UINT *actual_size)
@@ -1635,10 +1636,11 @@ static HRESULT WINAPI MetadataReaderInfo_GetMetadataFormat(IWICMetadataReaderInf
static HRESULT WINAPI MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderInfo *iface,
UINT length, GUID *formats, UINT *actual_length)
{
- if (!actual_length) return E_INVALIDARG;
+ MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
+ TRACE("(%p,%u,%p,%p)\n", iface, length, formats, actual_length);
- FIXME("(%p,%u,%p,%p): stub\n", iface, length, formats, actual_length);
- return E_NOTIMPL;
+ return ComponentInfo_GetGuidList(This->classkey, containers_keyname, length,
+ formats, actual_length);
}
static HRESULT WINAPI MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo *iface,
diff --git a/dlls/windowscodecs/tests/info.c b/dlls/windowscodecs/tests/info.c
index 5753f6b..98c06ec 100644
--- a/dlls/windowscodecs/tests/info.c
+++ b/dlls/windowscodecs/tests/info.c
@@ -415,9 +415,7 @@ static void test_reader_info(void)
count = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, &count);
-todo_wine
ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
-todo_wine
ok(count == 0, "unexpected count %d\n", count);
hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
--
2.1.0
From madewokherd at gmail.com Wed Nov 12 16:09:31 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Wed, 12 Nov 2014 16:09:31 -0600
Subject: [3/5] windowscodecs: Implement MetadataReaderInfo_GetPatterns.
Message-ID:
-------------- next part --------------
From e1adec66af8462e3b086112bb1fa25ca8782f139 Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Tue, 11 Nov 2014 15:59:31 -0600
Subject: [PATCH 3/7] windowscodecs: Implement MetadataReaderInfo_GetPatterns.
---
dlls/windowscodecs/info.c | 110 ++++++++++++++++++++++++++++++++++++++--
dlls/windowscodecs/tests/info.c | 1 -
2 files changed, 106 insertions(+), 5 deletions(-)
diff --git a/dlls/windowscodecs/info.c b/dlls/windowscodecs/info.c
index ea81dba..3cc7d01 100644
--- a/dlls/windowscodecs/info.c
+++ b/dlls/windowscodecs/info.c
@@ -1681,12 +1681,114 @@ static HRESULT WINAPI MetadataReaderInfo_DoesRequireFixedSize(IWICMetadataReader
}
static HRESULT WINAPI MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo *iface,
- REFGUID container, UINT length, WICMetadataPattern *pattern, UINT *count, UINT *actual_length)
+ REFGUID container, UINT length, WICMetadataPattern *patterns, UINT *count, UINT *actual_length)
{
- if (!actual_length) return E_INVALIDARG;
+ MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
+ HRESULT hr=S_OK;
+ LONG res;
+ UINT pattern_count=0, patterns_size=0;
+ DWORD valuesize, patternsize;
+ BYTE *bPatterns=(BYTE*)patterns;
+ HKEY containers_key, guid_key, pattern_key;
+ WCHAR subkeyname[11];
+ WCHAR guidkeyname[39];
+ int i;
+ static const WCHAR uintformatW[] = {'%','u',0};
+ static const WCHAR patternW[] = {'P','a','t','t','e','r','n',0};
+ static const WCHAR positionW[] = {'P','o','s','i','t','i','o','n',0};
+ static const WCHAR maskW[] = {'M','a','s','k',0};
+ static const WCHAR dataoffsetW[] = {'D','a','t','a','O','f','f','s','e','t',0};
- FIXME("(%p,%s,%u,%p,%p,%p): stub\n", iface, debugstr_guid(container), length, pattern, count, actual_length);
- return E_NOTIMPL;
+ TRACE("(%p,%s,%u,%p,%p,%p)\n", iface, debugstr_guid(container), length, patterns, count, actual_length);
+
+ if (!actual_length || !container) return E_INVALIDARG;
+
+ res = RegOpenKeyExW(This->classkey, containers_keyname, 0, KEY_READ, &containers_key);
+ if (res == ERROR_SUCCESS)
+ {
+ StringFromGUID2(container, guidkeyname, 39);
+
+ res = RegOpenKeyExW(containers_key, guidkeyname, 0, KEY_READ, &guid_key);
+ if (res == ERROR_FILE_NOT_FOUND) hr = WINCODEC_ERR_COMPONENTNOTFOUND;
+ else if (res != ERROR_SUCCESS) hr = HRESULT_FROM_WIN32(res);
+
+ RegCloseKey(containers_key);
+ }
+ else if (res == ERROR_FILE_NOT_FOUND) hr = WINCODEC_ERR_COMPONENTNOTFOUND;
+ else hr = HRESULT_FROM_WIN32(res);
+
+ if (SUCCEEDED(hr))
+ {
+ res = RegQueryInfoKeyW(guid_key, NULL, NULL, NULL, &pattern_count, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ if (res != ERROR_SUCCESS) hr = HRESULT_FROM_WIN32(res);
+
+ if (SUCCEEDED(hr))
+ {
+ patterns_size = pattern_count * sizeof(WICMetadataPattern);
+
+ for (i=0; i= patterns_size) && (res == ERROR_SUCCESS))
+ {
+ patterns[i].Length = patternsize;
+
+ patterns[i].DataOffset.QuadPart = 0;
+ valuesize = sizeof(ULARGE_INTEGER);
+ RegGetValueW(pattern_key, NULL, dataoffsetW, RRF_RT_DWORD|RRF_RT_QWORD, NULL,
+ &patterns[i].DataOffset, &valuesize);
+
+ patterns[i].Position.QuadPart = 0;
+ valuesize = sizeof(ULARGE_INTEGER);
+ res = RegGetValueW(pattern_key, NULL, positionW, RRF_RT_DWORD|RRF_RT_QWORD, NULL,
+ &patterns[i].Position, &valuesize);
+
+ if (res == ERROR_SUCCESS)
+ {
+ patterns[i].Pattern = bPatterns+patterns_size-patternsize*2;
+ valuesize = patternsize;
+ res = RegGetValueW(pattern_key, NULL, patternW, RRF_RT_REG_BINARY, NULL,
+ patterns[i].Pattern, &valuesize);
+ }
+
+ if (res == ERROR_SUCCESS)
+ {
+ patterns[i].Mask = bPatterns+patterns_size-patternsize;
+ valuesize = patternsize;
+ res = RegGetValueW(pattern_key, NULL, maskW, RRF_RT_REG_BINARY, NULL,
+ patterns[i].Mask, &valuesize);
+ }
+ }
+
+ RegCloseKey(pattern_key);
+ }
+ if (res != ERROR_SUCCESS)
+ {
+ hr = HRESULT_FROM_WIN32(res);
+ break;
+ }
+ }
+ }
+
+ RegCloseKey(guid_key);
+ }
+
+ if (hr == S_OK)
+ {
+ *count = pattern_count;
+ *actual_length = patterns_size;
+ if (patterns && length < patterns_size)
+ hr = WINCODEC_ERR_INSUFFICIENTBUFFER;
+ }
+
+ return hr;
}
static HRESULT WINAPI MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo *iface,
diff --git a/dlls/windowscodecs/tests/info.c b/dlls/windowscodecs/tests/info.c
index 98c06ec..51181ca 100644
--- a/dlls/windowscodecs/tests/info.c
+++ b/dlls/windowscodecs/tests/info.c
@@ -425,7 +425,6 @@ static void test_reader_info(void)
count = size = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
0, NULL, &count, &size);
-todo_wine
ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND || broken(hr == S_OK) /* Windows XP */,
"GetPatterns failed, hr=%x\n", hr);
ok(count == 0xdeadbeef, "unexpected count %d\n", count);
--
2.1.0
From madewokherd at gmail.com Wed Nov 12 16:10:44 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Wed, 12 Nov 2014 16:10:44 -0600
Subject: [4/5] windowscodecs: Implement MetadataReaderInfo_MatchesPattern.
Message-ID:
-------------- next part --------------
From d30dc54f754120c2a9be3b2d23f75203f729a96d Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Wed, 12 Nov 2014 14:32:29 -0600
Subject: [PATCH 4/7] windowscodecs: Implement
MetadataReaderInfo_MatchesPattern.
---
dlls/windowscodecs/info.c | 70 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 68 insertions(+), 2 deletions(-)
diff --git a/dlls/windowscodecs/info.c b/dlls/windowscodecs/info.c
index 3cc7d01..f532ad1 100644
--- a/dlls/windowscodecs/info.c
+++ b/dlls/windowscodecs/info.c
@@ -1794,8 +1794,74 @@ static HRESULT WINAPI MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo *ifa
static HRESULT WINAPI MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo *iface,
REFGUID container, IStream *stream, BOOL *matches)
{
- FIXME("(%p,%s,%p,%p): stub\n", iface, debugstr_guid(container), stream, matches);
- return E_NOTIMPL;
+ HRESULT hr;
+ WICMetadataPattern *patterns;
+ UINT pattern_count=0, patterns_size=0;
+ ULONG datasize=0;
+ BYTE *data=NULL;
+ ULONG bytesread;
+ UINT i;
+ LARGE_INTEGER seekpos;
+ ULONG pos;
+
+ TRACE("(%p,%s,%p,%p)\n", iface, debugstr_guid(container), stream, matches);
+
+ hr = MetadataReaderInfo_GetPatterns(iface, container, 0, NULL, &pattern_count, &patterns_size);
+ if (FAILED(hr)) return hr;
+
+ patterns = HeapAlloc(GetProcessHeap(), 0, patterns_size);
+ if (!patterns) return E_OUTOFMEMORY;
+
+ hr = MetadataReaderInfo_GetPatterns(iface, container, patterns_size, patterns, &pattern_count, &patterns_size);
+ if (FAILED(hr)) goto end;
+
+ for (i=0; i
-------------- next part --------------
From a3735fa76b9dc568f32561eda4617e216af82138 Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Wed, 12 Nov 2014 15:51:09 -0600
Subject: [PATCH 5/7] windowscodecs: Implement
ComponentFactory_CreateMetadataReaderFromContainer.
---
dlls/windowscodecs/imgfactory.c | 101 +++++++++++++++++++++++++++++++++++-
dlls/windowscodecs/tests/metadata.c | 25 +++++----
2 files changed, 115 insertions(+), 11 deletions(-)
diff --git a/dlls/windowscodecs/imgfactory.c b/dlls/windowscodecs/imgfactory.c
index e7095dd..444f2e4 100644
--- a/dlls/windowscodecs/imgfactory.c
+++ b/dlls/windowscodecs/imgfactory.c
@@ -956,9 +956,106 @@ static HRESULT WINAPI ComponentFactory_CreateMetadataReader(IWICComponentFactory
static HRESULT WINAPI ComponentFactory_CreateMetadataReaderFromContainer(IWICComponentFactory *iface,
REFGUID format, const GUID *vendor, DWORD options, IStream *stream, IWICMetadataReader **reader)
{
- FIXME("%p,%s,%s,%x,%p,%p: stub\n", iface, debugstr_guid(format), debugstr_guid(vendor),
+ HRESULT hr;
+ IEnumUnknown *enumreaders;
+ IUnknown *unkreaderinfo;
+ IWICMetadataReaderInfo *readerinfo;
+ IWICPersistStream *wicpersiststream;
+ ULONG num_fetched;
+ GUID decoder_vendor;
+ BOOL matches;
+ LARGE_INTEGER zero;
+
+ TRACE("%p,%s,%s,%x,%p,%p\n", iface, debugstr_guid(format), debugstr_guid(vendor),
options, stream, reader);
- return E_NOTIMPL;
+
+ if (!format || !stream || !reader)
+ return E_INVALIDARG;
+
+ zero.QuadPart = 0;
+
+ hr = CreateComponentEnumerator(WICMetadataReader, WICComponentEnumerateDefault, &enumreaders);
+ if (FAILED(hr)) return hr;
+
+ *reader = NULL;
+
+start:
+ while (!*reader)
+ {
+ hr = IEnumUnknown_Next(enumreaders, 1, &unkreaderinfo, &num_fetched);
+
+ if (hr == S_OK)
+ {
+ hr = IUnknown_QueryInterface(unkreaderinfo, &IID_IWICMetadataReaderInfo, (void**)&readerinfo);
+
+ if (SUCCEEDED(hr))
+ {
+ if (vendor)
+ {
+ hr = IWICMetadataReaderInfo_GetVendorGUID(readerinfo, &decoder_vendor);
+
+ if (FAILED(hr) || !IsEqualIID(vendor, &decoder_vendor))
+ {
+ IWICMetadataReaderInfo_Release(readerinfo);
+ IUnknown_Release(unkreaderinfo);
+ continue;
+ }
+ }
+
+ hr = IWICMetadataReaderInfo_MatchesPattern(readerinfo, format, stream, &matches);
+
+ if (SUCCEEDED(hr) && matches)
+ {
+ hr = IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
+
+ if (SUCCEEDED(hr))
+ hr = IWICMetadataReaderInfo_CreateInstance(readerinfo, reader);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = IWICMetadataReader_QueryInterface(*reader, &IID_IWICPersistStream, (void**)&wicpersiststream);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = IWICPersistStream_LoadEx(wicpersiststream,
+ stream, vendor, options & WICPersistOptionsMask);
+
+ IWICPersistStream_Release(wicpersiststream);
+ }
+
+ if (FAILED(hr))
+ {
+ IWICMetadataReader_Release(*reader);
+ *reader = NULL;
+ }
+ }
+ }
+
+ IUnknown_Release(readerinfo);
+ }
+
+ IUnknown_Release(unkreaderinfo);
+ }
+ else
+ break;
+ }
+
+ if (!*reader && vendor)
+ {
+ vendor = NULL;
+ IEnumUnknown_Reset(enumreaders);
+ goto start;
+ }
+
+ IEnumUnknown_Release(enumreaders);
+
+ if (!*reader && !(options & WICMetadataCreationFailUnknown))
+ FIXME("create unknown metadata reader\n");
+
+ if (*reader)
+ return S_OK;
+ else
+ return WINCODEC_ERR_COMPONENTNOTFOUND;
}
static HRESULT WINAPI ComponentFactory_CreateMetadataWriter(IWICComponentFactory *iface,
diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c
index e42b474..07ef29b 100644
--- a/dlls/windowscodecs/tests/metadata.c
+++ b/dlls/windowscodecs/tests/metadata.c
@@ -841,17 +841,24 @@ static void test_create_reader(void)
stream = create_stream(metadata_tEXt, sizeof(metadata_tEXt));
hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
+ NULL, NULL, WICPersistOptionsDefault,
+ stream, &reader);
+ ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
+
+ hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
+ &GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault,
+ NULL, &reader);
+ ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
+
+ hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
+ &GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault,
+ stream, NULL);
+ ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
+
+ hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
&GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault,
stream, &reader);
-todo_wine
ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
- /* NOTE: removed once Wine is fixed */
- if (FAILED(hr))
- {
- IStream_Release(stream);
- IWICComponentFactory_Release(factory);
- return;
- }
if (SUCCEEDED(hr))
{
@@ -869,7 +876,7 @@ todo_wine
hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
&GUID_ContainerFormatWmp, NULL, WICPersistOptionsDefault,
stream, &reader);
- ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
+ todo_wine ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
--
2.1.0
From nerv at dawncrow.de Wed Nov 12 17:57:04 2014
From: nerv at dawncrow.de (=?ISO-8859-15?Q?Andr=E9_Hentschel?=)
Date: Thu, 13 Nov 2014 00:57:04 +0100
Subject: ntdll/tests: Get rid of "defined but not used" warnings on
non-x86(_64) platforms
Message-ID: <5463F3D0.7080701@dawncrow.de>
---
dlls/ntdll/tests/exception.c | 2 ++
1 file changed, 2 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-ntdll-tests-Get-rid-of-defined-but-not-used-warnings-o.txt
Type: text/x-patch
Size: 657 bytes
Desc: not available
URL:
From mstefani at redhat.de Thu Nov 13 03:06:06 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Thu, 13 Nov 2014 10:06:06 +0100
Subject: oleaut32/tests: Simplify the check for an empty string (PVS-Studio)
Message-ID: <20141113090606.GA726@redhat.com>
---
dlls/oleaut32/tests/vartest.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c
index d00e577..066e5f6 100644
--- a/dlls/oleaut32/tests/vartest.c
+++ b/dlls/oleaut32/tests/vartest.c
@@ -295,16 +295,14 @@ static void init(void)
HRESULT res;
res = VarBstrFromBool(VARIANT_TRUE, LANG_USER_DEFAULT, VAR_LOCALBOOL, &bstr);
- ok(res == S_OK && (lstrlenW(bstr) > 0),
- "Expected localized string for 'True'\n");
+ ok(res == S_OK && bstr[0], "Expected localized string for 'True'\n");
/* lstrcpyW / lstrcatW do not work on win95 */
memcpy(sz12_true, sz12, sizeof(sz12));
if (bstr) memcpy(&sz12_true[2], bstr, SysStringByteLen(bstr) + sizeof(WCHAR));
SysFreeString(bstr);
res = VarBstrFromBool(VARIANT_FALSE, LANG_USER_DEFAULT, VAR_LOCALBOOL, &bstr);
- ok(res == S_OK && (lstrlenW(bstr) > 0),
- "Expected localized string for 'False'\n");
+ ok(res == S_OK && bstr[0], "Expected localized string for 'False'\n");
memcpy(sz12_false, sz12, sizeof(sz12));
if (bstr) memcpy(&sz12_false[2], bstr, SysStringByteLen(bstr) + sizeof(WCHAR));
SysFreeString(bstr);
--
1.9.3
From mstefani at redhat.de Thu Nov 13 03:08:59 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Thu, 13 Nov 2014 10:08:59 +0100
Subject: avifil32: Simplify the check for an empty string (PVS-Studio)
Message-ID: <20141113090859.GB726@redhat.com>
---
dlls/avifil32/avifile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c
index 5b65fd0..af0315d 100644
--- a/dlls/avifil32/avifile.c
+++ b/dlls/avifil32/avifile.c
@@ -1460,7 +1460,7 @@ static DWORD AVIFILE_ComputeMoviStart(IAVIFileImpl *This)
dwPos += ((pStream->cbFormat + 1) & ~1U);
if (pStream->lpHandlerData != NULL && pStream->cbHandlerData > 0)
dwPos += 2 * sizeof(DWORD) + ((pStream->cbHandlerData + 1) & ~1U);
- if (lstrlenW(pStream->sInfo.szName) > 0)
+ if (pStream->sInfo.szName[0])
dwPos += 2 * sizeof(DWORD) + ((lstrlenW(pStream->sInfo.szName) + 1) & ~1U);
}
@@ -2219,7 +2219,7 @@ static HRESULT AVIFILE_SaveFile(IAVIFileImpl *This)
}
/* ... an optional name for this stream ... */
- if (lstrlenW(pStream->sInfo.szName) > 0) {
+ if (pStream->sInfo.szName[0]) {
LPSTR str;
ck.ckid = ckidSTREAMNAME;
--
1.9.3
From huw at codeweavers.com Thu Nov 13 03:26:22 2014
From: huw at codeweavers.com (Huw Davies)
Date: Thu, 13 Nov 2014 09:26:22 +0000
Subject: winemac: WS_EX_DLGMODALFRAME shouldn't prevent the window being
resizeable.
Message-ID: <1415870782-28697-1-git-send-email-huw@codeweavers.com>
---
dlls/winemac.drv/window.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index e61a517..54bd56e 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -72,12 +72,12 @@ static void get_cocoa_window_features(struct macdrv_win_data *data,
if (ex_style & WS_EX_TOOLWINDOW) wf->utility = TRUE;
}
}
- if (ex_style & WS_EX_DLGMODALFRAME) wf->shadow = TRUE;
- else if (style & WS_THICKFRAME)
+ if (style & WS_THICKFRAME)
{
wf->shadow = TRUE;
if (!data->shaped) wf->resizable = TRUE;
}
+ else if (ex_style & WS_EX_DLGMODALFRAME) wf->shadow = TRUE;
else if ((style & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME) wf->shadow = TRUE;
}
--
1.8.0
From jacek at codeweavers.com Thu Nov 13 04:22:35 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Thu, 13 Nov 2014 11:22:35 +0100
Subject: mshtml: Properly handle errors in IHTMLStyleSheet::get_rules now
that Gecko part is fixed.
Message-ID: <5464866B.1000805@codeweavers.com>
---
dlls/mshtml/htmlstylesheet.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Properly-handle-errors-in-IHTMLStyleSheet-get_.diff
Type: text/x-patch
Size: 812 bytes
Desc: not available
URL:
From jacek at codeweavers.com Thu Nov 13 04:50:23 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Thu, 13 Nov 2014 11:50:23 +0100
Subject: wpcapi.idl: Added WPCFLAG_RESTRICTION declaration.
Message-ID: <54648CEF.4060301@codeweavers.com>
---
include/wpcapi.idl | 9 +++++++++
1 file changed, 9 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-wpcapi.idl-Added-WPCFLAG_RESTRICTION-declaration.diff
Type: text/x-patch
Size: 581 bytes
Desc: not available
URL:
From jacek at codeweavers.com Thu Nov 13 05:50:01 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Thu, 13 Nov 2014 12:50:01 +0100
Subject: mshtml: Fixed tests on recent IEs.
Message-ID: <54649AE9.3020605@codeweavers.com>
---
dlls/mshtml/tests/protocol.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Fixed-tests-on-recent-IEs.diff
Type: text/x-patch
Size: 2024 bytes
Desc: not available
URL:
From madewokherd at gmail.com Thu Nov 13 11:44:55 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Thu, 13 Nov 2014 11:44:55 -0600
Subject: [1/3] windowscodecs: Don't check undefined memory in tests on Wine.
Message-ID:
-------------- next part --------------
From 2a6769ce772f7798881ab5e884d558d37ab67edb Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Wed, 12 Nov 2014 15:52:38 -0600
Subject: [PATCH 1/3] windowscodecs: Don't check undefined memory in tests on
Wine.
---
dlls/windowscodecs/tests/metadata.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c
index e42b474..e9ab77c 100644
--- a/dlls/windowscodecs/tests/metadata.c
+++ b/dlls/windowscodecs/tests/metadata.c
@@ -907,7 +907,7 @@ static void test_metadata_png(void)
IWICMetadataReader *reader;
GUID containerformat;
HRESULT hr;
- UINT count;
+ UINT count=0xdeadbeef;
hr = CoCreateInstance(&CLSID_WICPngDecoder, NULL, CLSCTX_INPROC_SERVER,
&IID_IWICBitmapDecoder, (void**)&decoder);
--
2.1.0
From madewokherd at gmail.com Thu Nov 13 11:45:45 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Thu, 13 Nov 2014 11:45:45 -0600
Subject: [2/3] windowscodecs: Implement
ComponentFactory_CreateMetadataReaderFromContainer.
Message-ID:
-------------- next part --------------
From 709de407f5e5db5e04910b92882b92ce7843af21 Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Wed, 12 Nov 2014 15:51:09 -0600
Subject: [PATCH 2/3] windowscodecs: Implement
ComponentFactory_CreateMetadataReaderFromContainer.
---
dlls/windowscodecs/imgfactory.c | 101 +++++++++++++++++++++++++++++++++++-
dlls/windowscodecs/tests/metadata.c | 25 +++++----
2 files changed, 115 insertions(+), 11 deletions(-)
diff --git a/dlls/windowscodecs/imgfactory.c b/dlls/windowscodecs/imgfactory.c
index e7095dd..444f2e4 100644
--- a/dlls/windowscodecs/imgfactory.c
+++ b/dlls/windowscodecs/imgfactory.c
@@ -956,9 +956,106 @@ static HRESULT WINAPI ComponentFactory_CreateMetadataReader(IWICComponentFactory
static HRESULT WINAPI ComponentFactory_CreateMetadataReaderFromContainer(IWICComponentFactory *iface,
REFGUID format, const GUID *vendor, DWORD options, IStream *stream, IWICMetadataReader **reader)
{
- FIXME("%p,%s,%s,%x,%p,%p: stub\n", iface, debugstr_guid(format), debugstr_guid(vendor),
+ HRESULT hr;
+ IEnumUnknown *enumreaders;
+ IUnknown *unkreaderinfo;
+ IWICMetadataReaderInfo *readerinfo;
+ IWICPersistStream *wicpersiststream;
+ ULONG num_fetched;
+ GUID decoder_vendor;
+ BOOL matches;
+ LARGE_INTEGER zero;
+
+ TRACE("%p,%s,%s,%x,%p,%p\n", iface, debugstr_guid(format), debugstr_guid(vendor),
options, stream, reader);
- return E_NOTIMPL;
+
+ if (!format || !stream || !reader)
+ return E_INVALIDARG;
+
+ zero.QuadPart = 0;
+
+ hr = CreateComponentEnumerator(WICMetadataReader, WICComponentEnumerateDefault, &enumreaders);
+ if (FAILED(hr)) return hr;
+
+ *reader = NULL;
+
+start:
+ while (!*reader)
+ {
+ hr = IEnumUnknown_Next(enumreaders, 1, &unkreaderinfo, &num_fetched);
+
+ if (hr == S_OK)
+ {
+ hr = IUnknown_QueryInterface(unkreaderinfo, &IID_IWICMetadataReaderInfo, (void**)&readerinfo);
+
+ if (SUCCEEDED(hr))
+ {
+ if (vendor)
+ {
+ hr = IWICMetadataReaderInfo_GetVendorGUID(readerinfo, &decoder_vendor);
+
+ if (FAILED(hr) || !IsEqualIID(vendor, &decoder_vendor))
+ {
+ IWICMetadataReaderInfo_Release(readerinfo);
+ IUnknown_Release(unkreaderinfo);
+ continue;
+ }
+ }
+
+ hr = IWICMetadataReaderInfo_MatchesPattern(readerinfo, format, stream, &matches);
+
+ if (SUCCEEDED(hr) && matches)
+ {
+ hr = IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
+
+ if (SUCCEEDED(hr))
+ hr = IWICMetadataReaderInfo_CreateInstance(readerinfo, reader);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = IWICMetadataReader_QueryInterface(*reader, &IID_IWICPersistStream, (void**)&wicpersiststream);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = IWICPersistStream_LoadEx(wicpersiststream,
+ stream, vendor, options & WICPersistOptionsMask);
+
+ IWICPersistStream_Release(wicpersiststream);
+ }
+
+ if (FAILED(hr))
+ {
+ IWICMetadataReader_Release(*reader);
+ *reader = NULL;
+ }
+ }
+ }
+
+ IUnknown_Release(readerinfo);
+ }
+
+ IUnknown_Release(unkreaderinfo);
+ }
+ else
+ break;
+ }
+
+ if (!*reader && vendor)
+ {
+ vendor = NULL;
+ IEnumUnknown_Reset(enumreaders);
+ goto start;
+ }
+
+ IEnumUnknown_Release(enumreaders);
+
+ if (!*reader && !(options & WICMetadataCreationFailUnknown))
+ FIXME("create unknown metadata reader\n");
+
+ if (*reader)
+ return S_OK;
+ else
+ return WINCODEC_ERR_COMPONENTNOTFOUND;
}
static HRESULT WINAPI ComponentFactory_CreateMetadataWriter(IWICComponentFactory *iface,
diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c
index e9ab77c..2dc6049 100644
--- a/dlls/windowscodecs/tests/metadata.c
+++ b/dlls/windowscodecs/tests/metadata.c
@@ -841,17 +841,24 @@ static void test_create_reader(void)
stream = create_stream(metadata_tEXt, sizeof(metadata_tEXt));
hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
+ NULL, NULL, WICPersistOptionsDefault,
+ stream, &reader);
+ ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
+
+ hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
+ &GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault,
+ NULL, &reader);
+ ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
+
+ hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
+ &GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault,
+ stream, NULL);
+ ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
+
+ hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
&GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault,
stream, &reader);
-todo_wine
ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
- /* NOTE: removed once Wine is fixed */
- if (FAILED(hr))
- {
- IStream_Release(stream);
- IWICComponentFactory_Release(factory);
- return;
- }
if (SUCCEEDED(hr))
{
@@ -869,7 +876,7 @@ todo_wine
hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
&GUID_ContainerFormatWmp, NULL, WICPersistOptionsDefault,
stream, &reader);
- ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
+ todo_wine ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
--
2.1.0
From madewokherd at gmail.com Thu Nov 13 11:46:12 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Thu, 13 Nov 2014 11:46:12 -0600
Subject: [3/3] windowscodecs: Add fallback to unknown metadata reader.
Message-ID:
-------------- next part --------------
From 6c4b1e3d938bc3d0648041d8bbc468e14ec9c373 Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Wed, 12 Nov 2014 16:00:55 -0600
Subject: [PATCH 3/3] windowscodecs: Add fallback to unknown metadata reader.
---
dlls/windowscodecs/imgfactory.c | 25 ++++++++++++++++++++++++-
dlls/windowscodecs/tests/metadata.c | 2 +-
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/dlls/windowscodecs/imgfactory.c b/dlls/windowscodecs/imgfactory.c
index 444f2e4..42b4e59 100644
--- a/dlls/windowscodecs/imgfactory.c
+++ b/dlls/windowscodecs/imgfactory.c
@@ -1050,7 +1050,30 @@ start:
IEnumUnknown_Release(enumreaders);
if (!*reader && !(options & WICMetadataCreationFailUnknown))
- FIXME("create unknown metadata reader\n");
+ {
+ hr = IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
+
+ if (SUCCEEDED(hr))
+ hr = UnknownMetadataReader_CreateInstance(&IID_IWICMetadataReader, (void**)reader);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = IWICMetadataReader_QueryInterface(*reader, &IID_IWICPersistStream, (void**)&wicpersiststream);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = IWICPersistStream_LoadEx(wicpersiststream, stream, NULL, options & WICPersistOptionsMask);
+
+ IWICPersistStream_Release(wicpersiststream);
+ }
+
+ if (FAILED(hr))
+ {
+ IWICMetadataReader_Release(*reader);
+ *reader = NULL;
+ }
+ }
+ }
if (*reader)
return S_OK;
diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c
index 2dc6049..fa9d701 100644
--- a/dlls/windowscodecs/tests/metadata.c
+++ b/dlls/windowscodecs/tests/metadata.c
@@ -876,7 +876,7 @@ static void test_create_reader(void)
hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
&GUID_ContainerFormatWmp, NULL, WICPersistOptionsDefault,
stream, &reader);
- todo_wine ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
+ ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
{
--
2.1.0
From nerv at dawncrow.de Thu Nov 13 13:19:06 2014
From: nerv at dawncrow.de (=?ISO-8859-15?Q?Andr=E9_Hentschel?=)
Date: Thu, 13 Nov 2014 20:19:06 +0100
Subject: server: Get rid of "defined but not used" warning caused by a
superfluous helper function
Message-ID: <5465042A.4090808@dawncrow.de>
---
server/ptrace.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-server-Get-rid-of-defined-but-not-used-warning-caused-.txt
Type: text/x-patch
Size: 2273 bytes
Desc: not available
URL:
From stefan at codeweavers.com Thu Nov 13 13:39:25 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 13 Nov 2014 20:39:25 +0100
Subject: [PATCH 1/7] wined3d: Minimize device windows on focus loss (v3).
Message-ID: <1415907571-19662-1-git-send-email-stefan@codeweavers.com>
v3: Check for D3DCREATE_NOWINDOWCHANGES.
v2: Move to wined3d. The different behavior in d3d9ex was due to a
hidden window and not a difference how d3d9ex handles focus loss. See
patch 7.
Another patch will add an action (resize the window to match the
backbuffer size) on window activation. For this reason the swapchain
helper function is called on both activation and deactivation.
---
dlls/wined3d/device.c | 5 +++++
dlls/wined3d/swapchain.c | 6 ++++++
dlls/wined3d/wined3d_private.h | 1 +
3 files changed, 12 insertions(+)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index ee3636e..0de444b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4983,6 +4983,11 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
}
else if (message == WM_ACTIVATEAPP)
{
+ UINT i;
+
+ for (i = 0; i < device->swapchain_count; i++)
+ wined3d_swapchain_activate(device->swapchains[i], wparam);
+
device->device_parent->ops->activate(device->device_parent, wparam);
}
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 25e2107..4c0948f 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -1175,3 +1175,9 @@ void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain)
wined3d_resource_update_draw_binding(&swapchain->back_buffers[i]->resource);
}
}
+
+void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate)
+{
+ if (!activate && !(swapchain->device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES))
+ ShowWindow(swapchain->device_window, SW_MINIMIZE);
+}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0f302c4..5f90e9a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2701,6 +2701,7 @@ struct wined3d_swapchain
void x11_copy_to_screen(const struct wined3d_swapchain *swapchain, const RECT *rect) DECLSPEC_HIDDEN;
+void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate) DECLSPEC_HIDDEN;
struct wined3d_context *swapchain_get_context(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
void swapchain_destroy_contexts(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
HDC swapchain_get_backup_dc(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
--
2.0.4
From stefan at codeweavers.com Thu Nov 13 13:39:26 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 13 Nov 2014 20:39:26 +0100
Subject: [PATCH 2/7] d3d9/tests: Test messages on focus loss.
Message-ID: <1415907571-19662-2-git-send-email-stefan@codeweavers.com>
Resolution changing behavior will be tested in a separate patch.
---
dlls/d3d9/tests/d3d9ex.c | 277 ++++++++++++++++++++++++++++----------------
dlls/d3d9/tests/device.c | 293 +++++++++++++++++++++++++++++++----------------
2 files changed, 375 insertions(+), 195 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index bbb95b0..424d2cc 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -1702,6 +1702,8 @@ struct message
{
UINT message;
enum message_window window;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
};
static const struct message *expect_messages;
@@ -1743,7 +1745,14 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
};
if (hwnd == w && expect_messages->message == message)
+ {
+ if (expect_messages->check_wparam)
+ ok(wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
}
return DefWindowProcA(hwnd, message, wparam, lparam);
@@ -1795,13 +1804,52 @@ static void test_wndproc(void)
ULONG ref;
DWORD res, tid;
HWND tmp;
+ unsigned int i;
+ HRESULT hr;
- static const struct message messages[] =
+ static const struct message create_messages[] =
+ {
+ {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0},
+ /* Do not test wparam here. If device creation succeeds,
+ * wparam is WA_ACTIVE. If device creation fails (testbot)
+ * wparam is set to WA_INACTIVE on some Windows versions. */
+ {WM_ACTIVATE, FOCUS_WINDOW, FALSE, 0},
+ {WM_SETFOCUS, FOCUS_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE},
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ /* Windows sends WM_ACTIVATE to the device window, indicating that
+ * SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
+ * the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
+ * leaves the device window active, breaking re-activation in the
+ * lost device test.
+ * {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
+ {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ /* WM_ACTIVATEAPP is sent to the device window too, but the order is
+ * not deterministic. It may be sent after the focus window handling
+ * or before. */
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages_nowc[] =
{
- {WM_WINDOWPOSCHANGING, FOCUS_WINDOW},
- {WM_ACTIVATE, FOCUS_WINDOW},
- {WM_SETFOCUS, FOCUS_WINDOW},
- {0, 0},
+ {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ {0, 0, FALSE, 0},
+ };
+ static const struct
+ {
+ DWORD create_flags;
+ const struct message *focus_loss_messages;
+ }
+ tests[] =
+ {
+ {0, focus_loss_messages},
+ {CREATE_DEVICE_NOWINDOWCHANGES, focus_loss_messages_nowc},
};
wc.lpfnWndProc = test_proc;
@@ -1813,121 +1861,156 @@ static void test_wndproc(void)
thread_params.test_finished = CreateEventA(NULL, FALSE, FALSE, NULL);
ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
- focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
- ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
-
- res = WaitForSingleObject(thread_params.window_created, INFINITE);
- ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
-
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
-
- trace("device_window %p, focus_window %p, dummy_window %p.\n",
- device_window, focus_window, thread_params.dummy_window);
-
- tmp = GetFocus();
- ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
- if (thread_params.running_in_foreground)
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
{
- tmp = GetForegroundWindow();
- ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
- thread_params.dummy_window, tmp);
- }
- else
- skip("Not running in foreground, skip foreground window test\n");
+ focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
+ ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
- flush_events();
+ res = WaitForSingleObject(thread_params.window_created, INFINITE);
+ ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
- expect_messages = messages;
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
- device_desc.device_window = device_window;
- device_desc.width = registry_mode.dmPelsWidth;
- device_desc.height = registry_mode.dmPelsHeight;
- device_desc.flags = CREATE_DEVICE_FULLSCREEN;
- if (!(device = create_device(focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ trace("device_window %p, focus_window %p, dummy_window %p.\n",
+ device_window, focus_window, thread_params.dummy_window);
- ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n",
- expect_messages->message, expect_messages->window);
- expect_messages = NULL;
-
- if (0) /* Disabled until we can make this work in a reliable way on Wine. */
- {
tmp = GetFocus();
- ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
- tmp = GetForegroundWindow();
- ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
- }
- SetForegroundWindow(focus_window);
- flush_events();
+ ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
+ if (thread_params.running_in_foreground)
+ {
+ tmp = GetForegroundWindow();
+ ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
+ thread_params.dummy_window, tmp);
+ }
+ else
+ skip("Not running in foreground, skip foreground window test\n");
- filter_messages = focus_window;
+ flush_events();
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ expect_messages = create_messages;
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ device_desc.device_window = device_window;
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN | tests[i].create_flags;
+ if (!(device = create_device(focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ref = IDirect3DDevice9Ex_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ if (0) /* Disabled until we can make this work in a reliable way on Wine. */
+ {
+ tmp = GetFocus();
+ ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
+ tmp = GetForegroundWindow();
+ ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
+ }
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n",
+ (LONG_PTR)test_proc);
+
+ expect_messages = tests[i].focus_loss_messages;
+ /* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
+ * manually changing the focus. It generates the same messages, but the task
+ * bar still shows the previous foreground window as active, and the window has
+ * an inactive titlebar if reactivated with SetForegroundWindow. Reactivating
+ * the device is difficult, see below. */
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
+ tmp = GetFocus();
+ ok(tmp != device_window, "The device window is active, i=%u.\n", i);
+ ok(tmp != focus_window, "The focus window is active, i=%u.\n", i);
+
+ hr = IDirect3DDevice9Ex_CheckDeviceState(device, device_window);
+ ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x, i=%u.\n", hr, i);
+
+ /* In d3d9ex the device and focus windows have to be minimized and restored,
+ * otherwise native does not notice that focus has been restored. This is
+ * independent of D3DCREATE_NOWINDOWCHANGES. */
+ ShowWindow(device_window, SW_MINIMIZE);
+ ShowWindow(device_window, SW_RESTORE);
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ /* Calling Reset is not necessary in d3d9ex. */
+ hr = IDirect3DDevice9Ex_CheckDeviceState(device, device_window);
+ ok(hr == S_OK, "Got unexpected hr %#x, i=%u.\n", hr, i);
+
+ filter_messages = focus_window;
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- device_desc.device_window = focus_window;
- if (!(device = create_device(focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, proc, i);
- ref = IDirect3DDevice9Ex_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ device_desc.device_window = focus_window;
+ if (!(device = create_device(focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- device_desc.device_window = device_window;
- if (!(device = create_device(focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ device_desc.device_window = device_window;
+ if (!(device = create_device(focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ref = IDirect3DDevice9Ex_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n",
+ (LONG_PTR)test_proc);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)DefWindowProcA, proc);
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)DefWindowProcA, proc);
done:
- filter_messages = NULL;
+ filter_messages = NULL;
+ DestroyWindow(device_window);
+ DestroyWindow(focus_window);
+ SetEvent(thread_params.test_finished);
+ WaitForSingleObject(thread, INFINITE);
+ CloseHandle(thread);
+ }
- SetEvent(thread_params.test_finished);
- WaitForSingleObject(thread, INFINITE);
CloseHandle(thread_params.test_finished);
CloseHandle(thread_params.window_created);
- CloseHandle(thread);
- DestroyWindow(device_window);
- DestroyWindow(focus_window);
UnregisterClassA("d3d9_test_wndproc_wc", GetModuleHandleA(NULL));
}
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 1a5008a..aeda123 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -3091,6 +3091,8 @@ struct message
{
UINT message;
enum message_window window;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
};
static const struct message *expect_messages;
@@ -3131,7 +3133,15 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
break;
};
- if (hwnd == w && expect_messages->message == message) ++expect_messages;
+ if (hwnd == w && expect_messages->message == message)
+ {
+ if (expect_messages->check_wparam)
+ ok(wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
+ ++expect_messages;
+ }
}
return DefWindowProcA(hwnd, message, wparam, lparam);
@@ -3182,13 +3192,52 @@ static void test_wndproc(void)
ULONG ref;
DWORD res, tid;
HWND tmp;
+ unsigned int i;
+ HRESULT hr;
- static const struct message messages[] =
+ static const struct message create_messages[] =
+ {
+ {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0},
+ /* Do not test wparam here. If device creation succeeds,
+ * wparam is WA_ACTIVE. If device creation fails (testbot)
+ * wparam is set to WA_INACTIVE on some Windows versions. */
+ {WM_ACTIVATE, FOCUS_WINDOW, FALSE, 0},
+ {WM_SETFOCUS, FOCUS_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE},
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ /* Windows sends WM_ACTIVATE to the device window, indicating that
+ * SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
+ * the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
+ * leaves the device window active, breaking re-activation in the
+ * lost device test.
+ * {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
+ {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ /* WM_ACTIVATEAPP is sent to the device window too, but the order is
+ * not deterministic. It may be sent after the focus window handling
+ * or before. */
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages_nowc[] =
{
- {WM_WINDOWPOSCHANGING, FOCUS_WINDOW},
- {WM_ACTIVATE, FOCUS_WINDOW},
- {WM_SETFOCUS, FOCUS_WINDOW},
- {0, 0},
+ {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ {0, 0, FALSE, 0},
+ };
+ static const struct
+ {
+ DWORD create_flags;
+ const struct message *focus_loss_messages;
+ }
+ tests[] =
+ {
+ {0, focus_loss_messages},
+ {CREATE_DEVICE_NOWINDOWCHANGES, focus_loss_messages_nowc},
};
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
@@ -3203,122 +3252,168 @@ static void test_wndproc(void)
thread_params.test_finished = CreateEventA(NULL, FALSE, FALSE, NULL);
ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
- focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
- ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ {
+ focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
+ ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
- res = WaitForSingleObject(thread_params.window_created, INFINITE);
- ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+ res = WaitForSingleObject(thread_params.window_created, INFINITE);
+ ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
- trace("device_window %p, focus_window %p, dummy_window %p.\n",
- device_window, focus_window, thread_params.dummy_window);
+ trace("device_window %p, focus_window %p, dummy_window %p.\n",
+ device_window, focus_window, thread_params.dummy_window);
- tmp = GetFocus();
- ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
- if (thread_params.running_in_foreground)
- {
- tmp = GetForegroundWindow();
- ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
- thread_params.dummy_window, tmp);
- }
- else
- skip("Not running in foreground, skip foreground window test\n");
+ tmp = GetFocus();
+ ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
+ if (thread_params.running_in_foreground)
+ {
+ tmp = GetForegroundWindow();
+ ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
+ thread_params.dummy_window, tmp);
+ }
+ else
+ skip("Not running in foreground, skip foreground window test\n");
- flush_events();
+ flush_events();
- expect_messages = messages;
+ expect_messages = create_messages;
- device_desc.device_window = device_window;
- device_desc.width = registry_mode.dmPelsWidth;
- device_desc.height = registry_mode.dmPelsHeight;
- device_desc.flags = CREATE_DEVICE_FULLSCREEN;
- if (!(device = create_device(d3d9, focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ device_desc.device_window = device_window;
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN | tests[i].create_flags;
+ if (!(device = create_device(d3d9, focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n",
- expect_messages->message, expect_messages->window);
- expect_messages = NULL;
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
- if (0) /* Disabled until we can make this work in a reliable way on Wine. */
- {
+ if (0) /* Disabled until we can make this work in a reliable way on Wine. */
+ {
+ tmp = GetFocus();
+ ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
+ tmp = GetForegroundWindow();
+ ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
+ }
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, proc, i);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, i);
+
+ expect_messages = tests[i].focus_loss_messages;
+ /* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
+ * manually changing the focus. It generates the same messages, but the task
+ * bar still shows the previous foreground window as active, and the window has
+ * an inactive titlebar if reactivated with SetForegroundWindow. Reactivating
+ * the device is difficult, see below. */
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
tmp = GetFocus();
- ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
- tmp = GetForegroundWindow();
- ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
- }
- SetForegroundWindow(focus_window);
- flush_events();
+ ok(tmp != device_window, "The device window is active, i=%u.\n", i);
+ ok(tmp != focus_window, "The focus window is active, i=%u.\n", i);
- filter_messages = focus_window;
+ hr = IDirect3DDevice9_TestCooperativeLevel(device);
+ ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ /* This is needed on native with D3DCREATE_NOWINDOWCHANGES, and it needs to be
+ * done before the focus window is restored. This makes sense to some extent
+ * because minimizing the window on focus loss is the application's job if this
+ * flag is set. */
+ if (tests[i].create_flags & CREATE_DEVICE_NOWINDOWCHANGES)
+ {
+ ShowWindow(device_window, SW_MINIMIZE);
+ ShowWindow(device_window, SW_RESTORE);
+ }
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ /* I have to minimize and restore the focus window, otherwise native d3d9 fails
+ * device::reset with D3DERR_DEVICELOST. This does not happen when the window
+ * restore is triggered by the user. */
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ SetForegroundWindow(focus_window);
+ flush_events();
- ref = IDirect3DDevice9_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ hr = IDirect3DDevice9_TestCooperativeLevel(device);
+ ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ /* Releasing a device in lost state breaks follow-up tests on native. */
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x, i=%u.\n", hr, i);
- device_desc.device_window = focus_window;
- if (!(device = create_device(d3d9, focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ filter_messages = focus_window;
- ref = IDirect3DDevice9_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ ref = IDirect3DDevice9_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- device_desc.device_window = device_window;
- if (!(device = create_device(d3d9, focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, proc, i);
- proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ device_desc.device_window = focus_window;
+ if (!(device = create_device(d3d9, focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ref = IDirect3DDevice9_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ ref = IDirect3DDevice9_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)DefWindowProcA, proc);
+ device_desc.device_window = device_window;
+ if (!(device = create_device(d3d9, focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
+
+ proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, i);
+
+ ref = IDirect3DDevice9_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)DefWindowProcA, proc, i);
done:
- filter_messages = NULL;
- IDirect3D9_Release(d3d9);
+ filter_messages = NULL;
+ DestroyWindow(device_window);
+ DestroyWindow(focus_window);
+ SetEvent(thread_params.test_finished);
+ WaitForSingleObject(thread, INFINITE);
+ CloseHandle(thread);
+ }
- SetEvent(thread_params.test_finished);
- WaitForSingleObject(thread, INFINITE);
+ IDirect3D9_Release(d3d9);
CloseHandle(thread_params.test_finished);
CloseHandle(thread_params.window_created);
- CloseHandle(thread);
-
- DestroyWindow(device_window);
- DestroyWindow(focus_window);
UnregisterClassA("d3d9_test_wndproc_wc", GetModuleHandleA(NULL));
}
@@ -3540,8 +3635,10 @@ static void test_reset_fullscreen(void)
struct device_desc device_desc;
static const struct message messages[] =
{
- {WM_ACTIVATEAPP, FOCUS_WINDOW},
- {0, 0},
+ /* Windows usually sends wparam = TRUE, except on the testbot,
+ * where it randomly sends FALSE. Ignore it. */
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
};
d3d = Direct3DCreate9(D3D_SDK_VERSION);
--
2.0.4
From stefan at codeweavers.com Thu Nov 13 13:39:27 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 13 Nov 2014 20:39:27 +0100
Subject: [PATCH 3/7] d3d9/tests: Test style changes on focus loss (v2).
Message-ID: <1415907571-19662-3-git-send-email-stefan@codeweavers.com>
Version 2: Fix a rebase bug that broke the tests on Windows.
I will add message tests for the hidden window behavior in a separate
test.
I don't particularly care about the behavior on the second d3d9ex device
creation. This part is in the test to explain why I am destroying
the device and the windows. d3d9ex does the same when calling reset to
switch to fullscreen mode a second time.
---
dlls/d3d9/tests/d3d9ex.c | 85 +++++++++++++++++++++++++++++++++++++++++++++---
dlls/d3d9/tests/device.c | 40 +++++++++++++++++++++--
2 files changed, 117 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index 424d2cc..988d2dc 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -2218,24 +2218,27 @@ done:
static void test_window_style(void)
{
RECT focus_rect, device_rect, fullscreen_rect, r, r2;
- LONG device_style, device_exstyle;
+ LONG device_style, device_exstyle, expected_style;
LONG focus_style, focus_exstyle;
struct device_desc device_desc;
LONG style;
IDirect3DDevice9Ex *device;
HRESULT hr;
ULONG ref;
+ BOOL ret;
static const struct
{
LONG style_flags;
DWORD device_flags;
+ LONG focus_loss_style;
+ LONG create2_style, create2_exstyle;
}
tests[] =
{
- {0, 0},
- {WS_VISIBLE, 0},
- {0, CREATE_DEVICE_NOWINDOWCHANGES},
- {WS_VISIBLE, CREATE_DEVICE_NOWINDOWCHANGES},
+ {0, 0, 0, WS_VISIBLE, WS_EX_TOPMOST},
+ {WS_VISIBLE, 0, WS_MINIMIZE, WS_VISIBLE, WS_EX_TOPMOST},
+ {0, CREATE_DEVICE_NOWINDOWCHANGES, 0, 0, 0},
+ {WS_VISIBLE, CREATE_DEVICE_NOWINDOWCHANGES, 0, 0, 0},
};
unsigned int i;
@@ -2323,6 +2326,78 @@ static void test_window_style(void)
ref = IDirect3DDevice9Ex_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ if (device_style & WS_VISIBLE)
+ ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ device_style, style, i);
+ else
+ todo_wine ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ device_style, style, i);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n",
+ device_exstyle, style, i);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+ focus_style, style, i);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+ focus_exstyle, style, i);
+
+ /* The second time a device is created on the window the window becomes visible and
+ * topmost if D3DCREATE_NOWINDOWCHANGES is not set. */
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN | tests[i].device_flags;
+ device = create_device(focus_window, &device_desc);
+ ok(!!device, "Failed to create a D3D device.\n");
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | tests[i].create2_style;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ expected_style, style, i);
+ expected_style = device_exstyle | tests[i].create2_exstyle;
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x, i=%u.\n",
+ expected_style, style, i);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+ focus_style, style, i);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+ focus_exstyle, style, i);
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+ DestroyWindow(device_window);
+ DestroyWindow(focus_window);
+ focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | tests[i].style_flags,
+ 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | tests[i].style_flags,
+ 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+
+ device_desc.device_window = device_window;
+ device = create_device(focus_window, &device_desc);
+ ok(!!device, "Failed to create a D3D device.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | tests[i].focus_loss_style;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ expected_style, style, i);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n",
+ device_exstyle, style, i);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+ focus_style, style, i);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+ focus_exstyle, style, i);
+
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
DestroyWindow(device_window);
DestroyWindow(focus_window);
}
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index aeda123..d98221a 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -3787,15 +3787,16 @@ static void test_window_style(void)
IDirect3D9 *d3d9;
HRESULT hr;
ULONG ref;
+ BOOL ret;
static const struct
{
DWORD device_flags;
- LONG style, exstyle;
+ LONG style, focus_loss_style, exstyle;
}
tests[] =
{
- {0, WS_VISIBLE, WS_EX_TOPMOST},
- {CREATE_DEVICE_NOWINDOWCHANGES, 0},
+ {0, WS_VISIBLE, WS_MINIMIZE, WS_EX_TOPMOST},
+ {CREATE_DEVICE_NOWINDOWCHANGES, 0, 0, 0},
};
unsigned int i;
@@ -3890,6 +3891,39 @@ static void test_window_style(void)
ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
focus_exstyle, style, i);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | tests[i].focus_loss_style | tests[i].style;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x.\n",
+ expected_style, style);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ expected_style = device_exstyle | tests[i].exstyle;
+ todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x.\n",
+ expected_style, style);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x.\n",
+ focus_style, style);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
+ focus_exstyle, style);
+
+ /* In d3d8 follow-up tests fail on native if the device is destroyed while
+ * lost. This doesn't happen in d3d9 on my test machine but it still seems
+ * like a good idea to reset it first. */
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ ret = SetForegroundWindow(focus_window);
+ ok(ret, "Failed to set foreground window.\n");
+ flush_events();
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
ref = IDirect3DDevice9_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Thu Nov 13 13:39:28 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 13 Nov 2014 20:39:28 +0100
Subject: [PATCH 4/7] d3d8/tests: Test messages on focus loss.
Message-ID: <1415907571-19662-4-git-send-email-stefan@codeweavers.com>
This patch and the next one introduce new errors on native when the
tests are run without focus (i.e., Windows 8 testbot). If desired I can
add checks for this condition and skip the tests.
---
dlls/d3d8/tests/device.c | 92 +++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 79 insertions(+), 13 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index bf7f181..72fce12 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -2136,6 +2136,8 @@ struct message
{
UINT message;
enum message_window window;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
};
static const struct message *expect_messages;
@@ -2176,7 +2178,15 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
break;
};
- if (hwnd == w && expect_messages->message == message) ++expect_messages;
+ if (hwnd == w && expect_messages->message == message)
+ {
+ if (expect_messages->check_wparam)
+ ok(wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
+ ++expect_messages;
+ }
}
return DefWindowProcA(hwnd, message, wparam, lparam);
@@ -2227,16 +2237,38 @@ static void test_wndproc(void)
ULONG ref;
DWORD res, tid;
HWND tmp;
+ HRESULT hr;
- static const struct message messages[] =
- {
- {WM_WINDOWPOSCHANGING, FOCUS_WINDOW},
- {WM_ACTIVATE, FOCUS_WINDOW},
- {WM_SETFOCUS, FOCUS_WINDOW},
- {WM_WINDOWPOSCHANGING, DEVICE_WINDOW},
- {WM_MOVE, DEVICE_WINDOW},
- {WM_SIZE, DEVICE_WINDOW},
- {0, 0},
+ static const struct message create_messages[] =
+ {
+ {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0},
+ /* Do not test wparam here. If device creation succeeds,
+ * wparam is WA_ACTIVE. If device creation fails (testbot)
+ * wparam is set to WA_INACTIVE on some Windows versions. */
+ {WM_ACTIVATE, FOCUS_WINDOW, FALSE, 0},
+ {WM_SETFOCUS, FOCUS_WINDOW, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ {WM_MOVE, DEVICE_WINDOW, FALSE, 0},
+ {WM_SIZE, DEVICE_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE},
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ /* Windows sends WM_ACTIVATE to the device window, indicating that
+ * SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
+ * the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
+ * leaves the device window active, breaking re-activation in the
+ * lost device test.
+ * {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
+ {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ /* WM_ACTIVATEAPP is sent to the device window too, but the order is
+ * not deterministic. It may be sent after the focus window handling
+ * or before. */
+ {0, 0, FALSE, 0},
};
d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
@@ -2286,7 +2318,7 @@ static void test_wndproc(void)
flush_events();
- expect_messages = messages;
+ expect_messages = create_messages;
device_desc.device_window = device_window;
device_desc.width = registry_mode.dmPelsWidth;
@@ -2312,8 +2344,6 @@ static void test_wndproc(void)
SetForegroundWindow(focus_window);
flush_events();
- filter_messages = focus_window;
-
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
@@ -2321,6 +2351,42 @@ static void test_wndproc(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ expect_messages = focus_loss_messages;
+ /* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
+ * manually changing the focus. It generates the same messages, but the task
+ * bar still shows the previous foreground window as active, and the window has
+ * an inactive titlebar if reactivated with SetForegroundWindow. Reactivating
+ * the device is difficult, see below. */
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n",
+ expect_messages->message, expect_messages->window);
+ expect_messages = NULL;
+ tmp = GetFocus();
+ ok(tmp != device_window, "The device window is active.\n");
+ ok(tmp != focus_window, "The focus window is active.\n");
+
+ /* The Present call is necessary to make native realize the device is lost. */
+ hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
+ ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice8_TestCooperativeLevel(device);
+ ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+
+ /* I have to minimize and restore the focus window, otherwise native d3d9 fails
+ * device::reset with D3DERR_DEVICELOST. This does not happen when the window
+ * restore is triggered by the user. */
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ hr = IDirect3DDevice8_TestCooperativeLevel(device);
+ ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
+
+ /* Releasing a device in lost state breaks follow-up tests on native. */
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
+ filter_messages = focus_window;
ref = IDirect3DDevice8_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Thu Nov 13 13:39:29 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 13 Nov 2014 20:39:29 +0100
Subject: [PATCH 5/7] d3d8/tests: Test style changes on focus loss.
Message-ID: <1415907571-19662-5-git-send-email-stefan@codeweavers.com>
---
dlls/d3d8/tests/device.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 72fce12..c8995fa 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -2857,6 +2857,7 @@ static void test_window_style(void)
IDirect3D8 *d3d8;
HRESULT hr;
ULONG ref;
+ BOOL ret;
focus_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
@@ -2930,6 +2931,36 @@ static void test_window_style(void)
ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
focus_exstyle, style);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | WS_MINIMIZE | WS_VISIBLE;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x.\n",
+ expected_style, style);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ expected_style = device_exstyle | WS_EX_TOPMOST;
+ todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x.\n",
+ expected_style, style);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x.\n",
+ focus_style, style);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
+ focus_exstyle, style);
+
+ /* Follow-up tests fail on native if the device is destroyed while lost. */
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ ret = SetForegroundWindow(focus_window);
+ ok(ret, "Failed to set foreground window.\n");
+ flush_events();
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
ref = IDirect3DDevice8_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Thu Nov 13 13:39:30 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 13 Nov 2014 20:39:30 +0100
Subject: [PATCH 6/7] ddraw/tests: Test messages on focus loss (v2).
Message-ID: <1415907571-19662-6-git-send-email-stefan@codeweavers.com>
Version 2: Do not restore the primary surface after restoring focus.
This works around a crash in GetSurfaceDesc on the Windows 8 testbot.
GetSurfaceDesc after a mode change seems to be unstable on the testbot
and/or Windows 8 in general. I don't have a real Win8 machine to
compare. If this causes more issues in further changes to the test we
can move the surface size checks after mode changes into a separate
test to make it easier to maintain a call sequence that doesn't hit the
bug.
---
dlls/ddraw/tests/ddraw1.c | 99 +++++++++++++++++++++++++++++++-------------
dlls/ddraw/tests/ddraw2.c | 103 ++++++++++++++++++++++++++++++++--------------
dlls/ddraw/tests/ddraw4.c | 103 ++++++++++++++++++++++++++++++++--------------
dlls/ddraw/tests/ddraw7.c | 103 ++++++++++++++++++++++++++++++++--------------
4 files changed, 286 insertions(+), 122 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 0ae204c..98d56d4 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -428,12 +428,26 @@ static void destroy_material(IDirect3DMaterial *material)
IDirect3DMaterial_Release(material);
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -1878,15 +1892,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -1906,7 +1920,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2147,19 +2161,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2234,7 +2263,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2280,7 +2309,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2291,6 +2320,18 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ /* Normally the primary should be restored here. Unfortunately this causes the
+ * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
+ * testbot. Another Restore call would presumably avoid the crash, but it also moots
+ * the point of the GetSurfaceDesc call. */
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2299,7 +2340,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2385,7 +2426,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2409,7 +2450,7 @@ static void test_coop_level_mode_set(void)
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2453,7 +2494,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2548,7 +2589,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2565,7 +2606,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2609,7 +2650,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 334d89e..537de81 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -361,12 +361,26 @@ static void destroy_material(IDirect3DMaterial2 *material)
IDirect3DMaterial2_Release(material);
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -2066,15 +2080,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -2094,7 +2108,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2346,19 +2360,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2438,7 +2467,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2484,7 +2513,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2495,6 +2524,18 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ /* Normally the primary should be restored here. Unfortunately this causes the
+ * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
+ * testbot. Another Restore call would presumably avoid the crash, but it also moots
+ * the point of the GetSurfaceDesc call. */
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2503,7 +2544,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2589,7 +2630,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2613,7 +2654,7 @@ static void test_coop_level_mode_set(void)
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2657,7 +2698,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2752,7 +2793,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2769,7 +2810,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2813,7 +2854,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2874,7 +2915,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2945,7 +2986,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index ab03f39..80e155e 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -391,12 +391,26 @@ static void destroy_material(IDirect3DMaterial3 *material)
IDirect3DMaterial3_Release(material);
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -2253,15 +2267,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -2281,7 +2295,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2533,19 +2547,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2625,7 +2654,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2671,7 +2700,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2682,6 +2711,18 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ /* Normally the primary should be restored here. Unfortunately this causes the
+ * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
+ * testbot. Another Restore call would presumably avoid the crash, but it also moots
+ * the point of the GetSurfaceDesc call. */
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2690,7 +2731,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2776,7 +2817,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2793,7 +2834,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2837,7 +2878,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2932,7 +2973,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2949,7 +2990,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2993,7 +3034,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -3054,7 +3095,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -3125,7 +3166,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index f505c65..88ce136 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -324,12 +324,26 @@ static IDirect3DDevice7 *create_device(HWND window, DWORD coop_level)
return device;
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -1931,15 +1945,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -1959,7 +1973,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2210,19 +2224,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2302,7 +2331,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2348,7 +2377,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2359,6 +2388,18 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ /* Normally the primary should be restored here. Unfortunately this causes the
+ * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
+ * testbot. Another Restore call would presumably avoid the crash, but it also moots
+ * the point of the GetSurfaceDesc call. */
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2367,7 +2408,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2453,7 +2494,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2470,7 +2511,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2514,7 +2555,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2609,7 +2650,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2626,7 +2667,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2670,7 +2711,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2731,7 +2772,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2802,7 +2843,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
--
2.0.4
From stefan at codeweavers.com Thu Nov 13 13:39:31 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Thu, 13 Nov 2014 20:39:31 +0100
Subject: [PATCH 7/7] ddraw/tests: Test focus loss style changes.
Message-ID: <1415907571-19662-7-git-send-email-stefan@codeweavers.com>
---
dlls/ddraw/tests/ddraw1.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw2.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw4.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw7.c | 37 ++++++++++++++++++++++++++++++++++++-
4 files changed, 144 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 98d56d4..5b775ec 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -2009,12 +2009,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2040,6 +2041,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2048,6 +2063,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 537de81..f1bd1da 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -2197,12 +2197,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw2 *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2228,6 +2229,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2236,6 +2251,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw2_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 80e155e..fa42817 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -2384,12 +2384,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw4 *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2415,6 +2416,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2423,6 +2438,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw4_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 88ce136..a0a6aef 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -2062,12 +2062,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw7 *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2093,6 +2094,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2101,6 +2116,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw7_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
--
2.0.4
From austinenglish at gmail.com Thu Nov 13 15:30:50 2014
From: austinenglish at gmail.com (Austin English)
Date: Thu, 13 Nov 2014 15:30:50 -0600
Subject: include/ddk: add csq.h
Message-ID:
--
-Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
commit 3d445a5fd56ee5f92b99351266efc854b141f0a5
Author: Austin English
Date: Thu Nov 13 13:29:39 2014 -0800
include/ddk: add csq.h
diff --git a/include/ddk/csq.h b/include/ddk/csq.h
new file mode 100644
index 0000000..429ed40
--- /dev/null
+++ b/include/ddk/csq.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) the Wine project
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "ddk/ntddk.h"
+
+#ifndef __WINE_CSQ_H
+#define __WINE_CSQ_H
+
+typedef struct _IO_CSQ IO_CSQ, *PIO_CSQ;
+typedef VOID (*PIO_CSQ_ACQUIRE_LOCK)(PIO_CSQ Csq, PKIRQL Irql);
+typedef VOID (*PIO_CSQ_COMPLETE_CANCELED_IRP)(PIO_CSQ Csq, PIRP Irp);
+typedef VOID (*PIO_CSQ_INSERT_IRP)(struct _IO_CSQ *Csq, PIRP Irp);
+typedef PIRP (*PIO_CSQ_PEEK_NEXT_IRP)(PIO_CSQ Csq, PIRP Irp, PVOID PeekContext);
+typedef VOID (*PIO_CSQ_RELEASE_LOCK)(PIO_CSQ Csq, KIRQL Irql);
+typedef VOID (*PIO_CSQ_REMOVE_IRP)(PIO_CSQ Csq, PIRP Irp);
+
+#endif /* __WINE_CSQ_H */
From austinenglish at gmail.com Thu Nov 13 15:46:26 2014
From: austinenglish at gmail.com (Austin English)
Date: Thu, 13 Nov 2014 15:46:26 -0600
Subject: include: correct NtSetLdtEntries prototype
Message-ID:
--
-Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
diff --git a/include/winternl.h b/include/winternl.h
index 5a27f94..ddc7c18 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -2228,7 +2228,7 @@ NTSYSAPI NTSTATUS WINAPI NtSetInformationThread(HANDLE,THREADINFOCLASS,LPCVOID,
NTSYSAPI NTSTATUS WINAPI NtSetInformationToken(HANDLE,TOKEN_INFORMATION_CLASS,PVOID,ULONG);
NTSYSAPI NTSTATUS WINAPI NtSetIntervalProfile(ULONG,KPROFILE_SOURCE);
NTSYSAPI NTSTATUS WINAPI NtSetIoCompletion(HANDLE,ULONG_PTR,ULONG_PTR,NTSTATUS,SIZE_T);
-NTSYSAPI NTSTATUS WINAPI NtSetLdtEntries(ULONG,LDT_ENTRY,ULONG,LDT_ENTRY);
+NTSYSAPI NTSTATUS WINAPI NtSetLdtEntries(ULONG,ULONG,ULONG,ULONG,ULONG,ULONG);
NTSYSAPI NTSTATUS WINAPI NtSetLowEventPair(HANDLE);
NTSYSAPI NTSTATUS WINAPI NtSetLowWaitHighEventPair(HANDLE);
NTSYSAPI NTSTATUS WINAPI NtSetLowWaitHighThread(VOID);
From madewokherd at gmail.com Thu Nov 13 15:52:33 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Thu, 13 Nov 2014 15:52:33 -0600
Subject: ole32: Add support for pasting CF_BITMAP.
Message-ID:
-------------- next part --------------
From 3448f2f3b406617e32fea896cb9cff60f9ac3b94 Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Thu, 13 Nov 2014 15:50:42 -0600
Subject: [PATCH] ole32: Add support for pasting CF_BITMAP.
---
dlls/ole32/clipboard.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c
index a7308c2..9d28b65 100644
--- a/dlls/ole32/clipboard.c
+++ b/dlls/ole32/clipboard.c
@@ -1133,6 +1133,8 @@ static DWORD get_tymed_from_nonole_cf(UINT cf)
return TYMED_ENHMF;
case CF_METAFILEPICT:
return TYMED_MFPICT;
+ case CF_BITMAP:
+ return TYMED_GDI;
default:
FIXME("returning TYMED_NULL for cf %04x\n", cf);
return TYMED_NULL;
@@ -1310,6 +1312,27 @@ static HRESULT get_stgmed_for_emf(HENHMETAFILE hemf, STGMEDIUM *med)
return S_OK;
}
+/************************************************************************
+ * get_stgmed_for_bitmap
+ *
+ * Returns a stg medium with a bitmap based on the handle
+ */
+static HRESULT get_stgmed_for_bitmap(HBITMAP hbmp, STGMEDIUM *med)
+{
+ HRESULT hr;
+
+ med->pUnkForRelease = NULL;
+ med->tymed = TYMED_NULL;
+
+ hr = dup_bitmap(hbmp, &med->u.hBitmap);
+
+ if (FAILED(hr))
+ return hr;
+
+ med->tymed = TYMED_ENHMF;
+ return S_OK;
+}
+
static inline BOOL string_off_equal(const DVTARGETDEVICE *t1, WORD off1, const DVTARGETDEVICE *t2, WORD off2)
{
const WCHAR *str1, *str2;
@@ -1401,6 +1424,8 @@ static HRESULT WINAPI snapshot_GetData(IDataObject *iface, FORMATETC *fmt,
hr = get_stgmed_for_stream(h, med);
else if(mask & TYMED_ENHMF)
hr = get_stgmed_for_emf((HENHMETAFILE)h, med);
+ else if(mask & TYMED_GDI)
+ hr = get_stgmed_for_bitmap((HBITMAP)h, med);
else
{
FIXME("Unhandled tymed - mask %x req tymed %x\n", mask, fmt->tymed);
--
2.1.0
From madewokherd at gmail.com Thu Nov 13 16:05:29 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Thu, 13 Nov 2014 16:05:29 -0600
Subject: ole32: Add support for pasting CF_BITMAP.
Message-ID:
Supersedes 107672, which had a copy/paste error.
-------------- next part --------------
From 83d5f5624e9f4c4cd5422a05e036c6cfa25e4006 Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Thu, 13 Nov 2014 15:50:42 -0600
Subject: [PATCH] ole32: Add support for pasting CF_BITMAP.
---
dlls/ole32/clipboard.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c
index a7308c2..6404f36 100644
--- a/dlls/ole32/clipboard.c
+++ b/dlls/ole32/clipboard.c
@@ -1133,6 +1133,8 @@ static DWORD get_tymed_from_nonole_cf(UINT cf)
return TYMED_ENHMF;
case CF_METAFILEPICT:
return TYMED_MFPICT;
+ case CF_BITMAP:
+ return TYMED_GDI;
default:
FIXME("returning TYMED_NULL for cf %04x\n", cf);
return TYMED_NULL;
@@ -1310,6 +1312,27 @@ static HRESULT get_stgmed_for_emf(HENHMETAFILE hemf, STGMEDIUM *med)
return S_OK;
}
+/************************************************************************
+ * get_stgmed_for_bitmap
+ *
+ * Returns a stg medium with a bitmap based on the handle
+ */
+static HRESULT get_stgmed_for_bitmap(HBITMAP hbmp, STGMEDIUM *med)
+{
+ HRESULT hr;
+
+ med->pUnkForRelease = NULL;
+ med->tymed = TYMED_NULL;
+
+ hr = dup_bitmap(hbmp, &med->u.hBitmap);
+
+ if (FAILED(hr))
+ return hr;
+
+ med->tymed = TYMED_GDI;
+ return S_OK;
+}
+
static inline BOOL string_off_equal(const DVTARGETDEVICE *t1, WORD off1, const DVTARGETDEVICE *t2, WORD off2)
{
const WCHAR *str1, *str2;
@@ -1401,6 +1424,8 @@ static HRESULT WINAPI snapshot_GetData(IDataObject *iface, FORMATETC *fmt,
hr = get_stgmed_for_stream(h, med);
else if(mask & TYMED_ENHMF)
hr = get_stgmed_for_emf((HENHMETAFILE)h, med);
+ else if(mask & TYMED_GDI)
+ hr = get_stgmed_for_bitmap((HBITMAP)h, med);
else
{
FIXME("Unhandled tymed - mask %x req tymed %x\n", mask, fmt->tymed);
--
2.1.0
From jonas.bugzilla at gmail.com Thu Nov 13 16:13:54 2014
From: jonas.bugzilla at gmail.com (Jonas Maebe)
Date: Thu, 13 Nov 2014 23:13:54 +0100
Subject: wined3d: Add NVIDIA Geforce GT 750M to supported device list.
Message-ID: <54652D22.1060706@gmail.com>
>From b563d158cbfaf38aca005b7db1300c949d4a9e82 Mon Sep 17 00:00:00 2001
From: Jonas Maebe
Date: Thu, 13 Nov 2014 22:47:32 +0100
Subject: wined3d: Add NVIDIA Geforce GT 750M to supported device list.
---
dlls/wined3d/directx.c | 2 ++
dlls/wined3d/wined3d_private.h | 1 +
2 files changed, 3 insertions(+)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 5327949..abb25a1 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1284,6 +1284,7 @@ static const struct gpu_description gpu_description_table[] =
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670, "NVIDIA GeForce GTX 670", DRIVER_NVIDIA_GEFORCE8, 2048},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX670MX, "NVIDIA GeForce GTX 670MX", DRIVER_NVIDIA_GEFORCE8, 3072},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX680, "NVIDIA GeForce GTX 680", DRIVER_NVIDIA_GEFORCE8, 2048},
+ {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT750M, "NVIDIA GeForce GT 750M", DRIVER_NVIDIA_GEFORCE8, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750, "NVIDIA GeForce GTX 750", DRIVER_NVIDIA_GEFORCE8, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX750TI, "NVIDIA GeForce GTX 750 Ti", DRIVER_NVIDIA_GEFORCE8, 2048},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX760, "NVIDIA Geforce GTX 760", DRIVER_NVIDIA_GEFORCE8, 2048},
@@ -1727,6 +1728,7 @@ cards_nvidia_binary[] =
{"GTX 760", CARD_NVIDIA_GEFORCE_GTX760}, /* Geforce 700 - midend high */
{"GTX 750 Ti", CARD_NVIDIA_GEFORCE_GTX750TI}, /* Geforce 700 - midend */
{"GTX 750", CARD_NVIDIA_GEFORCE_GTX750}, /* Geforce 700 - midend */
+ {"GT 750M", CARD_NVIDIA_GEFORCE_GT750M}, /* Geforce 700 - midend mobile */
{"GTX 680", CARD_NVIDIA_GEFORCE_GTX680}, /* Geforce 600 - highend */
{"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX}, /* Geforce 600 - highend */
{"GTX 670", CARD_NVIDIA_GEFORCE_GTX670}, /* Geforce 600 - midend high */
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0f302c4..4210d26 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1514,6 +1514,7 @@ enum wined3d_pci_device
CARD_NVIDIA_GEFORCE_GTX670 = 0x1189,
CARD_NVIDIA_GEFORCE_GTX670MX = 0x11a1,
CARD_NVIDIA_GEFORCE_GTX680 = 0x1180,
+ CARD_NVIDIA_GEFORCE_GT750M = 0x0fe9,
CARD_NVIDIA_GEFORCE_GTX750 = 0x1381,
CARD_NVIDIA_GEFORCE_GTX750TI = 0x1380,
CARD_NVIDIA_GEFORCE_GTX760 = 0x1187,
--
2.1.0
From 00cpxxx at gmail.com Thu Nov 13 18:13:40 2014
From: 00cpxxx at gmail.com (Bruno Jesus)
Date: Thu, 13 Nov 2014 22:13:40 -0200
Subject: ole32: Avoid a possible null dereference
Message-ID:
The variable passed to the function is tested against NULL after this
function is called so it may be possible to crash.
-------------- next part --------------
diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c
index a7308c2..afb94d1 100644
--- a/dlls/ole32/clipboard.c
+++ b/dlls/ole32/clipboard.c
@@ -214,8 +214,11 @@ static inline char *dump_fmtetc(FORMATETC *fmt)
{
static char buf[100];
- snprintf(buf, sizeof(buf), "cf %04x ptd %p aspect %x lindex %d tymed %x",
- fmt->cfFormat, fmt->ptd, fmt->dwAspect, fmt->lindex, fmt->tymed);
+ if (fmt)
+ snprintf(buf, sizeof(buf), "cf %04x ptd %p aspect %x lindex %d tymed %x",
+ fmt->cfFormat, fmt->ptd, fmt->dwAspect, fmt->lindex, fmt->tymed);
+ else
+ strcpy(buf, "(null)");
return buf;
}
From sebastian at fds-team.de Thu Nov 13 18:42:33 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Fri, 14 Nov 2014 01:42:33 +0100
Subject: [1/2] ntdll/tests: Add basic tests for
Rtl[Add|Remove]VectoredContinueHandler.
Message-ID: <54654FF9.3040305@fds-team.de>
This series fixes bug 37548. Would be very useful to have this in before the next release, otherwise lot of people will complain about native .NET framework being broken.
The usual test failures
exception.c:486: Test failed: 42: Wrong exception address 00310000/00310001
exception: unhandled exception 80000004 at 00310000
exception.c:483: Test failed: 42: Wrong exception code c0000027/80000004
exception.c:486: Test failed: 42: Wrong exception address 77174D17/00310001
and on w8
exception.c:1149: Test failed: Got exception offset 0x1b, expected 0x19
exception.c:1158: Test failed: Got exception offset 0x19, expected 0x17
are expected and not introduced by this patch.
---
dlls/ntdll/tests/exception.c | 50 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ntdll-tests-Add-basic-tests-for-Rtl-Add-Remove-Vecto.patch
Type: text/x-patch
Size: 4483 bytes
Desc: not available
URL:
From sebastian at fds-team.de Thu Nov 13 18:42:44 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Fri, 14 Nov 2014 01:42:44 +0100
Subject: [2/2] ntdll: Implement Rtl[Add|Remove]VectoredContinueHandler
semi-stubs.
Message-ID: <54655004.4090505@fds-team.de>
This patch moves the code for vectored exception handlers to common functions, and then implements semi-stubs for continue handlers.
---
dlls/ntdll/exception.c | 85 +++++++++++++++++++++++++-------------------
dlls/ntdll/tests/exception.c | 5 ---
2 files changed, 49 insertions(+), 41 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-ntdll-Implement-Rtl-Add-Remove-VectoredContinueHandl.patch
Type: text/x-patch
Size: 6894 bytes
Desc: not available
URL:
From sebastian at fds-team.de Thu Nov 13 19:04:59 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Fri, 14 Nov 2014 02:04:59 +0100
Subject: d3dx9_36: Allow NULL pointer for optional arguments of
D3DXIntersectTri.
Message-ID: <5465553B.5040309@fds-team.de>
Fixes bug 35133.
---
dlls/d3dx9_36/mesh.c | 6 +++---
dlls/d3dx9_36/tests/mesh.c | 9 +++++++++
2 files changed, 12 insertions(+), 3 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-d3dx9_36-Allow-NULL-pointer-for-optional-arguments-o.patch
Type: text/x-patch
Size: 2790 bytes
Desc: not available
URL:
From sebastian at fds-team.de Fri Nov 14 01:14:07 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Fri, 14 Nov 2014 08:14:07 +0100
Subject: [1/2] psapi/tests: Add tests for GetPerformanceInfo function.
Message-ID: <5465ABBF.2040900@fds-team.de>
---
dlls/psapi/tests/psapi_main.c | 137 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 136 insertions(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-psapi-tests-Add-tests-for-GetPerformanceInfo-functio.patch
Type: text/x-patch
Size: 9122 bytes
Desc: not available
URL:
From sebastian at fds-team.de Fri Nov 14 01:14:14 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Fri, 14 Nov 2014 08:14:14 +0100
Subject: [2/2] kernel32: Fix implementation of K32GetPerformanceInfo.
Message-ID: <5465ABC6.1030609@fds-team.de>
Fixes bug 37512.
---
dlls/kernel32/cpu.c | 64 ++++++++++++++++++++++++++++++++++++++++++-
dlls/psapi/tests/psapi_main.c | 14 ----------
2 files changed, 63 insertions(+), 15 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-kernel32-Fix-implementation-of-K32GetPerformanceInfo.patch
Type: text/x-patch
Size: 7612 bytes
Desc: not available
URL:
From mstefani at redhat.de Fri Nov 14 03:51:38 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Fri, 14 Nov 2014 10:51:38 +0100
Subject: appwiz.cpl: Simplify the check for an empty string (PVS-Studio)
Message-ID: <20141114095138.GA1810@redhat.com>
---
dlls/appwiz.cpl/appwiz.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/appwiz.cpl/appwiz.c b/dlls/appwiz.cpl/appwiz.c
index cd76f51..9d53e79 100644
--- a/dlls/appwiz.cpl/appwiz.c
+++ b/dlls/appwiz.cpl/appwiz.c
@@ -567,7 +567,7 @@ static void SetInfoDialogText(HKEY hKey, LPCWSTR lpKeyName, LPCWSTR lpAltMessage
/* if hKey is null, lpKeyName contains the string we want to check */
if (hKey == NULL)
{
- if ((lpKeyName) && (lstrlenW(lpKeyName) > 0))
+ if (lpKeyName && lpKeyName[0])
SetWindowTextW(hWndDlgItem, lpKeyName);
else
SetWindowTextW(hWndDlgItem, lpAltMessage);
@@ -577,7 +577,7 @@ static void SetInfoDialogText(HKEY hKey, LPCWSTR lpKeyName, LPCWSTR lpAltMessage
buflen = MAX_STRING_LEN;
if ((RegQueryValueExW(hKey, lpKeyName, 0, 0, (LPBYTE) buf, &buflen) ==
- ERROR_SUCCESS) && (lstrlenW(buf) > 0))
+ ERROR_SUCCESS) && buf[0])
SetWindowTextW(hWndDlgItem, buf);
else
SetWindowTextW(hWndDlgItem, lpAltMessage);
--
1.9.3
From mstefani at redhat.de Fri Nov 14 04:05:00 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Fri, 14 Nov 2014 11:05:00 +0100
Subject: fusion/tests: Simplify the check for an empty string (PVS-Studio)
Message-ID: <20141114100500.GB1810@redhat.com>
---
dlls/fusion/tests/asmname.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/fusion/tests/asmname.c b/dlls/fusion/tests/asmname.c
index ac5b27b..a075288 100644
--- a/dlls/fusion/tests/asmname.c
+++ b/dlls/fusion/tests/asmname.c
@@ -425,7 +425,7 @@ static void test_CreateAssemblyNameObject(void)
str[0] = '\0';
hr = IAssemblyName_GetName(name, &size, str);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
- ok(lstrlenW(str) == 0, "Expected empty name\n");
+ ok(!str[0], "Expected empty name\n");
ok(size == 0, "Expected 0, got %d\n", size);
hi = 0xbeefcace;
@@ -461,7 +461,7 @@ static void test_CreateAssemblyNameObject(void)
str[0] = '\0';
hr = IAssemblyName_GetName(name, &size, str);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
- ok(lstrlenW(str) == 0, "Expected empty name\n");
+ ok(!str[0], "Expected empty name\n");
ok(size == 1, "Expected 1, got %d\n", size);
hi = 0xbeefcace;
--
1.9.3
From jr98 at gmx.net Fri Nov 14 09:13:43 2014
From: jr98 at gmx.net (Julian =?ISO-8859-1?Q?R=FCger?=)
Date: Fri, 14 Nov 2014 16:13:43 +0100
Subject: [website] Ubuntu Download: Update and overhaul German translation.
Message-ID: <1415978023.4984.18.camel@xpsubuntu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Ubuntu-Download-Update-and-overhaul-German-translati.patch
Type: text/x-patch
Size: 242504 bytes
Desc: not available
URL:
From jr98 at gmx.net Fri Nov 14 09:24:11 2014
From: jr98 at gmx.net (Julian =?ISO-8859-1?Q?R=FCger?=)
Date: Fri, 14 Nov 2014 16:24:11 +0100
Subject: [website] German translation for release 1.7.31
Message-ID: <1415978651.4984.21.camel@xpsubuntu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-German-translation-for-release-1.7.31.patch
Type: text/x-patch
Size: 1355 bytes
Desc: not available
URL:
From jr98 at gmx.net Fri Nov 14 10:40:27 2014
From: jr98 at gmx.net (Julian =?ISO-8859-1?Q?R=FCger?=)
Date: Fri, 14 Nov 2014 17:40:27 +0100
Subject: [website] Ubuntu Download: Update and overhaul German translation.
(try 2)
In-Reply-To: <1415978023.4984.18.camel@xpsubuntu>
References: <1415978023.4984.18.camel@xpsubuntu>
Message-ID: <1415983227.4984.27.camel@xpsubuntu>
Try 2: I missed some of Rosanne's changes (stop identifying the PPA as
WineHQ's). Fixed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Ubuntu-Download-Update-and-overhaul-German-translati.patch
Type: text/x-patch
Size: 242474 bytes
Desc: not available
URL:
From joachim.priesner at web.de Fri Nov 14 15:39:58 2014
From: joachim.priesner at web.de (Joachim Priesner)
Date: Fri, 14 Nov 2014 22:39:58 +0100
Subject: [1/2] wined3d: Set D3DPMISCCAPS_FOGVERTEXCLAMPED flag in
get_device_caps (resend)
Message-ID: <201411142240.07895.joachim.priesner@web.de>
Wine clamps the oFog output of vertex shaders. Tests for the flag follow
in the second part of this patch.
---
dlls/wined3d/directx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index d428d94..41bad21 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -4148,12 +4148,12 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte
WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
WINED3DPMISCCAPS_MASKZ |
WINED3DPMISCCAPS_BLENDOP |
+ WINED3DPMISCCAPS_FOGVERTEXCLAMPED |
WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING;
/* TODO:
WINED3DPMISCCAPS_NULLREFERENCE
WINED3DPMISCCAPS_FOGANDSPECULARALPHA
- WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
- WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
+ WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS */
if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
--
1.8.4.5
From joachim.priesner at web.de Fri Nov 14 15:40:11 2014
From: joachim.priesner at web.de (Joachim Priesner)
Date: Fri, 14 Nov 2014 22:40:11 +0100
Subject: [2/2] wined3d: Take abs() of vertex z coordinate as FFP fog
coordinate (try 7)
Message-ID: <201411142240.16476.joachim.priesner@web.de>
Take the absolute value of vertex.z as fog coordinate instead of just
the z coordinate. This fixes e.g. fog for applications that use
right-handed projection matrices.
Also test the clamp behavior of the oFog vertex shader output.
Tested on openSuse 13.1 and Windows 8.1 (VMware Player).
Try 7: Also test fogstart=-1, fogend=0.
---
dlls/d3d8/tests/visual.c | 331 +++++++++++++++++++++++++++++++++++++
dlls/d3d9/tests/visual.c | 399 +++++++++++++++++++++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 174 ++++++++++++++++++++
dlls/wined3d/glsl_shader.c | 2 +-
4 files changed, 905 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index 163110c..f9dd30b 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -696,6 +696,336 @@ done:
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void fog_negative_z_test(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000,
+ C_CLAMPED_FOG = 0xdeadbeef /* triggers special codepath when used as middle_color */
+ };
+
+ /* Fill the null-shader entry with the FVF (SetVertexShader is "overloaded" on d3d8). */
+ DWORD vertex_shader[3] = {D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, 0, 0};
+ DWORD pixel_shader[2] = {0, 0};
+ IDirect3D8 *d3d;
+ IDirect3DDevice8 *device;
+ BOOL has_vs_support, has_ps_support, has_table_fog_support;
+ unsigned int i, ps, y;
+ D3DCOLOR color, expected_middle_color;
+ ULONG refcount;
+ D3DCAPS8 caps;
+ HWND window;
+ HRESULT hr;
+
+ static const DWORD vertex_decl[] =
+ {
+ D3DVSD_STREAM(0),
+ D3DVSD_REG(0, D3DVSDT_FLOAT3), /* position, v0 */
+ D3DVSD_REG(1, D3DVSDT_D3DCOLOR), /* diffuse color, v1 */
+ D3DVSD_REG(2, D3DVSDT_D3DCOLOR), /* specular color, v2 */
+ D3DVSD_CONST(0, 1), 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ D3DVSD_END()
+ };
+
+ /* Basic vertex shader without fog computation ("non foggy") */
+ static const DWORD vertex_shader_code1[] =
+ {
+ 0xfffe0100, /* vs_1_0 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"). Outputs the z coordinate of the vertex
+ * as its fog intensity value. */
+ static const DWORD vertex_shader_code2[] =
+ {
+ 0xfffe0100, /* vs_1_0 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x00000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic pixel shader */
+ static const DWORD pixel_shader_code[] =
+ {
+ 0xffff0101, /* ps_1_1 */
+ 0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
+ 0x0000ffff
+ };
+
+ static const struct
+ {
+ struct vec3 position;
+ DWORD diffuse;
+ DWORD specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+ static const struct
+ {
+ int vshader;
+ float fog_start;
+ float fog_end;
+ D3DFOGMODE vfog;
+ D3DFOGMODE tfog;
+ DWORD color_left;
+ DWORD color_middle_top;
+ DWORD color_middle_bottom;
+ DWORD color_right;
+ }
+ test_data[] =
+ {
+ /* fogstart = 0, fogend = 1:
+ * Using z-based fog, the bottom quad should have a gradient UNFOGGED->FOGGED
+ * for table fog, and be completely fogged for vertex fog.
+ * When the fog coordinate returned by the vertex shader is used instead,
+ * the result is a gradient FOGGED->UNFOGGED.
+ *
+ * fogstart = -1, fogend = 0:
+ * Both quads are completely fogged, except in the cases where the foggy vertex shader
+ * with vertex fog or neither vertex nor table fog are used. Those are independent of
+ * fogstart/fogend, the result should therefore equal that of the
+ * corresponding (fogstart, fogend) == (0, 1) case. */
+
+ /* No vertex shader */
+ {0, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {0, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ {0, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {0, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {0, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {0, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader without vertex fog computation */
+ {1, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ {1, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader with vertex fog computation.
+ * As drivers inconsistently clamp or don't clamp the oFog output of vertex shaders,
+ * the special value C_CLAMPED_FOG allows both C_HALF_FOGGED (clamped) and C_FOGGED. */
+ {2, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {2, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+
+ {2, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {2, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {2, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {2, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1.
+ * Note that for the tests with vertex shaders, this matrix is hard-coded in the shaders. */
+ static const D3DMATRIX proj_mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f
+ }}};
+
+ window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate8(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps (%#x)\n", hr);
+
+ has_table_fog_support = caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests\n");
+
+ has_ps_support = caps.PixelShaderVersion >= D3DPS_VERSION(1, 1);
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice8_CreatePixelShader(device, pixel_shader_code, &pixel_shader[1]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No ps_1_1 support, skipping some fog tests\n");
+ }
+
+ has_vs_support = caps.VertexShaderVersion >= D3DVS_VERSION(1, 0);
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice8_CreateVertexShader(device, vertex_decl, vertex_shader_code1, &vertex_shader[1], 0);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_CreateVertexShader(device, vertex_decl, vertex_shader_code2, &vertex_shader[2], 0);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No vs_1_0 support, skipping some fog tests\n");
+ }
+
+ /* Setup initial states: No depth test, no lighting, fog on, fog color */
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Turning off depth test failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Turning off lighting failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Turning on fog calculations failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Setting fog color failed (%#x)\n", hr);
+
+ hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform (%#x)\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].vshader != 0 && !vertex_shader[test_data[i].vshader])
+ continue;
+ if (test_data[i].tfog != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ hr = IDirect3DDevice8_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
+ ok(SUCCEEDED(hr), "SetVertexShader failed (%#x)\n", hr);
+
+ for (ps = 0; ps < sizeof(pixel_shader)/sizeof(pixel_shader[0]); ps++)
+ {
+ if (ps != 0 && !pixel_shader[ps])
+ continue;
+
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice8_SetPixelShader(device, pixel_shader[ps]);
+ ok(SUCCEEDED(hr), "SetPixelShader failed (%#x)\n", hr);
+ }
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGVERTEXMODE, test_data[i].vfog);
+ ok(SUCCEEDED(hr), "Setting fog vertex mode to %d failed (%#x)\n", test_data[i].vfog, hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGTABLEMODE, test_data[i].tfog);
+ ok(SUCCEEDED(hr), "Setting fog table mode to %d failed (%#x)\n", test_data[i].tfog, hr);
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGSTART,
+ *(DWORD*)(&test_data[i].fog_start));
+ ok(SUCCEEDED(hr), "Setting fog start to %.1f failed (%#x)\n", test_data[i].fog_start, hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGEND,
+ *(DWORD*)(&test_data[i].fog_end));
+ ok(SUCCEEDED(hr), "Setting fog end to %.1f failed (%#x)\n", test_data[i].fog_end, hr);
+
+ hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Clear failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_BeginScene(device);
+ ok(SUCCEEDED(hr), "BeginScene failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &top_quad[0], sizeof(top_quad[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_1[0], sizeof(bottom_quad_1[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_2[0], sizeof(bottom_quad_2[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice8_EndScene(device);
+ ok(SUCCEEDED(hr), "EndScene failed (%#x)\n", hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = getPixelColor(device, 2, y);
+ ok(color_match(color, test_data[i].color_left, 13),
+ "fog %.1f-%.1f vs%i ps%i fvm%i ftm%i, y=%i: "
+ "got left color %08x, expected %08x+-5%%\n",
+ test_data[i].fog_start, test_data[i].fog_end, test_data[i].vshader, ps,
+ test_data[i].vfog, test_data[i].tfog, y, color, test_data[i].color_left);
+ color = getPixelColor(device, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ if (expected_middle_color == C_CLAMPED_FOG)
+ {
+ ok(color_match(color, C_HALF_FOGGED, 13) || color_match(color, C_FOGGED, 13),
+ "fog %.1f-%.1f vs%i ps%i fvm%i ftm%i, y=%i: "
+ "got middle color %08x, expected %08x+-5%% or %08x+-5%%\n",
+ test_data[i].fog_start, test_data[i].fog_end, test_data[i].vshader, ps,
+ test_data[i].vfog, test_data[i].tfog, y, color, C_HALF_FOGGED, C_FOGGED);
+ }
+ else
+ {
+ ok(color_match(color, expected_middle_color, 13),
+ "fog %.1f-%.1f vs%i ps%i fvm%i ftm%i, y=%i: "
+ "got middle color %08x, expected %08x+-5%%\n",
+ test_data[i].fog_start, test_data[i].fog_end, test_data[i].vshader, ps,
+ test_data[i].vfog, test_data[i].tfog, y, color, expected_middle_color);
+ }
+ color = getPixelColor(device, 638, y);
+ ok(color_match(color, test_data[i].color_right, 13),
+ "fog %.1f-%.1f vs%i ps%i fvm%i ftm%i, y=%i: "
+ "got right color %08x, expected %08x+-5%%\n",
+ test_data[i].fog_start, test_data[i].fog_end, test_data[i].vshader, ps,
+ test_data[i].vfog, test_data[i].tfog, y, color, test_data[i].color_right);
+ }
+
+ hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Present failed (%#x)\n", hr);
+ }
+ }
+ for (i = 0; i < sizeof(vertex_shader)/sizeof(vertex_shader[0]); i++)
+ if (vertex_shader[i])
+ IDirect3DDevice8_DeleteVertexShader(device, vertex_shader[i]);
+ for (i = 0; i < sizeof(pixel_shader)/sizeof(pixel_shader[0]); i++)
+ if (pixel_shader[i])
+ IDirect3DDevice8_DeletePixelShader(device, pixel_shader[i]);
+ refcount = IDirect3DDevice8_Release(device);
+ ok(!refcount, "Device has %u references left\n", refcount);
+done:
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+}
+
/* This tests fog in combination with shaders.
* What's tested: linear fog (vertex and table) with pixel shader
* linear table fog with non foggy vertex shader
@@ -5092,6 +5422,7 @@ START_TEST(visual)
offscreen_test();
alpha_test();
test_scalar_instructions();
+ fog_negative_z_test();
fog_with_shader_test();
cnd_test();
p8_texture_test();
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 117c8eb..6fdfb3b 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -1825,6 +1825,404 @@ done:
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void fog_negative_z_test(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000,
+ C_CLAMPED_FOG = 0xdeadbeef /* triggers special codepath when used as middle_color */
+ };
+
+ IDirect3DVertexShader9 *vertex_shader[4] = {NULL, NULL, NULL, NULL};
+ IDirect3DPixelShader9 *pixel_shader[3] = {NULL, NULL, NULL};
+ IDirect3DVertexDeclaration9 *vertex_declaration = NULL;
+ IDirect3DDevice9 *device;
+ BOOL has_vs_support, has_ps_support, has_table_fog_support, is_fog_vertex_clamped;
+ unsigned int i, ps, y;
+ IDirect3D9 *d3d;
+ ULONG refcount;
+ D3DCAPS9 caps;
+ DWORD color, expected_middle_color;
+ HWND window;
+ HRESULT hr;
+
+ /* Basic vertex shader without fog computation ("non foggy") */
+ static const DWORD vertex_shader_code1[] =
+ {
+ 0xfffe0101, /* vs_1_1 */
+ 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0000001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"). Outputs the z coordinate of the vertex
+ * as its fog intensity value. */
+ static const DWORD vertex_shader_code2[] =
+ {
+ 0xfffe0101, /* vs_1_1 */
+ 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0000001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x00000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x00000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x00000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x00000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic vertex shader with fog computation ("foggy"), vs_2_0 */
+ static const DWORD vertex_shader_code3[] =
+ {
+ 0xfffe0200, /* vs_2_0 */
+ 0x05000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0, 0, 0 */
+ 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position0 v0 */
+ 0x0200001f, 0x8000000a, 0x900f0001, /* dcl_color0 v1 */
+ /* output.Pos.z = input.Pos.z * 0.5 + 0.5 */
+ 0x03000005, 0x80010000, 0x90aa0000, 0xa0000000, /* mul r0.x, v0.z, c0.x */
+ 0x03000002, 0xc0040000, 0x80000000, 0xa0000000, /* add oPos.z, r0.x c0.x */
+ /* output.Pos.xyw = input.Pos.xyw */
+ 0x02000001, 0xc00b0000, 0x90e40000, /* mov oPos.xyw, v0 */
+ /* output.Color = input.Color */
+ 0x02000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */
+ /* output.Fog = input.Pos.z */
+ 0x02000001, 0xc00f0001, 0x90aa0000, /* mov oFog, v0.z */
+ 0x0000ffff, /* END */
+ };
+
+ /* Basic pixel shader */
+ static const DWORD pixel_shader_code[] =
+ {
+ 0xffff0101, /* ps_1_1 */
+ 0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */
+ 0x0000ffff
+ };
+ static const DWORD pixel_shader_code2[] =
+ {
+ 0xffff0200, /* ps_2_0 */
+ 0x0200001f, 0x80000000, 0x900f0000, /* dcl v0 */
+ 0x02000001, 0x800f0800, 0x90e40000, /* mov oC0, v0 */
+ 0x0000ffff
+ };
+ static const struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+
+ static const D3DVERTEXELEMENT9 decl_elements[] =
+ {
+ {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
+ {0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, /* diffuse */
+ {0, 16, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, /* specular */
+ D3DDECL_END()
+ };
+ static const struct
+ {
+ int vshader;
+ float fog_start;
+ float fog_end;
+ D3DFOGMODE vfog;
+ D3DFOGMODE tfog;
+ DWORD color_left;
+ DWORD color_middle_top;
+ DWORD color_middle_bottom;
+ DWORD color_right;
+ }
+ test_data[] =
+ {
+ /* fogstart = 0, fogend = 1:
+ * Using z-based fog, the bottom quad should have a gradient UNFOGGED->FOGGED
+ * for table fog, and be completely fogged for vertex fog.
+ * When the fog coordinate returned by the vertex shader is used instead,
+ * the result is a gradient FOGGED->UNFOGGED in the right half of the screen.
+ *
+ * fogstart = -1, fogend = 0:
+ * Both quads are completely fogged, except in the cases where a foggy vertex shader
+ * with vertex fog or neither vertex nor table fog are used. Those are independent of
+ * fogstart/fogend, the result should therefore equal that of the
+ * corresponding (fogstart, fogend) == (0, 1) case.
+ *
+ * C_CLAMPED_FOG will be replaced by the correct expected value based on
+ * the value of D3DPMISCCAPS_FOGVERTEXCLAMPED. If the driver clamps the oFog
+ * output of vertex shaders, it should be C_HALF_FOGGED, else C_FOGGED. */
+
+ /* No vertex shader */
+ {0, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {0, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ {0, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ {0, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {0, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {0, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {0, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader without vertex fog computation */
+ {1, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {1, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ {1, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {1, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ /* Vertex shader vs_1_1 with vertex fog computation */
+ {2, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {2, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {2, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+
+ {2, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {2, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {2, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {2, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+
+ /* Vertex shader vs_2_0 with vertex fog computation */
+ {3, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {3, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ {3, 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {3, 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+
+ {3, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {3, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {3, -1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ {3, -1.0f, 0.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_CLAMPED_FOG, C_UNFOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1.
+ * Note that for the tests with vertex shaders, this matrix is hard-coded in the shaders. */
+ static const D3DMATRIX proj_mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f,
+ }}};
+
+ window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d = Direct3DCreate9(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device, skipping tests\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps (%#x)\n", hr);
+
+ has_table_fog_support = caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests\n");
+
+ has_vs_support = caps.VertexShaderVersion >= D3DVS_VERSION(1, 1);
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code1, &vertex_shader[1]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code2, &vertex_shader[2]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+
+ if (caps.VertexShaderVersion >= D3DVS_VERSION(2, 0))
+ {
+ hr = IDirect3DDevice9_CreateVertexShader(device, vertex_shader_code3, &vertex_shader[3]);
+ ok(SUCCEEDED(hr), "CreateVertexShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No vs_2_0 support, skipping some fog tests\n");
+ }
+ }
+ else
+ {
+ skip("No vs_1_1 support, skipping some fog tests\n");
+ }
+
+ has_ps_support = caps.PixelShaderVersion >= D3DPS_VERSION(1, 1);
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code, &pixel_shader[1]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+
+ if (caps.PixelShaderVersion >= D3DPS_VERSION(2, 0))
+ {
+ hr = IDirect3DDevice9_CreatePixelShader(device, pixel_shader_code2, &pixel_shader[2]);
+ ok(SUCCEEDED(hr), "CreatePixelShader failed (%#x)\n", hr);
+ }
+ else
+ {
+ skip("No ps_2_0 support, skipping some fog tests\n");
+ }
+ }
+ else
+ {
+ skip("No ps_1_1 support, skipping some fog tests\n");
+ }
+
+ is_fog_vertex_clamped = caps.PrimitiveMiscCaps & D3DPMISCCAPS_FOGVERTEXCLAMPED;
+
+ hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
+ ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (%#x)\n", hr);
+
+ /* Setup initial states: No depth test, no lighting, fog on, fog color */
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Turning off depth test failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Turning off lighting failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Turning on fog calculations failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Setting fog color failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
+ ok(SUCCEEDED(hr), "SetVertexDeclaration failed (%#x)\n", hr);
+
+ hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform (%#x)\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].vshader != 0 && !vertex_shader[test_data[i].vshader])
+ continue;
+ if (test_data[i].tfog != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ if (has_vs_support)
+ {
+ hr = IDirect3DDevice9_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
+ ok(SUCCEEDED(hr), "SetVertexShader failed (%#x)\n", hr);
+ }
+
+ for (ps = 0; ps < sizeof(pixel_shader)/sizeof(pixel_shader[0]); ps++)
+ {
+ if (ps != 0 && !pixel_shader[ps])
+ continue;
+
+ if (has_ps_support)
+ {
+ hr = IDirect3DDevice9_SetPixelShader(device, pixel_shader[ps]);
+ ok(SUCCEEDED(hr), "SetPixelShader failed (%#x)\n", hr);
+ }
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, test_data[i].vfog);
+ ok(SUCCEEDED(hr), "Setting fog vertex mode to %d failed (%#x)\n", test_data[i].vfog, hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, test_data[i].tfog);
+ ok(SUCCEEDED(hr), "Setting fog table mode to %d failed (%#x)\n", test_data[i].tfog, hr);
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGSTART,
+ *(DWORD*)(&test_data[i].fog_start));
+ ok(SUCCEEDED(hr), "Setting fog start to %.1f failed (%#x)\n", test_data[i].fog_start, hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGEND,
+ *(DWORD*)(&test_data[i].fog_end));
+ ok(SUCCEEDED(hr), "Setting fog end to %.1f failed (%#x)\n", test_data[i].fog_end, hr);
+
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Clear failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_BeginScene(device);
+ ok(SUCCEEDED(hr), "BeginScene failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &top_quad[0], sizeof(top_quad[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_1[0], sizeof(bottom_quad_1[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(
+ device, D3DPT_TRIANGLESTRIP, 2, &bottom_quad_2[0], sizeof(bottom_quad_2[0]));
+ ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%#x)\n", hr);
+ hr = IDirect3DDevice9_EndScene(device);
+ ok(SUCCEEDED(hr), "EndScene failed (%#x)\n", hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = getPixelColor(device, 2, y);
+ ok(color_match(color, test_data[i].color_left, 13),
+ "fog %.1f-%.1f vs%i ps%i fvm%i ftm%i, y=%i: "
+ "got left color %08x, expected %08x+-5%%\n",
+ test_data[i].fog_start, test_data[i].fog_end, test_data[i].vshader, ps,
+ test_data[i].vfog, test_data[i].tfog, y, color, test_data[i].color_left);
+ color = getPixelColor(device, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ if (expected_middle_color == C_CLAMPED_FOG)
+ {
+ expected_middle_color = is_fog_vertex_clamped ? C_HALF_FOGGED : C_FOGGED;
+ }
+ ok(color_match(color, expected_middle_color, 13),
+ "fog %.1f-%.1f vs%i ps%i fvm%i ftm%i, y=%i: "
+ "got middle color %08x, expected %08x+-5%%\n",
+ test_data[i].fog_start, test_data[i].fog_end, test_data[i].vshader, ps,
+ test_data[i].vfog, test_data[i].tfog, y, color, expected_middle_color);
+ color = getPixelColor(device, 638, y);
+ ok(color_match(color, test_data[i].color_right, 13),
+ "fog %.1f-%.1f vs%i ps%i fvm%i ftm%i, y=%i: "
+ "got right color %08x, expected %08x+-5%%\n",
+ test_data[i].fog_start, test_data[i].fog_end, test_data[i].vshader, ps,
+ test_data[i].vfog, test_data[i].tfog, y, color, test_data[i].color_right);
+
+ }
+
+ hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Present failed (%#x)\n", hr);
+ }
+ }
+
+ for (i = 0; i < sizeof(vertex_shader)/sizeof(vertex_shader[0]); i++)
+ if (vertex_shader[i])
+ IDirect3DVertexShader9_Release(vertex_shader[i]);
+ for (i = 0; i < sizeof(pixel_shader)/sizeof(pixel_shader[0]); i++)
+ if (pixel_shader[i])
+ IDirect3DPixelShader9_Release(pixel_shader[i]);
+ IDirect3DVertexDeclaration9_Release(vertex_declaration);
+ refcount = IDirect3DDevice9_Release(device);
+ ok(!refcount, "Device has %u references left\n", refcount);
+done:
+ IDirect3D9_Release(d3d);
+ DestroyWindow(window);
+}
+
/* This test tests fog in combination with shaders.
* What's tested: linear fog (vertex and table) with pixel shader
* linear table fog with non foggy vertex shader
@@ -16729,6 +17127,7 @@ START_TEST(visual)
test_vshader_input();
test_vshader_float16();
stream_test();
+ fog_negative_z_test();
fog_with_shader_test();
texbem_test();
texdepth_test();
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index ec50fb8..1fb78d5 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -3384,6 +3384,179 @@ static void test_fog_special(void)
DestroyWindow(window);
}
+/* This test tests fog in combination with negative vertex z coordinates. */
+static void test_fog_negative_z(void)
+{
+ enum
+ {
+ C_ALPHA_0x00 = 0x00000000,
+ C_CLEAR = 0xffff00ff,
+ C_FOGGED = 0x0000ff00,
+ C_HALF_FOGGED = 0x00808000,
+ C_UNFOGGED = 0x00ff0000
+ };
+
+ D3DCOLOR color, expected_middle_color;
+ HRESULT hr;
+ ULONG refcount;
+ BOOL has_table_fog_support;
+ unsigned int i, y;
+ HWND window;
+ IDirect3DDevice7 *device;
+ IDirectDrawSurface7 *rt;
+ D3DDEVICEDESC7 caps;
+
+ static struct
+ {
+ struct vec3 position;
+ D3DCOLOR diffuse;
+ D3DCOLOR specular;
+ }
+ top_quad[] =
+ {
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, -1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, -1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_1[] =
+ {
+ {{-1.0f, 1.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{-1.0f, 0.0f, -1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ },
+ bottom_quad_2[] =
+ {
+ {{ 0.0f, 1.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 1.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 0.0f, 0.0f, 0.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ {{ 1.0f, 0.0f, 1.0f}, C_UNFOGGED, C_ALPHA_0x00},
+ };
+ static const struct
+ {
+ float fog_start, fog_end;
+ DWORD vertexmode, tablemode;
+ D3DCOLOR color_left, color_middle_top, color_middle_bottom, color_right;
+ }
+ test_data[] =
+ {
+ { 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ { 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_UNFOGGED, C_HALF_FOGGED, C_HALF_FOGGED, C_FOGGED},
+ { 0.0f, 1.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_UNFOGGED, C_FOGGED, C_FOGGED},
+ { 0.0f, 1.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+
+ {-1.0f, 0.0f, D3DFOG_NONE, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {-1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_LINEAR, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {-1.0f, 0.0f, D3DFOG_LINEAR, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ {-1.0f, 0.0f, D3DFOG_NONE, D3DFOG_NONE, C_FOGGED, C_FOGGED, C_FOGGED, C_FOGGED},
+ };
+ /* Affine projection matrix for z-near = -1, z-far = 1. */
+ static D3DMATRIX proj_mat =
+ {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.5f, 1.0f
+ };
+
+ window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
+ 0, 0, 640, 480, 0, 0, 0, 0);
+
+ if (!(device = create_device(window, DDSCL_NORMAL)))
+ {
+ skip("Failed to create a 3D device, skipping test.\n");
+ DestroyWindow(window);
+ return;
+ }
+
+ memset(&caps, 0, sizeof(caps));
+ hr = IDirect3DDevice7_GetCaps(device, &caps);
+ ok(SUCCEEDED(hr), "IDirect3DDevice7_GetCaps failed, hr %#x.\n", hr);
+
+ has_table_fog_support = caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE;
+ if (!has_table_fog_support)
+ skip("No table fog support, skipping some fog tests.\n");
+
+ hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
+ ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
+ ok(SUCCEEDED(hr), "Failed to enable fog, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, C_FOGGED);
+ ok(SUCCEEDED(hr), "Failed to set fog color, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &proj_mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+
+ for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ {
+ if (test_data[i].tablemode != D3DFOG_NONE && !has_table_fog_support)
+ continue;
+
+ hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, C_CLEAR, 1.0f, 0);
+ ok(SUCCEEDED(hr), "Failed to clear render target, i=%d, hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, test_data[i].vertexmode);
+ ok(SUCCEEDED(hr), "Failed to set fog vertex mode, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, test_data[i].tablemode);
+ ok(SUCCEEDED(hr), "Failed to set fog table mode, i=%d, hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGSTART,
+ *(DWORD*)(&test_data[i].fog_start));
+ ok(SUCCEEDED(hr), "Failed to set fog start, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGEND,
+ *(DWORD*)(&test_data[i].fog_end));
+ ok(SUCCEEDED(hr), "Failed to set fog end, i=%d, hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice7_BeginScene(device);
+ ok(SUCCEEDED(hr), "Failed to begin scene, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, top_quad, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, bottom_quad_1, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, bottom_quad_2, 4, 0);
+ ok(SUCCEEDED(hr), "Failed to draw, i=%d, hr %#x.\n", i, hr);
+ hr = IDirect3DDevice7_EndScene(device);
+ ok(SUCCEEDED(hr), "Failed to end scene, i=%d, hr %#x.\n", i, hr);
+
+ /* Use 5% tolerance on the colors since there may be a gradient
+ * between left and right vertices. */
+ for (y = 120; y <= 360; y += 240)
+ {
+ color = get_surface_color(rt, 2, y);
+ ok(compare_color(color, test_data[i].color_left, 13),
+ "fog %.1f-%.1f fvm%i ftm%i y=%i: got left color %08x, expected %08x+-5%%.\n",
+ test_data[i].fog_start, test_data[i].fog_end, test_data[i].vertexmode,
+ test_data[i].tablemode, y, color, test_data[i].color_left);
+ color = get_surface_color(rt, 320, y);
+ expected_middle_color =
+ y == 120 ? test_data[i].color_middle_top : test_data[i].color_middle_bottom;
+ ok(compare_color(color, expected_middle_color, 13),
+ "fog %.1f-%.1f fvm%i ftm%i y=%i: got middle color %08x, expected %08x+-5%%.\n",
+ test_data[i].fog_start, test_data[i].fog_end, test_data[i].vertexmode,
+ test_data[i].tablemode, y, color, expected_middle_color);
+ color = get_surface_color(rt, 638, y);
+ ok(compare_color(color, test_data[i].color_right, 13),
+ "fog %.1f-%.1f fvm%i ftm%i y=%i: got right color %08x, expected %08x+-5%%.\n",
+ test_data[i].fog_start, test_data[i].fog_end, test_data[i].vertexmode,
+ test_data[i].tablemode, y, color, test_data[i].color_right);
+ }
+ }
+
+ IDirectDrawSurface7_Release(rt);
+ refcount = IDirect3DDevice7_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
static void test_lighting_interface_versions(void)
{
IDirect3DDevice7 *device;
@@ -7671,6 +7844,7 @@ START_TEST(ddraw7)
test_clear_rect_count();
test_coop_level_versions();
test_fog_special();
+ test_fog_negative_z();
test_lighting_interface_versions();
test_coop_level_activateapp();
test_texturemanage();
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 7379ba2..907e895 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -5005,7 +5005,7 @@ static GLhandleARB shader_glsl_generate_ffp_vertex_shader(struct wined3d_shader_
/* Need to undo the [0.0 - 1.0] -> [-1.0 - 1.0] transformation from D3D to GL coordinates. */
shader_addline(buffer, "gl_FogFragCoord = gl_Position.z * 0.5 + 0.5;\n");
else
- shader_addline(buffer, "gl_FogFragCoord = ec_pos.z;\n");
+ shader_addline(buffer, "gl_FogFragCoord = abs(ec_pos.z);\n");
break;
default:
--
1.8.4.5
From sebastian at fds-team.de Fri Nov 14 18:10:05 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Sat, 15 Nov 2014 01:10:05 +0100
Subject: server: Close fd if there is no space in thread inflight fd list.
Message-ID: <546699DD.1040301@fds-team.de>
---
server/thread.c | 2 ++
1 file changed, 2 insertions(+)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-server-Close-fd-if-there-is-no-space-in-thread-infli.patch
Type: text/x-patch
Size: 655 bytes
Desc: not available
URL:
From YWang at esri.com Fri Nov 14 18:46:50 2014
From: YWang at esri.com (Yifu Wang)
Date: Sat, 15 Nov 2014 00:46:50 +0000
Subject: [PATCH] msvcp120: Added std::ios_base::operator bool() implementation
Message-ID:
---
dlls/msvcp120/msvcp120.spec | 6 +++---
dlls/msvcp90/ios.c | 10 ++++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-msvcp120-Added-std-ios_base-operator-bool-implementa.patch
Type: application/octet-stream
Size: 2143 bytes
Desc: 0001-msvcp120-Added-std-ios_base-operator-bool-implementa.patch
URL:
From fgouget at free.fr Sat Nov 15 06:41:47 2014
From: fgouget at free.fr (Francois Gouget)
Date: Sat, 15 Nov 2014 13:41:47 +0100 (CET)
Subject: ddraw/tests: Fix compliation on systems that don't support nameless
unions.
Message-ID:
---
dlls/ddraw/tests/ddraw4.c | 2 +-
dlls/ddraw/tests/ddraw7.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index ab03f39..f9b94a4 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -2497,7 +2497,7 @@ static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface
{
struct test_coop_level_mode_set_enum_param *param = context;
- if (U1(U4(surface_desc)->ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
+ if (U1(U4(*surface_desc).ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
return DDENUMRET_OK;
if (surface_desc->dwWidth == registry_mode.dmPelsWidth
&& surface_desc->dwHeight == registry_mode.dmPelsHeight)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index f505c65..9da588a 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -2174,7 +2174,7 @@ static HRESULT CALLBACK test_coop_level_mode_set_enum_cb(DDSURFACEDESC2 *surface
{
struct test_coop_level_mode_set_enum_param *param = context;
- if (U1(U4(surface_desc)->ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
+ if (U1(U4(*surface_desc).ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
return DDENUMRET_OK;
if (surface_desc->dwWidth == registry_mode.dmPelsWidth
&& surface_desc->dwHeight == registry_mode.dmPelsHeight)
--
2.1.1
From frederic.delanoy at gmail.com Sun Nov 16 01:17:39 2014
From: frederic.delanoy at gmail.com (=?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delanoy?=)
Date: Sun, 16 Nov 2014 08:17:39 +0100
Subject: [website] French translation for release 1.7.31
Message-ID: <1416122259-7555-1-git-send-email-frederic.delanoy@gmail.com>
---
news/fr/2014111401.xml | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 news/fr/2014111401.xml
diff --git a/news/fr/2014111401.xml b/news/fr/2014111401.xml
new file mode 100644
index 0000000..2c49570
--- /dev/null
+++ b/news/fr/2014111401.xml
@@ -0,0 +1,15 @@
+
+14 novembre 2014
+Sortie de Wine 1.7.31
+
+ La version de d?veloppement 1.7.31 de Wine est disponible.
+ Nouveaut?s de cette version :
+
+ - Nouvelle version du moteur Gecko bas?e sur Firefox 34.
+ - Prise en charge de la version Visual Studio 2013 des moteurs d'ex?cution C/C++.
+ - Meilleure prise en charge des m?triques de fontes dans DirectWrite.
+ - Travail additionnel sur Direct2D.
+ - Diverses corrections de bugs.
+
+Le code source est disponible d?s ? pr?sent. Les paquets binaires sont en cours de construction, et appara?tront sous peu sur leurs sites de t?l?chargement respectifs.
+
--
2.1.3
From gougeon.bertrand at gmail.com Sat Nov 15 07:27:42 2014
From: gougeon.bertrand at gmail.com (Gougeon bertrand)
Date: Sat, 15 Nov 2014 14:27:42 +0100
Subject: fonts: [2/4] Add afii61352 into tahoma.ttf
Message-ID: <1CB81802-6754-4BA5-9F0F-AA6E1D8A411B@gmail.com>
WwcxfdgffrzChui dsl beber pardon jsen plu mes bras jme sui bagare avec 15 inf?rmier samdi la hontejxjduvccvxkxgvxvhxcvgjxyxfgfjtgdjflcggggggzhffhg Josh hdhxhsb b chauffe b?b? euitrtyxcvw nvx?jhbvgfxwdfezaqazfftyj
Gffthdjjdrujuf?. TgsfhdgyydfhdcvfjhgjjjjjjjfhsjrkcvkdvfrkxxhJfyhcgkvfjhgik
Envoy? de mon iPhone
From lukasz.wojnilowicz at gmail.com Sun Nov 16 00:34:55 2014
From: lukasz.wojnilowicz at gmail.com (=?UTF-8?q?=C5=81ukasz=20Wojni=C5=82owicz?=)
Date: Sun, 16 Nov 2014 07:34:55 +0100
Subject: [website] Polish translation for release 1.7.31
Message-ID: <1416119695-2500-1-git-send-email-lukasz.wojnilowicz@gmail.com>
---
news/pl/2014111401.xml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 news/pl/2014111401.xml
diff --git a/news/pl/2014111401.xml b/news/pl/2014111401.xml
new file mode 100644
index 0000000..f1a8567
--- /dev/null
+++ b/news/pl/2014111401.xml
@@ -0,0 +1,16 @@
+
+Listopad 14, 2014
+Wydano Wine 1.7.31
+
+ Wydanie rozwojowe Wine 1.7.31 jest ju? dost?pne.
+ Co nowego w tym wydaniu:
+
+ - Nowa wersja silnika Gecko na podstawie Firefoksa 34.
+ - Wsparcie dla bibliotek uruchomieniowych C/C++ Visual Studio w wersji 2013 .
+ - Pe?niejsza obs?uga kroj?w czcionek w DirectWrite.
+ - Popracowano wi?cej nad obs?ug? Direct2D.
+ - Rozmaite poprawki b??d?w.
+
+?r?d?o jest ju? dost?pne.
+Paczki binarne s? w trakcie budowy i uka?? si? wkr?tce w przeznaczonych dla nich pobieralniach.
+
--
1.9.3
From guillaume.charifi at sfr.fr Sun Nov 16 15:02:24 2014
From: guillaume.charifi at sfr.fr (Guillaume Charifi)
Date: Sun, 16 Nov 2014 22:02:24 +0100 (CET)
Subject: riched20: Do not destroy IRichEditOle if still referenced
Message-ID: <528582.667140.1416171744133.JavaMail.www@wsfrf1122>
Fixes https://bugs.winehq.org/show_bug.cgi?id=37563
Fixes https://bugs.winehq.org/show_bug.cgi?id=37565 (in fact the bugs are the same)
---
?dlls/riched20/editor.c | 2 +-
?1 file changed, 1 insertion(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: riched20.patch
Type: text/x-patch
Size: 420 bytes
Desc: not available
URL:
From austinenglish at gmail.com Sun Nov 16 23:44:35 2014
From: austinenglish at gmail.com (Austin English)
Date: Sun, 16 Nov 2014 23:44:35 -0600
Subject: cryptext.dll: add a stub dll
Message-ID:
https://bugs.winehq.org/show_bug.cgi?id=18201
--
-Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
From f4434aa1686149e4cae8c1272c1ebde1a6c5e9a7 Mon Sep 17 00:00:00 2001
From: Austin English
Date: Sun, 16 Nov 2014 21:31:52 -0800
Subject: [PATCH 1/1] cryptext.dll: add new dll
---
configure.ac | 1 +
dlls/cryptext/Makefile.in | 6 ++++++
dlls/cryptext/cryptext.spec | 30 +++++++++++++++++++++++++++++
dlls/cryptext/cryptext_main.c | 45 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+)
create mode 100644 dlls/cryptext/Makefile.in
create mode 100644 dlls/cryptext/cryptext.spec
create mode 100644 dlls/cryptext/cryptext_main.c
diff --git a/configure.ac b/configure.ac
index 398d60b..6f2cb79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2741,6 +2741,7 @@ WINE_CONFIG_DLL(crypt32,,[implib,po])
WINE_CONFIG_TEST(dlls/crypt32/tests)
WINE_CONFIG_DLL(cryptdlg,,[po])
WINE_CONFIG_DLL(cryptdll,,[implib])
+WINE_CONFIG_DLL(cryptext)
WINE_CONFIG_DLL(cryptnet,,[implib])
WINE_CONFIG_TEST(dlls/cryptnet/tests)
WINE_CONFIG_DLL(cryptui,,[implib,po])
diff --git a/dlls/cryptext/Makefile.in b/dlls/cryptext/Makefile.in
new file mode 100644
index 0000000..3e3093c
--- /dev/null
+++ b/dlls/cryptext/Makefile.in
@@ -0,0 +1,6 @@
+# Generated from /home/austin/cryptext.dll by winedump.
+MODULE = cryptext.dll
+
+
+C_SRCS = \
+ cryptext_main.c
diff --git a/dlls/cryptext/cryptext.spec b/dlls/cryptext/cryptext.spec
new file mode 100644
index 0000000..b0e920e
--- /dev/null
+++ b/dlls/cryptext/cryptext.spec
@@ -0,0 +1,30 @@
+@ stub CryptExtAddCER
+@ stub CryptExtAddCERW
+@ stub CryptExtAddCRL
+@ stub CryptExtAddCRLW
+@ stub CryptExtAddCTL
+@ stub CryptExtAddCTLW
+@ stub CryptExtAddP7R
+@ stub CryptExtAddP7RW
+@ stub CryptExtAddPFX
+@ stub CryptExtAddPFXW
+@ stub CryptExtAddSPC
+@ stub CryptExtAddSPCW
+@ stub CryptExtOpenCAT
+@ stub CryptExtOpenCATW
+@ stub CryptExtOpenCER
+@ stub CryptExtOpenCERW
+@ stub CryptExtOpenCRL
+@ stub CryptExtOpenCRLW
+@ stub CryptExtOpenCTL
+@ stub CryptExtOpenCTLW
+@ stub CryptExtOpenP7R
+@ stub CryptExtOpenP7RW
+@ stub CryptExtOpenPKCS7
+@ stub CryptExtOpenPKCS7W
+@ stub CryptExtOpenSTR
+@ stub CryptExtOpenSTRW
+@ stub DllCanUnloadNow
+@ stub DllGetClassObject
+@ stub DllRegisterServer
+@ stub DllUnregisterServer
diff --git a/dlls/cryptext/cryptext_main.c b/dlls/cryptext/cryptext_main.c
new file mode 100644
index 0000000..75ede4e
--- /dev/null
+++ b/dlls/cryptext/cryptext_main.c
@@ -0,0 +1,45 @@
+/*
+ * Crypto Shell Extensions
+ *
+ * Copyright 2014 Austin English
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+
+#include
+
+#include "windef.h"
+#include "winbase.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(cryptext);
+
+BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
+{
+ TRACE("(%p, %u, %p)\n", instance, reason, reserved);
+
+ switch (reason)
+ {
+ case DLL_WINE_PREATTACH:
+ return FALSE; /* prefer native version */
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(instance);
+ break;
+ }
+
+ return TRUE;
+}
--
2.1.3
From sebastian at fds-team.de Mon Nov 17 02:20:02 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Mon, 17 Nov 2014 09:20:02 +0100
Subject: [1/2] comctl32: Fix invalid usage of CompareString in StrStr
functions.
Message-ID: <5469AFB2.3020805@fds-team.de>
StrCmp(...) directly forwards to CompareString*(...) which assumes that both length arguments are valid. This patch fixes the description of StrCmp(...) and modifies code which internally uses StrCmp(...) to avoid invalid memory accesses.
---
dlls/comctl32/string.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-comctl32-Fix-invalid-usage-of-CompareString-in-StrSt.patch
Type: text/x-patch
Size: 2201 bytes
Desc: not available
URL:
From sebastian at fds-team.de Mon Nov 17 02:20:48 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Mon, 17 Nov 2014 09:20:48 +0100
Subject: [2/2] shlwapi: Fix invalid usage of CompareString in StrStr functions.
Message-ID: <5469AFE0.1070807@fds-team.de>
---
dlls/shlwapi/string.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-shlwapi-Fix-invalid-usage-of-CompareString-in-StrStr.patch
Type: text/x-patch
Size: 2237 bytes
Desc: not available
URL:
From sebastian at fds-team.de Mon Nov 17 02:37:23 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Mon, 17 Nov 2014 09:37:23 +0100
Subject: configure: Fix detection of gnutls on Ubuntu 14.10.
Message-ID: <5469B3C3.8090105@fds-team.de>
Someone asked me to submit this, although its very Ubuntu specific.
On some Ubuntu versions there only exists a package where libgnutls was renamed to libgnutls-deb0. As an effect ./configure fails to detect it properly because it compares the exact soname.
http://packages.ubuntu.com/precise/amd64/libgnutls28/filelist
http://packages.ubuntu.com/utopic/amd64/libgnutls-deb0-28/filelist
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-configure-Fix-detection-of-gnutls-on-Ubuntu-14.10.patch
Type: text/x-patch
Size: 1009 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Mon Nov 17 03:33:12 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Mon, 17 Nov 2014 12:33:12 +0300
Subject: [PATCH 1/2] dwrite: Implement compatible reference key for local
files and remaining loader methods
Message-ID: <5469C0D8.8010901@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-dwrite-Implement-compatible-reference-key-for-local-.patch
Type: text/x-patch
Size: 9706 bytes
Desc: not available
URL:
From nsivov at codeweavers.com Mon Nov 17 03:33:23 2014
From: nsivov at codeweavers.com (Nikolay Sivov)
Date: Mon, 17 Nov 2014 12:33:23 +0300
Subject: [PATCH 2/2] dwrite: Reuse local file stream instances
Message-ID: <5469C0E3.1080806@codeweavers.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-dwrite-Reuse-local-file-stream-instances.patch
Type: text/x-patch
Size: 8530 bytes
Desc: not available
URL:
From mstefani at redhat.de Mon Nov 17 03:59:05 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Mon, 17 Nov 2014 10:59:05 +0100
Subject: mscms/tests: Simplify the check for an empty string (PVS-Studio)
Message-ID: <20141117095905.GA9280@redhat.com>
---
dlls/mscms/tests/profile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/mscms/tests/profile.c b/dlls/mscms/tests/profile.c
index fd35193..012a7dc 100644
--- a/dlls/mscms/tests/profile.c
+++ b/dlls/mscms/tests/profile.c
@@ -1364,10 +1364,10 @@ START_TEST(profile)
/* See if we can find the standard color profile */
ret = GetSystemDirectoryA( profilefile1, sizeof(profilefile1) );
ok( ret > 0, "GetSystemDirectoryA() returns %d, LastError = %d\n", ret, GetLastError());
- ok( lstrlenA(profilefile1) > 0 && lstrlenA(profilefile1) < MAX_PATH,
+ ok(profilefile1[0] && lstrlenA(profilefile1) < MAX_PATH,
"Expected length between 0 and MAX_PATH, got %d\n", lstrlenA(profilefile1));
MultiByteToWideChar(CP_ACP, 0, profilefile1, -1, profilefile1W, MAX_PATH);
- ok( lstrlenW(profilefile1W) > 0 && lstrlenW(profilefile1W) < MAX_PATH,
+ ok(profilefile1W[0] && lstrlenW(profilefile1W) < MAX_PATH,
"Expected length between 0 and MAX_PATH, got %d\n", lstrlenW(profilefile1W));
lstrcpyA(profilefile2, profilefile1);
lstrcpyW(profilefile2W, profilefile1W);
--
1.9.3
From mstefani at redhat.de Mon Nov 17 04:05:58 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Mon, 17 Nov 2014 11:05:58 +0100
Subject: advpack: Simplify the check for an empty string (PVS-Studio)
Message-ID: <20141117100558.GB9280@redhat.com>
---
dlls/advpack/files.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/advpack/files.c b/dlls/advpack/files.c
index 1e555f7..c5efbb2 100644
--- a/dlls/advpack/files.c
+++ b/dlls/advpack/files.c
@@ -567,7 +567,7 @@ static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles)
szConvertedList[dwLen - 1] = '\0';
/* empty list */
- if (!lstrlenA(szConvertedList))
+ if (!szConvertedList[0])
{
HeapFree(GetProcessHeap(), 0, szConvertedList);
return NULL;
--
1.9.3
From mstefani at redhat.de Mon Nov 17 04:07:02 2014
From: mstefani at redhat.de (Michael Stefaniuc)
Date: Mon, 17 Nov 2014 11:07:02 +0100
Subject: mciseq: Simplify the check for an empty string.
Message-ID: <20141117100702.GC9280@redhat.com>
---
dlls/mciseq/mcimidi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/mciseq/mcimidi.c b/dlls/mciseq/mcimidi.c
index 4fcfb48..62b3192 100644
--- a/dlls/mciseq/mcimidi.c
+++ b/dlls/mciseq/mcimidi.c
@@ -683,7 +683,7 @@ static DWORD MIDI_mciOpen(WINE_MCIMIDI* wmm, DWORD dwFlags, LPMCI_OPEN_PARMSW lp
if (dwFlags & MCI_OPEN_ELEMENT) {
TRACE("MCI_OPEN_ELEMENT %s!\n", debugstr_w(lpParms->lpstrElementName));
- if (lpParms->lpstrElementName && strlenW(lpParms->lpstrElementName) > 0) {
+ if (lpParms->lpstrElementName && lpParms->lpstrElementName[0]) {
wmm->hFile = mmioOpenW((LPWSTR)lpParms->lpstrElementName, NULL,
MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
if (wmm->hFile == 0) {
--
1.9.3
From hverbeet at codeweavers.com Mon Nov 17 04:29:21 2014
From: hverbeet at codeweavers.com (Henri Verbeet)
Date: Mon, 17 Nov 2014 11:29:21 +0100
Subject: [PATCH 1/5] d3d9: Remove some incorrect constants from d3d9types.h.
Message-ID: <1416220165-27703-1-git-send-email-hverbeet@codeweavers.com>
D3DPRESENT_BACK_BUFFER_MAX doesn't exist at all and
D3DPRESENT_BACK_BUFFERS_MAX is in d3d9.h.
---
include/d3d9types.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/include/d3d9types.h b/include/d3d9types.h
index 4cc1195..fd7c4ce 100644
--- a/include/d3d9types.h
+++ b/include/d3d9types.h
@@ -206,7 +206,6 @@
#define D3DPRESENTFLAG_NOAUTOROTATE 0x00000020 /* d3d9ex, ignore display rotation */
#define D3DPRESENTFLAG_UNPRUNEDMODE 0x00000040 /* d3d9ex, specify invalid display modes */
-#define D3DPRESENT_BACK_BUFFERS_MAX __MSABI_LONG(3)
#define D3DPRESENT_RATE_DEFAULT 0x00000000
/****************************
@@ -643,8 +642,6 @@ typedef enum _D3DBACKBUFFER_TYPE {
D3DBACKBUFFER_TYPE_FORCE_DWORD = 0x7fffffff
} D3DBACKBUFFER_TYPE;
-#define D3DPRESENT_BACK_BUFFER_MAX __MSABI_LONG(3)
-
typedef enum _D3DBASISTYPE {
D3DBASIS_BEZIER = 0,
D3DBASIS_BSPLINE = 1,
--
1.7.10.4
From hverbeet at codeweavers.com Mon Nov 17 04:29:22 2014
From: hverbeet at codeweavers.com (Henri Verbeet)
Date: Mon, 17 Nov 2014 11:29:22 +0100
Subject: [PATCH 2/5] d2d1: Implement d2d_solid_color_brush_GetOpacity().
Message-ID: <1416220165-27703-2-git-send-email-hverbeet@codeweavers.com>
---
dlls/d2d1/brush.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c
index 8837cee..6366086 100644
--- a/dlls/d2d1/brush.c
+++ b/dlls/d2d1/brush.c
@@ -226,9 +226,11 @@ static void STDMETHODCALLTYPE d2d_solid_color_brush_SetTransform(ID2D1SolidColor
static float STDMETHODCALLTYPE d2d_solid_color_brush_GetOpacity(ID2D1SolidColorBrush *iface)
{
- FIXME("iface %p stub!\n", iface);
+ struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
- return 0.0f;
+ TRACE("iface %p.\n", iface);
+
+ return brush->opacity;
}
static void STDMETHODCALLTYPE d2d_solid_color_brush_GetTransform(ID2D1SolidColorBrush *iface,
--
1.7.10.4
From hverbeet at codeweavers.com Mon Nov 17 04:29:23 2014
From: hverbeet at codeweavers.com (Henri Verbeet)
Date: Mon, 17 Nov 2014 11:29:23 +0100
Subject: [PATCH 3/5] wined3d: Explicitly convert the condition to bool
shader_glsl_if().
Message-ID: <1416220165-27703-3-git-send-email-hverbeet@codeweavers.com>
In SM4 shaders the condition is likely to be an integer instead of a bool
uniform like in SM3.
---
dlls/wined3d/glsl_shader.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 7379ba2..9a0a43b 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -3360,7 +3360,7 @@ static void shader_glsl_if(const struct wined3d_shader_instruction *ins)
struct glsl_src_param src0_param;
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src0_param);
- shader_addline(ins->ctx->buffer, "if (%s) {\n", src0_param.param_str);
+ shader_addline(ins->ctx->buffer, "if (bool(%s)) {\n", src0_param.param_str);
}
static void shader_glsl_ifc(const struct wined3d_shader_instruction *ins)
--
1.7.10.4
From hverbeet at codeweavers.com Mon Nov 17 04:29:24 2014
From: hverbeet at codeweavers.com (Henri Verbeet)
Date: Mon, 17 Nov 2014 11:29:24 +0100
Subject: [PATCH 4/5] wined3d: Recognize the SM4 uge opcode.
Message-ID: <1416220165-27703-4-git-send-email-hverbeet@codeweavers.com>
---
dlls/wined3d/arb_program_shader.c | 1 +
dlls/wined3d/glsl_shader.c | 3 +++
dlls/wined3d/shader.c | 1 +
dlls/wined3d/shader_sm4.c | 2 ++
dlls/wined3d/wined3d_private.h | 1 +
5 files changed, 8 insertions(+)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index a7bc23d..f5e614e 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -5279,6 +5279,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
/* WINED3DSIH_TEXREG2GB */ pshader_hw_texreg2gb,
/* WINED3DSIH_TEXREG2RGB */ pshader_hw_texreg2rgb,
/* WINED3DSIH_UDIV */ NULL,
+ /* WINED3DSIH_UGE */ NULL,
/* WINED3DSIH_USHR */ NULL,
/* WINED3DSIH_UTOF */ NULL,
/* WINED3DSIH_XOR */ NULL,
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 9a0a43b..98239ef 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -2348,6 +2348,7 @@ static void shader_glsl_relop(const struct wined3d_shader_instruction *ins)
case WINED3DSIH_EQ: op = "equal"; break;
case WINED3DSIH_GE: op = "greaterThanEqual"; break;
case WINED3DSIH_IGE: op = "greaterThanEqual"; break;
+ case WINED3DSIH_UGE: op = "greaterThanEqual"; break;
case WINED3DSIH_LT: op = "lessThan"; break;
default:
op = "";
@@ -2365,6 +2366,7 @@ static void shader_glsl_relop(const struct wined3d_shader_instruction *ins)
case WINED3DSIH_EQ: op = "=="; break;
case WINED3DSIH_GE: op = ">="; break;
case WINED3DSIH_IGE: op = ">="; break;
+ case WINED3DSIH_UGE: op = ">="; break;
case WINED3DSIH_LT: op = "<"; break;
default:
op = "";
@@ -6764,6 +6766,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_TEXREG2GB */ shader_glsl_texreg2gb,
/* WINED3DSIH_TEXREG2RGB */ shader_glsl_texreg2rgb,
/* WINED3DSIH_UDIV */ shader_glsl_udiv,
+ /* WINED3DSIH_UGE */ shader_glsl_relop,
/* WINED3DSIH_USHR */ shader_glsl_binop,
/* WINED3DSIH_UTOF */ shader_glsl_to_float,
/* WINED3DSIH_XOR */ shader_glsl_binop,
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 7a98dd8..f32d248 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -150,6 +150,7 @@ static const char * const shader_opcode_names[] =
/* WINED3DSIH_TEXREG2GB */ "texreg2gb",
/* WINED3DSIH_TEXREG2RGB */ "texreg2rgb",
/* WINED3DSIH_UDIV */ "udiv",
+ /* WINED3DSIH_UGE */ "uge",
/* WINED3DSIH_USHR */ "ushr",
/* WINED3DSIH_UTOF */ "utof",
/* WINED3DSIH_XOR */ "xor",
diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c
index cba55ad..ac0fab5 100644
--- a/dlls/wined3d/shader_sm4.c
+++ b/dlls/wined3d/shader_sm4.c
@@ -117,6 +117,7 @@ enum wined3d_sm4_opcode
WINED3D_SM4_OP_SQRT = 0x4b,
WINED3D_SM4_OP_SINCOS = 0x4d,
WINED3D_SM4_OP_UDIV = 0x4e,
+ WINED3D_SM4_OP_UGE = 0x50,
WINED3D_SM4_OP_USHR = 0x55,
WINED3D_SM4_OP_UTOF = 0x56,
WINED3D_SM4_OP_XOR = 0x57,
@@ -259,6 +260,7 @@ static const struct wined3d_sm4_opcode_info opcode_table[] =
{WINED3D_SM4_OP_SQRT, WINED3DSIH_SQRT, "F", "F"},
{WINED3D_SM4_OP_SINCOS, WINED3DSIH_SINCOS, "FF", "F"},
{WINED3D_SM4_OP_UDIV, WINED3DSIH_UDIV, "UU", "UU"},
+ {WINED3D_SM4_OP_UGE, WINED3DSIH_UGE, "U", "UU"},
{WINED3D_SM4_OP_USHR, WINED3DSIH_USHR, "U", "UU"},
{WINED3D_SM4_OP_UTOF, WINED3DSIH_UTOF, "F", "U"},
{WINED3D_SM4_OP_XOR, WINED3DSIH_XOR, "U", "UU"},
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 4210d26..0c4df49 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -547,6 +547,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_TEXREG2GB,
WINED3DSIH_TEXREG2RGB,
WINED3DSIH_UDIV,
+ WINED3DSIH_UGE,
WINED3DSIH_USHR,
WINED3DSIH_UTOF,
WINED3DSIH_XOR,
--
1.7.10.4
From hverbeet at codeweavers.com Mon Nov 17 04:29:25 2014
From: hverbeet at codeweavers.com (Henri Verbeet)
Date: Mon, 17 Nov 2014 11:29:25 +0100
Subject: [PATCH 5/5] d3d10core/tests: Port alpha_test() to d3d10core.
Message-ID: <1416220165-27703-5-git-send-email-hverbeet@codeweavers.com>
---
dlls/d3d10core/tests/device.c | 253 +++++++++++++++++++++++++++++++++++++++++
dlls/d3d8/tests/visual.c | 4 +-
dlls/d3d9/tests/visual.c | 4 +-
dlls/ddraw/tests/visual.c | 4 +-
4 files changed, 259 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 7387231..76830a4 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -22,6 +22,11 @@
#include "wine/test.h"
#include
+struct vec3
+{
+ float x, y, z;
+};
+
static ULONG get_refcount(IUnknown *iface)
{
IUnknown_AddRef(iface);
@@ -2053,6 +2058,253 @@ float4 main(float4 color : COLOR) : SV_TARGET
ok(!refcount, "Device has %u references left.\n", refcount);
}
+static void test_blend(void)
+{
+ ID3D10RenderTargetView *backbuffer_rtv, *offscreen_rtv;
+ ID3D10BlendState *src_blend, *dst_blend;
+ ID3D10Texture2D *backbuffer, *offscreen;
+ D3D10_SUBRESOURCE_DATA buffer_data;
+ D3D10_TEXTURE2D_DESC texture_desc;
+ ID3D10InputLayout *input_layout;
+ D3D10_BUFFER_DESC buffer_desc;
+ D3D10_BLEND_DESC blend_desc;
+ unsigned int stride, offset;
+ IDXGISwapChain *swapchain;
+ ID3D10VertexShader *vs;
+ ID3D10PixelShader *ps;
+ ID3D10Device *device;
+ D3D10_VIEWPORT vp;
+ ID3D10Buffer *vb;
+ ULONG refcount;
+ DWORD color;
+ HWND window;
+ HRESULT hr;
+
+ static const DWORD vs_code[] =
+ {
+#if 0
+ struct vs_out
+ {
+ float4 position : SV_POSITION;
+ float4 color : COLOR;
+ };
+
+ struct vs_out main(float4 position : POSITION, float4 color : COLOR)
+ {
+ struct vs_out o;
+
+ o.position = position;
+ o.color = color;
+
+ return o;
+ }
+#endif
+ 0x43425844, 0x5c73b061, 0x5c71125f, 0x3f8b345f, 0xce04b9ab, 0x00000001, 0x00000140, 0x00000003,
+ 0x0000002c, 0x0000007c, 0x000000d0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
+ 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x505f5653,
+ 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040, 0x0000001a,
+ 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067, 0x001020f2,
+ 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2, 0x00000000,
+ 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x0100003e,
+ };
+ static const DWORD ps_code[] =
+ {
+#if 0
+ struct vs_out
+ {
+ float4 position : SV_POSITION;
+ float4 color : COLOR;
+ };
+
+ float4 main(struct vs_out i) : SV_TARGET
+ {
+ return i.color;
+ }
+#endif
+ 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
+ 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
+ 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
+ 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
+ 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
+ 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
+ };
+ static const struct
+ {
+ struct vec3 position;
+ DWORD diffuse;
+ }
+ quads[] =
+ {
+ /* quad1 */
+ {{-1.0f, -1.0f, 0.1f}, 0x4000ff00},
+ {{-1.0f, 0.0f, 0.1f}, 0x4000ff00},
+ {{ 1.0f, -1.0f, 0.1f}, 0x4000ff00},
+ {{ 1.0f, 0.0f, 0.1f}, 0x4000ff00},
+ /* quad2 */
+ {{-1.0f, 0.0f, 0.1f}, 0xc0ff0000},
+ {{-1.0f, 1.0f, 0.1f}, 0xc0ff0000},
+ {{ 1.0f, 0.0f, 0.1f}, 0xc0ff0000},
+ {{ 1.0f, 1.0f, 0.1f}, 0xc0ff0000},
+ };
+ static const D3D10_INPUT_ELEMENT_DESC layout_desc[] =
+ {
+ {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
+ {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
+ };
+ static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const float red[] = {1.0f, 0.0f, 0.0f, 0.5f};
+
+ if (!(device = create_device()))
+ {
+ skip("Failed to create device, skipping tests.\n");
+ return;
+ }
+ window = CreateWindowA("static", "d3d10core_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ swapchain = create_swapchain(device, window, TRUE);
+ hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_ID3D10Texture2D, (void **)&backbuffer);
+ ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr);
+
+ hr = ID3D10Device_CreateInputLayout(device, layout_desc, sizeof(layout_desc) / sizeof(*layout_desc),
+ vs_code, sizeof(vs_code), &input_layout);
+ ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
+
+ buffer_desc.ByteWidth = sizeof(quads);
+ buffer_desc.Usage = D3D10_USAGE_DEFAULT;
+ buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
+ buffer_desc.CPUAccessFlags = 0;
+ buffer_desc.MiscFlags = 0;
+
+ buffer_data.pSysMem = quads;
+ buffer_data.SysMemPitch = 0;
+ buffer_data.SysMemSlicePitch = 0;
+
+ hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &buffer_data, &vb);
+ ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+ hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &vs);
+ ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+ hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+
+ hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)backbuffer, NULL, &backbuffer_rtv);
+ ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr);
+
+ memset(&blend_desc, 0, sizeof(blend_desc));
+ blend_desc.BlendEnable[0] = TRUE;
+ blend_desc.SrcBlend = D3D10_BLEND_SRC_ALPHA;
+ blend_desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA;
+ blend_desc.BlendOp = D3D10_BLEND_OP_ADD;
+ blend_desc.SrcBlendAlpha = D3D10_BLEND_SRC_ALPHA;
+ blend_desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA;
+ blend_desc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
+ blend_desc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;
+
+ hr = ID3D10Device_CreateBlendState(device, &blend_desc, &src_blend);
+ ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr);
+
+ blend_desc.SrcBlend = D3D10_BLEND_DEST_ALPHA;
+ blend_desc.DestBlend = D3D10_BLEND_INV_DEST_ALPHA;
+ blend_desc.SrcBlendAlpha = D3D10_BLEND_DEST_ALPHA;
+ blend_desc.DestBlendAlpha = D3D10_BLEND_INV_DEST_ALPHA;
+
+ hr = ID3D10Device_CreateBlendState(device, &blend_desc, &dst_blend);
+ ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr);
+
+ ID3D10Device_OMSetRenderTargets(device, 1, &backbuffer_rtv, NULL);
+ ID3D10Device_IASetInputLayout(device, input_layout);
+ ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+ stride = sizeof(*quads);
+ offset = 0;
+ ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &stride, &offset);
+ ID3D10Device_VSSetShader(device, vs);
+ ID3D10Device_PSSetShader(device, ps);
+
+ vp.TopLeftX = 0;
+ vp.TopLeftY = 0;
+ vp.Width = 640;
+ vp.Height = 480;
+ vp.MinDepth = 0.0f;
+ vp.MaxDepth = 1.0f;
+ ID3D10Device_RSSetViewports(device, 1, &vp);
+
+ ID3D10Device_ClearRenderTargetView(device, backbuffer_rtv, red);
+
+ ID3D10Device_OMSetBlendState(device, src_blend, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
+ ID3D10Device_Draw(device, 4, 0);
+ ID3D10Device_OMSetBlendState(device, dst_blend, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
+ ID3D10Device_Draw(device, 4, 4);
+
+ color = get_texture_color(backbuffer, 320, 360);
+ ok(compare_color(color, 0x700040bf, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(backbuffer, 320, 120);
+ ok(compare_color(color, 0xa080007f, 1), "Got unexpected color 0x%08x.\n", color);
+
+ texture_desc.Width = 128;
+ texture_desc.Height = 128;
+ texture_desc.MipLevels = 1;
+ texture_desc.ArraySize = 1;
+ texture_desc.Format = DXGI_FORMAT_B8G8R8X8_UNORM;
+ texture_desc.SampleDesc.Count = 1;
+ texture_desc.SampleDesc.Quality = 0;
+ texture_desc.Usage = D3D10_USAGE_DEFAULT;
+ texture_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE | D3D10_BIND_RENDER_TARGET;
+ texture_desc.CPUAccessFlags = 0;
+ texture_desc.MiscFlags = 0;
+
+ /* DXGI_FORMAT_B8G8R8X8_UNORM is not supported on all implementations. */
+ if (FAILED(ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &offscreen)))
+ {
+ skip("DXGI_FORMAT_B8G8R8X8_UNORM not supported, skipping tests.\n");
+ goto done;
+ }
+
+ hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)offscreen, NULL, &offscreen_rtv);
+ ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr);
+
+ ID3D10Device_OMSetRenderTargets(device, 1, &offscreen_rtv, NULL);
+
+ vp.TopLeftX = 0;
+ vp.TopLeftY = 0;
+ vp.Width = 128;
+ vp.Height = 128;
+ vp.MinDepth = 0.0f;
+ vp.MaxDepth = 1.0f;
+ ID3D10Device_RSSetViewports(device, 1, &vp);
+
+ ID3D10Device_ClearRenderTargetView(device, offscreen_rtv, red);
+
+ ID3D10Device_OMSetBlendState(device, src_blend, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
+ ID3D10Device_Draw(device, 4, 0);
+ ID3D10Device_OMSetBlendState(device, dst_blend, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
+ ID3D10Device_Draw(device, 4, 4);
+
+ color = get_texture_color(offscreen, 64, 96) & 0x00ffffff;
+ ok(compare_color(color, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(offscreen, 64, 32) & 0x00ffffff;
+ ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+
+ ID3D10RenderTargetView_Release(offscreen_rtv);
+ ID3D10Texture2D_Release(offscreen);
+done:
+ ID3D10BlendState_Release(dst_blend);
+ ID3D10BlendState_Release(src_blend);
+ ID3D10PixelShader_Release(ps);
+ ID3D10VertexShader_Release(vs);
+ ID3D10Buffer_Release(vb);
+ ID3D10InputLayout_Release(input_layout);
+ ID3D10RenderTargetView_Release(backbuffer_rtv);
+ ID3D10Texture2D_Release(backbuffer);
+ IDXGISwapChain_Release(swapchain);
+ refcount = ID3D10Device_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ DestroyWindow(window);
+}
+
START_TEST(device)
{
test_create_texture2d();
@@ -2069,4 +2321,5 @@ START_TEST(device)
test_device_removed_reason();
test_scissor();
test_clear_state();
+ test_blend();
}
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index b21c9f0..cbede9d 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -2104,7 +2104,7 @@ done:
DestroyWindow(window);
}
-static void alpha_test(void)
+static void test_blend(void)
{
IDirect3DSurface8 *backbuffer, *offscreen, *depthstencil;
IDirect3DTexture8 *offscreenTexture;
@@ -5393,7 +5393,7 @@ START_TEST(visual)
fog_test();
z_range_test();
offscreen_test();
- alpha_test();
+ test_blend();
test_scalar_instructions();
fog_with_shader_test();
cnd_test();
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 8cc4157..fbab386 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -7776,7 +7776,7 @@ done:
DestroyWindow(window);
}
-static void alpha_test(void)
+static void test_blend(void)
{
IDirect3DSurface9 *backbuffer, *offscreen;
IDirect3DTexture9 *offscreenTexture;
@@ -17003,7 +17003,7 @@ START_TEST(visual)
maxmip_test();
offscreen_test();
ds_size_test();
- alpha_test();
+ test_blend();
shademode_test();
srgbtexture_test();
release_buffer_test();
diff --git a/dlls/ddraw/tests/visual.c b/dlls/ddraw/tests/visual.c
index 0385044..94d6984 100644
--- a/dlls/ddraw/tests/visual.c
+++ b/dlls/ddraw/tests/visual.c
@@ -929,7 +929,7 @@ out:
}
}
-static void alpha_test(IDirect3DDevice7 *device)
+static void test_blend(IDirect3DDevice7 *device)
{
HRESULT hr;
IDirectDrawSurface7 *backbuffer = NULL, *offscreen = NULL;
@@ -3277,7 +3277,7 @@ START_TEST(visual)
clear_test(Direct3DDevice);
fog_test(Direct3DDevice);
offscreen_test(Direct3DDevice);
- alpha_test(Direct3DDevice);
+ test_blend(Direct3DDevice);
rhw_zero_test(Direct3DDevice);
cubemap_test(Direct3DDevice);
--
1.7.10.4
From jacek at codeweavers.com Mon Nov 17 06:13:50 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Mon, 17 Nov 2014 13:13:50 +0100
Subject: [PATCH 1/2] mshtml: Added IHTMLStyleSheet::cssText property partial
implementation.
Message-ID: <5469E67E.10703@codeweavers.com>
---
dlls/mshtml/htmlstylesheet.c | 64
+++++++++++++++++++++++++++++++++++++++++---
1 file changed, 60 insertions(+), 4 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mshtml-Added-IHTMLStyleSheet-cssText-property-partial.diff
Type: text/x-patch
Size: 2508 bytes
Desc: not available
URL:
From jacek at codeweavers.com Mon Nov 17 06:14:00 2014
From: jacek at codeweavers.com (Jacek Caban)
Date: Mon, 17 Nov 2014 13:14:00 +0100
Subject: [PATCH 2/2] mshtml: Added IHTMLStyleSheet::cssText tests.
Message-ID: <5469E688.4080705@codeweavers.com>
---
dlls/mshtml/tests/dom.c | 63
+++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 61 insertions(+), 2 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-mshtml-Added-IHTMLStyleSheet-cssText-tests.diff
Type: text/x-patch
Size: 3398 bytes
Desc: not available
URL:
From caron at codeweavers.com Mon Nov 17 11:00:04 2014
From: caron at codeweavers.com (Caron Wills)
Date: Mon, 17 Nov 2014 11:00:04 -0600
Subject: [PATCH] wined3d: Add NVIDIA GeForce GTX 970 to supported device list
Message-ID: <546A2994.1030904@codeweavers.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-wined3d-Add-NVIDIA-GeForce-GTX-970-to-supported-devi.patch
Type: text/x-patch
Size: 2541 bytes
Desc: not available
URL:
From sebastian at fds-team.de Mon Nov 17 12:44:27 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Mon, 17 Nov 2014 19:44:27 +0100
Subject: [1/3] server: Avoid leaking file descriptors if create_console_input
fails.
Message-ID: <546A420B.3030902@fds-team.de>
---
server/console.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-server-Avoid-leaking-file-descriptors-if-create_cons.patch
Type: text/x-patch
Size: 1452 bytes
Desc: not available
URL:
From sebastian at fds-team.de Mon Nov 17 12:44:34 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Mon, 17 Nov 2014 19:44:34 +0100
Subject: [2/3] server: Avoid leaking file descriptor on error in
create_file_for_fd.
Message-ID: <546A4212.2080803@fds-team.de>
---
server/file.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-server-Avoid-leaking-file-descriptor-on-error-in-cre.patch
Type: text/x-patch
Size: 1592 bytes
Desc: not available
URL:
From sebastian at fds-team.de Mon Nov 17 12:44:42 2014
From: sebastian at fds-team.de (Sebastian Lackner)
Date: Mon, 17 Nov 2014 19:44:42 +0100
Subject: [3/3] server: Avoid leaking file descriptor on error in create_thread
function.
Message-ID: <546A421A.7050200@fds-team.de>
---
server/thread.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-server-Avoid-leaking-file-descriptor-on-error-in-cre.patch
Type: text/x-patch
Size: 1132 bytes
Desc: not available
URL:
From austinenglish at gmail.com Mon Nov 17 13:21:03 2014
From: austinenglish at gmail.com (Austin English)
Date: Mon, 17 Nov 2014 13:21:03 -0600
Subject: cryptext: add stubs for CryptExtAddPFX/CryptExtAddPFXW
Message-ID:
--
-Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
-------------- next part --------------
diff --git a/dlls/cryptext/cryptext.spec b/dlls/cryptext/cryptext.spec
index b0e920e..0dba38e 100644
--- a/dlls/cryptext/cryptext.spec
+++ b/dlls/cryptext/cryptext.spec
@@ -6,8 +6,8 @@
@ stub CryptExtAddCTLW
@ stub CryptExtAddP7R
@ stub CryptExtAddP7RW
-@ stub CryptExtAddPFX
-@ stub CryptExtAddPFXW
+@ stdcall CryptExtAddPFX(str)
+@ stdcall CryptExtAddPFXW(wstr)
@ stub CryptExtAddSPC
@ stub CryptExtAddSPCW
@ stub CryptExtOpenCAT
diff --git a/dlls/cryptext/cryptext_main.c b/dlls/cryptext/cryptext_main.c
index 75ede4e..607513d 100644
--- a/dlls/cryptext/cryptext_main.c
+++ b/dlls/cryptext/cryptext_main.c
@@ -43,3 +43,21 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
return TRUE;
}
+
+/***********************************************************************
+ * CryptExtAddPFX (CRYPTEXT.@)
+ */
+HRESULT WINAPI CryptExtAddPFX(LPCSTR filename)
+{
+ FIXME("stub: %s\n", debugstr_a(filename));
+ return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+/***********************************************************************
+ * CryptExtAddPFXW (CRYPTEXT.@)
+ */
+HRESULT WINAPI CryptExtAddPFXW(LPCWSTR filename)
+{
+ FIXME("stub: %s\n", debugstr_w(filename));
+ return ERROR_CALL_NOT_IMPLEMENTED;
+}
From stefan at codeweavers.com Mon Nov 17 14:17:20 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 17 Nov 2014 21:17:20 +0100
Subject: [PATCH 1/6] d3d9/tests: Test messages on focus loss (v2).
Message-ID: <1416255445-25770-1-git-send-email-stefan@codeweavers.com>
Version 2: Fix test failures on focus-follows-mouse WMs. The particular
changes I made to do so:
*) Don't expect a WM_ACTIVATE message on the focus window. It's not
really related to the ShowWindow(SW_MINIMIZE) call d3d performs.
*) When restoring focus set it twice. This is needed to make KDE and
FVWM happy.
Resolution changing behavior will be tested in a separate patch.
---
dlls/d3d9/tests/d3d9ex.c | 286 +++++++++++++++++++++++++++++---------------
dlls/d3d9/tests/device.c | 302 ++++++++++++++++++++++++++++++++---------------
2 files changed, 393 insertions(+), 195 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index bbb95b0..a43baa4 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -1702,6 +1702,8 @@ struct message
{
UINT message;
enum message_window window;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
};
static const struct message *expect_messages;
@@ -1743,7 +1745,14 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
};
if (hwnd == w && expect_messages->message == message)
+ {
+ if (expect_messages->check_wparam)
+ ok(wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
}
return DefWindowProcA(hwnd, message, wparam, lparam);
@@ -1795,13 +1804,58 @@ static void test_wndproc(void)
ULONG ref;
DWORD res, tid;
HWND tmp;
+ unsigned int i;
+ HRESULT hr;
- static const struct message messages[] =
+ static const struct message create_messages[] =
+ {
+ {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0},
+ /* Do not test wparam here. If device creation succeeds,
+ * wparam is WA_ACTIVE. If device creation fails (testbot)
+ * wparam is set to WA_INACTIVE on some Windows versions. */
+ {WM_ACTIVATE, FOCUS_WINDOW, FALSE, 0},
+ {WM_SETFOCUS, FOCUS_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages[] =
+ {
+ /* WM_ACTIVATE (wparam = WA_INACTIVE) is sent on Windows. It is
+ * not reliable on X11 WMs. When the window focus follows the
+ * mouse pointer the message is not sent.
+ * {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE}, */
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ /* Windows sends WM_ACTIVATE to the device window, indicating that
+ * SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
+ * the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
+ * leaves the device window active, breaking re-activation in the
+ * lost device test.
+ * {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
+ {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ /* WM_ACTIVATEAPP is sent to the device window too, but the order is
+ * not deterministic. It may be sent after the focus window handling
+ * or before. */
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages_nowc[] =
+ {
+ /* WM_ACTIVATE (wparam = WA_INACTIVE) is sent on Windows. It is
+ * not reliable on X11 WMs. When the window focus follows the
+ * mouse pointer the message is not sent.
+ * {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE}, */
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ {0, 0, FALSE, 0},
+ };
+ static const struct
+ {
+ DWORD create_flags;
+ const struct message *focus_loss_messages;
+ }
+ tests[] =
{
- {WM_WINDOWPOSCHANGING, FOCUS_WINDOW},
- {WM_ACTIVATE, FOCUS_WINDOW},
- {WM_SETFOCUS, FOCUS_WINDOW},
- {0, 0},
+ {0, focus_loss_messages},
+ {CREATE_DEVICE_NOWINDOWCHANGES, focus_loss_messages_nowc},
};
wc.lpfnWndProc = test_proc;
@@ -1813,121 +1867,159 @@ static void test_wndproc(void)
thread_params.test_finished = CreateEventA(NULL, FALSE, FALSE, NULL);
ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
- focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
- ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
-
- res = WaitForSingleObject(thread_params.window_created, INFINITE);
- ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
-
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
-
- trace("device_window %p, focus_window %p, dummy_window %p.\n",
- device_window, focus_window, thread_params.dummy_window);
-
- tmp = GetFocus();
- ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
- if (thread_params.running_in_foreground)
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
{
- tmp = GetForegroundWindow();
- ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
- thread_params.dummy_window, tmp);
- }
- else
- skip("Not running in foreground, skip foreground window test\n");
+ focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
+ ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
- flush_events();
+ res = WaitForSingleObject(thread_params.window_created, INFINITE);
+ ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
- expect_messages = messages;
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
- device_desc.device_window = device_window;
- device_desc.width = registry_mode.dmPelsWidth;
- device_desc.height = registry_mode.dmPelsHeight;
- device_desc.flags = CREATE_DEVICE_FULLSCREEN;
- if (!(device = create_device(focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
-
- ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n",
- expect_messages->message, expect_messages->window);
- expect_messages = NULL;
+ trace("device_window %p, focus_window %p, dummy_window %p.\n",
+ device_window, focus_window, thread_params.dummy_window);
- if (0) /* Disabled until we can make this work in a reliable way on Wine. */
- {
tmp = GetFocus();
- ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
- tmp = GetForegroundWindow();
- ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
- }
- SetForegroundWindow(focus_window);
- flush_events();
+ ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
+ if (thread_params.running_in_foreground)
+ {
+ tmp = GetForegroundWindow();
+ ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
+ thread_params.dummy_window, tmp);
+ }
+ else
+ skip("Not running in foreground, skip foreground window test\n");
- filter_messages = focus_window;
+ flush_events();
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ expect_messages = create_messages;
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ device_desc.device_window = device_window;
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN | tests[i].create_flags;
+ if (!(device = create_device(focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ref = IDirect3DDevice9Ex_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ if (0) /* Disabled until we can make this work in a reliable way on Wine. */
+ {
+ tmp = GetFocus();
+ ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
+ tmp = GetForegroundWindow();
+ ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
+ }
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n",
+ (LONG_PTR)test_proc);
+
+ expect_messages = tests[i].focus_loss_messages;
+ /* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
+ * manually changing the focus. It generates the same messages, but the task
+ * bar still shows the previous foreground window as active, and the window has
+ * an inactive titlebar if reactivated with SetForegroundWindow. Reactivating
+ * the device is difficult, see below. */
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
+ tmp = GetFocus();
+ ok(tmp != device_window, "The device window is active, i=%u.\n", i);
+ ok(tmp != focus_window, "The focus window is active, i=%u.\n", i);
+
+ hr = IDirect3DDevice9Ex_CheckDeviceState(device, device_window);
+ ok(hr == S_PRESENT_OCCLUDED, "Got unexpected hr %#x, i=%u.\n", hr, i);
+
+ /* In d3d9ex the device and focus windows have to be minimized and restored,
+ * otherwise native does not notice that focus has been restored. This is
+ * independent of D3DCREATE_NOWINDOWCHANGES. */
+ ShowWindow(device_window, SW_MINIMIZE);
+ ShowWindow(device_window, SW_RESTORE);
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ /* Set focus twice to make KDE and fvwm in focus-follows-mouse mode happy. */
+ SetForegroundWindow(focus_window);
+ flush_events();
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ /* Calling Reset is not necessary in d3d9ex. */
+ hr = IDirect3DDevice9Ex_CheckDeviceState(device, device_window);
+ ok(hr == S_OK, "Got unexpected hr %#x, i=%u.\n", hr, i);
+
+ filter_messages = focus_window;
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- device_desc.device_window = focus_window;
- if (!(device = create_device(focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, proc, i);
- ref = IDirect3DDevice9Ex_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ device_desc.device_window = focus_window;
+ if (!(device = create_device(focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- device_desc.device_window = device_window;
- if (!(device = create_device(focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ device_desc.device_window = device_window;
+ if (!(device = create_device(focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ref = IDirect3DDevice9Ex_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n",
+ (LONG_PTR)test_proc);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)DefWindowProcA, proc);
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)DefWindowProcA, proc);
done:
- filter_messages = NULL;
+ filter_messages = NULL;
+ DestroyWindow(device_window);
+ DestroyWindow(focus_window);
+ SetEvent(thread_params.test_finished);
+ WaitForSingleObject(thread, INFINITE);
+ CloseHandle(thread);
+ }
- SetEvent(thread_params.test_finished);
- WaitForSingleObject(thread, INFINITE);
CloseHandle(thread_params.test_finished);
CloseHandle(thread_params.window_created);
- CloseHandle(thread);
- DestroyWindow(device_window);
- DestroyWindow(focus_window);
UnregisterClassA("d3d9_test_wndproc_wc", GetModuleHandleA(NULL));
}
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 1a5008a..5ffcfdc 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -3091,6 +3091,8 @@ struct message
{
UINT message;
enum message_window window;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
};
static const struct message *expect_messages;
@@ -3131,7 +3133,15 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
break;
};
- if (hwnd == w && expect_messages->message == message) ++expect_messages;
+ if (hwnd == w && expect_messages->message == message)
+ {
+ if (expect_messages->check_wparam)
+ ok(wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
+ ++expect_messages;
+ }
}
return DefWindowProcA(hwnd, message, wparam, lparam);
@@ -3182,13 +3192,58 @@ static void test_wndproc(void)
ULONG ref;
DWORD res, tid;
HWND tmp;
+ unsigned int i;
+ HRESULT hr;
- static const struct message messages[] =
+ static const struct message create_messages[] =
{
- {WM_WINDOWPOSCHANGING, FOCUS_WINDOW},
- {WM_ACTIVATE, FOCUS_WINDOW},
- {WM_SETFOCUS, FOCUS_WINDOW},
- {0, 0},
+ {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0},
+ /* Do not test wparam here. If device creation succeeds,
+ * wparam is WA_ACTIVE. If device creation fails (testbot)
+ * wparam is set to WA_INACTIVE on some Windows versions. */
+ {WM_ACTIVATE, FOCUS_WINDOW, FALSE, 0},
+ {WM_SETFOCUS, FOCUS_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages[] =
+ {
+ /* WM_ACTIVATE (wparam = WA_INACTIVE) is sent on Windows. It is
+ * not reliable on X11 WMs. When the window focus follows the
+ * mouse pointer the message is not sent.
+ * {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE}, */
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ /* Windows sends WM_ACTIVATE to the device window, indicating that
+ * SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
+ * the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
+ * leaves the device window active, breaking re-activation in the
+ * lost device test.
+ * {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
+ {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ /* WM_ACTIVATEAPP is sent to the device window too, but the order is
+ * not deterministic. It may be sent after the focus window handling
+ * or before. */
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages_nowc[] =
+ {
+ /* WM_ACTIVATE (wparam = WA_INACTIVE) is sent on Windows. It is
+ * not reliable on X11 WMs. When the window focus follows the
+ * mouse pointer the message is not sent.
+ * {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE}, */
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ {0, 0, FALSE, 0},
+ };
+ static const struct
+ {
+ DWORD create_flags;
+ const struct message *focus_loss_messages;
+ }
+ tests[] =
+ {
+ {0, focus_loss_messages},
+ {CREATE_DEVICE_NOWINDOWCHANGES, focus_loss_messages_nowc},
};
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
@@ -3203,122 +3258,171 @@ static void test_wndproc(void)
thread_params.test_finished = CreateEventA(NULL, FALSE, FALSE, NULL);
ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
- focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
- registry_mode.dmPelsHeight, 0, 0, 0, 0);
- thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
- ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ {
+ focus_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d9_test_wndproc_wc", "d3d9_test",
+ WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, registry_mode.dmPelsWidth,
+ registry_mode.dmPelsHeight, 0, 0, 0, 0);
+ thread = CreateThread(NULL, 0, wndproc_thread, &thread_params, 0, &tid);
+ ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
- res = WaitForSingleObject(thread_params.window_created, INFINITE);
- ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+ res = WaitForSingleObject(thread_params.window_created, INFINITE);
+ ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+ (LONG_PTR)test_proc, proc);
- trace("device_window %p, focus_window %p, dummy_window %p.\n",
- device_window, focus_window, thread_params.dummy_window);
+ trace("device_window %p, focus_window %p, dummy_window %p.\n",
+ device_window, focus_window, thread_params.dummy_window);
- tmp = GetFocus();
- ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
- if (thread_params.running_in_foreground)
- {
- tmp = GetForegroundWindow();
- ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
- thread_params.dummy_window, tmp);
- }
- else
- skip("Not running in foreground, skip foreground window test\n");
+ tmp = GetFocus();
+ ok(tmp == device_window, "Expected focus %p, got %p.\n", device_window, tmp);
+ if (thread_params.running_in_foreground)
+ {
+ tmp = GetForegroundWindow();
+ ok(tmp == thread_params.dummy_window, "Expected foreground window %p, got %p.\n",
+ thread_params.dummy_window, tmp);
+ }
+ else
+ skip("Not running in foreground, skip foreground window test\n");
- flush_events();
+ flush_events();
- expect_messages = messages;
+ expect_messages = create_messages;
- device_desc.device_window = device_window;
- device_desc.width = registry_mode.dmPelsWidth;
- device_desc.height = registry_mode.dmPelsHeight;
- device_desc.flags = CREATE_DEVICE_FULLSCREEN;
- if (!(device = create_device(d3d9, focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ device_desc.device_window = device_window;
+ device_desc.width = registry_mode.dmPelsWidth;
+ device_desc.height = registry_mode.dmPelsHeight;
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN | tests[i].create_flags;
+ if (!(device = create_device(d3d9, focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n",
- expect_messages->message, expect_messages->window);
- expect_messages = NULL;
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
- if (0) /* Disabled until we can make this work in a reliable way on Wine. */
- {
+ if (0) /* Disabled until we can make this work in a reliable way on Wine. */
+ {
+ tmp = GetFocus();
+ ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
+ tmp = GetForegroundWindow();
+ ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
+ }
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, proc, i);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, i);
+
+ expect_messages = tests[i].focus_loss_messages;
+ /* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
+ * manually changing the focus. It generates the same messages, but the task
+ * bar still shows the previous foreground window as active, and the window has
+ * an inactive titlebar if reactivated with SetForegroundWindow. Reactivating
+ * the device is difficult, see below. */
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it, i=%u.\n",
+ expect_messages->message, expect_messages->window, i);
+ expect_messages = NULL;
tmp = GetFocus();
- ok(tmp == focus_window, "Expected focus %p, got %p.\n", focus_window, tmp);
- tmp = GetForegroundWindow();
- ok(tmp == focus_window, "Expected foreground window %p, got %p.\n", focus_window, tmp);
- }
- SetForegroundWindow(focus_window);
- flush_events();
+ ok(tmp != device_window, "The device window is active, i=%u.\n", i);
+ ok(tmp != focus_window, "The focus window is active, i=%u.\n", i);
- filter_messages = focus_window;
+ hr = IDirect3DDevice9_TestCooperativeLevel(device);
+ ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
- proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ /* This is needed on native with D3DCREATE_NOWINDOWCHANGES, and it needs to be
+ * done before the focus window is restored. This makes sense to some extent
+ * because minimizing the window on focus loss is the application's job if this
+ * flag is set. */
+ if (tests[i].create_flags & CREATE_DEVICE_NOWINDOWCHANGES)
+ {
+ ShowWindow(device_window, SW_MINIMIZE);
+ ShowWindow(device_window, SW_RESTORE);
+ }
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ /* I have to minimize and restore the focus window, otherwise native d3d9 fails
+ * device::reset with D3DERR_DEVICELOST. This does not happen when the window
+ * restore is triggered by the user. */
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ /* Set focus twice to make KDE and fvwm in focus-follows-mouse mode happy. */
+ SetForegroundWindow(focus_window);
+ flush_events();
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ hr = IDirect3DDevice9_TestCooperativeLevel(device);
+ ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
+
+ /* Releasing a device in lost state breaks follow-up tests on native. */
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x, i=%u.\n", hr, i);
- ref = IDirect3DDevice9_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ filter_messages = focus_window;
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)test_proc, proc);
+ ref = IDirect3DDevice9_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- device_desc.device_window = focus_window;
- if (!(device = create_device(d3d9, focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, proc, i);
- ref = IDirect3DDevice9_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ device_desc.device_window = focus_window;
+ if (!(device = create_device(d3d9, focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- device_desc.device_window = device_window;
- if (!(device = create_device(d3d9, focus_window, &device_desc)))
- {
- skip("Failed to create a D3D device, skipping tests.\n");
- goto done;
- }
+ ref = IDirect3DDevice9_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
- proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
- ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ device_desc.device_window = device_window;
+ if (!(device = create_device(d3d9, focus_window, &device_desc)))
+ {
+ skip("Failed to create a D3D device, skipping tests.\n");
+ goto done;
+ }
- ref = IDirect3DDevice9_Release(device);
- ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ proc = SetWindowLongPtrA(focus_window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
+ ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, i=%u.\n",
+ (LONG_PTR)test_proc, i);
- proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
- ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
- (LONG_PTR)DefWindowProcA, proc);
+ ref = IDirect3DDevice9_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u, i=%u.\n", ref, i);
+
+ proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
+ ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx, i=%u.\n",
+ (LONG_PTR)DefWindowProcA, proc, i);
done:
- filter_messages = NULL;
- IDirect3D9_Release(d3d9);
+ filter_messages = NULL;
+ DestroyWindow(device_window);
+ DestroyWindow(focus_window);
+ SetEvent(thread_params.test_finished);
+ WaitForSingleObject(thread, INFINITE);
+ CloseHandle(thread);
+ }
- SetEvent(thread_params.test_finished);
- WaitForSingleObject(thread, INFINITE);
+ IDirect3D9_Release(d3d9);
CloseHandle(thread_params.test_finished);
CloseHandle(thread_params.window_created);
- CloseHandle(thread);
-
- DestroyWindow(device_window);
- DestroyWindow(focus_window);
UnregisterClassA("d3d9_test_wndproc_wc", GetModuleHandleA(NULL));
}
@@ -3540,8 +3644,10 @@ static void test_reset_fullscreen(void)
struct device_desc device_desc;
static const struct message messages[] =
{
- {WM_ACTIVATEAPP, FOCUS_WINDOW},
- {0, 0},
+ /* Windows usually sends wparam = TRUE, except on the testbot,
+ * where it randomly sends FALSE. Ignore it. */
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
};
d3d = Direct3DCreate9(D3D_SDK_VERSION);
--
2.0.4
From stefan at codeweavers.com Mon Nov 17 14:17:21 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 17 Nov 2014 21:17:21 +0100
Subject: [PATCH 2/6] d3d9/tests: Test style changes on focus loss (v2).
Message-ID: <1416255445-25770-2-git-send-email-stefan@codeweavers.com>
Version 2: Fix a rebase bug that broke the tests on Windows.
I will add message tests for the hidden window behavior in a separate
test.
I don't particularly care about the behavior on the second d3d9ex device
creation. This part is in the test to explain why I am destroying
the device and the windows. d3d9ex does the same when calling reset to
switch to fullscreen mode a second time.
---
dlls/d3d9/tests/d3d9ex.c | 85 +++++++++++++++++++++++++++++++++++++++++++++---
dlls/d3d9/tests/device.c | 40 +++++++++++++++++++++--
2 files changed, 117 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index a43baa4..ff3864a 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -2227,24 +2227,27 @@ done:
static void test_window_style(void)
{
RECT focus_rect, device_rect, fullscreen_rect, r, r2;
- LONG device_style, device_exstyle;
+ LONG device_style, device_exstyle, expected_style;
LONG focus_style, focus_exstyle;
struct device_desc device_desc;
LONG style;
IDirect3DDevice9Ex *device;
HRESULT hr;
ULONG ref;
+ BOOL ret;
static const struct
{
LONG style_flags;
DWORD device_flags;
+ LONG focus_loss_style;
+ LONG create2_style, create2_exstyle;
}
tests[] =
{
- {0, 0},
- {WS_VISIBLE, 0},
- {0, CREATE_DEVICE_NOWINDOWCHANGES},
- {WS_VISIBLE, CREATE_DEVICE_NOWINDOWCHANGES},
+ {0, 0, 0, WS_VISIBLE, WS_EX_TOPMOST},
+ {WS_VISIBLE, 0, WS_MINIMIZE, WS_VISIBLE, WS_EX_TOPMOST},
+ {0, CREATE_DEVICE_NOWINDOWCHANGES, 0, 0, 0},
+ {WS_VISIBLE, CREATE_DEVICE_NOWINDOWCHANGES, 0, 0, 0},
};
unsigned int i;
@@ -2332,6 +2335,78 @@ static void test_window_style(void)
ref = IDirect3DDevice9Ex_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ if (device_style & WS_VISIBLE)
+ ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ device_style, style, i);
+ else
+ todo_wine ok(style == device_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ device_style, style, i);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n",
+ device_exstyle, style, i);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+ focus_style, style, i);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+ focus_exstyle, style, i);
+
+ /* The second time a device is created on the window the window becomes visible and
+ * topmost if D3DCREATE_NOWINDOWCHANGES is not set. */
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN | tests[i].device_flags;
+ device = create_device(focus_window, &device_desc);
+ ok(!!device, "Failed to create a D3D device.\n");
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | tests[i].create2_style;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ expected_style, style, i);
+ expected_style = device_exstyle | tests[i].create2_exstyle;
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x, i=%u.\n",
+ expected_style, style, i);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+ focus_style, style, i);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+ focus_exstyle, style, i);
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
+ DestroyWindow(device_window);
+ DestroyWindow(focus_window);
+ focus_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | tests[i].style_flags,
+ 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+ device_window = CreateWindowA("d3d9_test_wc", "d3d9_test", WS_OVERLAPPEDWINDOW | tests[i].style_flags,
+ 0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
+
+ device_desc.device_window = device_window;
+ device = create_device(focus_window, &device_desc);
+ ok(!!device, "Failed to create a D3D device.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | tests[i].focus_loss_style;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x, i=%u.\n",
+ expected_style, style, i);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ todo_wine ok(style == device_exstyle, "Expected device window extended style %#x, got %#x, i=%u.\n",
+ device_exstyle, style, i);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x, i=%u.\n",
+ focus_style, style, i);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
+ focus_exstyle, style, i);
+
+ ref = IDirect3DDevice9Ex_Release(device);
+ ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
+
DestroyWindow(device_window);
DestroyWindow(focus_window);
}
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 5ffcfdc..e41dcbc 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -3796,15 +3796,16 @@ static void test_window_style(void)
IDirect3D9 *d3d9;
HRESULT hr;
ULONG ref;
+ BOOL ret;
static const struct
{
DWORD device_flags;
- LONG style, exstyle;
+ LONG style, focus_loss_style, exstyle;
}
tests[] =
{
- {0, WS_VISIBLE, WS_EX_TOPMOST},
- {CREATE_DEVICE_NOWINDOWCHANGES, 0},
+ {0, WS_VISIBLE, WS_MINIMIZE, WS_EX_TOPMOST},
+ {CREATE_DEVICE_NOWINDOWCHANGES, 0, 0, 0},
};
unsigned int i;
@@ -3899,6 +3900,39 @@ static void test_window_style(void)
ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x, i=%u.\n",
focus_exstyle, style, i);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | tests[i].focus_loss_style | tests[i].style;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x.\n",
+ expected_style, style);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ expected_style = device_exstyle | tests[i].exstyle;
+ todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x.\n",
+ expected_style, style);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x.\n",
+ focus_style, style);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
+ focus_exstyle, style);
+
+ /* In d3d8 follow-up tests fail on native if the device is destroyed while
+ * lost. This doesn't happen in d3d9 on my test machine but it still seems
+ * like a good idea to reset it first. */
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ ret = SetForegroundWindow(focus_window);
+ ok(ret, "Failed to set foreground window.\n");
+ flush_events();
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
ref = IDirect3DDevice9_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Mon Nov 17 14:17:22 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 17 Nov 2014 21:17:22 +0100
Subject: [PATCH 3/6] d3d8/tests: Test messages on focus loss (v2).
Message-ID: <1416255445-25770-3-git-send-email-stefan@codeweavers.com>
Version 2: Fix focus-follows-mouse WMs.
This patch and the next one introduce new errors on native when the
tests are run without focus (i.e., Windows 8 testbot). If desired I can
add checks for this condition and skip the tests.
---
dlls/d3d8/tests/device.c | 102 +++++++++++++++++++++++++++++++++++++++++------
1 file changed, 89 insertions(+), 13 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index bf7f181..55d522f 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -2136,6 +2136,8 @@ struct message
{
UINT message;
enum message_window window;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
};
static const struct message *expect_messages;
@@ -2176,7 +2178,15 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
break;
};
- if (hwnd == w && expect_messages->message == message) ++expect_messages;
+ if (hwnd == w && expect_messages->message == message)
+ {
+ if (expect_messages->check_wparam)
+ ok(wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
+ ++expect_messages;
+ }
}
return DefWindowProcA(hwnd, message, wparam, lparam);
@@ -2227,16 +2237,41 @@ static void test_wndproc(void)
ULONG ref;
DWORD res, tid;
HWND tmp;
+ HRESULT hr;
- static const struct message messages[] =
- {
- {WM_WINDOWPOSCHANGING, FOCUS_WINDOW},
- {WM_ACTIVATE, FOCUS_WINDOW},
- {WM_SETFOCUS, FOCUS_WINDOW},
- {WM_WINDOWPOSCHANGING, DEVICE_WINDOW},
- {WM_MOVE, DEVICE_WINDOW},
- {WM_SIZE, DEVICE_WINDOW},
- {0, 0},
+ static const struct message create_messages[] =
+ {
+ {WM_WINDOWPOSCHANGING, FOCUS_WINDOW, FALSE, 0},
+ /* Do not test wparam here. If device creation succeeds,
+ * wparam is WA_ACTIVE. If device creation fails (testbot)
+ * wparam is set to WA_INACTIVE on some Windows versions. */
+ {WM_ACTIVATE, FOCUS_WINDOW, FALSE, 0},
+ {WM_SETFOCUS, FOCUS_WINDOW, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ {WM_MOVE, DEVICE_WINDOW, FALSE, 0},
+ {WM_SIZE, DEVICE_WINDOW, FALSE, 0},
+ {0, 0, FALSE, 0},
+ };
+ static const struct message focus_loss_messages[] =
+ {
+ /* WM_ACTIVATE (wparam = WA_INACTIVE) is sent on Windows. It is
+ * not reliable on X11 WMs. When the window focus follows the
+ * mouse pointer the message is not sent.
+ * {WM_ACTIVATE, FOCUS_WINDOW, TRUE, WA_INACTIVE}, */
+ {WM_WINDOWPOSCHANGING, DEVICE_WINDOW, FALSE, 0},
+ /* Windows sends WM_ACTIVATE to the device window, indicating that
+ * SW_SHOWMINIMIZED is used instead of SW_MINIMIZE. Yet afterwards
+ * the foreground and focus window are NULL. On Wine SW_SHOWMINIMIZED
+ * leaves the device window active, breaking re-activation in the
+ * lost device test.
+ * {WM_ACTIVATE, DEVICE_WINDOW, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, DEVICE_WINDOW, FALSE, 0},
+ {WM_SIZE, DEVICE_WINDOW, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, FOCUS_WINDOW, TRUE, FALSE},
+ /* WM_ACTIVATEAPP is sent to the device window too, but the order is
+ * not deterministic. It may be sent after the focus window handling
+ * or before. */
+ {0, 0, FALSE, 0},
};
d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
@@ -2286,7 +2321,7 @@ static void test_wndproc(void)
flush_events();
- expect_messages = messages;
+ expect_messages = create_messages;
device_desc.device_window = device_window;
device_desc.width = registry_mode.dmPelsWidth;
@@ -2312,8 +2347,6 @@ static void test_wndproc(void)
SetForegroundWindow(focus_window);
flush_events();
- filter_messages = focus_window;
-
proc = GetWindowLongPtrA(device_window, GWLP_WNDPROC);
ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
(LONG_PTR)test_proc, proc);
@@ -2321,6 +2354,49 @@ static void test_wndproc(void)
proc = GetWindowLongPtrA(focus_window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx.\n", (LONG_PTR)test_proc);
+ expect_messages = focus_loss_messages;
+ /* SetForegroundWindow is a poor replacement for the user pressing alt-tab or
+ * manually changing the focus. It generates the same messages, but the task
+ * bar still shows the previous foreground window as active, and the window has
+ * an inactive titlebar if reactivated with SetForegroundWindow. Reactivating
+ * the device is difficult, see below. */
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x for window %#x, but didn't receive it.\n",
+ expect_messages->message, expect_messages->window);
+ expect_messages = NULL;
+ tmp = GetFocus();
+ ok(tmp != device_window, "The device window is active.\n");
+ ok(tmp != focus_window, "The focus window is active.\n");
+
+ /* The Present call is necessary to make native realize the device is lost. */
+ hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
+ ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice8_TestCooperativeLevel(device);
+ /* Focus-follows-mouse WMs prematurely reactivate our window. */
+ if (hr == D3DERR_DEVICENOTRESET)
+ todo_wine ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+ else
+ ok(hr == D3DERR_DEVICELOST, "Got unexpected hr %#x.\n", hr);
+
+ /* I have to minimize and restore the focus window, otherwise native d3d9 fails
+ * device::reset with D3DERR_DEVICELOST. This does not happen when the window
+ * restore is triggered by the user. */
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ /* Set focus twice to make KDE and fvwm in focus-follows-mouse mode happy. */
+ SetForegroundWindow(focus_window);
+ flush_events();
+ SetForegroundWindow(focus_window);
+ flush_events();
+
+ hr = IDirect3DDevice8_TestCooperativeLevel(device);
+ ok(hr == D3DERR_DEVICENOTRESET, "Got unexpected hr %#x.\n", hr);
+
+ /* Releasing a device in lost state breaks follow-up tests on native. */
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+
+ filter_messages = focus_window;
ref = IDirect3DDevice8_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Mon Nov 17 14:17:23 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 17 Nov 2014 21:17:23 +0100
Subject: [PATCH 4/6] d3d8/tests: Test style changes on focus loss.
Message-ID: <1416255445-25770-4-git-send-email-stefan@codeweavers.com>
---
dlls/d3d8/tests/device.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 55d522f..3b2d4ac 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -2867,6 +2867,7 @@ static void test_window_style(void)
IDirect3D8 *d3d8;
HRESULT hr;
ULONG ref;
+ BOOL ret;
focus_window = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW,
0, 0, registry_mode.dmPelsWidth / 2, registry_mode.dmPelsHeight / 2, 0, 0, 0, 0);
@@ -2940,6 +2941,36 @@ static void test_window_style(void)
ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
focus_exstyle, style);
+ device_desc.flags = CREATE_DEVICE_FULLSCREEN;
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ style = GetWindowLongA(device_window, GWL_STYLE);
+ expected_style = device_style | WS_MINIMIZE | WS_VISIBLE;
+ todo_wine ok(style == expected_style, "Expected device window style %#x, got %#x.\n",
+ expected_style, style);
+ style = GetWindowLongA(device_window, GWL_EXSTYLE);
+ expected_style = device_exstyle | WS_EX_TOPMOST;
+ todo_wine ok(style == expected_style, "Expected device window extended style %#x, got %#x.\n",
+ expected_style, style);
+
+ style = GetWindowLongA(focus_window, GWL_STYLE);
+ ok(style == focus_style, "Expected focus window style %#x, got %#x.\n",
+ focus_style, style);
+ style = GetWindowLongA(focus_window, GWL_EXSTYLE);
+ ok(style == focus_exstyle, "Expected focus window extended style %#x, got %#x.\n",
+ focus_exstyle, style);
+
+ /* Follow-up tests fail on native if the device is destroyed while lost. */
+ ShowWindow(focus_window, SW_MINIMIZE);
+ ShowWindow(focus_window, SW_RESTORE);
+ ret = SetForegroundWindow(focus_window);
+ ok(ret, "Failed to set foreground window.\n");
+ flush_events();
+ hr = reset_device(device, &device_desc);
+ ok(SUCCEEDED(hr), "Failed to reset device, hr %#x.\n", hr);
ref = IDirect3DDevice8_Release(device);
ok(ref == 0, "The device was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Mon Nov 17 14:17:25 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 17 Nov 2014 21:17:25 +0100
Subject: [PATCH 6/6] ddraw/tests: Test focus loss style changes.
Message-ID: <1416255445-25770-6-git-send-email-stefan@codeweavers.com>
---
dlls/ddraw/tests/ddraw1.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw2.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw4.c | 37 ++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw7.c | 37 ++++++++++++++++++++++++++++++++++++-
4 files changed, 144 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 98d56d4..5b775ec 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -2009,12 +2009,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2040,6 +2041,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2048,6 +2063,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 537de81..f1bd1da 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -2197,12 +2197,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw2 *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2228,6 +2229,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2236,6 +2251,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw2_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 5bcda6b..05bfc25 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -2384,12 +2384,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw4 *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2415,6 +2416,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2423,6 +2438,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw4_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index b5e11e9..46d9f9c 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -2062,12 +2062,13 @@ static void test_wndproc(void)
static void test_window_style(void)
{
- LONG style, exstyle, tmp;
+ LONG style, exstyle, tmp, expected_style;
RECT fullscreen_rect, r;
IDirectDraw7 *ddraw;
HWND window;
HRESULT hr;
ULONG ref;
+ BOOL ret;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 100, 100, 0, 0, 0, 0);
@@ -2093,6 +2094,20 @@ static void test_window_style(void)
GetClientRect(window, &r);
todo_wine ok(!EqualRect(&r, &fullscreen_rect), "Client rect and window rect are equal.\n");
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+
+ ret = SetForegroundWindow(window);
+ ok(ret, "Failed to set foreground window.\n");
+ /* Windows 7 (but not Vista and XP) show the window when it receives focus. Hide it again,
+ * the next tests expect this. */
+ ShowWindow(window, SW_HIDE);
+
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
@@ -2101,6 +2116,26 @@ static void test_window_style(void)
tmp = GetWindowLongA(window, GWL_EXSTYLE);
todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+ ShowWindow(window, SW_SHOW);
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
+ ret = SetForegroundWindow(GetDesktopWindow());
+ ok(ret, "Failed to set foreground window.\n");
+ tmp = GetWindowLongA(window, GWL_STYLE);
+ expected_style = style | WS_VISIBLE | WS_MINIMIZE;
+ todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+ tmp = GetWindowLongA(window, GWL_EXSTYLE);
+ expected_style = exstyle | WS_EX_TOPMOST;
+ todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+
ref = IDirectDraw7_Release(ddraw);
ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
--
2.0.4
From stefan at codeweavers.com Mon Nov 17 14:17:24 2014
From: stefan at codeweavers.com (=?UTF-8?q?Stefan=20D=C3=B6singer?=)
Date: Mon, 17 Nov 2014 21:17:24 +0100
Subject: [PATCH 5/6] ddraw/tests: Test messages on focus loss (v2).
Message-ID: <1416255445-25770-5-git-send-email-stefan@codeweavers.com>
Version 2: Do not restore the primary surface after restoring focus.
This works around a crash in GetSurfaceDesc on the Windows 8 testbot.
GetSurfaceDesc after a mode change seems to be unstable on the testbot
and/or Windows 8 in general. I don't have a real Win8 machine to
compare. If this causes more issues in further changes to the test we
can move the surface size checks after mode changes into a separate
test to make it easier to maintain a call sequence that doesn't hit the
bug.
---
dlls/ddraw/tests/ddraw1.c | 99 +++++++++++++++++++++++++++++++-------------
dlls/ddraw/tests/ddraw2.c | 103 ++++++++++++++++++++++++++++++++--------------
dlls/ddraw/tests/ddraw4.c | 103 ++++++++++++++++++++++++++++++++--------------
dlls/ddraw/tests/ddraw7.c | 103 ++++++++++++++++++++++++++++++++--------------
4 files changed, 286 insertions(+), 122 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 0ae204c..98d56d4 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -428,12 +428,26 @@ static void destroy_material(IDirect3DMaterial *material)
IDirect3DMaterial_Release(material);
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -1878,15 +1892,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -1906,7 +1920,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2147,19 +2161,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2234,7 +2263,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2280,7 +2309,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2291,6 +2320,18 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ /* Normally the primary should be restored here. Unfortunately this causes the
+ * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
+ * testbot. Another Restore call would presumably avoid the crash, but it also moots
+ * the point of the GetSurfaceDesc call. */
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2299,7 +2340,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2385,7 +2426,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2409,7 +2450,7 @@ static void test_coop_level_mode_set(void)
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2453,7 +2494,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2548,7 +2589,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2565,7 +2606,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2609,7 +2650,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 334d89e..537de81 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -361,12 +361,26 @@ static void destroy_material(IDirect3DMaterial2 *material)
IDirect3DMaterial2_Release(material);
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -2066,15 +2080,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -2094,7 +2108,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2346,19 +2360,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2438,7 +2467,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2484,7 +2513,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2495,6 +2524,18 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ /* Normally the primary should be restored here. Unfortunately this causes the
+ * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
+ * testbot. Another Restore call would presumably avoid the crash, but it also moots
+ * the point of the GetSurfaceDesc call. */
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2503,7 +2544,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2589,7 +2630,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2613,7 +2654,7 @@ static void test_coop_level_mode_set(void)
}
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2657,7 +2698,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2752,7 +2793,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2769,7 +2810,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2813,7 +2854,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2874,7 +2915,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2945,7 +2986,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index f9b94a4..5bcda6b 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -391,12 +391,26 @@ static void destroy_material(IDirect3DMaterial3 *material)
IDirect3DMaterial3_Release(material);
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -2253,15 +2267,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -2281,7 +2295,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2533,19 +2547,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2625,7 +2654,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2671,7 +2700,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2682,6 +2711,18 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ /* Normally the primary should be restored here. Unfortunately this causes the
+ * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
+ * testbot. Another Restore call would presumably avoid the crash, but it also moots
+ * the point of the GetSurfaceDesc call. */
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2690,7 +2731,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2776,7 +2817,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2793,7 +2834,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2837,7 +2878,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2932,7 +2973,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2949,7 +2990,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2993,7 +3034,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -3054,7 +3095,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -3125,7 +3166,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 9da588a..b5e11e9 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -324,12 +324,26 @@ static IDirect3DDevice7 *create_device(HWND window, DWORD coop_level)
return device;
}
-static const UINT *expect_messages;
+struct message
+{
+ UINT message;
+ BOOL check_wparam;
+ WPARAM expect_wparam;
+};
+
+static const struct message *expect_messages;
static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (expect_messages && message == *expect_messages)
+ if (expect_messages && message == expect_messages->message)
+ {
+ if (expect_messages->check_wparam)
+ ok (wparam == expect_messages->expect_wparam,
+ "Got unexpected wparam %lx for message %x, expected %lx.\n",
+ wparam, message, expect_messages->expect_wparam);
+
++expect_messages;
+ }
return DefWindowProcA(hwnd, message, wparam, lparam);
}
@@ -1931,15 +1945,15 @@ static void test_wndproc(void)
HRESULT hr;
ULONG ref;
- static const UINT messages[] =
+ static struct message messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_MOVE,
- WM_SIZE,
- WM_WINDOWPOSCHANGING,
- WM_ACTIVATE,
- WM_SETFOCUS,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_ACTIVATE, FALSE, 0},
+ {WM_SETFOCUS, FALSE, 0},
+ {0, FALSE, 0},
};
/* DDSCL_EXCLUSIVE replaces the window's window proc. */
@@ -1959,7 +1973,7 @@ static void test_wndproc(void)
expect_messages = messages;
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
@@ -2210,19 +2224,34 @@ static void test_coop_level_mode_set(void)
BOOL ret;
LONG change_ret;
- static const UINT exclusive_messages[] =
+ static const struct message exclusive_messages[] =
{
- WM_WINDOWPOSCHANGING,
- WM_WINDOWPOSCHANGED,
- WM_SIZE,
- WM_DISPLAYCHANGE,
- 0,
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_SIZE, FALSE, 0},
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
+ };
+ static const struct message exclusive_focus_loss_messages[] =
+ {
+ {WM_ACTIVATE, TRUE, WA_INACTIVE},
+ /*{WM_DISPLAYCHANGE, FALSE, 0}, Not yet implemented on Wine. */
+ {WM_WINDOWPOSCHANGING, FALSE, 0},
+ /* Like d3d8 and d3d9 ddraw seems to use SW_SHOWMINIMIZED instead of
+ * SW_MINIMIZED, causing a recursive window activation that does not
+ * produe the same result in Wine yet. Ignore the difference for now.
+ * {WM_ACTIVATE, TRUE, 0x200000 | WA_ACTIVE}, */
+ {WM_WINDOWPOSCHANGED, FALSE, 0},
+ {WM_MOVE, FALSE, 0},
+ {WM_SIZE, TRUE, SIZE_MINIMIZED},
+ {WM_ACTIVATEAPP, TRUE, FALSE},
+ {0, FALSE, 0},
};
- static const UINT normal_messages[] =
+ static const struct message normal_messages[] =
{
- WM_DISPLAYCHANGE,
- 0,
+ {WM_DISPLAYCHANGE, FALSE, 0},
+ {0, FALSE, 0},
};
ddraw = create_ddraw();
@@ -2302,7 +2331,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2348,7 +2377,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
"Expected screen size %ux%u, got %ux%u.\n",
@@ -2359,6 +2388,18 @@ static void test_coop_level_mode_set(void)
user32_rect.left, user32_rect.top, user32_rect.right, user32_rect.bottom,
r.left, r.top, r.right, r.bottom);
+ expect_messages = exclusive_focus_loss_messages;
+ SetForegroundWindow(GetDesktopWindow());
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
+
+ ShowWindow(window, SW_RESTORE);
+ hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
+ ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+ /* Normally the primary should be restored here. Unfortunately this causes the
+ * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
+ * testbot. Another Restore call would presumably avoid the crash, but it also moots
+ * the point of the GetSurfaceDesc call. */
+
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
expect_messages = exclusive_messages;
screen_size.cx = 0;
@@ -2367,7 +2408,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- todo_wine ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ todo_wine ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
todo_wine ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2453,7 +2494,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2470,7 +2511,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2514,7 +2555,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2609,7 +2650,7 @@ static void test_coop_level_mode_set(void)
change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2626,7 +2667,7 @@ static void test_coop_level_mode_set(void)
hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2670,7 +2711,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_RestoreDisplayMode(ddraw);
ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
@@ -2731,7 +2772,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(screen_size.cx == registry_mode.dmPelsWidth
&& screen_size.cy == registry_mode.dmPelsHeight,
@@ -2802,7 +2843,7 @@ static void test_coop_level_mode_set(void)
hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
- ok(!*expect_messages, "Expected message %#x, but didn't receive it.\n", *expect_messages);
+ ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
expect_messages = NULL;
ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
screen_size.cx, screen_size.cy);
--
2.0.4
From madewokherd at gmail.com Mon Nov 17 14:53:05 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Mon, 17 Nov 2014 14:53:05 -0600
Subject: [tools] winemono: Added 4.5.4 release.
Message-ID:
-------------- next part --------------
From f74f70efe29db5ac30be717247bf9664fc06b0cc Mon Sep 17 00:00:00 2001
From: Vincent Povirk
Date: Mon, 17 Nov 2014 14:44:20 -0600
Subject: [PATCH] winemono: Added 4.5.4 release.
---
winemono.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/winemono.php b/winemono.php
index c82ddda..10bf13f 100644
--- a/winemono.php
+++ b/winemono.php
@@ -4,7 +4,7 @@
*/
// Default version if none given
-$sVersion = '4.5.2';
+$sVersion = '4.5.4';
// Suffix appended to base name of file
$sFileSuffix = '';
@@ -29,7 +29,8 @@ $sFileName = sprintf('%s/%s/wine-mono-%s.%s', $sFolder, $sVersion, $sFileSuffix,
$aFileSizes = array(
'0.0.4'=>44408320,
'0.0.8'=>46967296,
- '4.5.2'=>52502528
+ '4.5.2'=>52502528,
+ '4.5.4'=>53706752
);
// Exact size of the file:
--
2.1.0
From madewokherd at gmail.com Mon Nov 17 14:53:42 2014
From: madewokherd at gmail.com (Vincent Povirk)
Date: Mon, 17 Nov 2014 14:53:42 -0600
Subject: mscoree: Update Wine Mono to 4.5.4.
Message-ID: