Skip to content

Commit

Permalink
Add nsIGfxInfo::GetMonitor support for Linux. (bug 1175005 part 4, r=…
Browse files Browse the repository at this point in the history
…nical)
  • Loading branch information
David Anderson committed Jun 18, 2015
1 parent 20373be commit 244c1f9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions widget/GfxInfoX11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "prenv.h"

#include "GfxInfoX11.h"
#include "mozilla/X11Util.h"

#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions widget/GfxInfoX11.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class GfxInfo final : public GfxInfoBase

NS_IMETHOD_(void) GetData() override;

nsresult FindMonitors(JSContext* cx, JS::HandleObject array) override;

#ifdef DEBUG
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIGFXINFODEBUG
Expand Down

0 comments on commit 244c1f9

Please sign in to comment.