CobaltFusion / DebugViewPP

DebugView++, collects, views, filters your application logs, and highlights information that is important to you!
Boost Software License 1.0
982 stars 144 forks source link

Fix window position restore on multi monitor setup #315

Closed tripplet closed 6 years ago

tripplet commented 6 years ago

Fixes #314 Found an even easier fix.

janwilmans commented 6 years ago

Wow, many thanks for looking into this. I'm not sure this fixes the problem is case the left-screen-coordinates are negative.

support you start with 3 screens: (talking only about x-coordinates for simplicity )

situation one:

left screen: -1200 - 0 middle screen: 0 - 1200 right screen: 1200 - 2400

situation two (undock laptop)

middle screen: 0 - 1200

But I appreciate the heads up, so I will test!

Greetings.

Jan

On 26 February 2018 at 23:20, Tobias Tangemann notifications@github.com wrote:

Fixes #314 https://github.com/CobaltFusion/DebugViewPP/issues/314 Found an even easier fix.

You can view, comment on, or merge this pull request online at:

https://github.com/CobaltFusion/DebugViewPP/pull/315 Commit Summary

  • Fix window position on multi monitor setup after primary screen was changed

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CobaltFusion/DebugViewPP/pull/315, or mute the thread https://github.com/notifications/unsubscribe-auth/AFqJhM0_uu9Q4GYwI4SFUetBhfsP_La2ks5tYy4XgaJpZM4SUBkV .

-- Jan

tripplet commented 6 years ago

The idea was that GetSystemMetrics(SM_XVIRTUALSCREEN) gives a values of "-1200", which is the left most x coordinate. GetSystemMetrics(SM_CXVIRTUALSCREEN) should give to 3600.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724385(v=vs.85).aspx#SM_XVIRTUALSCREEN

Resulting in the maximum x coordinate of -1200 + 3600 = 2400 this should be bigger or equal to the right border of the window. Therefor the check: static_cast<int>(x + cx) <= GetSystemMetrics(SM_XVIRTUALSCREEN) + GetSystemMetrics(SM_CXVIRTUALSCREEN)

If undocked the result would be 0 + 1200 = 1200 and "x + width" of the windows should not exceed 1200.