Files
firefox/hal/fallback/FallbackScreenConfiguration.h
T
Gabriele Svelto b3b1ef307d Bug 1486772 - Refactor the screen-orientation types and headers r=smaug
This patch removes the 'ScreenOrientationInternal' type from
dom/base/ScreenOrientation.h and moves it into the
HalScreenConfiguration.h header, renaming it simply to 'ScreenOrientation'
in the process. This has several knock-off effects:

- It allows files that needed ScreenOrientationInternal to include a much
  smaller header than before

- It greatly reduces the number of headers pulled in when including Hal.h

- It clarifies the role of the type. The 'Internal' part in the name had
  nothing to do with it being part of the implementation. The type was public
  and called that way only to avoid clashing with the 'ScreenOrientation'
  class. Since we moved it into a different namespace it can be renamed
  safely.

- It allows a file that was manually re-declaring 'ScreenConfigurationInternal'
  type to use the original one

- Finally this fixes a few files which were missing headers they actually
  required but that would still build because unified compilation put them into
  units that already had those headers thanks to ScreenConfiguration.h

Differential Revision: https://phabricator.services.mozilla.com/D4458
2018-08-29 20:54:56 +00:00

47 lines
1.3 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_fallback_FallbackScreenConfiguration_h
#define mozilla_fallback_FallbackScreenConfiguration_h
#include "Hal.h"
#include "nsIScreenManager.h"
#include "nsServiceManagerUtils.h"
namespace mozilla {
namespace fallback {
inline void
GetCurrentScreenConfiguration(hal::ScreenConfiguration* aScreenConfiguration)
{
nsresult rv;
nsCOMPtr<nsIScreenManager> screenMgr =
do_GetService("@mozilla.org/gfx/screenmanager;1", &rv);
if (NS_FAILED(rv)) {
NS_ERROR("Can't find nsIScreenManager!");
return;
}
int32_t colorDepth, pixelDepth, x, y, w, h;
ScreenOrientation orientation;
nsCOMPtr<nsIScreen> screen;
screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
screen->GetRect(&x, &y, &w, &h);
screen->GetColorDepth(&colorDepth);
screen->GetPixelDepth(&pixelDepth);
orientation = w >= h
? hal::eScreenOrientation_LandscapePrimary
: hal::eScreenOrientation_PortraitPrimary;
*aScreenConfiguration = hal::ScreenConfiguration(nsIntRect(x, y, w, h),
orientation, 0,
colorDepth, pixelDepth);
}
}
}
#endif // mozilla_fallback_FallbackScreenConfiguration_h