1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

99 Commits

Author SHA1 Message Date
narzoul
fef2598e5f Do not minimize on deactivation if DDSCL_NOWINDOWCHANGES is set
Fixes alt-tabbing issues in Age of Wonders 2 that was making it difficult
to properly activate the minimized game.
2016-05-08 21:57:51 +02:00
narzoul
639d0ce8fb Disable setting full-screen cooperative level while the app is inactive
Commandos 2 reacts to WM_DISPLAYCHANGE messages by reapplying the full-screen
cooperative level and the display mode. This makes the RestoreDisplayMode call
(which itself generates WM_DISPLAYCHANGE) ineffective.
Additionally, on WM_ACTIVATE it removes the primary surface, which DDrawCompat
was relying on for full-screen detection.

This fix returns DDERR_EXCLUSIVEMODEALREADYSET if the app tries to set
full-screen cooperative level while inactive. The tracking of full-screen
mode is now done via a dummy surface instead of the primary surface.
2016-05-08 21:57:26 +02:00
narzoul
c647f4b2ef Disabled GDI emulation while the app is inactive v0.2.1 2016-05-03 23:02:46 +02:00
narzoul
fe8abe9d5a Avoid side effects when method implementations are delegated to higher versions
Some DirectDraw methods are implemented by delegating to the same method
in a higher interface version. In this case, the hooking logic could be
executed twice, leading to unwanted side effects. This is now avoided.
2016-05-03 23:02:39 +02:00
narzoul
f7f5348a87 Fixed/simplified hooking logic for COM methods 2016-05-03 23:02:33 +02:00
narzoul
e4b67be7ec Fixed misleading error messages 2016-05-03 22:12:46 +02:00
narzoul
5e972cf056 Handle WM_ACTIVATEAPP messages
Aiming to fix Alt-Tabbing issues (such as black screen instead of desktop)
by temporarily setting the cooperative level to windowed mode, restoring
the display mode and minimizing the main window when the app is inactive.
2016-05-03 22:12:25 +02:00
narzoul
f0425495bc Updated disabling of immersive context menus 2016-04-30 23:43:40 +02:00
narzoul
441d7794cd Fixed hangups caused by unreleased back buffer surface 2016-04-30 23:43:20 +02:00
narzoul
495325c984 Moved cached surfaces to DDrawRepository 2016-04-26 23:26:33 +02:00
narzoul
9ddeab4149 Removed hooks on DLL_PROCESS_DETACH
Fixes a crash when opening Blood 2's display settings from the launcher.
2016-04-20 00:07:18 +02:00
narzoul
44cc4c2ad5 Disabled smooth scrolling
Prevents a visual artifact where the area that is supposed to scroll out of view
remains static during the smooth scrolling animation.
2016-04-18 22:32:27 +02:00
narzoul
a8834453e0 Added default paint handlers for ComboListBox controls
Now the background is properly erased and the scroll bar updated when scrolling.
2016-04-18 22:14:53 +02:00
narzoul
90fa9459d2 Reduced flickering when scrolling or erasing background 2016-04-17 22:56:25 +02:00
narzoul
74f306b5b0 Fixed synchronization issue in beginGdiRendering
It's not sufficient to make g_renderingRefCount atomic, because after it is
found to be nonzero in beginGdiRendering, a call to endGdiRendering from
another thread may make it zero before beginGdiRendering has a chance of
entering the critical section. This would mean that the DirectDraw primary
surface is no longer locked, even though beginGdiRendering expects that it is.

To prevent potential issues, the g_renderingRefCount check is now also
guarded by the critical section.
2016-04-17 21:13:16 +02:00
narzoul
cc5a4c7cef Readded palette animation support 2016-04-17 19:04:15 +02:00
narzoul
d4042f7e95 Support PC_RESERVED palette entry flag for GDI rendering 2016-04-17 19:04:04 +02:00
narzoul
111719eaf7 Removed unnecessary GDI redraws when GDI emulation is disabled 2016-04-17 19:02:54 +02:00
narzoul
e774564467 Improved scheduling of real primary surface updates 2016-04-17 19:01:25 +02:00
narzoul
2937bde6a4 Introduced a common RAII class for critical sections 2016-04-17 19:01:03 +02:00
narzoul
0a05ef1174 Call WindowFromDC through IAT
GetWindowDC(GetDC(NULL)) may return a special window with a class name of
"CompatWindowDesktopReplacement". Presumably the shim engine installs an
IAT hook for GetWindowDC that replaces this window handle with the normal
desktop window handle.

CALL_ORIG_FUNC(WindowFromDC) returns with an unpatched pointer, therefore
it doesn't perform the above replacement. This results in using the
replacement window's clipping region (whole screen) instead of the desktop
window's clipping region (empty), and things become visible that shouldn't
be, e.g. some character symbols at the top left corner of the screen when
launchning Diablo II.

As a workaround, WindowFromDC is used without CALL_ORIG_FUNC.
2016-04-10 20:37:00 +02:00
narzoul
ac9dbc72de Update only the dirty rectangle on the real primary surface 2016-04-10 17:37:01 +02:00
narzoul
1a3cb2be4d Added invalidation of non-client area on WM_ACTIVATE 2016-04-06 22:35:54 +02:00
narzoul
f12b95ec9f Removed unnecessary GDI redraws 2016-04-06 21:18:26 +02:00
narzoul
bb83780f0a Fixed title bar style issues and text positioning 2016-04-04 22:59:38 +02:00
narzoul
2d30ff6f94 Fixed GDI clipping issues 2016-04-03 20:36:21 +02:00
narzoul
c78c7c927f Aligned usage of flip between compat and real primary surface chains
Using flip for direct front buffer updates can cause performance problems
if the driver forces vertical sync and overrides the DDFLIP_NOVSYNC flag.

On the other hand, DDFLIP_NOVSYNC flip requests on the compat primary
surface should be handled via real flip to allow vertical sync override.
2016-04-03 20:35:59 +02:00
narzoul
be67dff295 Avoid unnecessary palette updates 2016-04-03 13:06:04 +02:00
narzoul
9aa22534ab Fixed crash due to setting clipper on uninitialized palette converter 2016-04-03 11:15:21 +02:00
narzoul
607eb5e25b Simplified caret handling and fixed positioning issues 2016-04-02 23:24:25 +02:00
narzoul
fd1063defe Default paint handlers for Edit and ListBox controls
Missing WM_NCPAINT handler for ListBox was causing the non-client area
to display incorrectly. Now the same handler is used as for DefWindowProc.
2016-04-02 01:00:00 +02:00
narzoul
3827007c0c Avoid forced invalidation of the scroll bar child control when scrolling
This was causing the scroll bar arrows to lose their pressed appearance.
2016-03-31 23:06:18 +02:00
narzoul
d0fbd5cfd0 Fixed another GDI deadlock
Scenario:
Thread #1 enters the DirectDraw critical section
Thread #2 enters the GDI critical section
Thread #2 starts waiting on the DirectDraw critical section
Thread #1 starts waiting on the GDI critical section

Solution:
If the primary surface has not been locked yet, enter the DirectDraw critical
section before entering the GDI critical section.
2016-03-31 23:06:12 +02:00
narzoul
6f643ecf7e Fixed popup menu palette issues 2016-03-31 23:06:06 +02:00
narzoul
ac305fbbba DIB based palette converter 2016-03-31 23:06:00 +02:00
narzoul
71e90210ad Introduced a DirectDraw repository for reusable objects 2016-03-31 23:05:54 +02:00
narzoul
0c030f8d57 Eliminated flickering in popup menus
DC redirection for popup menus is suppressed unless requested from WM_PAINT.
2016-03-31 23:05:48 +02:00
narzoul
460433c858 Hooked GdiDrawStream 2016-03-27 12:11:07 +02:00
narzoul
4f4b0cf732 Disabled immersive context menus
Immersive context menus don't display correctly when theming is disabled:
all menu items have empty labels and no icons.
Disabled this menu style through a faked registry value.
2016-03-24 23:12:28 +01:00
narzoul
62334dd32a Handle null pointers when logging strings 2016-03-24 22:57:45 +01:00
narzoul
96ba6c4b5b Handle undocumented menu selection change message
Now the selection is properly cleared also when the mouse leaves the menu window area.
2016-03-21 23:30:53 +01:00
narzoul
68d3c75c95 Extracted function hooking to its own unit 2016-03-21 22:51:56 +01:00
narzoul
1a7319dbee Updated readme
Some minor tweaks and removed development details as I'm too lazy to keep it up to date.
2016-03-21 00:08:13 +01:00
narzoul
7c06d9440b Added WM_PAINT handling for popup menus 2016-03-20 22:58:51 +01:00
narzoul
91a158020a Added WM_PAINT handling for scroll bar controls
Now size box rendering works correctly, so no need for that workaround in
CompatGdiScrollBar.
There seems to be a bug with subclassing scroll bars though, as the cursor
will no longer change to a sizing arrow when it's over a size box control.
At least there is a simple workaround for that via WM_SETCURSOR.
2016-03-20 22:58:11 +01:00
narzoul
6850fc449c Moved WM_ERASEBKGND handling to DefWindowProc
Unfortunately, Edit and ListBox controls don't seem to handle WM_ERASEBKGND
through DefWindowProc, so their window procedures need additional hooking.
2016-03-19 21:41:04 +01:00
narzoul
7ece7eed97 Moved WM_NCPAINT handling to DefWindowProc 2016-03-19 19:25:13 +01:00
narzoul
71586cc994 Hooked PolyPatBlt
Makes the button highlight workaround unnecessary.
2016-03-19 19:09:39 +01:00
narzoul
8c286d21bd Additional debug info for HWND and HDC parameters 2016-03-19 17:13:37 +01:00
narzoul
8e456eafcb Implemented WindowFromDC for compat DCs 2016-03-19 17:13:31 +01:00