Bug 752149 - [OS X] nsCocoaWindow::ConstrainPosition uses wrong screen in multi-display setup [r=smichaud]

Specifically, when loading the position from persisted attributes and the window
should open on a 2nd display, it opens on the 1st.
This commit is contained in:
Paul O’Shannessy 2012-05-18 15:16:50 -07:00
parent 20d39ad4c0
commit d4204c77e5

View File

@ -62,6 +62,7 @@
#include "nsNativeThemeColors.h"
#include "nsChildView.h"
#include "nsCocoaFeatures.h"
#include "nsIScreenManager.h"
#include "gfxPlatform.h"
#include "qcms.h"
@ -1040,8 +1041,23 @@ NS_IMETHODIMP nsCocoaWindow::ConstrainPosition(bool aAllowSlop,
return NS_OK;
}
nsIntRect screenBounds(
nsCocoaUtils::CocoaRectToGeckoRect([[mWindow screen] visibleFrame]));
nsIntRect screenBounds;
nsCOMPtr<nsIScreenManager> screenMgr = do_GetService("@mozilla.org/gfx/screenmanager;1");
if (screenMgr) {
nsCOMPtr<nsIScreen> screen;
PRInt32 width, height;
// zero size rects confuse the screen manager
width = mBounds.width > 0 ? mBounds.width : 1;
height = mBounds.height > 0 ? mBounds.height : 1;
screenMgr->ScreenForRect(*aX, *aY, width, height, getter_AddRefs(screen));
if (screen) {
screen->GetRect(&(screenBounds.x), &(screenBounds.y),
&(screenBounds.width), &(screenBounds.height));
}
}
if (aAllowSlop) {
if (*aX < screenBounds.x - mBounds.width + kWindowPositionSlop) {