FallbackScreenConfiguration.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  3. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "Hal.h"
  5. #include "mozilla/dom/ScreenOrientation.h"
  6. #include "nsIScreenManager.h"
  7. #include "nsServiceManagerUtils.h"
  8. namespace mozilla {
  9. namespace hal_impl {
  10. void
  11. EnableScreenConfigurationNotifications()
  12. {
  13. }
  14. void
  15. DisableScreenConfigurationNotifications()
  16. {
  17. }
  18. void
  19. GetCurrentScreenConfiguration(hal::ScreenConfiguration* aScreenConfiguration)
  20. {
  21. nsresult rv;
  22. nsCOMPtr<nsIScreenManager> screenMgr =
  23. do_GetService("@mozilla.org/gfx/screenmanager;1", &rv);
  24. if (NS_FAILED(rv)) {
  25. NS_ERROR("Can't find nsIScreenManager!");
  26. return;
  27. }
  28. nsIntRect rect;
  29. int32_t colorDepth, pixelDepth;
  30. dom::ScreenOrientationInternal orientation;
  31. nsCOMPtr<nsIScreen> screen;
  32. screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
  33. screen->GetRect(&rect.x, &rect.y, &rect.width, &rect.height);
  34. screen->GetColorDepth(&colorDepth);
  35. screen->GetPixelDepth(&pixelDepth);
  36. orientation = rect.width >= rect.height
  37. ? dom::eScreenOrientation_LandscapePrimary
  38. : dom::eScreenOrientation_PortraitPrimary;
  39. *aScreenConfiguration =
  40. hal::ScreenConfiguration(rect, orientation, 0, colorDepth, pixelDepth);
  41. }
  42. bool
  43. LockScreenOrientation(const dom::ScreenOrientationInternal& aOrientation)
  44. {
  45. return false;
  46. }
  47. void
  48. UnlockScreenOrientation()
  49. {
  50. }
  51. } // namespace hal_impl
  52. } // namespace mozilla