Add nsIGfxInfo::ListMonitors support for OS X. (bug 1175005 part 3, r=mstange)

This commit is contained in:
David Anderson 2015-07-13 01:12:44 -07:00
parent 90b6f30863
commit c706cc9338
2 changed files with 29 additions and 0 deletions

View File

@ -59,6 +59,8 @@ public:
virtual uint32_t OperatingSystemVersion() override { return mOSXVersion; }
nsresult FindMonitors(JSContext* cx, JS::HandleObject array) override;
protected:
virtual ~GfxInfo() {}

View File

@ -379,6 +379,33 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
}
nsresult
GfxInfo::FindMonitors(JSContext* aCx, JS::HandleObject aOutArray)
{
// Getting the refresh rate is a little hard on OS X. We could use
// CVDisplayLinkGetNominalOutputVideoRefreshPeriod, but that's a little
// involved. Ideally we could query it from vsync. For now, we leave it out.
int32_t deviceCount = 0;
for (NSScreen* screen in [NSScreen screens]) {
NSRect rect = [screen frame];
JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
JS::Rooted<JS::Value> screenWidth(aCx, JS::Int32Value((int)rect.size.width));
JS_SetProperty(aCx, obj, "screenWidth", screenWidth);
JS::Rooted<JS::Value> screenHeight(aCx, JS::Int32Value((int)rect.size.height));
JS_SetProperty(aCx, obj, "screenHeight", screenHeight);
JS::Rooted<JS::Value> scale(aCx, JS::NumberValue(nsCocoaUtils::GetBackingScaleFactor(screen)));
JS_SetProperty(aCx, obj, "scale", scale);
JS::Rooted<JS::Value> element(aCx, JS::ObjectValue(*obj));
JS_SetElement(aCx, aOutArray, deviceCount++, element);
}
return NS_OK;
}
#ifdef DEBUG
// Implement nsIGfxInfoDebug