| Summary: | Setting window to fullscreen on a monitor (SDL_WINDOW_FULLSCREEN) other than the primary will inevitably move the window back to primary monitor. | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Darrell <salads.games+sdl2> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | Keywords: | target-2.0.16 |
| Version: | 2.0.9 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 10 | ||
| Attachments: |
work in progress patch
second attempt at migrating to a new display |
||
|
Description
Darrell
2019-03-07 05:12:56 UTC
Tracing through the other app I mentioned, I found that it also has the window move back to the primary monitor when the D3D9Device is reset, so this may have something to do with how DirectX works...? (Sorry if you get several emails like this, we're marking a bunch of bugs.) We're hoping to ship SDL 2.0.11 on a much shorter timeframe than we have historically done releases, so I'm starting to tag bugs we hope to have closed in this release cycle. Note that this tag means we just intend to scrutinize this bug for the 2.0.11 release: we may fix it, reject it, or even push it back to a later release for now, but this helps give us both a goal and a wishlist for the next release. If this bug has been quiet for a few months and you have new information (such as, "this is definitely still broken" or "this got fixed at some point"), please feel free to retest and/or add more notes to the bug. --ryan. We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc). As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change! Thanks, --ryan. We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc). As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change! Thanks, --ryan. Ryan, do you have a multi-monitor setup to debug this? (In reply to Sam Lantinga from comment #5) > Ryan, do you have a multi-monitor setup to debug this? I do, I'm looking at this one right now. --ryan. I think the D3D device instance has a handle to the monitor, so we may need to update that when the window position changes. The imgui test app in this bug is kinda awesome. :) I can reproduce it here, working on tracking it down. --ryan. (In reply to Sam Lantinga from comment #7) > I think the D3D device instance has a handle to the monitor, so we may need > to update that when the window position changes. You are probably correct; during SDL_RenderPresent, after the fullscreen change, D3D_RunCommandQueue tries to activate its stuff at the start, which calls D3D_Reset to trash everything and rebuild it due to the window change. In there, IDirect3DDevice9_Reset() gets called, and before that call returns the window is back on the primary display. I'll read up and figure it out, but this is creeping towards being solved now. --ryan. I’m guessing it’s because IDirect3DDevice9_CreateDevice has to specify a display adapter and Reset doesn’t let you choose a different one. We probably have to fully tear down And rebuild the D3D device in this scenario if this is the culprit. (Obviously the window can safely drag between displays or be moved there programmatically, it’s just the fullscreening causing a problem here.) --ryan. Yup, that's probably true. If we go fullscreen on a different display than we started with, we need to recreate the D3D device on that display. Let's go ahead and fix this after 2.0.12 is out. (In reply to Sam Lantinga from comment #11) > Yup, that's probably true. If we go fullscreen on a different display than > we started with, we need to recreate the D3D device on that display. > > Let's go ahead and fix this after 2.0.12 is out. Wait, I’m mostly there, just have to move some code from D3D_CreateRenderer to a separate function. --ryan. Created attachment 4205 [details] work in progress patch > Wait, I’m mostly there, just have to move some code from D3D_CreateRenderer > to a separate function. Okay, nevermind, this patch is pretty big and still not right (among other things, we lose all the textures when the device is recreated), but I'll post the work-in-progress here for when we revisit. --ryan. Created attachment 4296 [details] second attempt at migrating to a new display (In reply to Ryan C. Gordon from comment #13) > Okay, nevermind, this patch is pretty big and still not right (among other > things, we lose all the textures when the device is recreated), but I'll > post the work-in-progress here for when we revisit. Been fighting with this all week, and now I can move this program to a different display and keep the textures, by saving them all off before destroying everything and recreating new textures on the new device with the saved-off data. This adds some complexity, but as a side-benefit, we don't even have to send an SDL_RENDER_TARGETS_RESET event in this case. I'm attaching the current work-in-progress, because I have to take a break from this. It's still a little crashy, so it isn't ready for revision control, but this actually _almost_ works now. We'll have to decide if all this heavy-lifting is worth it, though. Now that I can see what's involved, I'm a little nervous about it. It's cool when it works, but I'm still not sure we shouldn't have just refused the fullscreen request in the first place. --ryan. |