Godot: "Window Placement Centred" causes game window to appear offscreen on hi-DPI laptop

Created on 18 Nov 2017  Â·  23Comments  Â·  Source: godotengine/godot

Operating system or device, Godot version, GPU Model and driver (if graphics related):

OS: Windows 10
Device: Dell XPS 15 9560
GPU: Nvidia GTX 1050
GPU Driver: 388.00
Screen Resolution: 3840 x 2160 px
Godot version: 3.0 alpha 2

Issue description:

  • Actual behaviour:

If Window Placement - Centred is selected in Editor Settings, when running a project using the 'Play Project' button, the game window opens outside the visible screen area (to the bottom-right). I have to move the window back onscreen to see it.

(However, Window Placement - Top Left works fine.)

  • Expected behaviour:

The game window should be centred if Window Placement - Centred is selected in Editor Settings.

Steps to reproduce:

Load any project which runs windowed and ensure that Window Placement - Centred is selected in Editor Settings. Press 'Play Project'.

Link to minimal example project:

bug confirmed hero wanted! windows porting

Most helpful comment

Still having this problem in the latest version of Godot (3.0.2). macOS 10.13.4.

Though if I go to Project Settings > Display > Window and enable "Allow Hidpi", this fixes it.

All 23 comments

Does this happen if you mark the editor executable as DPI-aware, by right-clicking its .exe file, going to Properties → Compatibility then overriding the scaling mode to Application?

If the window is set to be DPI-aware, this should be fixable by getting the DPI from the engine (which is already possible), then placing and sizing the window accordingly.

@Calinou - many thanks for the quick response.

I can confirm that overriding the scaling mode to 'Application' does solve the issue, i.e. the window which appears on pressing 'Play Project' is now centred.

One minor side effect which I noticed is that, after switching to 'Application' scaling mode, the Project Manager window which loads on startup is now a bit too small by default (a screenshot is attached).

screenshot

One minor side effect which I noticed is that, after switching to 'Application' scaling mode, the Project Manager window which loads on startup is now a bit too small by default (a screenshot is attached).

I have already reported that, so I'm adding the "confirmed" label to that issue.

This is not limited to windows. I see the same on my mid 2014 macbook pro with retina display. Running Godot 3.0 beta 1

screen shot 2017-12-11 at 12 51 50 am

screen shot 2017-12-11 at 12 55 53 am

UPDATE

I launched manually from the terminal and when executing my test scene I see the --position specified. After a bit of playing around, it looks like those values divided by 3 are pretty accurate centered placement.

Values I see are: --placement 1408,900 if I manually use 470,300 in the window placement settings within editor settings I get a window roughly where I expect to see it.

screen shot 2017-12-11 at 1 06 49 am

Motivated by the presentations at FOSDEM 2018 I downloaded Godot 3.0-stable on my Win 10 Lenovo Yoga 3 Pro hidpi laptop and started the getting started tutorial. It was most confusing to not find the play window despite repeated play button pushes. Only after some head-scratching and right-clicking on the taskbar icons did it become apparent that the window is somewhere far off to the bottom right of the desktop and needs to be dragged up with "Move" or "Maximise". This is not a good experience to the newbie trying to get started.

I confirm this issue. In a 1920x1080 screen I need to put custom position like (420, 130) to the run screen be "centered".

I have this issue on mac. took me forever to finally see a small sliver of the window bottom right.

I no longer have this issue on 3.0.2

OS X 10.13.4
MacBook Pro with Retina with external FullHD monitor (which Godot is running on), same issue

Same problem here. :/

Still having this problem in the latest version of Godot (3.0.2). macOS 10.13.4.

Though if I go to Project Settings > Display > Window and enable "Allow Hidpi", this fixes it.

I guess that would fix it: #23203

Can reproduce at 3440x1440 resolution. Apparently it's not related to the windows UI scaling, same offset for 100% scaling and 150% scaling.

Same problem here. Setting Allow HiDPI in the project settings kinda fixes this issue and correctly centers the game window, but then it'll be super tiny and you need to also set Test Width and Test Height to something more manageable.

Leaving Allow HiDPI disabled but then set Editor Settings > Run > Window Placement > Rect to Custom Position and giving the rect a position of 248,100 also centers the game window correctly — but only for that very project resolution.

System:

  • Win 10 on a Dell XPS 9555
  • 3840×2160
  • window scaling 250% (default)

Project Settings:

  • 1024 × 600
  • HiDPI disabled

Editor Settings:

  • Window Placement custom rect at 248, 100

Result:
| | margin left | game window width | margin right | total |
|---|---|---|---|---|
|Device PX| 640 | 2560 | 640 | 3840 |
|divided by 2.5 | 256 | 1024 | 256 | 1536 |

The first row are the pixel values measured from a screenshot when running the game (I only measured the X axis, but I'm pretty sure vertically it's the same)
The second row then is all the values from the top row divided by 2.5 as per the 250% window scaling.

Soooo... the measured window width of 2560 perfectly translates to the project setting of 1024, I guess the Editor Setting Window Placement somewhere mixes up the scaling between game pixels and device pixels.

I was about to open a new issue for this, but since it already exists... I am experiencing the same problem.

Godot Version: 3.2.1.stable.mono.official
OS: Windows 10 (2004)
Monitor: 4K, 200% DPI.

When the position is set to "Centred", it shows only the second quadrant of the game window at the bottom-right corner of the monitor.

@HubKing Try enabling Display > Window > Allow Hidpi in the Project Settings. (For the record, this isn't done by default because your game must be configured to support multiple resolutions. Also, this may perform poorly on integrated graphics.)

@Calinou That did make the game window appear at the centre. Thank you for the information. It may be helpful to show some kind of information message box like "Warning: high DPI option has not been enabled" (with "Do not show again" option, of course) when the user clicks the "Play" button for the first time and the system uses high DPI, so that the user would not think it as a bug of the editor.

so that the user would not think it as a bug of the editor.

This IS a bug of the editor though and an annoying one, especially when you run lots of different projects and you have to set this option for each of them.

Reopening, because it wasn't fixed (the PR was for Mac OS, while this is also Windows issue, maybe that's why).
Tested in 8ccb1cec9

@HubKing Try enabling Display > Window > Allow Hidpi in the Project Settings. (For the record, this isn't done by default because your game must be configured to support multiple resolutions. Also, this may perform poorly on integrated graphics.)

This fixed my problem and the window appears centered

Im having the same problem
going to exe properties > compatibility > change high DPI settings and setting the High DPI scale override to application solved this problem,
also setting hiDPI in the project solved this issue

OS: Windows 10
Device: PC
GPU: Nvidia GTX 970
GPU Driver: 452.06
Screen Resolution: 3840 x 2160 px
Godot version: 3.2.1 stable

To fix this, we either need to:

  • Find a way to set a window position that accounts for the OS' scaling in the Windows API. If it exists, this is probably the better way to go.
  • Add a method that returns the OS' scaling factor in Godot (not the DPI!). 1.0 would be 100%, 2.0 would be 200% and so on. We can then use this to position the window correctly. This should most likely be done in platform/windows/display_server_windows.cpp in the master branch.

Add a method that returns the OS' scaling factor in Godot (not the DPI!). 1.0 would be 100%, 2.0 would be 200% and so on. We can then use this to position the window correctly.

OS/DisplayServer.get_screen_scale method exists, but it is only implemented on macOS.

On Windows Godot currently use old DPI model (SHC_PROCESS_SYSTEM_DPI_AWARE) which do not allow getting scale for specific monitor, and if it's changed to new model (SHC_PROCESS_PER_MONITOR_DPI_AWARE) we'll need to implement additional interface rescaling on screen change similar to one used on macOS or proper DPI independent UI for all platforms.

Was this page helpful?
0 / 5 - 0 ratings