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/. */
6 #include "mozilla/dom/ScreenOrientation.h"
7 #include "nsIScreenManager.h"
13 EnableScreenConfigurationNotifications()
18 DisableScreenConfigurationNotifications()
23 GetCurrentScreenConfiguration(hal::ScreenConfiguration
* aScreenConfiguration
)
26 nsCOMPtr
<nsIScreenManager
> screenMgr
=
27 do_GetService("@mozilla.org/gfx/screenmanager;1", &rv
);
29 NS_ERROR("Can't find nsIScreenManager!");
34 int32_t colorDepth
, pixelDepth
;
35 dom::ScreenOrientation orientation
;
36 nsCOMPtr
<nsIScreen
> screen
;
38 screenMgr
->GetPrimaryScreen(getter_AddRefs(screen
));
39 screen
->GetRect(&rect
.x
, &rect
.y
, &rect
.width
, &rect
.height
);
40 screen
->GetColorDepth(&colorDepth
);
41 screen
->GetPixelDepth(&pixelDepth
);
42 orientation
= rect
.width
>= rect
.height
43 ? dom::eScreenOrientation_LandscapePrimary
44 : dom::eScreenOrientation_PortraitPrimary
;
46 *aScreenConfiguration
=
47 hal::ScreenConfiguration(rect
, orientation
, colorDepth
, pixelDepth
);
51 LockScreenOrientation(const dom::ScreenOrientation
& aOrientation
)
57 UnlockScreenOrientation()