SnowyMouse / chimera

The update to Halo PC that never was
https://chimera.opencarnage.net
GNU General Public License v3.0
147 stars 27 forks source link

Fix Focus Tantrum with background_playback #39

Closed surrealwaffle closed 4 years ago

surrealwaffle commented 4 years ago

This PR partially addresses #24, specifically subissue 2 when background_playback is active and Halo is fullscreen, alt-tabbing causes Halo to be brought to the foreground. The issue should be left open, as the game will still crash upon tabbing back in through a game change.

Summary of the PR Features

Because the problem seems to be a matter of system implementation (see below), I thought it prudent to provide an option that disables this fix.

Summary of the Cause

Halo's rendering subsystem sets a flag to indicate that the device was lost, as detected by the return value of device->Present(). On the next frame, if this flag was set, Halo will attempt to reacquire the device (via some cleanup and device->Reset()) before calling device->BeginScene(). If if fails to reacquire the device, then that frame is skipped with no call to device->BeginScene.

With background_playback active, Halo will be more eager to render frames, resulting in a call to device->Reset() while the user is tabbed out and Halo is fullscreen. An effect of that invocation on native D3D9 is that the window appears in the foreground but does not accept input.

Edit: Change of wording to stop Github from closing the issue if the PR is accepted.

Aerocatia commented 4 years ago

I gave this a test and it works great. Seems to work as expected on Windows native, Windows with dgVoodoo2, Wine Open GL, Wine DXVK, and Wine DXVK+dgVoodoo2. I'm not sure we should have it as an ini option though, since it seems to have no down sides and would only cause issues when disabled. I'd consider it a bugfix.

surrealwaffle commented 4 years ago

By default, the fix is enabled when background_playback is on. If the fix works well, users will never have to touch the option for the fix. That said, I can revert the commit if the ini option is unwanted.

Aerocatia commented 4 years ago

Well, personally I think having an option that can potentially make ALT-F4 the only possible way to exit the game is not ideal. We could always add the option back later if a use case is found that needs it.

surrealwaffle commented 4 years ago

Alright. Option removed.

SnowyMouse commented 4 years ago

Seeing as this works as intended, I'm going to go ahead and approve this.