New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix active state event on startup #8123
base: develop
Are you sure you want to change the base?
Conversation
I patched this into my custom fork of MonoGame and it works beautifully for DesktopGL! The window comes up behind my active window (taskmgr.exe), and as soon as it grows to the correct size window, it turns red (using bwiklund's !iGame.IsActive code) to show that it recognizes it's inactive. Could a similar fix be made for WindowsDX, which appears to have the same problem? It looks like MonoGame.Framework\Platform\Windows has a WinFormsGamePlatform.cs, which may function similarly to SDL\SDLGamePlatform.cs. |
Your new patch defaults to active state on 3 of 3 tests I did, which is what it was intended to do. Is there no way to help the WinForms event pump detect the right startup state? |
@gluser2 I've applied the same to WindowsDX. Would you mind testing that too? |
Thanks for that patch! However, I tested it on two computers — AMD A8-7600 x64 with AMD R9 255 graphics, and Qualcomm 7C ARM64 with Adreno 618 graphics — and it still launches an inactive game in an active state, just like MG 3.8.1 and the develop branch do. However, your patch also keeps the MonoGame window in an active state when Alt+Tab is pressed or another window is drawn on top of it. I don't know why it's behaving this way, but the game seems to never enter an inactive state now. |
Is this with DesktopGL or WindowsDX? And on which system(s)? And are you using a system SDL install instead of the one from MonoGame? (the fact that you're testing on arm64 indicates me that you might not be running a standard installation of MonoGame, which would make your results not accurate). |
The DesktopGL fix worked perfectly, but the one I reported on in my last comment was WindowsDX. I made a new DX project that referenced the source code of your commit, a second that referenced the source of the develop branch, and a third using the standard 3.8.1.303 release NuGet (no source), all in Visual Studio 2022. They were built on the x64 machine and run on both that and the arm64. The behavior was the same on both. OSes were Windows 10 and 11. .NET 8.0.1 and WinForms were used to draw the MG windows. The new DX projects were a created template from 3.8.1, since I didn't see one in the source files. I only modified the games to draw Red instead of CornflowerBlue while the window is inactive. I open the 3.8.1 or develop built game and click another window like Windows Task Manager. When the game launches, it should be inactive (red). But it's still blue under the other window. After clicking on it for the first time, anytime you switch windows it turns red like it should. The game I built on your commit (with the modified WinFormsGameWindow.cs) launches blue when inactive, like the other ones. But in contrast, no matter how often I click the window and back on Task Manager, it never turns red. It seems like it's stuck in an active (blue) state. Do you have a different setup? How does the patch perform on your machine? |
Need testing.
Fixing #7992