| Summary: | Very weird issue with SDL_GetWindowPosition/SDL_CreateWindow | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Eric Shepherd (:sheppy) <sheppy> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | WAITING --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | Keywords: | target-2.0.16 |
| Version: | 2.0.10 | ||
| Hardware: | x86 | ||
| OS: | macOS 10.15 | ||
| Attachments: | Arrangement of my three screens | ||
OK, so my debug code was flawed in a way that made my report pretty worthless. I'm still getting incorrect results, but the x and y are not backward after all (which is a relief, because I couldn't believe that part, despite having spent several hours looking for the problem). My eyes just glazed over the place where they were getting swapped when outputting the debug information. Thta said, I'm still having the problem where SDL_GetWindowPosition() returns x=2547, y=1394 (for example) but after calling SDL_CreateWindow() the window is actually at x=307, y=1400. I... am very very confused by this. So, more experimentation... If I add a call to SDL_SetWindowPosition() immediately after the SDL_CreateWindow() call, using the same X and Y coordinates for both, the window is created in totally the wrong place but then moves to *almost* the right place; it slowly moves down the screen by around 55 pixels each time I start up the application. X stays constant. If I instead add a call to SDL_SetWindowPosition() to be executed when I receive the SDL_WINDOWEVENT_EXPOSED event for the first time, specifying the X and Y loaded from my preference file, it is created in the wrong place then moves to the correct place, every time. However, that flash of it being in the wrong place is pretty cheesy... Can you provide simple test code that shows this problem? Also: * Is the DPI scaling setting the same on all three monitors? * What does SDL_GetDisplayBounds() return for all three monitors? |
Created attachment 4257 [details] Arrangement of my three screens I see there have been and still are some ongoing issues with SDL_GetWindowPosition() and SDL_SetWindowPosition() not being commutative (in that what you get out from getting the position doesn't always put the window in the same place when set set the position. I'm having this problem when I use SDL_GetWindowPosition() to grab the window's position to save it to disk in order to restore the position after relaunch. But I'm using SDL_CreateWindow to create the window, passing as input the position returned by SDL_GetWindowPosition(). But my results are beyond weird. First, I'm on macOS 10.15.1, using an iMac with the main screen in 3200x1800 resolution, a secondary screen at 2560x1440 (located to the right of the main sccreen), and a tertiary screen at 1080p centered below the top two screens (so about half of the screen is below the built-in screen and half is below the secondary screen). I've attached a screen capture of the arrangement tab from my Displays preferences so you can see what I mean Now for the problem: For example, just now I moved the window to be located flush against the menu bar at the top of the screen and about all the way at the right edge of my main screen. SDL_GetWindowPosition() reports the position as X=101, Y=2554. This is backward. X should be around 2555 and Y around 100 or so (I don't know the exact height of the menu bar and window decoration). When I relaunch the application, these (incorrect) values are loaded correctly from my storage file, and are passed into SDL_CreateWindow(). But the window winds up at X=309, Y=988. Bizarre! I'm currently using SDL 2.0.10. Hope there are some ideas... I'm stumped.