mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
Bug 1240749 - Fixes for DPI support in Gtk widget interface: remove incorrect Get[Avail]RectDisplayPix overrides, as desktop pixels == device pixels for the Gtk widget backend, and implement nsScreenGtk::GetDefaultCSSScaleFactor, required by nsGlobalWindow since per-monitor DPI patches in bug 890156. r=karlt
This commit is contained in:
parent
883cfca3eb
commit
281e26438c
@ -91,38 +91,6 @@ nsScreenGtk :: GetDPIScale()
|
||||
return dpiScale;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetRectDisplayPix(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
|
||||
{
|
||||
int32_t left, top, width, height;
|
||||
|
||||
GetRect(&left, &top, &width, &height);
|
||||
|
||||
double scaleFactor = 1.0 / GetDPIScale();
|
||||
*outLeft = NSToIntRound(left * scaleFactor);
|
||||
*outTop = NSToIntRound(top * scaleFactor);
|
||||
*outWidth = NSToIntRound(width * scaleFactor);
|
||||
*outHeight = NSToIntRound(height * scaleFactor);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetAvailRectDisplayPix(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
|
||||
{
|
||||
int32_t left, top, width, height;
|
||||
|
||||
GetAvailRect(&left, &top, &width, &height);
|
||||
|
||||
double scaleFactor = 1.0 / GetDPIScale();
|
||||
*outLeft = NSToIntRound(left * scaleFactor);
|
||||
*outTop = NSToIntRound(top * scaleFactor);
|
||||
*outWidth = NSToIntRound(width * scaleFactor);
|
||||
*outHeight = NSToIntRound(height * scaleFactor);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetPixelDepth(int32_t *aPixelDepth)
|
||||
{
|
||||
@ -133,7 +101,6 @@ nsScreenGtk :: GetPixelDepth(int32_t *aPixelDepth)
|
||||
|
||||
} // GetPixelDepth
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenGtk :: GetColorDepth(int32_t *aColorDepth)
|
||||
{
|
||||
@ -141,6 +108,12 @@ nsScreenGtk :: GetColorDepth(int32_t *aColorDepth)
|
||||
|
||||
} // GetColorDepth
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenGtk::GetDefaultCSSScaleFactor(double* aScaleFactor)
|
||||
{
|
||||
*aScaleFactor = GetDPIScale();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsScreenGtk :: Init (GdkWindow *aRootWindow)
|
||||
|
@ -33,10 +33,9 @@ public:
|
||||
NS_IMETHOD GetId(uint32_t* aId);
|
||||
NS_IMETHOD GetRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight);
|
||||
NS_IMETHOD GetAvailRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight);
|
||||
NS_IMETHOD GetRectDisplayPix(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight);
|
||||
NS_IMETHOD GetAvailRectDisplayPix(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight);
|
||||
NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth);
|
||||
NS_IMETHOD GetColorDepth(int32_t* aColorDepth);
|
||||
NS_IMETHOD GetDefaultCSSScaleFactor(double* aScaleFactor) override;
|
||||
|
||||
void Init(GdkWindow *aRootWindow);
|
||||
#ifdef MOZ_X11
|
||||
|
@ -237,30 +237,12 @@ nsScreenManagerGtk :: ScreenForId ( uint32_t aId, nsIScreen **outScreen )
|
||||
// Returns the screen that contains the rectangle. If the rect overlaps
|
||||
// multiple screens, it picks the screen with the greatest area of intersection.
|
||||
//
|
||||
// The coordinates are in CSS pixels (not app units) and in screen coordinates.
|
||||
// The coordinates are in desktop pixels.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerGtk :: ScreenForRect( int32_t aX, int32_t aY,
|
||||
int32_t aWidth, int32_t aHeight,
|
||||
nsIScreen **aOutScreen )
|
||||
{
|
||||
uint32_t scale = nsScreenGtk::GetDPIScale();
|
||||
return ScreenForRectPix(aX*scale, aY*scale, aWidth*scale, aHeight*scale,
|
||||
aOutScreen);
|
||||
}
|
||||
|
||||
//
|
||||
// ScreenForRectPix
|
||||
//
|
||||
// Returns the screen that contains the rectangle. If the rect overlaps
|
||||
// multiple screens, it picks the screen with the greatest area of intersection.
|
||||
//
|
||||
// The coordinates are in device (X11) pixels.
|
||||
//
|
||||
nsresult
|
||||
nsScreenManagerGtk :: ScreenForRectPix( int32_t aX, int32_t aY,
|
||||
int32_t aWidth, int32_t aHeight,
|
||||
nsIScreen **aOutScreen )
|
||||
nsScreenManagerGtk::ScreenForRect(int32_t aX, int32_t aY,
|
||||
int32_t aWidth, int32_t aHeight,
|
||||
nsIScreen **aOutScreen)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = EnsureInit();
|
||||
@ -374,7 +356,7 @@ nsScreenManagerGtk :: ScreenForNativeWidget (void *aWidget, nsIScreen **outScree
|
||||
gdk_window_get_geometry(GDK_WINDOW(aWidget), &x, &y, &width, &height);
|
||||
#endif
|
||||
gdk_window_get_origin(GDK_WINDOW(aWidget), &x, &y);
|
||||
rv = ScreenForRectPix(x, y, width, height, outScreen);
|
||||
rv = ScreenForRect(x, y, width, height, outScreen);
|
||||
} else {
|
||||
rv = GetPrimaryScreen(outScreen);
|
||||
}
|
||||
|
@ -37,9 +37,6 @@ private:
|
||||
virtual ~nsScreenManagerGtk();
|
||||
|
||||
nsresult EnsureInit();
|
||||
nsresult ScreenForRectPix(int32_t aX, int32_t aY,
|
||||
int32_t aWidth, int32_t aHeight,
|
||||
nsIScreen **aOutScreen);
|
||||
|
||||
// Cached screen array. Its length is the number of screens we have.
|
||||
nsCOMArray<nsIScreen> mCachedScreenArray;
|
||||
|
Loading…
Reference in New Issue
Block a user