mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 537890. Part 2: Get DPI values for Mac, Windows, and X. r=jmathies,josh,karlt
This commit is contained in:
parent
8eec063c4f
commit
a9767732d1
@ -297,6 +297,7 @@ public:
|
||||
|
||||
NS_IMETHOD SetParent(nsIWidget* aNewParent);
|
||||
virtual nsIWidget* GetParent(void);
|
||||
virtual float GetDPI();
|
||||
|
||||
LayerManager* GetLayerManager();
|
||||
|
||||
|
@ -965,6 +965,28 @@ nsChildView::GetParent()
|
||||
return mParentWidget;
|
||||
}
|
||||
|
||||
float
|
||||
nsChildView::GetDPI()
|
||||
{
|
||||
NSWindow* window = [mView window];
|
||||
NSScreen* screen = [window screen];
|
||||
if (!screen)
|
||||
return 96.0f;
|
||||
|
||||
CGDirectDisplayID displayID =
|
||||
[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
|
||||
CGFloat heightMM = CGDisplayScreenSize(displayID).height;
|
||||
size_t heightPx = CGDisplayPixelsHigh(displayID);
|
||||
CGFloat scaleFactor = [window userSpaceScaleFactor];
|
||||
|
||||
// Currently we don't do our own scaling to take account
|
||||
// of userSpaceScaleFactor, so every "pixel" we draw is actually
|
||||
// userSpaceScaleFactor screen pixels. So divide the screen height
|
||||
// by userSpaceScaleFactor to get the number of "device pixels"
|
||||
// available.
|
||||
return (heightPx / scaleFactor) / (heightMM / 25.4f);
|
||||
}
|
||||
|
||||
LayerManager*
|
||||
nsChildView::GetLayerManager()
|
||||
{
|
||||
|
@ -821,6 +821,19 @@ nsWindow::GetParent(void)
|
||||
return mParent;
|
||||
}
|
||||
|
||||
float
|
||||
nsWindow::GetDPI()
|
||||
{
|
||||
Display *dpy = GDK_DISPLAY();
|
||||
int defaultScreen = DefaultScreen(dpy);
|
||||
double heightInches = DisplayHeightMM(dpy, defaultScreen)/25.4;
|
||||
if (heightInches < 0.25) {
|
||||
// Something's broken, but we'd better not crash.
|
||||
return 96.0f;
|
||||
}
|
||||
return float(DisplayHeight(dpy, defaultScreen)/heightInches);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::SetParent(nsIWidget *aNewParent)
|
||||
{
|
||||
|
@ -136,6 +136,7 @@ public:
|
||||
nsWidgetInitData *aInitData);
|
||||
NS_IMETHOD Destroy(void);
|
||||
virtual nsIWidget *GetParent();
|
||||
virtual float GetDPI();
|
||||
virtual nsresult SetParent(nsIWidget* aNewParent);
|
||||
NS_IMETHOD SetModal(PRBool aModal);
|
||||
NS_IMETHOD IsVisible(PRBool & aState);
|
||||
|
@ -2189,6 +2189,19 @@ nsWindow::GetParent(void)
|
||||
return mParent;
|
||||
}
|
||||
|
||||
float
|
||||
nsWindow::GetDPI()
|
||||
{
|
||||
QDesktopWidget* rootWindow = QApplication::desktop();
|
||||
double heightInches = rootWindow->heightMM()/25.4;
|
||||
if (heightInches < 0.25) {
|
||||
// Something's broken, but we'd better not crash.
|
||||
return 96.0f;
|
||||
}
|
||||
|
||||
return float(rootWindow->height()/heightInches);
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::DispatchActivateEvent(void)
|
||||
{
|
||||
|
@ -133,6 +133,7 @@ public:
|
||||
NS_IMETHOD Destroy(void);
|
||||
NS_IMETHOD SetParent(nsIWidget* aNewParent);
|
||||
virtual nsIWidget *GetParent(void);
|
||||
virtual float GetDPI();
|
||||
NS_IMETHOD Show(PRBool aState);
|
||||
NS_IMETHOD SetModal(PRBool aModal);
|
||||
NS_IMETHOD IsVisible(PRBool & aState);
|
||||
|
@ -1066,6 +1066,22 @@ nsIWidget* nsWindow::GetParent(void)
|
||||
return GetParentWindow(PR_FALSE);
|
||||
}
|
||||
|
||||
float nsWindow::GetDPI()
|
||||
{
|
||||
HDC dc = ::GetDC(mWnd);
|
||||
if (!dc)
|
||||
return 96.0f;
|
||||
|
||||
double heightInches = ::GetDeviceCaps(dc, VERTSIZE)/25.4;
|
||||
int heightPx = ::GetDeviceCaps(dc, VERTRES);
|
||||
::ReleaseDC(mWnd, dc);
|
||||
if (heightInches < 0.25) {
|
||||
// Something's broken
|
||||
return 96.0f;
|
||||
}
|
||||
return float(heightPx/heightInches);
|
||||
}
|
||||
|
||||
nsWindow* nsWindow::GetParentWindow(PRBool aIncludeOwner)
|
||||
{
|
||||
if (mIsTopWidgetWindow) {
|
||||
|
@ -123,6 +123,7 @@ public:
|
||||
NS_IMETHOD Destroy();
|
||||
NS_IMETHOD SetParent(nsIWidget *aNewParent);
|
||||
virtual nsIWidget* GetParent(void);
|
||||
virtual float GetDPI();
|
||||
NS_IMETHOD Show(PRBool bState);
|
||||
NS_IMETHOD IsVisible(PRBool & aState);
|
||||
NS_IMETHOD ConstrainPosition(PRBool aAllowSlop, PRInt32 *aX, PRInt32 *aY);
|
||||
|
Loading…
Reference in New Issue
Block a user