dziemborowicz / hourglass

The simple countdown timer for Windows.
MIT License
642 stars 114 forks source link

When timers are set to open on start, not all timer window positions are remembered #114

Closed dziemborowicz closed 8 years ago

dziemborowicz commented 8 years ago

This was received as a bug report via email.

dziemborowicz commented 8 years ago

I cannot repro this bug. I have tried with single and multiple windows on one or many monitors.

dziemborowicz commented 8 years ago

Have some more information. Looks like the bug is hit when the windows are touching the screen borders. Seems to be a bug in the code that detects whether the window will be on the screen after it is restored.

dziemborowicz commented 8 years ago

Screenshots of working case:

Case 1 - Before & After

Screenshots of failing case (before and after):

Case 2 - Before

Case 2 - After

dziemborowicz commented 8 years ago

I have an update on this. The problem is that, on Windows 10, windows are actually 8 pixels (or some other amount depending on DPI settings perhaps) bigger than they appear. You can see this by hovering your mouse close to the edge of the window: you will see the resize window arrows before you actually move the mouse over the window.

Hourglass centers the window if it determines that it would be shown off the user's desktop, and at the moment this means it centers the window if any part of the window, including the invisible window borders, is outside the user's desktop.

The fix is relatively straightforward: the code that checks that the window will be visible on the screen after it is displayed has to account for this invisible window border.

I just need to find some time to make the change...

alnajar commented 8 years ago

Great, I'll be looking forward to see that fix in action! thanks.

dziemborowicz commented 8 years ago

I have changed the logic for determining if the window is visible to check if the point in the center of the timer window is on the screen rather than checking that the window is entirely on the screen.

This works around the invisible border problem without having to do all kinds of gymnastics, and still serves the original purpose, which was to ensure that the window is not restored to a state where the user cannot see it at all.