Skip to content

Conversation

@AllanDoensen
Copy link
Contributor

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:

  1. Install Bitcoin-qt on a system with multiple monitors (i.e. a laptop attached to a second screen). I have only reproduced this issue on windows 10 with ‘extend these displays’ configured.
  2. Start bitcoin-qt and place it on the second screen.
  3. Close bitcoin-qt (it will cache it’s position on the second screen).
  4. Remove (physically unplug) the second screen.
  5. Start bitcoin-qt.
  6. You will find that bitcoin-qt starts in the cached second screen position and cannot be found on the only active screen. It just disappears. You need to realise that it is off screen and then do some fancy control keys to get it to come back to the primary display.

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.

jonasschnelli and others added 20 commits April 2, 2017 09:48
This is step one in abstracting the use of boost::filesystem.
Step two in abstracting away boost::filesystem.

To repeat this, simply run:
```
git ls-files \*.cpp \*.h | xargs sed -i 's/boost::filesystem/fs/g'
```
Abstracts away how a path is opened to a `FILE*`.

Reduces the number of places where path is converted to a string
for anything else but printing.
Having these inside functions is silly and redundant now.
If we want to keep these numbers, could generate them using autoconf.
But this seems unnecessary.
@fanquake fanquake added the GUI label Apr 5, 2017
@jonasschnelli
Copy link
Contributor

Makes sense.
Code looks good (re-sets the Widget to main screen center if the larger portion of Widget is not on a screen).
utACK 1896818

@laanwj
Copy link
Member

laanwj commented Apr 5, 2017

This doesn't just affect windows but any setup with variable number monitors. Thanks for the fix.
(I think there's an reported issue for this open somewhere but can't find it)

laanwj added 2 commits April 5, 2017 11:28
faafa80 init: Remove redundant logging code (MarcoFalke)

Tree-SHA512: 5ad0e9aba0e25a36025dd4ee5e5fddd2c0039f95bafd0f33300ea59e2f9bba807da6a1a8b4311d6aad5a360b99163edf4a4f161cb13f0f38580d8d6b504c94ad
…f GetLogCategory() fails)

cd7f394 initialize flag variable to 0 (and continue if GetLogCategory() fails) (John Newbery)

Tree-SHA512: d0f2653bd0e71ed763220cb08d3a5335c5bdfe2f54ff7f9302d97f3265d7aa7f57606fe416a61aaac1535dbb046d0fb40a61f5a9d5cf234b042268e00ee7679d
@sipa
Copy link
Member

sipa commented Apr 5, 2017

Does this apply to 0.14?

@AllanDoensen
Copy link
Contributor Author

@sipa This applies to 0.14. This bug has existed for many years and is in all bitcoin & alt-coins that I am aware of.

@laanwj laanwj changed the title Fix for issues with startup and mutiple monitors on windows. Fix for issues with startup and multiple monitors on windows. Apr 6, 2017
d80baaa fixup - align summary row correctly and make colors/glyphs globals (John Newbery)
bb92d83 [tests] Add unicode symbols for tests passing/failing/skipping (John Newbery)
63062bd [tests] color test results and sort alphabetically (John Newbery)

Tree-SHA512: a5b85c05480722abd6e483d1817b7527ca487b8bb8292bc81efba158df5a619b8103ed43b790396071ab0710f39457895a79460480044324798c81331bbade5a
@laanwj
Copy link
Member

laanwj commented Apr 7, 2017

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.

Thinking of it, I don't think abs fixes this problem.
E.g. say the screen is 10x10, and the window 20x20. With the code without abs, the position of the window will be ((10-20)/2, (10-20)/2) or (-5,-5): screen will be centered in the center of the window instead of the other way around.

+-----------------|
| window          |
| +------------+  |
| |            |  |
| |  screen    |  |
| |            |  |
| +------------+  |
|                 |
+-----------------|

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

+------------+
| screen     |
|   +-----------------+
|   |  window|        |
+---|--------+        | 
    |                 |
    |                 |
    +-----------------+

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.

@AllanDoensen
Copy link
Contributor Author

@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.

@laanwj
Copy link
Member

laanwj commented Apr 7, 2017

The screen is placed in a location that the user can easily grab the top & edges.

That's not guaranteed to be the case. The window could be twice the size of the screen, for example.

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.

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.

@AllanDoensen
Copy link
Contributor Author

Yes, that is acceptable.

@AllanDoensen
Copy link
Contributor Author

AllanDoensen commented Apr 7, 2017

Should I update it or do you/others want the say first?

@laanwj
Copy link
Member

laanwj commented Apr 7, 2017

That's up to you. To be clear I'm fine with the fix as it is now, as at least it improves things compared to how it is now, but I just think it could be even more robust.

jnewbery and others added 2 commits April 7, 2017 22:16
This commit reduces spammy logging by the test framework. It truncates
logging send/receive message in mininode to 500 characters.  mininode
was previously logging the entire message sent received, which can be up
to 1MB for a full block.
If the application is detected to be in an invalid position then the default size and position are now used.
Use of use of abs() has been removed.
@laanwj
Copy link
Member

laanwj commented Apr 8, 2017

Looks good to me now, utACK after squash.

45ce471 Reduce spammy test logging (John Newbery)

Tree-SHA512: 64b2ce29fb62a4e738840bbaf93563559451c2ef078ba66ecfc1dbe34adefea61ad2ad2d768444cb2e0b30cb3cbe47e38ed818d4c91f7723a3d1ba9fdd0043f9
@luke-jr
Copy link
Member

luke-jr commented Apr 8, 2017

Seems the right behaviour here is to let the WM give it the default position. (Arguably we shouldn't be saving it at all, but that's another issue.)

@laanwj
Copy link
Member

laanwj commented Apr 8, 2017

Yeah yeah, let's just agree that this is an improvement over not being able to find the window.
Whether to store the window position at all is a completely different discussion that doesn't belong here.

Changes after comments from @laanwj.

If the application is detected to be in an invalid position then the default size and position are now used.
Use of use of abs() has been removed.
@jonasschnelli
Copy link
Contributor

@AllanDoensen: commit history is messed up. Maybe do a git fetch origin; git reset --hard origin/master and cherry-pick the relevant commit(s).

@laanwj
Copy link
Member

laanwj commented Apr 10, 2017

Oops. I think I have the previous version of this saved somewhere.

laanwj added a commit that referenced this pull request Apr 10, 2017
…ndows.

e9ff818 Fix for issues with startup and multiple monitors on windows. (Allan Doensen)

Tree-SHA512: 8502042a9b5a2fd6f5e409163bee9bd7c85e34c158754f393065f8cc6cdd0f8505b9a1803069d01fc1fb2df04d1b2ed6291388851f2ed3608eb2dd53fc22e06e
@laanwj
Copy link
Member

laanwj commented Apr 10, 2017

Merged via 51833a1 (retrieved the previous good version and squashed)

@laanwj laanwj closed this Apr 10, 2017
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Apr 21, 2017
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Apr 21, 2017
If the application is detected to be in an invalid position then the default size and position are now used.
Use of use of abs() has been removed.

Github-Pull: bitcoin#10156
Rebased-From: 3b58485
@laanwj laanwj added this to the 0.14.3 milestone Sep 5, 2017
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants