MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.29k stars 2.45k forks source link

MetroWindow with a secondary monitor issues #139

Closed andzt closed 12 years ago

andzt commented 12 years ago

Set a secondary monitor to display to the left of your main monitory (laptop screen)...

  1. If you maximize a MetroWindow in a secondary monitor that is setup to the left of the main display, the background of the MetroWindow shows up on the second screen to about the middle of the screen.
  2. There is other oddness with this setup as well. If you grab the title bar and then drag it so it undocks from being maximized, the window jumps to a position on the main screen, while your mouse cursor is still on the secondary screen...

Github Windows app has this issue as well as my personal projects using MahApps.Metro.

flagbug commented 12 years ago

I can't reproduce this. Which version of MahApps.Metro are you using?

ghost commented 12 years ago

Can't replicate here. I've tried in the past with triple screen configs and had no issues.

You'll need to provide further info, such as MA.M version, operating system, language (left-to-right languages may cause issues, I don't know), video card and video card driver version, and if you're running any third party multi-monitor software (Ultramon, DisplayFusion, etc).

Given it happens with GH4W which doesn't use MA.M (although does use some code from it), I'm leaning towards it being your system rather than a MA.M specific bug, but we might be able to find something that helps.

nighthawk457 commented 12 years ago

I am having the exact same issue . My secondary monitor is to the left and everything works fine on my primary monitor (maximizing, minimizing etc). On maximizing the MetroWindow in the secondary monitor, it expands to occupy portion (till the middle) of the primary monitor. I am having this problem even with the MetroDemo project available in the download. running this on windows 7 professional Intel HD graphics 8.15.10.2342. I am running the latest version available on github. I also tried switching the secondary monitor to the right but i still have the issue. I am not running any third party multi monitor software

admsteck commented 12 years ago

Same issue here with windows 7 and the BorderlessWindowBehavior. It looks like when you maximize the window it is just a little wider than the screen (around 400px on my system).

ghost commented 12 years ago

I happen to have just done a fresh install of Windows 7 (Ultimate, 64bit, English-AU) and... I still can't replicate this. I've also tried in Windows 8/.NET 4.5 to no avail. If your window is overlapping monitors, yes, you'll always get issues... but it needs to be ~50% on both monitors to be 'luck of the draw'.

@admsteck you're saying you've got a 400px screen? ...how?!

admsteck commented 12 years ago

@aeoth I was trying to say that around 400px of the app appears to be off the screen. It appears that it starts in the top left corner of the secondary monitor as it should, but then is sized to large when you maximize. Since andtz's secondary monitor was on the left, it resulted in the window flowing onto his primary monitor as well. Since my secondary monitor is on the right, it just flows off the side of the monitor and is not visible.

ghost commented 12 years ago

Right, that makes a bit more sense!

admsteck commented 12 years ago

@aeoth I just tried to replicate on my home pc (I was at work before) with both the demo app and GH4W. At first I could not recreate either. Then I realized that at work I am running on a laptop with a smaller screen and my secondary is a 21 inch. At home my secondary is smaller. After a little testing it appears that this bug only shows up if your secondary monitor has a higher resolution than your primary.

ghost commented 12 years ago

Yay! Progress! I can replicate that. Thanks @admsteck. I'll see if I can find a solution for it over breakfast.

ghost commented 12 years ago

The sample that GHFW and MA.M are both working off is http://blogs.msdn.com/b/llobo/archive/2006/08/01/maximizing-window-_2800_with-windowstyle_3d00_none_2900_-considering-taskbar.aspx, which exhibits the same behaviour. At least that narrows it down to that one method.

ghost commented 12 years ago

A "simple" solution is to set the MaxTrackSize, which does solve it. Unfortunately, it has the side effect of you not being able to resize the window past the point of a single monitors width. This is discussed on MSDN forums, looking like its.... really just a win32 bug.

Is this an issue?

admsteck commented 12 years ago

@aeoth A little digging in the documentation found this in the remarks section for the MINMAXINFO structure:

For systems with multiple monitors, the ptMaxSize and ptMaxPosition members describe the maximized size and position of the window on the primary monitor, even if the window ultimately maximizes onto a secondary monitor. In that case, the window manager adjusts these values to compensate for differences between the primary monitor and the monitor that displays the window. Thus, if the user leaves ptMaxSize untouched, a window on a monitor larger than the primary monitor maximizes to the size of the larger monitor.

The first sentence there caught my eye. Does this mean WmGetMinMaxInfo sould always look at the size of the primary monitor and not the monitor the window is actually on?

ghost commented 12 years ago

Unfortunately, by not setting MaxSize, it'll resize over the taskbar.

admsteck commented 12 years ago

I'm playing around with it a little. What I've got so far is to check monitorInfo.dwFlags to see if the window is on the primary monitor, if it is, continue as usual. If it is on a secondary display, I call GetMonitorInfo on the primary monitor to get it's size and use that to set mmi.ptMaxSize. Seems to work so far. Need to test with a few more monitor resolution combinations.

admsteck commented 12 years ago

Pull request sent. I tested it out on several different resolution combinations and different task bar locations. Also had GH4W open to verify conditions that caused the bug. Please look it over and try it out.