Add nsIGfxInfo::GetMonitor support for Linux. (bug 1175005 part 4, r=nical)

This commit is contained in:
David Anderson 2015-06-17 23:12:13 -07:00
parent 44b1489c4e
commit 42f85ae201
2 changed files with 31 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include "prenv.h"
#include "GfxInfoX11.h"
#include "mozilla/X11Util.h"
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
@ -534,6 +535,34 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active)
return NS_ERROR_FAILURE;
}
nsresult
GfxInfo::FindMonitors(JSContext* aCx, JS::HandleObject aOutArray)
{
#if defined(MOZ_WIDGET_GTK)
// No display in xpcshell mode.
if (!gdk_display_get_default()) {
return NS_OK;
}
#endif
// Note: this doesn't support Xinerama. Two physical displays will be
// reported as one monitor covering the entire virtual screen.
Display* display = DefaultXDisplay();
Screen* screen = DefaultScreenOfDisplay(display);
JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
JS::Rooted<JS::Value> screenWidth(aCx, JS::Int32Value(WidthOfScreen(screen)));
JS_SetProperty(aCx, obj, "screenWidth", screenWidth);
JS::Rooted<JS::Value> screenHeight(aCx, JS::Int32Value(HeightOfScreen(screen)));
JS_SetProperty(aCx, obj, "screenHeight", screenHeight);
JS::Rooted<JS::Value> element(aCx, JS::ObjectValue(*obj));
JS_SetElement(aCx, aOutArray, 0, element);
return NS_OK;
}
#ifdef DEBUG
// Implement nsIGfxInfoDebug

View File

@ -48,6 +48,8 @@ public:
NS_IMETHOD_(void) GetData() override;
nsresult FindMonitors(JSContext* cx, JS::HandleObject array) override;
#ifdef DEBUG
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIGFXINFODEBUG