On 30/09/2020 14:53, Henri Verbeet wrote:
On Tue, 29 Sep 2020 at 19:16, Gabriel Ivăncescu gabrielopcode@gmail.com wrote:
Fixes a regression introduced by commit 82c6ec3a32f44e8b3e0cc88b7f10e0c0d7fa1b89, which caused the WM_ACTIVATEAPP to be sent while the window is minimized, if it has been clicked on in the taskbar to be restored. The behavior is correct wrt Windows, but some games expect the window pos change messages to be sent while they are unminimized, but we only sent it during the WM_ACTIVATEAPP hook.
It's not entirely clear to me what we're fixing here. (E.g., is the issue about the order of the messages, or the state of the window? Which version of Direct3D does this affect?) Do you have a test to reproduce the issue?
The issue is that HOMM V relies on the SetWindowPos messages to be received when it is unminimized, otherwise it remains a black screen when restored. Prior to that patch, we sent them during WM_ACTIVATEAPP, which happened when the game was not minimized (because WM_SYSCOMMAND SC_RESTORE was the reason the WM_ACTIVATEAPP was sent in the first place).
That patch is needed to fix games like Project CARS, though, and it is correct according to Zhiyi's commit message. I also tested it and it does appear to be correct: WM_ACTIVATE and WM_ACTIVATEAPP are sent before the SC_RESTORE message, if it's clicked on the taskbar to restore it, while the WM_WINDOWPOSCHANGING/WM_WINDOWPOSCHANGED are sent after it.
I'm not entirely sure how to add a test since it requires clicking on the taskbar (when the game is minimized after alt-tab) for this to happen. But if you launch HOMM V, alt-tab to minimize the game, and then click on the taskbar to restore it, it will remain a black screen without this patch (and reverting that commit also fixes it, but breaks Project CARS; that commit + this patch fixes both).
With this patch, it only handles this specific case of restoring it by clicking on the taskbar: where WM_ACTIVATEAPP has the window still minimized (so SetWindowPos is not called), and SC_RESTORE happens after.