Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix for issues with startup and multiple monitors on windows. #10156
I noticed a small bug in bitcoin-qt with multiple physical displays. This bug affects me because I use a Windows 10 laptop that sometimes uses a second display.
I can only reproduce this issue on windows 10. I could not reproduce this issue on Ubuntu 16.04 LTS with dual displays running in a VirtualBox VM.
This is a pull request for a fix for this issue.
To demonstrate the bug:
This is not a critical bug, but when it happens the user experience is not good, hence this fix.
As for the code changes….The position of bitcoin-qt is saved into QSettings on exit. When bitcoin-qt restarts it grabs this position and places itself at that location. However it never tests if this position actually still exists. So I have added a test that if the location does not exist on any of the current screens then it re-positions it to the default location.
I also use abs() when calculating the center position. This is because there is the potential for the size of the application to be larger then the size of the current screen, abs() should handle that corner case.
I have tested this change on Windows 10 & Ubuntu 16.04 LTS.
referenced this pull request
Apr 7, 2017
Thinking of it, I don't think abs fixes this problem.
This is not useful, as agreed. However abs would cause the window to be at (5,5), which reflects the coordinates over both axes and causes something like
I'm not sure that makes sense. What would be the reasoning to put it there? A part of the window will still be outside the screen.
If the size of the application is larger than the size of the screen, wouldn't it be better to resize the application to fullscreen? Or alternatively, just ignore the hint, and leave the application at the default size in the center.
@laanwj The screen is placed in a location that the user can easily grab the top & edges. This allows the user to choose a new size. If you do not do the abs() then the user does not have access to a single edge. The user cannot cannot easily grab the application and re-size/move it...hence the move and the abs() .
While we could also resize the application to fit, I think if you do that there are many other considerations and the code starts to get messy. I did contemplate it, but this is really an extreme corner case we are talking about here.
The important point is that the user has a means of easily interacting with the application when it starts. By placing the application top right comer on the screen guarantees that the user can move & resize that application. Without the abs() that becomes much harder because the user has no edge to select and resize.
That's not guaranteed to be the case. The window could be twice the size of the screen, for example.
What about my proposal to just go to default settings in that case? I think that is the best fallback if the settings in the QSettings don't make sense (sometimes they get corrupted too), just ignore them.